@@ -17,7 +17,7 @@ namespace calib {
1717 : fMonWidth (pset.get<int >(" MonWidth" , 12 )),
1818 fTotalCAENBoards (pset.get<int >(" TotalCAENBoards" , 8 )),
1919 PMTPerBoard(pset.get<int >(" PMTPerBoard" , 15 )),
20- Baseline(pset.get<int >(" Baseline" , 14250 )),
20+ Baseline(pset.get<int >(" Baseline" )),
2121 fMC(pset.get<bool >(" MC" , true ))
2222 {}
2323
@@ -29,9 +29,11 @@ namespace calib {
2929 int MonThreshold,
3030 std::vector<int > *MonPulse,
3131 int FlashCounter,
32- int *numPairsOverThreshold
32+ int *numPairsOverThreshold,
33+ std::vector<int > PMT_Channels
3334 )
3435 {
36+
3537 // Loop over the entries in our waveform vector
3638 // We care about getting the pairing correct
3739
@@ -44,22 +46,37 @@ namespace calib {
4446 }
4547
4648 std::map<int , const raw::OpDetWaveform*> channel_to_waveform;
47- for (const auto & wvf : fWaveforms )
49+ for (const auto & wvf : fWaveforms ) {
4850 channel_to_waveform[wvf.ChannelNumber ()] = &wvf;
51+ }
4952
5053 std::vector<int > Pair2 = { 6 , 8 , 10 , 12 , 14 , 16 , 36 , 38 , 40 , 60 , 62 , 66 , 68 , 70 , 84 , 86 , 88 , 90 , 92 , 94 , 114 , 116 , 118 , 138 , 140 , 144 , 146 , 148 , 162 , 164 , 168 , 170 , 172 , 192 , 194 , 196 , 216 , 218 , 220 , 222 , 224 , 226 , 240 , 242 , 246 , 248 , 250 , 270 , 272 , 274 , 294 , 296 , 298 , 300 , 302 , 304 };
5154 std::vector<int > Pair1 = { 7 , 9 , 11 , 13 , 15 , 17 , 37 , 39 , 41 , 61 , 63 , 67 , 69 , 71 , 85 , 87 , 89 , 91 , 93 , 95 , 115 , 117 , 119 , 139 , 141 , 145 , 147 , 149 , 163 , 165 , 169 , 171 , 173 , 193 , 195 , 197 , 217 , 219 , 221 , 223 , 225 , 227 , 241 , 243 , 247 , 249 , 251 , 271 , 273 , 275 , 295 , 297 , 299 , 301 , 303 , 305 };
5255 std::vector<int > Unpaired = {65 , 64 , 143 , 142 , 167 , 166 , 245 , 244 };
5356 std::set<int > used_channels;
5457
5558 // resize
56- int ReadoutSize = fWaveforms [0 ].size ();
59+ int ReadoutSize;
60+ if (PMT_Channels.empty ()) { std::cout<<" Warning: Please provide PMT channels list." <<std::endl; ReadoutSize = fWaveforms [Pair1[0 ]].size (); }
61+ else ReadoutSize = fWaveforms [PMT_Channels[0 ]].size ();
5762 MonPulse->assign (ReadoutSize, 0 );
5863
5964 for (size_t i = 0 ; i < Pair1.size (); ++i) {
6065 int ch1 = Pair1[i];
6166 int ch2 = Pair2[i];
6267
68+ // check that ch1 and ch2 show up in PMT_Channels
69+ if (PMT_Channels.empty ()) std::cout<<" Warning: Please provide PMT channels list to check if channels are PMT channels." <<std::endl;
70+ else {
71+ if (!(std::find (PMT_Channels.begin (), PMT_Channels.end (), ch1) != PMT_Channels.end ())) {
72+ throw cet::exception (" TriggerEmulationService" ) << " Paired channel " << ch1 << " is not PMT channel. Check Pairs list. Skipping..." << std::endl;
73+ continue ;
74+ } if (!(std::find (PMT_Channels.begin (), PMT_Channels.end (), ch2) != PMT_Channels.end ())) {
75+ throw cet::exception (" TriggerEmulationService" ) << " Paired channel " << ch2 << " is not PMT channel. Check Pairs list. Skipping..." << std::endl;
76+ continue ;
77+ }
78+ }
79+
6380 // skip if either waveform is missing
6481 if (channel_to_waveform.count (ch1) == 0 || channel_to_waveform.count (ch2) == 0 ) continue ;
6582 // skip if already processed
@@ -82,6 +99,16 @@ namespace calib {
8299 }
83100
84101 for (int ch : Unpaired) { // Unpaired channels
102+
103+ // check that ch1 and ch2 show up in PMT_Channels
104+ if (PMT_Channels.empty ()) std::cout<<" Warning: Please provide PMT channels list to check if channels are PMT channels." <<std::endl;
105+ else {
106+ if (!(std::find (PMT_Channels.begin (), PMT_Channels.end (), ch) != PMT_Channels.end ())) {
107+ throw cet::exception (" TriggerEmulationService" ) << " Unpaired channel " << ch << " is not PMT channel. Check list. Skipping..." << std::endl;
108+ continue ;
109+ }
110+ }
111+
85112 if (used_channels.count (ch)) continue ;
86113 if (channel_to_waveform.count (ch) == 0 ) continue ;
87114
@@ -143,6 +170,9 @@ namespace calib {
143170 CAENChannel=CAENChannel+ChannelStep;
144171 } // loop over channels
145172 } // loop over boards
173+
174+ if (numPairsOverThreshold) *numPairsOverThreshold = *std::max_element (MonPulse->begin (), MonPulse->end ());
175+
146176 } // data
147177 } // ConstructMonPulse
148178
0 commit comments