25 static pthread_mutex_t tt_mutex = PTHREAD_MUTEX_INITIALIZER;
31 static bool tt_initialized =
false;
32 return tt_initialized;
37 static map<DTranslationTable::csc_t, DTranslationTable::DChannelInfo> TT;
43 static map<uint32_t, uint32_t> rocid_map;
49 static map<uint32_t, uint32_t> rocid_inv_map;
55 static map<DTranslationTable::Detector_t, set<uint32_t> > rocid_by_system;
56 return rocid_by_system;
79 }
else{
return a->
end < b->
end; }
100 SYSTEMS_TO_PARSE =
"";
102 gPARMS->SetDefaultParameter(
"TT:NO_CCDB", NO_CCDB,
103 "Don't try getting translation table from CCDB and just look"
104 " for file. Only useful if you want to force reading tt.xml."
105 " This is automatically set if you specify a different"
106 " filename via the TT:XML_FILENAME parameter.");
107 JParameter *p = gPARMS->SetDefaultParameter(
"TT:XML_FILENAME",
XML_FILENAME,
108 "Fallback filename of translation table XML file."
109 " If set to non-default, CCDB will not be checked.");
110 if (p->GetDefault() != p->GetValue())
112 gPARMS->SetDefaultParameter(
"TT:VERBOSE",
VERBOSE,
113 "Verbosity level for Applying Translation Table."
114 " 0=no messages, 10=all messages.");
116 ROCID_MAP_FILENAME =
"rocid.map";
117 gPARMS->SetDefaultParameter(
"TT:ROCID_MAP_FILENAME", ROCID_MAP_FILENAME,
118 "Optional rocid to rocid conversion map for use with files"
119 " generated with the non-standard rocid's");
121 gPARMS->SetDefaultParameter(
"TT:SYSTEMS_TO_PARSE", SYSTEMS_TO_PARSE,
"This is deprecated. Please use EVIO:SYSTEMS_TO_PARSE instead.");
123 gPARMS->SetDefaultParameter(
"TT:CALL_STACK", CALL_STACK,
124 "Set this to one to try and force correct recording of the"
125 "JANA call stack. You will want this if using the janadot"
126 "plugin, but otherwise, it will just give a slight performance"
128 if(SYSTEMS_TO_PARSE !=
""){
129 jerr <<
"You have set the TT:SYSTEMS_TO_PARSE config. parameter." << endl;
130 jerr <<
"This is now deprecated. Please use EVIO:SYSTEMS_TO_PARSE" << endl;
131 jerr <<
"instead. Quitting now to make sure you see this message." << endl;
139 InitNsamplesOverride();
142 ttout.SetTag(
"--- TT ---: ");
143 ttout.SetTimestampFlag();
144 ttout.SetThreadstampFlag();
147 ReadOptionalROCidTranslation();
151 ReadTranslationTable(loop->GetJCalibration());
155 InitFactoryPointers(loop);
185 ifstream ifs(ROCID_MAP_FILENAME.c_str());
186 if (!ifs.is_open())
return;
188 std::cout <<
"Opened ROC id translation map: " << ROCID_MAP_FILENAME << std::endl;
191 ifs.getline(line, 256);
192 if (ifs.gcount() < 1)
break;
193 if (line[0] ==
'#')
continue;
195 stringstream ss(line);
196 uint32_t from=10000, to=10000;
199 if ( from != 10000) {
200 std::cout <<
"unable to convert line:" << std::endl;
201 std::cout <<
" " << line;
204 Get_ROCID_Map()[from] = to;
205 Get_ROCID_Inv_Map()[to] = from;
210 if (Get_ROCID_Map().
size() == Get_ROCID_Inv_Map().
size()) {
211 std::cout <<
" Read " << Get_ROCID_Map().size() <<
" entries" << std::endl;
212 map<uint32_t,uint32_t>::iterator iter;
213 for (iter=Get_ROCID_Map().begin(); iter != Get_ROCID_Map().end(); iter++) {
214 std::cout <<
" rocid " << iter->first <<
" -> rocid "
215 << iter->second << std::endl;
218 std::cout <<
"Entries not unique! This can happen if there are"
220 std::cout <<
"more than one entry with the same value (either"
222 std::cout <<
"two keys or two vals the same.)"
224 std::cout <<
"Please fix the file \"" << ROCID_MAP_FILENAME <<
"\"."
241 if(systems ==
"")
return;
242 jout <<
"Setting systems to parse to: " << systems << endl;
247 if( (!eviosource) && !(evioppsource) ) {
248 jerr <<
"eventsource not a JEventSource_EVIO or JEventSource_EVIOpp object! Cannot restrict parsing list!" << endl;
253 map<string, Detector_t> name_to_id;
254 for(uint32_t dettype=UNKNOWN_DETECTOR; dettype<NUM_DETECTOR_TYPES; dettype++){
267 auto &rocid_map = Get_ROCID_By_System();
268 if(rocid_map.empty()){
269 rocid_map[name_to_id[
"UNKNOWN"]] = {14, 78};
270 rocid_map[name_to_id[
"BCAL"]] = {31, 32, 33, 34, 35 ,36, 37, 38, 39, 40, 41, 42};
271 rocid_map[name_to_id[
"CDC"]] = {25, 26, 27, 28};
272 rocid_map[name_to_id[
"FCAL"]] = {11, 12, 13, 14 ,15, 16, 17, 18, 19, 20, 21, 22};
273 rocid_map[name_to_id[
"FDC_CATHODES"]] = {52, 53, 55, 56, 57, 58, 59, 60, 61, 62};
274 rocid_map[name_to_id[
"FDC_WIRES"]] = {51, 54, 63, 64};
275 rocid_map[name_to_id[
"PS"]] = {83, 84};
276 rocid_map[name_to_id[
"PSC"]] = {84, 95};
277 rocid_map[name_to_id[
"RF"]] = {51, 73, 75, 78, 94, 95};
278 rocid_map[name_to_id[
"SC"]] = {94, 95};
279 rocid_map[name_to_id[
"TAGH"]] = {73, 75};
280 rocid_map[name_to_id[
"TAGM"]] = {71, 75};
281 rocid_map[name_to_id[
"TOF"]] = {77, 78};
282 rocid_map[name_to_id[
"TPOL"]] = {84};
283 rocid_map[name_to_id[
"TAC"]] = {14, 78};
284 rocid_map[name_to_id[
"CCAL"]] = {90};
285 rocid_map[name_to_id[
"CCAL_REF"]] = {90};
286 rocid_map[name_to_id[
"DIRC"]] = {92};
291 std::istringstream ss(systems);
293 while(std::getline(ss, token,
',')) {
296 set<uint32_t> rocids = rocid_map[name_to_id[token]];
300 set<uint32_t> rocids1 = rocid_map[name_to_id[
"FDC_CATHODES"]];
301 set<uint32_t> rocids2 = rocid_map[name_to_id[
"FDC_WIRES"]];
302 rocids.insert(rocids1.begin(), rocids1.end());
303 rocids.insert(rocids2.begin(), rocids2.end());
308 set<uint32_t> rocids1 = rocid_map[name_to_id[
"PSC"]];
309 rocids.insert(rocids1.begin(), rocids1.end());
312 set<uint32_t>::iterator it;
313 for(it=rocids.begin(); it!=rocids.end(); it++){
316 uint32_t rocid = *it;
319 jout <<
" Added rocid " << rocid <<
" for system " << token <<
" to parse list" << endl;
334 if (
VERBOSE > 2) ttout <<
"Entering ApplyTranslationTable:" << std::endl;
344 bool record_call_stack = loop->GetCallStackRecordingStatus();
345 if (record_call_stack) loop->DisableCallStackRecording();
348 vector<const Df250PulseIntegral*> pulseintegrals250;
349 loop->Get(pulseintegrals250);
350 if (
VERBOSE > 2) ttout <<
" Number Df250PulseIntegral objects: " << pulseintegrals250.size() << std::endl;
351 for (uint32_t i=0; i<pulseintegrals250.size(); i++) {
355 uint32_t rocid = pi->
rocid;
356 map<uint32_t, uint32_t>::iterator rocid_iter = Get_ROCID_Map().find(rocid);
357 if (rocid_iter != Get_ROCID_Map().end()) rocid = rocid_iter->second;
360 ttout <<
" Looking for rocid:" << rocid <<
" slot:" << pi->
slot
361 <<
" chan:" << pi->
channel << std::endl;
366 map<csc_t, DChannelInfo>::const_iterator iter = Get_TT().find(csc);
367 if (iter == Get_TT().end()) {
369 ttout <<
" - Didn't find it" << std::endl;
374 ttout <<
" - Found entry for: " << DetectorName(chaninfo.
det_sys)
384 if( pt == NULL || pp == NULL)
continue;
388 case BCAL: MakeBCALDigiHit(chaninfo.
bcal, pi, pt, pp);
break;
389 case FCAL: MakeFCALDigiHit(chaninfo.
fcal, pi, pt, pp);
break;
390 case CCAL: MakeCCALDigiHit(chaninfo.
ccal, pi, pt, pp);
break;
391 case CCAL_REF: MakeCCALRefDigiHit(chaninfo.
ccal_ref, pi, pt, pp);
break;
392 case SC: MakeSCDigiHit( chaninfo.
sc, pi, pt, pp);
break;
393 case TOF: MakeTOFDigiHit( chaninfo.
tof, pi, pt, pp);
break;
394 case TAGM: MakeTAGMDigiHit(chaninfo.
tagm, pi, pt, pp);
break;
395 case TAGH: MakeTAGHDigiHit(chaninfo.
tagh, pi, pt, pp);
break;
396 case PS: MakePSDigiHit(chaninfo.
ps, pi, pt, pp);
break;
397 case PSC: MakePSCDigiHit(chaninfo.
psc, pi, pt, pp);
break;
398 case RF: MakeRFDigiTime(chaninfo.
rf, pt);
break;
399 case TPOLSECTOR: MakeTPOLSectorDigiHit(chaninfo.
tpolsector, pi, pt, pp);
break;
400 case TAC: MakeTACDigiHit(chaninfo.
tac, pi, pt, pp);
break;
403 if (
VERBOSE > 4) ttout <<
" - Don't know how to make DigiHit objects for this detector type!" << std::endl;
409 vector<const Df250PulseData*> pulsedatas250;
410 loop->Get(pulsedatas250);
411 if (
VERBOSE > 2) ttout <<
" Number Df250PulseData objects: " << pulsedatas250.size() << std::endl;
412 for(
auto pd : pulsedatas250){
415 uint32_t rocid = pd->rocid;
416 map<uint32_t, uint32_t>::iterator rocid_iter = Get_ROCID_Map().find(rocid);
417 if (rocid_iter != Get_ROCID_Map().end()) rocid = rocid_iter->second;
419 if (
VERBOSE > 4) ttout <<
" Looking for rocid:" << rocid <<
" slot:" << pd->slot <<
" chan:" << pd->channel << std::endl;
423 csc_t csc = {rocid, pd->
slot, pd->channel};
424 map<csc_t, DChannelInfo>::const_iterator iter = Get_TT().find(csc);
425 if (iter == Get_TT().end()) {
426 if (
VERBOSE > 6) ttout <<
" - Didn't find it" << std::endl;
430 if (
VERBOSE > 6) ttout <<
" - Found entry for: " << DetectorName(chaninfo.
det_sys) << std::endl;
434 case BCAL: MakeBCALDigiHit( chaninfo.
bcal, pd);
break;
435 case FCAL: MakeFCALDigiHit( chaninfo.
fcal, pd);
break;
436 case CCAL: MakeCCALDigiHit( chaninfo.
ccal, pd);
break;
437 case CCAL_REF: MakeCCALRefDigiHit( chaninfo.
ccal_ref, pd);
break;
438 case SC: MakeSCDigiHit( chaninfo.
sc, pd);
break;
439 case TOF: MakeTOFDigiHit( chaninfo.
tof, pd);
break;
440 case TAGM: MakeTAGMDigiHit( chaninfo.
tagm, pd);
break;
441 case TAGH: MakeTAGHDigiHit( chaninfo.
tagh, pd);
break;
442 case PS: MakePSDigiHit( chaninfo.
ps, pd);
break;
443 case PSC: MakePSCDigiHit( chaninfo.
psc, pd);
break;
444 case RF: MakeRFDigiTime( chaninfo.
rf, pd);
break;
445 case TPOLSECTOR: MakeTPOLSectorDigiHit(chaninfo.
tpolsector, pd);
break;
446 case TAC: MakeTACDigiHit(chaninfo.
tac, pd);
break;
448 if (
VERBOSE > 4) ttout <<
" - Don't know how to make DigiHit objects for this detector type!" << std::endl;
454 vector<const Df125PulseIntegral*> pulseintegrals125;
455 loop->Get(pulseintegrals125);
456 if (
VERBOSE > 2) ttout <<
" Number Df125PulseIntegral objects: " << pulseintegrals125.size() << std::endl;
457 for (uint32_t i=0; i<pulseintegrals125.size(); i++) {
461 uint32_t rocid = pi->
rocid;
462 map<uint32_t, uint32_t>::iterator rocid_iter = Get_ROCID_Map().find(rocid);
463 if (rocid_iter != Get_ROCID_Map().end()) rocid = rocid_iter->second;
466 ttout <<
" Looking for rocid:" << rocid <<
" slot:" << pi->
slot
467 <<
" chan:" << pi->
channel << std::endl;
472 map<csc_t, DChannelInfo>::const_iterator iter = Get_TT().find(csc);
473 if (iter == Get_TT().end()) {
475 ttout <<
" - Didn't find it" << std::endl;
480 ttout <<
" - Found entry for: " << DetectorName(chaninfo.
det_sys)
491 case CDC: MakeCDCDigiHit(chaninfo.
cdc, pi, pt, pp);
break;
492 case FDC_CATHODES: MakeFDCCathodeDigiHit(chaninfo.
fdc_cathodes, pi, pt, pp);
break;
494 if (
VERBOSE > 4) ttout <<
" - Don't know how to make DigiHit objects for this detector type!" << std::endl;
500 vector<const Df125CDCPulse*> cdcpulses;
501 loop->Get(cdcpulses);
502 if (
VERBOSE > 2) ttout <<
" Number Df125CDCPulse objects: " << cdcpulses.size() << std::endl;
503 for (uint32_t i=0; i<cdcpulses.size(); i++) {
507 uint32_t rocid = p->
rocid;
508 map<uint32_t, uint32_t>::iterator rocid_iter = Get_ROCID_Map().find(rocid);
509 if (rocid_iter != Get_ROCID_Map().end()) rocid = rocid_iter->second;
512 ttout <<
" Looking for rocid:" << rocid <<
" slot:" << p->
slot
513 <<
" chan:" << p->
channel << std::endl;
518 map<csc_t, DChannelInfo>::const_iterator iter = Get_TT().find(csc);
519 if (iter == Get_TT().end()) {
521 ttout <<
" - Didn't find it" << std::endl;
526 ttout <<
" - Found entry for: " << DetectorName(chaninfo.
det_sys)
531 case CDC: MakeCDCDigiHit(chaninfo.
cdc, p);
break;
533 if (
VERBOSE > 4) ttout <<
" - Don't know how to make DigiHit objects for this detector type!" << std::endl;
539 vector<const Df125FDCPulse*> fdcpulses;
540 loop->Get(fdcpulses);
541 if (
VERBOSE > 2) ttout <<
" Number Df125FDCPulse objects: " << fdcpulses.size() << std::endl;
542 for (uint32_t i=0; i<fdcpulses.size(); i++) {
546 uint32_t rocid = p->
rocid;
547 map<uint32_t, uint32_t>::iterator rocid_iter = Get_ROCID_Map().find(rocid);
548 if (rocid_iter != Get_ROCID_Map().end()) rocid = rocid_iter->second;
551 ttout <<
" Looking for rocid:" << rocid <<
" slot:" << p->
slot
552 <<
" chan:" << p->
channel << std::endl;
557 map<csc_t, DChannelInfo>::const_iterator iter = Get_TT().find(csc);
558 if (iter == Get_TT().end()) {
560 ttout <<
" - Didn't find it" << std::endl;
565 ttout <<
" - Found entry for: " << DetectorName(chaninfo.
det_sys)
570 case FDC_CATHODES: MakeFDCCathodeDigiHit(chaninfo.
fdc_cathodes, p);
break;
571 case CDC : MakeCDCDigiHit(chaninfo.
cdc, p);
break;
573 if (
VERBOSE > 4) ttout <<
" - Don't know how to make DigiHit objects for this detector type!" << std::endl;
579 vector<const DF1TDCHit*> f1tdchits;
580 loop->Get(f1tdchits);
581 if (
VERBOSE > 2) ttout <<
" Number DF1TDCHit objects: " << f1tdchits.size() << std::endl;
582 for (uint32_t i=0; i<f1tdchits.size(); i++) {
586 uint32_t rocid = hit->
rocid;
587 map<uint32_t, uint32_t>::iterator rocid_iter = Get_ROCID_Map().find(rocid);
588 if (rocid_iter != Get_ROCID_Map().end()) rocid = rocid_iter->second;
591 ttout <<
" Looking for rocid:" << rocid <<
" slot:" << hit->
slot
592 <<
" chan:" << hit->
channel << std::endl;
597 map<csc_t, DChannelInfo>::const_iterator iter = Get_TT().find(csc);
598 if (iter == Get_TT().end()) {
600 ttout <<
" - Didn't find it" << std::endl;
605 ttout <<
" - Found entry for: "
606 << DetectorName(chaninfo.
det_sys) << std::endl;
610 case BCAL: MakeBCALTDCDigiHit(chaninfo.
bcal, hit);
break;
611 case FDC_WIRES: MakeFDCWireDigiHit(chaninfo.
fdc_wires, hit);
break;
612 case RF: MakeRFTDCDigiTime(chaninfo.
rf, hit);
break;
613 case SC: MakeSCTDCDigiHit(chaninfo.
sc, hit);
break;
614 case TAGM: MakeTAGMTDCDigiHit(chaninfo.
tagm, hit);
break;
615 case TAGH: MakeTAGHTDCDigiHit(chaninfo.
tagh, hit);
break;
616 case PSC: MakePSCTDCDigiHit(chaninfo.
psc, hit);
break;
618 if (
VERBOSE > 4) ttout <<
" - Don't know how to make DigiHit objects for this detector type!" << std::endl;
624 vector<const DCAEN1290TDCHit*> caen1290tdchits;
625 loop->Get(caen1290tdchits);
626 if (
VERBOSE > 2) ttout <<
" Number DCAEN1290TDCHit objects: " << caen1290tdchits.size() << std::endl;
627 for (uint32_t i=0; i<caen1290tdchits.size(); i++) {
631 uint32_t rocid = hit->
rocid;
632 map<uint32_t, uint32_t>::iterator rocid_iter = Get_ROCID_Map().find(rocid);
633 if (rocid_iter != Get_ROCID_Map().end()) rocid = rocid_iter->second;
636 ttout <<
" Looking for rocid:" << rocid <<
" slot:" << hit->
slot
637 <<
" chan:" << hit->
channel << std::endl;
642 map<csc_t, DChannelInfo>::const_iterator iter = Get_TT().find(csc);
643 if (iter == Get_TT().end()) {
645 ttout <<
" - Didn't find it" << std::endl;
650 ttout <<
" - Found entry for: " << DetectorName(chaninfo.
det_sys)
655 case TOF: MakeTOFTDCDigiHit(chaninfo.
tof, hit);
break;
656 case RF: MakeRFTDCDigiTime(chaninfo.
rf, hit);
break;
657 case TAC: MakeTACTDCDigiHit(chaninfo.
tac, hit);
break;
659 if (
VERBOSE > 4) ttout <<
" - Don't know how to make DigiHit objects for this detector type!" << std::endl;
665 vector<const DDIRCTDCHit*> dirctdchits;
666 loop->Get(dirctdchits);
667 if (
VERBOSE > 2) ttout <<
" Number DDIRCTDCHit objects: " << dirctdchits.size() << std::endl;
668 for (uint32_t i=0; i<dirctdchits.size(); i++) {
672 uint32_t rocid = hit->
rocid;
673 map<uint32_t, uint32_t>::iterator rocid_iter = Get_ROCID_Map().find(rocid);
674 if (rocid_iter != Get_ROCID_Map().end()) rocid = rocid_iter->second;
677 ttout <<
" Looking for rocid:" << rocid <<
" slot:" << hit->
slot
678 <<
" chan:" << hit->
channel << std::endl;
683 map<csc_t, DChannelInfo>::const_iterator iter = Get_TT().find(csc);
684 if (iter == Get_TT().end()) {
686 ttout <<
" - Didn't find it" << std::endl;
691 ttout <<
" - Found entry for: " << DetectorName(chaninfo.
det_sys)
696 case DIRC: MakeDIRCTDCDigiHit(chaninfo.
dirc, hit);
break;
698 if (
VERBOSE > 4) ttout <<
" - Don't know how to make DigiHit objects for this detector type!" << std::endl;
716 if (
VERBOSE > 3) PrintVectorSizes();
722 if (record_call_stack) {
724 loop->EnableCallStackRecording();
727 Addf250ObjectsToCallStack(loop,
"DBCALDigiHit");
728 Addf250ObjectsToCallStack(loop,
"DFCALDigiHit");
729 Addf250ObjectsToCallStack(loop,
"DCCALDigiHit");
730 Addf250ObjectsToCallStack(loop,
"DCCALRefDigiHit");
731 Addf250ObjectsToCallStack(loop,
"DSCDigiHit");
732 Addf250ObjectsToCallStack(loop,
"DTOFDigiHit");
733 Addf250ObjectsToCallStack(loop,
"DTACDigiHit");
734 Addf125CDCObjectsToCallStack(loop,
"DCDCDigiHit", cdcpulses.size()>0);
735 Addf125FDCObjectsToCallStack(loop,
"DFDCCathodeDigiHit", fdcpulses.size()>0);
736 AddF1TDCObjectsToCallStack(loop,
"DBCALTDCDigiHit");
737 AddF1TDCObjectsToCallStack(loop,
"DFDCWireDigiHit");
738 AddF1TDCObjectsToCallStack(loop,
"DRFDigiTime");
739 AddF1TDCObjectsToCallStack(loop,
"DRFTDCDigiTime");
740 AddF1TDCObjectsToCallStack(loop,
"DSCTDCDigiHit");
741 AddCAEN1290TDCObjectsToCallStack(loop,
"DTOFTDCDigiHit");
742 AddCAEN1290TDCObjectsToCallStack(loop,
"DTACTDCDigiHit");
754 ttout <<
" - Making DBCALDigiHit for (mod,lay,sec,end)=("
759 CopyDf250Info(
h, pd);
766 vDBCALDigiHit.push_back(
h);
778 CopyDf250Info(h, pd);
783 vDFCALDigiHit.push_back(h);
795 CopyDf250Info(h, pd);
812 vDCCALDigiHit.push_back(h);
824 CopyDf250Info(h, pd);
828 vDCCALRefDigiHit.push_back(h);
841 CopyDf250Info(h, pd);
847 vDTOFDigiHit.push_back(h);
859 CopyDf250Info(h, pd);
863 vDSCDigiHit.push_back(h);
875 CopyDf250Info(h, pd);
880 vDTAGMDigiHit.push_back(h);
892 CopyDf250Info(h, pd);
896 vDTAGHDigiHit.push_back(h);
908 CopyDf250Info(h, pd);
912 vDPSCDigiHit.push_back(h);
924 CopyDf250Info(h, pd);
929 vDPSDigiHit.push_back(h);
943 ttout <<
" - Making DBCALDigiHit for (mod,lay,sec,end)=("
948 CopyDf250Info(
h, pi, pt, pp);
957 vDBCALDigiHit.push_back(
h);
971 CopyDf250Info(h, pi, pt, pp);
976 vDFCALDigiHit.push_back(h);
990 CopyDf250Info(h, pi, pt, pp);
1005 vDCCALDigiHit.push_back(h);
1019 CopyDf250Info(h, pi, pt, pp);
1023 vDCCALRefDigiHit.push_back(h);
1038 CopyDf250Info(h, pi, pt, pp);
1044 vDTOFDigiHit.push_back(h);
1058 CopyDf250Info(h, pi, pt, pp);
1062 vDSCDigiHit.push_back(h);
1076 CopyDf250Info(h, pi, pt, pp);
1081 vDTAGMDigiHit.push_back(h);
1095 CopyDf250Info(h, pi, pt, pp);
1099 vDTAGHDigiHit.push_back(h);
1113 CopyDf250Info(h, pi, pt, pp);
1117 vDPSCDigiHit.push_back(h);
1131 CopyDf250Info(h, pi, pt, pp);
1136 vDPSDigiHit.push_back(h);
1150 CopyDf125Info(h, pi, pt, pp);
1156 vDCDCDigiHit.push_back(h);
1178 h->AddAssociatedObject(p);
1180 vDCDCDigiHit.push_back(h);
1202 h->AddAssociatedObject(p);
1204 vDCDCDigiHit.push_back(h);
1219 CopyDf125Info(h, pi, pt, pp);
1227 vDFDCCathodeDigiHit.push_back(h);
1253 h->AddAssociatedObject(p);
1255 vDFDCCathodeDigiHit.push_back(h);
1268 CopyDF1TDCInfo(h, hit);
1275 vDBCALTDCDigiHit.push_back(h);
1288 CopyDF1TDCInfo(h, hit);
1294 vDFDCWireDigiHit.push_back(h);
1307 CopyDF1TDCInfo(h, hit);
1312 vDRFTDCDigiTime.push_back(h);
1325 CopyDCAEN1290TDCInfo(h, hit);
1330 vDRFTDCDigiTime.push_back(h);
1347 vDRFDigiTime.push_back(h);
1364 vDRFDigiTime.push_back(h);
1377 CopyDF1TDCInfo(h, hit);
1381 vDSCTDCDigiHit.push_back(h);
1394 CopyDF1TDCInfo(h, hit);
1399 vDTAGMTDCDigiHit.push_back(h);
1412 CopyDF1TDCInfo(h, hit);
1416 vDTAGHTDCDigiHit.push_back(h);
1429 CopyDF1TDCInfo(h, hit);
1433 vDPSCTDCDigiHit.push_back(h);
1446 CopyDCAEN1290TDCInfo(h, hit);
1452 vDTOFTDCDigiHit.push_back(h);
1466 CopyDf250Info(h, pi, pt, pp);
1470 vDTPOLSectorDigiHit.push_back(h);
1482 CopyDf250Info(h, pd);
1486 vDTPOLSectorDigiHit.push_back(h);
1502 CopyDf250Info(h, pi, pt, pp);
1504 vDTACDigiHit.push_back(h);
1516 CopyDf250Info(h, pd);
1518 vDTACDigiHit.push_back(h);
1531 CopyDCAEN1290TDCInfo(h, hit);
1533 vDTACTDCDigiHit.push_back(h);
1546 CopyDIRCTDCInfo(h, hit);
1550 vDDIRCTDCDigiHit.push_back(h);
1561 map<DTranslationTable::csc_t, DTranslationTable::DChannelInfo>::const_iterator detector_index_itr = Get_TT().find(in_daq_index);
1562 if (detector_index_itr == Get_TT().end()) {
1563 stringstream ss_err;
1564 ss_err <<
"Could not find detector channel in Translaton Table: "
1565 <<
"rocid = " << in_daq_index.
rocid
1566 <<
"slot = " << in_daq_index.
slot
1567 <<
"channel = " << in_daq_index.
channel;
1568 throw JException(ss_err.str());
1571 return detector_index_itr->second;
1580 map<DTranslationTable::csc_t, DTranslationTable::DChannelInfo>::const_iterator tt_itr = Get_TT().begin();
1585 for (; tt_itr != Get_TT().end(); tt_itr++) {
1588 switch ( in_channel.
det_sys ) {
1590 if ( det_channel.
bcal == in_channel.
bcal )
1594 if ( det_channel.
cdc == in_channel.
cdc )
1598 if ( det_channel.
fcal == in_channel.
fcal )
1602 if ( det_channel.
ccal == in_channel.
ccal )
1618 if ( det_channel.
ps == in_channel.
ps )
1622 if ( det_channel.
psc == in_channel.
psc )
1626 if ( det_channel.
rf == in_channel.
rf )
1630 if ( det_channel.
sc == in_channel.
sc )
1634 if ( det_channel.
tagh == in_channel.
tagh )
1638 if ( det_channel.
tagm == in_channel.
tagm )
1642 if ( det_channel.
tof == in_channel.
tof )
1650 if ( det_channel.
tac == in_channel.
tac )
1654 if ( det_channel.
dirc == in_channel.
dirc )
1659 jerr <<
"DTranslationTable::GetDAQIndex(): "
1660 <<
"Invalid detector type = " << in_channel.
det_sys
1669 if (tt_itr == Get_TT().end()) {
1670 stringstream ss_err;
1671 ss_err <<
"Could not find DAQ channel in Translaton Table: "
1672 << Channel2Str(in_channel) << std::endl;
1673 throw JException(ss_err.str());
1676 return tt_itr->first;
1686 switch ( in_channel.
det_sys ) {
1692 ss <<
"ring = " << in_channel.
cdc.
ring <<
" straw = " << in_channel.
cdc.
straw;
1695 ss <<
"row = " << in_channel.
fcal.
row <<
" column = " << in_channel.
fcal.
col;
1698 ss <<
"row = " << in_channel.
ccal.
row <<
" column = " << in_channel.
ccal.
col;
1716 ss <<
"side = " << in_channel.
ps.
side <<
" id = " << in_channel.
ps.
id;
1719 ss <<
"id = " << in_channel.
psc.
id;
1725 ss <<
"sector = " << in_channel.
sc.
sector;
1728 ss <<
"id = " << in_channel.
tagh.
id;
1731 ss <<
"row = " << in_channel.
tagm.
row <<
" column = " << in_channel.
tagm.
col;
1734 ss <<
"plane = " << in_channel.
tof.
plane <<
" bar = " << in_channel.
tof.
bar
1735 <<
" end = " << in_channel.
tof.
end;
1744 ss <<
"pixel = " << in_channel.
dirc.
pixel;
1748 ss <<
"Unknown detector type" << std::endl;
1759 AddToCallStack(loop, caller,
"Df250Config");
1760 AddToCallStack(loop, caller,
"Df250PulseIntegral");
1761 AddToCallStack(loop, caller,
"Df250PulsePedestal");
1762 AddToCallStack(loop, caller,
"Df250PulseTime");
1770 AddToCallStack(loop, caller,
"Df125Config");
1773 AddToCallStack(loop, caller,
"Df125CDCPulse");
1776 AddToCallStack(loop, caller,
"Df125PulseIntegral");
1777 AddToCallStack(loop, caller,
"Df125PulsePedestal");
1778 AddToCallStack(loop, caller,
"Df125PulseTime");
1787 AddToCallStack(loop, caller,
"Df125Config");
1790 AddToCallStack(loop, caller,
"Df125FDCPulse");
1793 AddToCallStack(loop, caller,
"Df125PulseIntegral");
1794 AddToCallStack(loop, caller,
"Df125PulsePedestal");
1795 AddToCallStack(loop, caller,
"Df125PulseTime");
1804 AddToCallStack(loop, caller,
"DF1TDCConfig");
1805 AddToCallStack(loop, caller,
"DF1TDCHit");
1813 AddToCallStack(loop, caller,
"DCAEN1290TDCConfig");
1814 AddToCallStack(loop, caller,
"DCAEN1290TDCHit");
1821 string caller,
string callee)
const
1829 JEventLoop::call_stack_t cs;
1830 cs.start_time = cs.end_time = 0.0;
1831 cs.caller_name = caller;
1832 cs.callee_name = callee;
1833 cs.data_source = JEventLoop::DATA_FROM_CACHE;
1834 loop->AddToCallStack(cs);
1835 cs.callee_name = cs.caller_name;
1836 cs.caller_name =
"<ignore>";
1837 cs.data_source = JEventLoop::DATA_FROM_FACTORY;
1838 loop->AddToCallStack(cs);
1848 static void StartElement(
void *userData,
const char *xmlname,
const char **atts);
1849 static void EndElement(
void *userData,
const char *xmlname);
1859 pthread_mutex_lock(&Get_TT_Mutex());
1860 if (Get_TT_Initialized()) {
1861 pthread_mutex_unlock(&Get_TT_Mutex());
1869 if (jcalib && !NO_CCDB) {
1870 map<string,string> tt;
1871 string namepath =
"Translation/DAQ2detector";
1872 jout <<
"Reading translation table from calib DB: " << namepath <<
" ..." << std::endl;
1873 jcalib->GetCalib(namepath, tt);
1874 if (tt.size() != 1) {
1875 jerr <<
" Error: Unexpected translation table format!" << std::endl;
1876 jerr <<
" tt.size()=" << tt.size() <<
" (expected 1)" << std::endl;
1879 map<string,string>::iterator iter = tt.begin();
1880 tt_xml = iter->second;
1885 if (tt_xml.size() == 0) {
1886 if (!NO_CCDB) jout <<
"Unable to get translation table from CCDB." << std::endl;
1887 jout <<
"Will try reading TT from local file: " <<
XML_FILENAME << std::endl;
1891 if (! ifs.is_open()) {
1892 jerr <<
" Error: Cannot open file! Translation table unavailable." << std::endl;
1893 pthread_mutex_unlock(&Get_TT_Mutex());
1899 while (ifs.good()) {
1901 ifs.getline(line, 4096);
1918 auto save_rocid_map = Get_ROCID_By_System();
1919 Get_ROCID_By_System().clear();
1922 XML_Parser xmlParser = XML_ParserCreate(NULL);
1923 if (xmlParser == NULL) {
1924 jerr <<
"readTranslationTable...unable to create parser" << std::endl;
1928 XML_SetUserData(xmlParser, &Get_TT());
1931 int status=XML_Parse(xmlParser, tt_xml.c_str(), tt_xml.size(), 1);
1933 jerr <<
" ?readTranslationTable...parseXMLFile parse error for " <<
XML_FILENAME << std::endl;
1934 jerr << XML_ErrorString(XML_GetErrorCode(xmlParser)) << std::endl;
1939 if( !save_rocid_map.empty() ){
1940 if( save_rocid_map != Get_ROCID_By_System() ){
1941 jerr <<
"The rocid by system map read from the translation table in" << endl;
1942 jerr <<
"the CCDB differs from the default. This may happen if you" << endl;
1943 jerr <<
"specified EVIO:SYSTEMS_TO_PARSE and the hardcoded table is" << endl;
1944 jerr <<
"out of date. If this is the case, you'll need to modify" << endl;
1945 jerr <<
"DTranslationTable.cc or just run without specifying which" << endl;
1946 jerr <<
"systems to parse." << endl;
1947 for(
auto it : Get_ROCID_By_System()){
1948 cerr <<
" " << DetectorName((
Detector_t)it.first) <<
": CCDB rocids=" << Get_ROCID_By_System()[it.first].size() <<
" hardcoded rocids=" << save_rocid_map[it.first].size() << endl;
1950 for(
auto a : Get_ROCID_By_System()[it.first]) cerr << a <<
", ";
1951 cerr <<
"} hardcoded={";
1952 for(
auto a : save_rocid_map[it.first]) cerr << a <<
", ";
1953 cerr <<
"}" << endl;
1955 for(
auto it : save_rocid_map){
1956 if(Get_ROCID_By_System().find(it.first) != Get_ROCID_By_System().end())
continue;
1957 cerr <<
" " << DetectorName((
Detector_t)it.first) <<
": CCDB rocids=" << Get_ROCID_By_System()[it.first].size() <<
" hardcoded rocids=" << save_rocid_map[it.first].size() << endl;
1959 for(
auto a : Get_ROCID_By_System()[it.first]) cerr << a <<
", ";
1960 cerr <<
"} hardcoded={";
1961 for(
auto a : save_rocid_map[it.first]) cerr << a <<
", ";
1962 cerr <<
"}" << endl;
1968 jout << Get_TT().size() <<
" channels defined in translation table" << std::endl;
1969 XML_ParserFree(xmlParser);
1971 pthread_mutex_unlock(&Get_TT_Mutex());
1972 Get_TT_Initialized() =
true;
1980 if ( type ==
"fdc_cathodes" ) {
1982 }
else if ( type ==
"fdc_wires" ) {
1984 }
else if ( type ==
"bcal" ) {
1986 }
else if ( type ==
"cdc" ) {
1988 }
else if ( type ==
"fcal" ) {
1990 }
else if ( type ==
"ccal" ) {
1992 }
else if ( type ==
"ccal_ref" ) {
1994 }
else if ( type ==
"ps" ) {
1996 }
else if ( type ==
"psc" ) {
1998 }
else if ( type ==
"rf" ) {
2000 }
else if ( type ==
"st" ) {
2005 }
else if ( type ==
"tagh" ) {
2007 }
else if ( type ==
"tagm" ) {
2009 }
else if ( type ==
"tof" ) {
2011 }
else if ( type ==
"tpol" ) {
2013 }
else if ( type ==
"tac" ) {
2015 }
else if ( type ==
"dirc" ) {
2028 static int crate=0, slot=0;
2030 static string type,Type;
2033 string Detector, locSystem;
2036 int ring=0,straw=0,plane=0,bar=0;
2037 int package=0,chamber=0,view=0,strip=0,wire=0;
2038 int id=0, strip_type=0;
2045 map<DTranslationTable::csc_t, DTranslationTable::DChannelInfo> &TT = *((map<DTranslationTable::csc_t, DTranslationTable::DChannelInfo>*)userData);
2048 if (strcasecmp(xmlname,
"halld_online_translation_table") == 0) {
2051 }
else if (strcasecmp(xmlname,
"crate") == 0) {
2052 for (
int i=0; atts[i]; i+=2) {
2053 if (strcasecmp(atts[i],
"number") == 0) {
2054 crate = atoi(atts[i+1]);
2059 }
else if (strcasecmp(xmlname,
"slot") == 0) {
2060 for (
int i=0; atts[i]; i+=2) {
2061 if (strcasecmp(atts[i],
"number") == 0) {
2062 slot = atoi(atts[i+1]);
2063 }
else if (strcasecmp(atts[i],
"type") == 0) {
2064 Type =
string(atts[i+1]);
2065 type =
string(atts[i+1]);
2066 std::transform(type.begin(), type.end(), type.begin(), (int(*)(int)) tolower);
2080 }
else if (strcasecmp(xmlname,
"channel") == 0) {
2082 for (
int i=0; atts[i]; i+=2) {
2083 string tag(atts[i+0]);
2084 string sval(atts[i+1]);
2085 int ival = atoi(atts[i+1]);
2087 if (tag ==
"number")
2089 else if (tag ==
"detector")
2091 else if (tag ==
"row")
2093 else if (tag ==
"column")
2095 else if (tag ==
"col")
2097 else if (tag ==
"module")
2099 else if (tag ==
"sector")
2101 else if (tag ==
"layer")
2103 else if (tag ==
"chan");
2105 else if (tag ==
"ring")
2107 else if (tag ==
"straw")
2109 else if (tag ==
"gPlane");
2111 else if (tag ==
"element");
2113 else if (tag ==
"plane")
2115 else if (tag ==
"bar")
2117 else if (tag ==
"package")
2119 else if (tag ==
"chamber")
2121 else if (tag ==
"view") {
2124 else if (sval ==
"D")
2127 else if (tag ==
"strip")
2129 else if (tag ==
"wire")
2131 else if (tag ==
"side") {
2135 else if (sval ==
"B") {
2139 else if (tag ==
"pixel") {
2142 else if (tag ==
"id")
2144 else if (tag ==
"end") {
2149 else if (sval ==
"D") {
2153 else if (sval ==
"N")
2155 else if (sval ==
"S")
2157 else if (sval ==
"UP")
2159 else if (sval ==
"DW")
2162 else if (tag ==
"strip_type") {
2165 else if (sval ==
"A")
2167 else if (sval ==
"B")
2170 else if (tag ==
"system")
2181 if (type ==
"a1535sn")
2207 string detector = Detector;
2208 std::transform(detector.begin(), detector.end(), detector.begin(), (int(*)(int)) tolower);
2220 switch (ci.det_sys) {
2222 ci.bcal.module = module;
2223 ci.bcal.layer =
layer;
2224 ci.bcal.sector = sector;
2229 ci.cdc.straw = straw;
2240 ci.ccal_ref.id = id;
2243 ci.fdc_cathodes.package = package;
2244 ci.fdc_cathodes.chamber = chamber;
2245 ci.fdc_cathodes.view = view;
2246 ci.fdc_cathodes.strip = strip;
2247 ci.fdc_cathodes.strip_type = strip_type;
2250 ci.fdc_wires.package = package;
2251 ci.fdc_wires.chamber = chamber;
2252 ci.fdc_wires.wire = wire;
2258 ci.sc.sector = sector;
2268 ci.tof.plane = plane;
2280 ci.tpolsector.sector = sector;
2286 ci.dirc.pixel = pixel;
2294 jerr << std::endl << std::endl
2295 <<
"?startElement...unknown xml tag " << xmlname
2296 << std::endl << std::endl;
DFDCCathodeDigiHit * MakeFDCCathodeDigiHit(const FDC_CathodesIndex_t &idx, const Df125PulseIntegral *pi, const Df125PulseTime *pt, const Df125PulsePedestal *pp) const
DCCALRefDigiHit * MakeCCALRefDigiHit(const CCALRefIndex_t &idx, const Df250PulseData *pd) const
DSCDigiHit * MakeSCDigiHit(const SCIndex_t &idx, const Df250PulseData *pd) const
uint32_t first_max_amp
from second word
DPSDigiHit * MakePSDigiHit(const PSIndex_t &idx, const Df250PulseData *pd) const
int counter_id
counter id 1-274
DTAGMDigiHit * MakeTAGMDigiHit(const TAGMIndex_t &idx, const Df250PulseData *pd) const
DBCALTDCDigiHit * MakeBCALTDCDigiHit(const BCALIndex_t &idx, const DF1TDCHit *hit) const
void ApplyTranslationTable(jana::JEventLoop *loop) const
int column
column number 1-102
map< uint32_t, uint32_t > & Get_ROCID_Map(void) const
DCDCDigiHit * MakeCDCDigiHit(const CDCIndex_t &idx, const Df125PulseIntegral *pi, const Df125PulseTime *pt, const Df125PulsePedestal *pp) const
static DTranslationTable::Detector_t DetectorStr2DetID(string &type)
bool operator<(const DSourceComboUse &lhs, const DSourceComboUse &rhs)
DPSCDigiHit * MakePSCDigiHit(const PSCIndex_t &idx, const Df250PulseData *pd) const
DTACDigiHit * MakeTACDigiHit(const TACIndex_t &idx, const Df250PulseData *pd) const
int sector
sector number 1-24
DDIRCTDCDigiHit * MakeDIRCTDCDigiHit(const DIRCIndex_t &idx, const DDIRCTDCHit *hit) const
FDC_CathodesIndex_t fdc_cathodes
DBCALDigiHit * MakeBCALDigiHit(const BCALIndex_t &idx, const Df250PulseData *pd) const
TPOLSECTORIndex_t tpolsector
uint32_t peak_amp
from second word (type 9)
static map< DTranslationTable::Detector_t, set< uint32_t > > & Get_ROCID_By_System(void)
uint32_t pulse_integral
identified pulse integral as returned by FPGA algorithm
uint32_t pedestal
from second word
uint32_t integral
from second word (type 6)
void AddROCIDtoParseList(uint32_t rocid)
uint32_t QF
Quality Factor from FPGA algorithms.
DSCTDCDigiHit * MakeSCTDCDigiHit(const SCIndex_t &idx, const DF1TDCHit *hit) const
uint32_t overflow_count
from first word
DPSCTDCDigiHit * MakePSCTDCDigiHit(const PSCIndex_t &idx, const DF1TDCHit *hit) const
int counter_id
counter id 1-274
void Addf125CDCObjectsToCallStack(JEventLoop *loop, string caller, bool addpulseobjs) const
uint32_t pulse_peak
from Pulse Pedestal Data word
void AddROCIDtoParseList(uint32_t rocid)
DCCALDigiHit * MakeCCALDigiHit(const CCALIndex_t &idx, const Df250PulseData *pd) const
bool & Get_TT_Initialized(void) const
void Addf250ObjectsToCallStack(JEventLoop *loop, string caller) const
uint32_t le_time
from first word
uint32_t pulse_time
identified pulse time as returned by FPGA algorithm
string Channel2Str(const DChannelInfo &in_channel) const
uint32_t nsamples_pedestal
number of samples used in integral
DTAGMTDCDigiHit * MakeTAGMTDCDigiHit(const TAGMIndex_t &idx, const DF1TDCHit *hit) const
bool SortBCALDigiHit(const DBCALDigiHit *a, const DBCALDigiHit *b)
DRFDigiTime * MakeRFDigiTime(const RFIndex_t &idx, const Df250PulseData *pd) const
uint32_t pedestal
pedestal info used by FPGA (if any)
uint32_t le_time
from first word
uint32_t nsamples_integral
number of samples used in integral
static void EndElement(void *userData, const char *xmlname)
DTOFDigiHit * MakeTOFDigiHit(const TOFIndex_t &idx, const Df250PulseData *pd) const
DTOFTDCDigiHit * MakeTOFTDCDigiHit(const TOFIndex_t &idx, const DCAEN1290TDCHit *hit) const
const DChannelInfo & GetDetectorIndex(const csc_t &in_daq_index) const
DetectorSystem_t NameToSystem(const char *locSystemName)
How this Event Source Works
DTAGHDigiHit * MakeTAGHDigiHit(const TAGHIndex_t &idx, const Df250PulseData *pd) const
uint32_t pulse_integral
identified pulse integral as returned by FPGA algorithm
void Addf125FDCObjectsToCallStack(JEventLoop *loop, string caller, bool addpulseobjs) const
const csc_t & GetDAQIndex(const DChannelInfo &in_channel) const
DRFTDCDigiTime * MakeRFTDCDigiTime(const RFIndex_t &idx, const DF1TDCHit *hit) const
DFDCWireDigiHit * MakeFDCWireDigiHit(const FDC_WiresIndex_t &idx, const DF1TDCHit *hit) const
DTAGHTDCDigiHit * MakeTAGHTDCDigiHit(const TAGHIndex_t &idx, const DF1TDCHit *hit) const
uint32_t time_quality_bit
from first word
uint32_t time_quality_bit
from first word
DTranslationTable(JEventLoop *loop)
const char * SystemName(DetectorSystem_t sys)
uint32_t pulse_time
identified pulse time as returned by FPGA algorithm
uint32_t time
from Pulse Time Data word
uint32_t QF
Quality Factor from FPGA algorithms.
pthread_mutex_t & Get_TT_Mutex(void) const
map< DTranslationTable::csc_t, DTranslationTable::DChannelInfo > & Get_TT(void) const
int end
left/right 0/1 or North/South 0/1
void ReadTranslationTable(JCalibration *jcalib=NULL)
void AddF1TDCObjectsToCallStack(JEventLoop *loop, string caller) const
DTACTDCDigiHit * MakeTACTDCDigiHit(const TACIndex_t &idx, const DCAEN1290TDCHit *hit) const
uint32_t pedestal
from second word
void AddCAEN1290TDCObjectsToCallStack(JEventLoop *loop, string caller) const
uint32_t nsamples_integral
number of samples used in pedestal
void ReadOptionalROCidTranslation(void)
uint32_t nsamples_pedestal
number of samples used in pedestal
uint32_t nsamples_integral
number of samples used in pedestal
uint32_t nsamples_integral
number of samples used in integral
uint32_t pulse_time
identified pulse time as returned by FPGA algorithm
uint32_t nsamples_pedestal
number of samples used in pedestal
The JEventSource_EVIO class implements a JEventSource capable of reading in EVIO data from raw data f...
int plane
plane (0: vertical, 1: horizontal)
DTPOLSectorDigiHit * MakeTPOLSectorDigiHit(const TPOLSECTORIndex_t &idx, const Df250PulseData *pd) const
static void StartElement(void *userData, const char *xmlname, const char **atts)
uint32_t integral
from second word
static void SetSystemsToParse(string systems, JEventSource *eventsource)
uint32_t pedestal
pedestal info used by FPGA (if any)
FDC_WiresIndex_t fdc_wires
uint32_t pulse_peak
identified pulse first peak as returned by FPGA algorithm (could be either Df125CDCPulse::first_max_a...
void AddToCallStack(JEventLoop *loop, string caller, string callee) const
map< uint32_t, uint32_t > & Get_ROCID_Inv_Map(void) const
uint32_t nsamples_pedestal
number of samples used in integral
uint32_t overflow_count
from first word
DFCALDigiHit * MakeFCALDigiHit(const FCALIndex_t &idx, const Df250PulseData *pd) const