79 vector<pair<CRTData, vector<AuxDetIDE>>> dataCol;
82 throw cet::exception(
"CRTDetSimAlg") <<
"CreateData() called with empty taggers map!";
88 int ncombined_c=0, ncombined_m=0, ncombined_d=0;
89 int nmiss_lock_c=0, nmiss_lock_d=0, nmiss_lock_m=0;
90 int nmiss_dead_c=0, nmiss_dead_d=0, nmiss_dead_m=0;
91 int nmiss_opencoin_c = 0, nmiss_opencoin_d = 0;
96 int nhit_m=0, nhit_c=0, nhit_d=0;
97 int neve_m=0, neve_c=0, neve_d=0;
115 set<int> trackNHold = {};
116 set<int> layerNHold = {};
117 if((
int)trg.first==INT_MAX)
std::cout <<
"WARNING: bad mac5 found!" << std::endl;
118 bool minosPairFound =
false, istrig=
false;
119 vector<ChanData> passingData;
120 vector<AuxDetIDE> passingIDE;
121 uint64_t ttrig=0.0, ttmp=0.0;
123 size_t trigIndex = 0;
140 << trg.second.data.size() <<
" entries..." <<
'\n'
141 <<
" type: " << trg.second.type <<
'\n'
142 <<
" region: " << trg.second.reg <<
'\n'
143 <<
" layerID: " << *trg.second.layerid.begin() <<
'\n' << std::endl;
146 for (
size_t i=0; i< trg.second.data.size(); i++ ) {
150 chanTrigData = &(trg.second.data[0].first);
151 ttrig = chanTrigData->ts;
152 trackNHold.insert(chanTrigData->channel);
153 layerNHold.insert(trg.second.chanlayer[chanTrigData->channel]);
154 passingData.push_back(*chanTrigData);
155 passingIDE.push_back(trg.second.data[0].second);
157 idetmp = passingIDE.back();
158 if(trg.second.type!=
'm')
163 chanTmpData = &(trg.second.data[i].first);
164 ttmp = chanTmpData->ts;
165 idetmp = trg.second.data[i].second;
170 if ( layerNHold.size()==1 &&
175 chanTrigData = &(trg.second.data[trigIndex].first);
177 ttrig = chanTrigData->ts;
182 trackNHold.insert(chanTrigData->channel);
183 layerNHold.insert(trg.second.chanlayer[chanTrigData->channel]);
184 passingData.push_back(*chanTrigData);
185 passingIDE.push_back(trg.second.data[trigIndex].second);
186 if(trg.second.type==
'c') nmiss_coin_c++;
187 if(trg.second.type==
'd') nmiss_coin_d++;
192 std::cout <<
"checking for coincidence..." << std::endl;
197 for (
auto trg2 :fTaggers) {
199 if( trg2.second.type!=
'm' ||
200 trg.second.modid == trg2.second.modid ||
201 trg.second.reg != trg2.second.reg ||
202 *trg2.second.layerid.begin() == *trg.second.layerid.begin())
207 for (
size_t j=0; j< trg2.second.data.size(); j++ ) {
208 uint64_t t2tmp = trg2.second.data[j].first.ts;
210 minosPairFound =
true;
220 if(!minosPairFound) {
222 std::cout <<
"MINOS pair NOT found! Skipping to next FEB..." << std::endl;
223 if(trg.second.data.size()==1)
continue;
225 chanTrigData = &(trg.second.data[trigIndex].first);
227 ttrig = chanTrigData->ts;
232 trackNHold.insert(chanTrigData->channel);
233 layerNHold.insert(trg.second.chanlayer[chanTrigData->channel]);
234 passingData.push_back(*chanTrigData);
235 passingIDE.push_back(trg.second.data[trigIndex].second);
244 std::cout <<
"done checking coinceidence...moving on to latency effects..." << std::endl;
245 if(!minosPairFound && trg.second.type==
'm')
246 std::cout <<
"WARNING: !minosPairFound...should not see this message!" << std::endl;
256 if ((trackNHold.insert(chanTmpData->channel)).
second) {
259 passingData.push_back(*chanTmpData);
260 passingIDE.push_back(idetmp);
263 if (layerNHold.insert(trg.second.chanlayer[chanTmpData->channel]).second
264 && trg.second.type !=
'm')
273 for(
size_t dat=0;
dat<passingData.size();
dat++) {
274 if(passingData[
dat].channel!=chanTmpData->channel)
276 adctmp = passingData[
dat].adc;
277 adctmp += chanTmpData->adc;
279 passingData[
dat].adc = adctmp;
280 passingIDE.push_back(idetmp);
285 switch (trg.second.type) {
286 case 'c' : ncombined_c++;
break;
287 case 'd' : ncombined_d++;
break;
288 case 'm' : ncombined_m++;
break;
292 else switch (trg.second.type) {
293 case 'c' : nmiss_lock_c++;
break;
294 case 'd' : nmiss_lock_d++;
break;
295 case 'm' : nmiss_lock_m++;
break;
300 else if ( i>0 && ttmp <= ttrig +
fDeadTime ) {
301 switch (trg.second.type) {
302 case 'c' : nmiss_dead_c++;
break;
303 case 'd' : nmiss_dead_d++;
break;
304 case 'm' : nmiss_dead_m++;
break;
317 std::cout <<
"creating CRTData product just after deadtime" <<
'\n'
318 <<
" event: " << eve <<
'\n'
319 <<
" mac5: " << trg.first <<
'\n'
320 <<
" FEB entry: " <<
event <<
'\n'
321 <<
" trig time: " << ttrig <<
'\n'
322 <<
" trig channel: " << chanTrigData->channel <<
'\n'
323 <<
" passing data: " << std::endl;
324 for(
size_t i=0; i<passingData.size(); i++) {
326 <<
" index: " << i <<
'\n'
327 <<
" channel: " << passingData[i].channel <<
'\n'
328 <<
" t0: " << passingData[i].ts <<
'\n'
329 <<
" adc: " << passingData[i].adc << std::endl;
333 if(passingData.size()>passingIDE.size())
334 std::cout <<
"data/IDE size mismatch!" << passingData.size()-passingIDE.size() << std::endl;
336 dataCol.push_back(std::make_pair(
342 if (trg.second.type==
'c') {neve_c++; nhit_c+=passingData.size(); }
343 if (trg.second.type==
'd') {neve_d++; nhit_d+=passingData.size(); }
344 if (trg.second.type==
'm') {neve_m++; nhit_m+=passingData.size(); } }
347 chanTrigData = chanTmpData;
352 passingData.push_back(*chanTrigData);
353 passingIDE.push_back(idetmp);
354 trackNHold.insert(chanTrigData->channel);
355 layerNHold.insert(trg.second.chanlayer[chanTmpData->channel]);
356 minosPairFound =
false;
360 if (!(ttmp > ttrig +
fDeadTime) && i==trg.second.data.size()-1 && istrig) {
363 std::cout <<
"creating CRTData product at end of FEB events..." <<
'\n'
364 <<
" event: " << eve <<
'\n'
365 <<
" mac5: " << trg.first <<
'\n'
366 <<
" FEB entry: " <<
event <<
'\n'
367 <<
" trig time: " << ttrig <<
'\n'
368 <<
" trig channel: " << chanTrigData->channel <<
'\n'
369 <<
" passing data: " << std::endl;
370 for(
size_t i=0; i<passingData.size(); i++) {
372 <<
" index: " << i <<
'\n'
373 <<
" channel: " << passingData[i].channel <<
'\n'
374 <<
" t0: " << passingData[i].ts <<
'\n'
375 <<
" adc: " << passingData[i].adc << std::endl;
383 if(passingData.size()>passingIDE.size())
384 std::cout <<
"data/IDE size mismatch! " << passingData.size()-passingIDE.size() << std::endl;
386 dataCol.push_back( std::make_pair(
390 std::cout <<
" ...success!" << std::endl;
392 if (trg.second.type==
'c') {neve_c++; nhit_c+=passingData.size(); }
393 if (trg.second.type==
'd') {neve_d++; nhit_d+=passingData.size(); }
394 if (trg.second.type==
'm') {neve_m++; nhit_m+=passingData.size(); }
399 if(
fUltraVerbose)
std::cout <<
" outside loop over FEB data entries...moving on to next FEB..." << std::endl;
404 std::cout <<
"|---------------------- CRTDetSim Summary ----------------------|" <<
'\n'
405 <<
" - - - EDeps from AuxDetIDE's - - -" <<
'\n'
406 <<
" CERN sim strip hits: " <<
fNsim_c <<
'\n'
407 <<
" MINOS sim strip hits: " <<
fNsim_m <<
'\n'
408 <<
" DC sim strip hits: " <<
fNsim_d <<
'\n' <<
'\n'
409 <<
" - - - Single Channel Threshold - - -" <<
'\n'
411 <<
" CERN channel signals > thresh: " <<
fNchandat_c <<
'\n'
412 <<
" MINOS channel signals > thresh: " <<
fNchandat_m <<
'\n'
413 <<
" both ends > thresh: " <<
fNdual_m <<
'\n'
414 <<
" DC channel signals > thresh: " <<
fNchandat_d <<
'\n'
416 <<
" CERN channel signals < thresh: " <<
fNmissthr_c <<
'\n'
417 <<
" MINOS channel signals < thresh: " <<
fNmissthr_m <<
'\n'
418 <<
" DC channel signals < thresh: " <<
fNmissthr_d <<
'\n' <<
'\n'
419 <<
" - - - System Specifc Coincidence Loss- - -" <<
'\n'
421 <<
" CERN open layer-layer: " << nmiss_opencoin_c <<
'\n'
422 <<
" DC open layer-layer: " << nmiss_opencoin_d <<
'\n'
423 <<
" CERN layer-layer: " << nmiss_coin_c <<
" (" << 100.0*nmiss_coin_c/
fNchandat_c <<
"%)" <<
'\n'
424 <<
" MINOS layer-layer: " << nmiss_coin_m <<
" (" << 100.0*nmiss_coin_m/
fNchandat_m <<
"%)" <<
'\n'
425 <<
" DC layer-layer: " << nmiss_coin_d <<
" (" << 100.0*nmiss_coin_d/
fNchandat_d <<
"%)" <<
'\n' <<
'\n'
426 <<
" - - - Front-End Electronics Effects - - -" <<
'\n'
427 <<
" CERN trackNHold loss: " << nmiss_lock_c <<
" (" << 100.0*nmiss_lock_c/
fNchandat_c <<
"%)" <<
'\n'
428 <<
" MINOS trackNHold loss: " << nmiss_lock_m <<
" (" << 100.0*nmiss_lock_m/
fNchandat_m <<
"%)" <<
'\n'
429 <<
" DC trackNHold loss: " << nmiss_lock_d <<
" (" << 100.0*nmiss_lock_d/
fNchandat_d <<
"%)" <<
'\n'
430 <<
" CERN combined: " << ncombined_c <<
" (" << 100.0*ncombined_c/
fNchandat_c <<
"%)" <<
'\n'
431 <<
" MINOS combined: " << ncombined_m <<
" (" << 100.0*ncombined_m/
fNchandat_m <<
"%)" <<
'\n'
432 <<
" DC combined: " << ncombined_d <<
" (" << 100.0*ncombined_d/
fNchandat_d <<
"%)" <<
'\n'
433 <<
" CERN deadTime loss: " << nmiss_dead_c <<
" (" << 100.0*nmiss_dead_c/
fNchandat_c <<
"%)" <<
'\n'
434 <<
" MINOS deadTime loss: " << nmiss_dead_m <<
" (" << 100.0*nmiss_dead_m/
fNchandat_m <<
"%)" <<
'\n'
435 <<
" DC deadTime loss: " << nmiss_dead_d <<
" (" << 100.0*nmiss_dead_d/
fNchandat_d <<
"%)" <<
'\n' <<
'\n'
436 <<
" - - - Passing Hits Pushed To Event - - -" <<
'\n'
437 <<
" CERN strip hits remaining: " << nhit_c+ncombined_c <<
" (" << 100.0*(nhit_c+ncombined_c)/
fNchandat_c <<
"%)" <<
'\n'
438 <<
" MINOS strip hits remaining: " << nhit_m+ncombined_m <<
" (" << 100.0*(nhit_m+ncombined_m)/
fNchandat_m <<
"%)" <<
'\n'
439 <<
" DC strip hits remaining: " << nhit_d+ncombined_d <<
" (" << 100.0*(nhit_d+ncombined_d)/
fNchandat_d <<
"%)" <<
'\n'
440 <<
" CERN channel signals generated: " << nhit_c <<
'\n'
441 <<
" MINOS channel signals generated: " << nhit_m <<
'\n'
442 <<
" DC channel signals generated: " << nhit_d <<
'\n'
443 <<
" CERN events: " << neve_c <<
'\n'
444 <<
" MINOS events: " << neve_m <<
'\n'
445 <<
" DC events: " << neve_d <<
'\n'
446 <<
" Total pushes to event: " << dataCol.size() << std::endl;
448 if(dataCol.size()>0) {
449 std::map<int,int>::iterator it =
fRegCounts.begin();
450 std::cout <<
'\n' <<
"FEB events per CRT region: " <<
'\n' << std::endl;
double fLayerCoincidenceWindowM
Time window for two layer coincidence between MINOS modules [ns].
double fLayerCoincidenceWindowC
Time window for two layer coincidence in a CERN module [ns].
bool fApplyCoincidenceM
Whether or not to apply coincidence between hits in adjacent layers.
double fDeadTime
Dead Time inherent in the front-end electronics.
void FillAdcArr(const vector< ChanData > &data, uint16_t arr[32])
int AuxDetRegionNameToNum(string reg)
uint16_t fQMax
ADC saturation value [ADC].
double fBiasTime
Hard cut off for follow-up hits after primary trigger to bias ADC level.
string GetRegionNameFromNum(int num)
bool fApplyCoincidenceC
Whether or not to apply coincidence between hits in adjacent layers.
map< uint8_t, Tagger > fTaggers
auto end(FixedBins< T, C > const &) noexcept
CRTData FillCRTData(uint8_t mac, uint32_t entry, uint64_t t0, uint64_t ts1, uint16_t adc[32])
map< int, int > fRegCounts
bool TimeOrderCRTData(std::pair< ChanData, AuxDetIDE > crtdat1, std::pair< ChanData, AuxDetIDE > crtdat2)
constexpr auto absDiff(A const &a, B const &b)
Returns the absolute value of the difference between two values.
MC truth information to make RawDigits and do back tracking.
CRTCommonUtils * fCrtutils
double fLayerCoincidenceWindowD
Time window for two layer coincidence in a DC module [ns].
BEGIN_PROLOG could also be cout
bool fApplyCoincidenceD
Whether or not to apply coincidence between hits in adjacent layers.