69 static TH1F *tofEnergies;
70 static TH1F *fcalEnergies;
71 static TH1F *bcalEnergies;
72 static TH1F *stEnergies;
73 static TH1F *tagmEnergies;
74 static TH1F *taghEnergies;
76 static TH1F *fdcCharges;
77 static TH1F *cdcCharges;
79 static TH1F *tofTimes;
80 static TH1F *fdcTimes;
81 static TH1F *cdcTimes;
82 static TH1F *fcalTimes;
83 static TH1F *bcalTimes;
85 static TH1F *tagmTimes;
86 static TH1F *taghTimes;
101 string lexical_cast(T t)
110 static pthread_mutex_t rawMutex = PTHREAD_MUTEX_INITIALIZER;
114 static evioFileChannel *
chan = NULL;
115 static string fileBase =
"rawevent";
116 static string outputFileName;
117 static string translationTableName =
"tt.xml";
121 static int runNumber;
122 static unsigned int user_runNumber=0xdeadbeef;
128 static map<string,cscVal> cscMap;
131 static cscVal CDCBAL_NULL = {-1, -1, -1};
132 static cscRef CSCREF_NULL = CDCBAL_NULL;
136 #define MAXDCRATE 99+1
137 #define MAXDSLOT 21+1
138 #define MAXDCHANNEL 72+1
139 static string detectorMap[MAXDCRATE][MAXDSLOT][MAXDCHANNEL];
145 #define MAXEVENTSIZE 30000*4 // in bytes
148 static string expName =
"HallD";
152 static int nCrate = 0;
153 static int maxCrateNum = 0;
154 static int crateID[MAXCRATE];
155 static int nModules[MAXCRATE];
156 static int modules[MAXCRATE][MAXSLOT];
157 static int detID[MAXCRATE][MAXSLOT];
161 static uint64_t trigTime = 32000000;
162 static float tMin = -100000.;
165 static double trigtick = 4000;
166 static double CAENTDCtick = 25.;
167 static double F1TDC32tick = 60.;
168 static double F1TDC48tick = 115.;
169 static double FADC250tick = 62.5;
170 static double FADC125tick = 800.;
172 static double CDC_ADCscale = 0.25E5/1.0E6;
173 static double FDC_ADCscale = 1.3E5/2.4E4;
174 static double FCAL_ADCscale = 2.5E5/4.0E1;
175 static double BCAL_ADCscale = 10000.;
176 static double TOF_ADCscale = 5.2E5/0.2;
177 static double SC_ADCscale = 10000.;
180 static double PSC_ADCscale = 10000.;
181 static double PS_ADCscale = 10000.;
184 static float CDC_ADCtick = FADC125tick;
185 static double FDC_ADCtick = FADC125tick;
186 static double FCAL_ADCtick = FADC250tick;
187 static double BCAL_ADCtick = FADC250tick;
188 static double TOF_ADCtick = FADC250tick;
189 static double SC_ADCtick = FADC250tick;
192 static double PSC_ADCtick = FADC250tick;
193 static double PS_ADCtick = FADC250tick;
195 static double FDC_TDCtick = F1TDC48tick;
196 static double BCAL_TDCtick = F1TDC32tick;
197 static double TOF_TDCtick = CAENTDCtick;
198 static double SC_TDCtick = F1TDC32tick;
201 static double PSC_TDCtick = F1TDC32tick;
208 static double CDC_time_window = -1.;
209 static double FDC_time_window = -1.;
210 static double FCAL_time_window = -1.;
211 static double BCAL_time_window = -1.;
212 static double TOF_time_window = 100.;
213 static double SC_time_window = -1.;
214 static double TAGH_time_window = -1.;
215 static double TAGM_time_window = -1.;
216 static double PSC_time_window = 200.;
217 static double PS_time_window = 200.;
220 static int dumphits = 0;
221 static int nomc2coda = 0;
222 static int noroot = 0;
223 static int dumpmap = 0;
226 bool NO_CCDB =
false;
254 bool operator == (cscRef a, cscRef b) {
255 if (a.channel != b.channel)
257 if (a.slot != b.slot)
259 return a.crate == b.crate;
275 gPARMS->SetDefaultParameter(
"TT:NO_CCDB", NO_CCDB,
"Don't try getting"
276 " translation table from CCDB and just look for file. Only useful"
277 " if you want to force reading tt.xml. This is automatically set"
278 " if you specify a different filename via the "
279 "TT:XML_FILENAME parameter.");
280 JParameter *p = gPARMS->SetDefaultParameter(
"TT:XML_FILENAME", XML_FILENAME,
281 "Fallback filename of translation table XML file."
282 " If set to non-default, CCDB will not be checked.");
283 if (p->GetDefault() != p->GetValue())
288 gPARMS->SetDefaultParameter(
"RAWEVENT:FILEBASE",fileBase);
291 gPARMS->SetDefaultParameter(
"RAWEVENT:TRANSLATION",translationTableName);
294 gPARMS->SetDefaultParameter(
"RAWEVENT:TRIGTIME",trigTime);
297 gPARMS->SetDefaultParameter(
"RAWEVENT:TMIN",tMin);
300 gPARMS->SetDefaultParameter(
"RAWEVENT:NOMC2CODA",nomc2coda);
303 gPARMS->SetDefaultParameter(
"RAWEVENT:NOROOT",noroot);
306 gPARMS->SetDefaultParameter(
"RAWEVENT:DUMPHITS",dumphits);
309 gPARMS->SetDefaultParameter(
"RAWEVENT:DUMPMAP",dumpmap,
310 "Dump map of translation table map to file (for debugging)");
313 gPARMS->SetDefaultParameter(
"RAWEVENT:RUNNUMBER",user_runNumber,
314 "Override run number from input file with this one"
315 " which will be written to every event in output file");
318 gPARMS->SetDefaultParameter(
"RAWEVENT:NO_PEDESTAL",NO_PEDESTAL,
"Set to non-zero value to enable pedestals (default is to always use \"0\" for all pedestals)");
319 gPARMS->SetDefaultParameter(
"RAWEVENT:NO_RANDOM_PEDESTAL",NO_RANDOM_PEDESTAL,
"Set this to zero to disable any randomness in pedestals (def. is to randomize)");
320 gPARMS->SetDefaultParameter(
"RAWEVENT:MEAN_PEDESTAL",MEAN_PEDESTAL,
"Mean value of single sample pedestal.");
321 gPARMS->SetDefaultParameter(
"RAWEVENT:SIGMA_COMMON_PEDESTAL",SIGMA_COMMON_PEDESTAL,
"Stochastic width of common pedestal distribution. Common pedestal is used for all channels in a module but will be different module to module.");
322 gPARMS->SetDefaultParameter(
"RAWEVENT:SIGMA_INDIVIDUAL_PEDESTAL",SIGMA_INDIVIDUAL_PEDESTAL,
"Stochastic width of MEASURED pedestal");
325 gPARMS->SetDefaultParameter(
"RAWEVENT:CDC_TIME_WINDOW",CDC_time_window,
"Optional window size in which to save CDC hits (in ns)");
326 gPARMS->SetDefaultParameter(
"RAWEVENT:FDC_TIME_WINDOW",FDC_time_window,
"Optional window size in which to save FDC hits (in ns)");
327 gPARMS->SetDefaultParameter(
"RAWEVENT:FCAL_TIME_WINDOW",FCAL_time_window,
"Optional window size in which to save FCAL hits (in ns)");
328 gPARMS->SetDefaultParameter(
"RAWEVENT:BCAL_TIME_WINDOW",BCAL_time_window,
"Optional window size in which to save BCAL hits (in ns)");
329 gPARMS->SetDefaultParameter(
"RAWEVENT:TOF_TIME_WINDOW",TOF_time_window,
"Optional window size in which to save TOF hits (in ns)");
330 gPARMS->SetDefaultParameter(
"RAWEVENT:SC_TIME_WINDOW",SC_time_window,
"Optional window size in which to save Start Counter hits (in ns)");
331 gPARMS->SetDefaultParameter(
"RAWEVENT:TAGH_TIME_WINDOW",TAGH_time_window,
"Optional window size in which to save Tagger Hodoscope hits (in ns)");
332 gPARMS->SetDefaultParameter(
"RAWEVENT:TAGM_TIME_WINDOW",TAGM_time_window,
"Optional window size in which to save Tagger Microscope hits (in ns)");
333 gPARMS->SetDefaultParameter(
"RAWEVENT:PSC_TIME_WINDOW",PSC_time_window,
"Optional window size in which to save Coarse Pair Spectrometer hits (in ns)");
334 gPARMS->SetDefaultParameter(
"RAWEVENT:PS_TIME_WINDOW",PS_time_window,
"Optional window size in which to save Fine Pair Spectrometer hits (in ns)");
348 if (nomc2coda == 0) {
363 readTranslationTable();
366 if (nomc2coda == 0) {
369 jerr <<
"?NULL return from mc2codaInitExp()" << std::endl;
378 if (nomc2coda == 0) {
379 for (
int i=0; i<nCrate; i++) {
380 int nMod = nModules[i]-2;
386 if(crateID[i] == 51) {
392 stat =
mc2codaSetCrate(expID,crateID[i],nModules[i]-2,modules[i],detID[i]);
394 jerr <<
"?JEventProcessor_rawevent...error return from mc2codaSetCrate()"
395 << std::endl << std::endl;
403 ofstream *ofs =
new ofstream(
"cscMap.out");
405 jout <<
"Dumping translation table map to cscMap.out ..." << std::endl;
406 map<string,cscVal>::iterator iter = cscMap.begin();
407 for (; iter != cscMap.end(); iter++) {
408 cscVal &csc = iter->second;
409 *ofs << iter->first <<
" " << csc.crate <<
" " << csc.slot
410 <<
" " << csc.channel << std::endl;
419 tofEnergies =
new TH1F(
"tofe",
"TOF energies in keV",1000,0.,5000.);
420 stEnergies =
new TH1F(
"ste",
"ST energies in keV",1000,0.,5000.);
421 fcalEnergies =
new TH1F(
"fcale",
"FCAL energies in keV",1000,0.,500000.);
422 bcalEnergies =
new TH1F(
"bcale",
"BCAL energies in keV",1000,0.,1000000.);
423 tagmEnergies =
new TH1F(
"tagme",
"Tagger microscope energies in keV",1000,0.,40000.);
424 taghEnergies =
new TH1F(
"taghe",
"Tagger hodoscope array energies in keV",1000,0.,40000.);
426 fdcCharges =
new TH1F(
"fdcq",
"FDC charges in fC",1000,0.,1500.);
427 cdcCharges =
new TH1F(
"cdcq",
"CDC charges in fC",1000,0.,25000.);
429 tofTimes =
new TH1F(
"toft",
" TOF times in nsec",1000,0.,500.-tMin/1000);
430 stTimes =
new TH1F(
"stt",
"ST times in nsec",1000,0.,250.-tMin/1000);
431 fdcTimes =
new TH1F(
"fdct",
"FDC times in nsec",1000,0.,2000.-tMin/1000);
432 cdcTimes =
new TH1F(
"cdct",
"CDC times in nsec",1000,0.,1000.-tMin/1000);
433 bcalTimes =
new TH1F(
"bcalt",
"BCAL times in nsec",1000,0.,200.-tMin/1000);
434 fcalTimes =
new TH1F(
"fcalt",
"FCAL times in nsec",1000,0.,200.-tMin/1000);
435 tagmTimes =
new TH1F(
"tagmt",
"Tagger microscope times in nsec",1000,0.,250.-tMin/1000);
436 taghTimes =
new TH1F(
"tahft",
"Tagger hodoscope times in nsec",1000,0.,250.-tMin/1000);
452 jout << std::endl <<
" brun called for run " << runNumber << std::endl;
453 if (user_runNumber != 0xdeadbeef) {
454 jout <<
" *** overriding with user-supplied run number: "
455 << user_runNumber <<
" ***" << std::endl;
456 runNumber = runnumber = user_runNumber;
470 ss << fileBase <<
"_" << setw(6) << setfill(
'0') << runNumber <<
".evio" << ends;
471 outputFileName=ss.str();
475 chan =
new evioFileChannel(outputFileName,
"w");
477 jout << std::endl <<
" opening output file: " << outputFileName << std::endl << std::endl << std::endl;
484 jout <<
"Loading ADC/TDC scale factors..." << endl;
487 map<string, int> tdc_parms;
488 if(eventLoop->GetCalib(
"/F1TDC/rollover", tdc_parms))
489 jout <<
"Error loading /F1TDC/rollover !" << endl;
490 map<string, int>::const_iterator locMapIterator = tdc_parms.find(
"tframe");
491 double dRolloverTimeWindowLength = (locMapIterator != tdc_parms.end()) ?
double(tdc_parms[
"tframe"]) : std::numeric_limits<double>::quiet_NaN();
493 locMapIterator = tdc_parms.find(
"count");
494 uint64_t dNumTDCTicksInRolloverTimeWindow = (locMapIterator != tdc_parms.end()) ?
double(tdc_parms[
"count"]) : std::numeric_limits<double>::quiet_NaN();
495 double locTDCToNsScaleFactor = dRolloverTimeWindowLength/double(dNumTDCTicksInRolloverTimeWindow);
497 FDC_TDCtick = 1000.0*locTDCToNsScaleFactor*2.0;
498 BCAL_TDCtick = 1000.0*locTDCToNsScaleFactor;
499 SC_TDCtick = 1000.0*locTDCToNsScaleFactor;
500 PSC_TDCtick = 1000.0*locTDCToNsScaleFactor;
502 map<string,double> scale_factors;
503 if (eventLoop->GetCalib(
"/CDC/digi_scales", scale_factors))
504 jout <<
"Error loading /CDC/digi_scales !" << endl;
505 if ( scale_factors.find(
"CDC_ADC_ASCALE") != scale_factors.end() ) {
506 CDC_ADCscale = 1. / scale_factors[
"CDC_ADC_ASCALE"];
508 jerr <<
"Unable to get CDC_ADC_ASCALE from /CDC/digi_scales !" << endl;
510 if ( scale_factors.find(
"CDC_ADC_TSCALE") != scale_factors.end() ) {
511 CDC_ADCtick = 1000. * scale_factors[
"CDC_ADC_TSCALE"];
513 jerr <<
"Unable to get CDC_ADC_TSCALE from /CDC/digi_scales !" << endl;
516 if (eventLoop->GetCalib(
"/FDC/digi_scales", scale_factors))
517 jout <<
"Error loading /FDC/digi_scales !" << endl;
518 if ( scale_factors.find(
"FDC_ADC_ASCALE") != scale_factors.end() ) {
519 FDC_ADCscale = 1. / scale_factors[
"FDC_ADC_ASCALE"];
521 jerr <<
"Unable to get FDC_ADC_ASCALE from /FDC/digi_scales !" << endl;
523 if ( scale_factors.find(
"FDC_ADC_TSCALE") != scale_factors.end() ) {
524 FDC_ADCtick = 1000. * scale_factors[
"FDC_ADC_TSCALE"];
526 jerr <<
"Unable to get FDC_ADC_TSCALE from /FDC/digi_scales !" << endl;
529 if (eventLoop->GetCalib(
"/FCAL/digi_scales", scale_factors))
530 jout <<
"Error loading /FCAL/digi_scales !" << endl;
531 if ( scale_factors.find(
"FCAL_ADC_ASCALE") != scale_factors.end() ) {
532 FCAL_ADCscale = 1. / scale_factors[
"FCAL_ADC_ASCALE"];
534 jerr <<
"Unable to get FCAL_ADC_ASCALE from /FCAL/digi_scales !" << endl;
536 if ( scale_factors.find(
"FCAL_ADC_TSCALE") != scale_factors.end() ) {
537 FCAL_ADCtick = 1000. * scale_factors[
"FCAL_ADC_TSCALE"];
539 jerr <<
"Unable to get FCAL_ADC_TSCALE from /FCAL/digi_scales !" << endl;
542 if (eventLoop->GetCalib(
"/BCAL/digi_scales", scale_factors))
543 jout <<
"Error loading /BCAL/digi_scales !" << endl;
544 if ( scale_factors.find(
"BCAL_ADC_ASCALE") != scale_factors.end() ) {
545 BCAL_ADCscale = 1. / scale_factors[
"BCAL_ADC_ASCALE"];
547 jerr <<
"Unable to get BCAL_ADC_ASCALE from /BCAL/digi_scales !" << endl;
549 if ( scale_factors.find(
"BCAL_ADC_TSCALE") != scale_factors.end() ) {
550 BCAL_ADCtick = 1000. * scale_factors[
"BCAL_ADC_TSCALE"];
552 jerr <<
"Unable to get BCAL_ADC_TSCALE from /BCAL/digi_scales !" << endl;
555 if (eventLoop->GetCalib(
"/TOF/digi_scales", scale_factors))
556 jout <<
"Error loading /TOF/digi_scales !" << endl;
557 if ( scale_factors.find(
"TOF_ADC_ASCALE") != scale_factors.end() ) {
558 TOF_ADCscale = 1. / scale_factors[
"TOF_ADC_ASCALE"];
560 jerr <<
"Unable to get TOF_ADC_ASCALE from /TOF/digi_scales !" << endl;
562 if ( scale_factors.find(
"TOF_ADC_TSCALE") != scale_factors.end() ) {
563 TOF_ADCtick = 1000. * scale_factors[
"TOF_ADC_TSCALE"];
565 jerr <<
"Unable to get TOF_ADC_TSCALE from /TOF/digi_scales !" << endl;
567 if ( scale_factors.find(
"TOF_TDC_SCALE") != scale_factors.end() ) {
568 TOF_TDCtick = 1000. * scale_factors[
"TOF_TDC_SCALE"];
570 jerr <<
"Unable to get TOF_TDC_SCALE from /TOF/digi_scales !" << endl;
573 if (eventLoop->GetCalib(
"/START_COUNTER/digi_scales", scale_factors))
574 jout <<
"Error loading /START_COUNTER/digi_scales !" << endl;
575 if ( scale_factors.find(
"SC_ADC_ASCALE") != scale_factors.end() ) {
576 SC_ADCscale = 1. / scale_factors[
"SC_ADC_ASCALE"];
578 jerr <<
"Unable to get SC_ADC_ASCALE from /START_COUNTER/digi_scales !" << endl;
580 if ( scale_factors.find(
"SC_ADC_TSCALE") != scale_factors.end() ) {
581 SC_ADCtick = 1000. * scale_factors[
"SC_ADC_TSCALE"];
583 jerr <<
"Unable to get SC_ADC_TSCALE from /START_COUNTER/digi_scales !" << endl;
587 if (eventLoop->GetCalib(
"/PHOTON_BEAM/pair_spectrometer/digi_scales", scale_factors))
588 jout <<
"Error loading /PHOTON_BEAM/pair_spectrometer/digi_scales !" << endl;
589 if ( scale_factors.find(
"PSC_ADC_ASCALE") != scale_factors.end() ) {
590 PSC_ADCscale = 1. / scale_factors[
"PSC_ADC_ASCALE"];
592 jerr <<
"Unable to get PSC_ADC_ASCALE from /PHOTON_BEAM/pair_spectrometer/digi_scales !" << endl;
594 if ( scale_factors.find(
"PSC_ADC_TSCALE") != scale_factors.end() ) {
595 PSC_ADCtick = 1000. * scale_factors[
"PSC_ADC_TSCALE"];
597 jerr <<
"Unable to get PSC_ADC_TSCALE from /PHOTON_BEAM/pair_spectrometer/digi_scales !" << endl;
600 if ( scale_factors.find(
"PS_ADC_ASCALE") != scale_factors.end() ) {
601 PS_ADCscale = 1. / scale_factors[
"PS_ADC_ASCALE"];
603 jerr <<
"Unable to get PS_ADC_ASCALE from /PHOTON_BEAM/pair_spectrometer/digi_scales !" << endl;
605 if ( scale_factors.find(
"PS_ADC_TSCALE") != scale_factors.end() ) {
606 PS_ADCtick = 1000. * scale_factors[
"PS_ADC_TSCALE"];
608 jerr <<
"Unable to get PS_ADC_TSCALE from /PHOTON_BEAM/pair_spectrometer/digi_scales !" << endl;
633 }
else if (h1->
bar != h2->
bar) {
635 }
else if (h1->
end != h2->
end) {
659 }
else if (h1->
end != h2->
end) {
673 }
else if (h1->
end != h2->
end) {
680 static bool compareDFDCHits(
const DFDCHit* h1,
const DFDCHit* h2) {
690 static bool compareDCDCHits(
const DCDCHit* h1,
const DCDCHit* h2) {
700 static bool compareDSTHits(
const DSCHit* h1,
const DSCHit* h2) {
712 else if (h1->
row != h2->
row) {
713 return (h1->
row < h2->
row);
715 else if (h1->
t != h2->
t) {
716 return (h1->
t <h2->
t);
727 else if (h1->
t != h2->
t) {
728 return (h1->
t < h2->
t);
735 static bool compareDPSCHits(
const DPSCHit* h1,
const DPSCHit* h2) {
746 static bool compareDPSHits(
const DPSHit* h1,
const DPSHit* h2) {
780 static bool first_time =
true;
786 unsigned short eventType = 0;
790 if (nomc2coda == 0) {
793 eventID =
mc2codaOpenEvent(expID, (uint64_t)eventnumber, trigTime/trigtick, eventType, MAXEVENTSIZE);
794 if (eventID == NULL) {
795 jerr <<
"?NULL return from mc2codaOpenEvent()" << std::endl << std::endl;
799 int stat =
mc2codaResetEvent(eventID, (uint64_t)eventnumber, trigTime/trigtick, eventType);
801 jerr <<
"?error return from mc2codaResetEvent()" << std::endl << std::endl;
822 vector<const DCDCHit*> dcdchits;
823 eventLoop->Get(dcdchits);
824 sort(dcdchits.begin(),dcdchits.end(),compareDCDCHits);
827 for (i=0; i<dcdchits.size(); i++) {
828 if ((dcdchits[i]->q > 0) && ((dcdchits[i]->t*1000.) >
tMin) &&
829 (dcdchits[i]->t*1000. < trigTime))
831 if(CDC_time_window > 0.)
832 if(fabs(dcdchits[i]->t) > CDC_time_window)
836 uint32_t q = dcdchits[i]->q * CDC_ADCscale;
841 float t = dcdchits[i]->t - (tMin/1000.);
847 cdcCharges->Fill(dcdchits[i]->q);
849 cdcTimes->Fill(dcdchits[i]->t-tMin/1000);
851 cscRef cscADC = DCDCHitTranslationADC(dcdchits[i]);
852 if (cscADC == CSCREF_NULL)
861 hit[0].
chan_id = cscADC.channel;
865 hit[0].
hdata = mcData;
868 hit[0].
hdata[1] = t/(CDC_ADCtick/1000.);
873 jout <<
" CDC ADC ring,straw are " << dcdchits[i]->ring
874 <<
", " << dcdchits[i]->straw << std::endl;
875 jout <<
" c,s,c are " << cscADC.crate <<
", "
876 << cscADC.slot <<
", " << cscADC.channel << std::endl;
877 jout <<
" hdata is: " << hit[0].
hdata[0] <<
", "
878 << hit[0].
hdata[1] << std::endl;
879 jout <<
" q,t are " << q <<
", " << t << std::endl;
883 if (nomc2coda == 0) {
886 jerr <<
"?error return from mc2codaWrite() for CDC ADC: "
887 << stat << std::endl << std::endl;
893 if ((dumphits >= 1) && (hc > 0)) {
894 jout << std::endl <<
"CDC hits: " << hc << std::endl << std::endl;
899 vector<const DTOFHit*> dtofrawhits;
900 eventLoop->Get(dtofrawhits);
901 sort(dtofrawhits.begin(),dtofrawhits.end(),compareDTOFHits);
904 for (i=0; i < dtofrawhits.size(); i++) {
905 if ((dtofrawhits[i]->dE > 0) && ((dtofrawhits[i]->t*1000.) >
tMin) &&
906 (dtofrawhits[i]->t*1000. < trigTime))
908 if(TOF_time_window > 0.)
909 if(fabs(dtofrawhits[i]->t) > TOF_time_window)
913 uint32_t E = dtofrawhits[i]->dE*TOF_ADCscale;
914 uint32_t t = dtofrawhits[i]->t*1000.-
tMin;
917 tofEnergies->Fill(dtofrawhits[i]->dE*1000000.);
919 tofTimes->Fill(dtofrawhits[i]->t-tMin/1000);
924 cscRef cscADC = DTOFHitTranslationADC(dtofrawhits[i]);
929 hit[0].
chan_id = cscADC.channel;
933 hit[0].
hdata = mcData;
935 hit[0].
hdata[1] =
static_cast<double>(t)/TOF_ADCtick;
937 std::cerr <<
"E too large for TOF: " << E << std::endl;
941 jout <<
" TOF ADC plane,bar,lr are " << dtofrawhits[i]->plane <<
", " << dtofrawhits[i]->bar
942 <<
", " << dtofrawhits[i]->end << std::endl;
943 jout <<
" c,s,c are " << cscADC.crate <<
", " << cscADC.slot <<
", " << cscADC.channel << std::endl;
944 jout <<
" hdata is: " << hit[0].
hdata[0] <<
", " << hit[0].
hdata[1] << std::endl;
945 jout <<
" E,t are " << E <<
", " << t << std::endl;
949 if (nomc2coda == 0) {
952 jerr <<
"?error return from mc2codaWrite() for TOF ADC: " << stat << std::endl << std::endl;
959 cscRef cscTDC = DTOFHitTranslationTDC(dtofrawhits[i]);
964 hit[0].
chan_id = cscTDC.channel;
968 hit[0].
hdata = mcData;
969 hit[0].
hdata[0] =
static_cast<double>(t)/TOF_TDCtick;
973 jout <<
" TOF TDC plane,bar,lr are " << dtofrawhits[i]->plane <<
", " << dtofrawhits[i]->bar
974 <<
", " << dtofrawhits[i]->end << std::endl;
975 jout <<
" c,s,c are " << cscTDC.crate <<
", " << cscTDC.slot <<
", " << cscTDC.channel << std::endl;
976 jout <<
" hdata is: " << hit[0].
hdata[0] << std::endl;
977 jout <<
" E,t are " << E <<
", " << t << std::endl;
981 if (nomc2coda == 0) {
984 jerr <<
"?error return from mc2codaWrite() for TOF TDC: " << stat << std::endl << std::endl;
990 if ((dumphits >= 1) && (hc > 0)) {
991 jout << std::endl <<
"TOF hits: " << hc << std::endl << std::endl;
996 vector<const DBCALHit*> dbcalhits;
997 eventLoop->Get(dbcalhits);
998 sort(dbcalhits.begin(),dbcalhits.end(),compareDBCALHits);
1001 for (i=0; i < dbcalhits.size(); i++) {
1002 if ((dbcalhits[i]->E > 0) && ((dbcalhits[i]->t*1000.) >
tMin) &&
1003 (dbcalhits[i]->t*1000. < trigTime))
1005 if(BCAL_time_window > 0.)
1006 if(fabs(dbcalhits[i]->t) > BCAL_time_window)
1009 uint32_t E = dbcalhits[i]->E*BCAL_ADCscale;
1010 uint32_t t = dbcalhits[i]->t*1000.-
tMin;
1013 bcalEnergies->Fill(dbcalhits[i]->E*1000.);
1015 bcalTimes->Fill(dbcalhits[i]->t-tMin/1000);
1017 cscRef cscADC = DBCALHitTranslationADC(dbcalhits[i]);
1018 if (cscADC == CSCREF_NULL)
1023 hit[0].
hit_id = hitCount;
1027 hit[0].
chan_id = cscADC.channel;
1031 hit[0].
hdata = mcData;
1032 hit[0].
hdata[0] = E;
1033 hit[0].
hdata[1] =
static_cast<double>(t)/BCAL_ADCtick;
1035 std::cerr <<
"E too large for BCAL: " << E << std::endl;
1039 jout <<
" BCAL ADC module,sector,layer,end are "
1040 << dbcalhits[i]->module <<
", " << dbcalhits[i]->sector
1041 <<
", " << dbcalhits[i]->layer <<
", "
1042 << dbcalhits[i]->end << std::endl;
1043 jout <<
" c,s,c are " << cscADC.crate <<
", "
1044 << cscADC.slot <<
", " << cscADC.channel << std::endl;
1045 jout <<
" hdata is: " << hit[0].
hdata[0] <<
", "
1046 << hit[0].
hdata[1] << std::endl;
1047 jout <<
" E,t are " << E <<
", " << t << std::endl;
1052 if (nomc2coda == 0) {
1054 if (stat != nhits) {
1055 jerr <<
"?error return from mc2codaWrite() for BCAL ADC: "
1056 << stat << std::endl << std::endl;
1095 if ((dumphits >= 1) && (hc > 0)) {
1096 jout << std::endl <<
"BCAL hits: " << hc << std::endl << std::endl;
1101 vector<const DBCALTDCHit*> dbcaltdchits;
1102 eventLoop->Get(dbcaltdchits);
1103 sort(dbcaltdchits.begin(),dbcaltdchits.end(),compareDBCALTDCHits);
1106 for (i=0; i<dbcaltdchits.size(); i++) {
1107 if (((dbcaltdchits[i]->t*1000.) > tMin) &&
1108 (dbcaltdchits[i]->t*1000. < trigTime))
1110 if(BCAL_time_window > 0.)
1111 if(fabs(dbcaltdchits[i]->t) > BCAL_time_window)
1115 int32_t t = dbcaltdchits[i]->t*1000.-
tMin;
1118 bcalTimes->Fill(dbcaltdchits[i]->t-tMin/1000);
1120 cscRef cscTDC = DBCALHitTranslationTDC(dbcaltdchits[i]);
1121 if (cscTDC == CSCREF_NULL)
1127 hit[0].
hit_id = hitCount;
1131 hit[0].
chan_id = cscTDC.channel;
1135 hit[0].
hdata = mcData;
1136 hit[0].
hdata[0] =
static_cast<double>(t)/BCAL_TDCtick;
1140 jout <<
" BCAL TDC module,sector,layer,end are "
1141 << dbcaltdchits[i]->module <<
", " << dbcaltdchits[i]->sector
1142 <<
", " << dbcaltdchits[i]->layer <<
", "
1143 << dbcaltdchits[i]->end << std::endl;
1144 jout <<
" c,s,c are " << cscTDC.crate <<
", "
1145 << cscTDC.slot <<
", " << cscTDC.channel << std::endl;
1146 jout <<
" hdata is: " << hit[0].
hdata[0] << std::endl;
1147 jout <<
" E,t are " << E <<
", " << t << std::endl;
1151 if (nomc2coda == 0) {
1153 if (stat != nhits) {
1154 jerr <<
"?error return from mc2codaWrite() for BCAL TDC: "
1155 << stat << std::endl << std::endl;
1161 if ((dumphits >= 1) && (hc > 0)) {
1162 jout << std::endl <<
"BCAL TDC hits: " << hc << std::endl << std::endl;
1167 vector<const DFCALHit*> dfcalhits;
1168 eventLoop->Get(dfcalhits);
1169 sort(dfcalhits.begin(),dfcalhits.end(),compareDFCALHits);
1172 for (i=0; i<dfcalhits.size(); i++) {
1173 if ((dfcalhits[i]->E > 0) && ((dfcalhits[i]->t*1000.) >
tMin) &&
1174 (dfcalhits[i]->t*1000. < trigTime))
1176 if(FCAL_time_window > 0.)
1177 if(fabs(dfcalhits[i]->t) > FCAL_time_window)
1180 uint32_t E = dfcalhits[i]->E*FCAL_ADCscale;
1181 uint32_t t = dfcalhits[i]->t*1000.-
tMin;
1184 fcalEnergies->Fill(dfcalhits[i]->E*1000000.);
1186 fcalTimes->Fill(dfcalhits[i]->t-tMin/1000);
1191 cscRef cscADC = DFCALHitTranslationADC(dfcalhits[i]);
1192 hit[0].
hit_id = hitCount;
1196 hit[0].
chan_id = cscADC.channel;
1200 hit[0].
hdata = mcData;
1201 hit[0].
hdata[0] = E;
1202 hit[0].
hdata[1] =
static_cast<double>(t)/FCAL_ADCtick;
1204 std::cerr <<
"E too large for FCAL: " << E << std::endl;
1208 jout <<
" FCAL ADC row,column are " << dfcalhits[i]->row
1209 <<
", " << dfcalhits[i]->column << std::endl;
1210 jout <<
" c,s,c are " << cscADC.crate <<
", " << cscADC.slot
1211 <<
", " << cscADC.channel << std::endl;
1212 jout <<
" hdata is: " << hit[0].
hdata[0] <<
", "
1213 << hit[0].
hdata[1] << std::endl;
1214 jout <<
" E,t are " << E <<
", " << t << std::endl;
1218 if (nomc2coda == 0) {
1220 if (stat != nhits) {
1221 jerr <<
"?error return from mc2codaWrite() for FCAL ADC: "
1222 << stat << std::endl << std::endl;
1228 if ((dumphits >= 1) && (hc > 0)) {
1229 jout << std::endl <<
"FCAL hits: " << hc << std::endl << std::endl;
1234 vector<const DFDCHit*> dfdchits;
1235 eventLoop->Get(dfdchits);
1236 sort(dfdchits.begin(),dfdchits.end(),compareDFDCHits);
1239 for (i=0; i < dfdchits.size(); i++) {
1240 if ((dfdchits[i]->q > 0) && ((dfdchits[i]->t*1000.) >
tMin) &&
1241 (dfdchits[i]->t*1000. < trigTime))
1243 if(FDC_time_window > 0.)
1244 if(fabs(dfdchits[i]->t) > FDC_time_window)
1247 uint32_t q = dfdchits[i]->q*FDC_ADCscale;
1248 if (dfdchits[i]->type == 0)
1250 uint32_t t = dfdchits[i]->t*1000.-
tMin;
1253 fdcCharges->Fill(dfdchits[i]->q);
1254 if (noroot == 0)fdcTimes->Fill(dfdchits[i]->t-tMin/1000);
1256 int type = dfdchits[i]->type;
1262 cscRef cscADC = DFDCCathodeHitTranslation(dfdchits[i]);
1263 hit[0].
hit_id = hitCount;
1267 hit[0].
chan_id = cscADC.channel;
1271 hit[0].
hdata = mcData;
1272 hit[0].
hdata[0] = q;
1273 hit[0].
hdata[1] =
static_cast<double>(t)/FDC_ADCtick;
1279 jout <<
" FDC ADC gPlane,element are " << dfdchits[i]->gPlane
1280 <<
", " << dfdchits[i]->element << std::endl;
1281 jout <<
" c,s,c are " << cscADC.crate <<
", " << cscADC.slot
1282 <<
", " << cscADC.channel << std::endl;
1283 jout <<
" hdata is: " << hit[0].
hdata[0] <<
", "
1284 << hit[0].
hdata[1] << std::endl;
1285 jout <<
" q,t are " << q <<
", " << t << std::endl;
1289 if (nomc2coda == 0) {
1291 if (stat != nhits) {
1292 jerr <<
"?error return from mc2codaWrite() for FDC ADC: "
1293 << stat << std::endl << std::endl;
1300 else if (type == 0) {
1304 cscRef cscTDC = DFDCAnodeHitTranslation(dfdchits[i]);
1305 hit[0].
hit_id = hitCount;
1309 hit[0].
chan_id = cscTDC.channel;
1313 hit[0].
hdata = mcData;
1314 hit[0].
hdata[0] =
static_cast<double>(t)/FDC_TDCtick;
1318 jout <<
" FDC TDC gPlane,element are " << dfdchits[i]->gPlane
1319 <<
", " << dfdchits[i]->element << std::endl;
1320 jout <<
" c,s,c are " << cscTDC.crate <<
", "
1321 << cscTDC.slot <<
", " << cscTDC.channel << std::endl;
1322 jout <<
" hdata is: " << hit[0].
hdata[0] << std::endl;
1323 jout <<
" q,t are " << q <<
", " << t << std::endl;
1327 if (nomc2coda == 0) {
1329 if (stat != nhits) {
1330 jerr <<
"?error return from mc2codaWrite() for Fdc TDC: "
1331 << stat << std::endl << std::endl;
1339 if ((dumphits >= 1) && (hc > 0)) {
1340 jout << std::endl <<
"FDC hits: " << hc << std::endl << std::endl;
1345 vector<const DSCHit*> dsthits;
1346 eventLoop->Get(dsthits);
1347 sort(dsthits.begin(),dsthits.end(),compareDSTHits);
1350 for (i=0; i < dsthits.size(); i++) {
1351 if ((dsthits[i]->dE > 0) && ((dsthits[i]->t*1000.) >
tMin) &&
1352 (dsthits[i]->t*1000. < trigTime))
1354 if(SC_time_window > 0.)
1355 if(fabs(dsthits[i]->t) > SC_time_window)
1358 uint32_t E = dsthits[i]->dE*SC_ADCscale;
1359 uint32_t t = dsthits[i]->t*1000.-
tMin;
1362 stEnergies->Fill(dsthits[i]->dE*1000000.);
1364 stTimes->Fill(dsthits[i]->t-tMin/1000);
1369 cscRef cscADC = DSTHitTranslationADC(dsthits[i]);
1370 hit[0].
hit_id = hitCount;
1374 hit[0].
chan_id = cscADC.channel;
1378 hit[0].
hdata = mcData;
1379 hit[0].
hdata[0] = E;
1380 hit[0].
hdata[1] =
static_cast<double>(t)/SC_ADCtick;
1382 std::cerr <<
"E too large for ST: " << E << std::endl;
1386 jout <<
" ST ADC sector is " << dsthits[i]->sector << std::endl;
1387 jout <<
" c,s,c are " << cscADC.crate <<
", " << cscADC.slot
1388 <<
", " << cscADC.channel << std::endl;
1389 jout <<
" hdata is: " << hit[0].
hdata[0] <<
", "
1390 << hit[0].
hdata[1] << std::endl;
1391 jout <<
" E,t are " << E <<
", " << t << std::endl;
1395 if (nomc2coda == 0) {
1397 if (stat != nhits) {
1398 jerr <<
"?error return from mc2codaWrite() for ST ADC: "
1399 << stat << std::endl << std::endl;
1406 cscRef cscTDC = DSTHitTranslationTDC(dsthits[i]);
1407 hit[0].
hit_id = hitCount;
1411 hit[0].
chan_id = cscTDC.channel;
1415 hit[0].
hdata = mcData;
1416 hit[0].
hdata[0] =
static_cast<double>(t)/SC_TDCtick;
1420 jout <<
" ST TDC sector is " << dsthits[i]->sector << std::endl;
1421 jout <<
" c,s,c are " << cscTDC.crate <<
", " << cscTDC.slot
1422 <<
", " << cscTDC.channel << std::endl;
1423 jout <<
" hdata is: " << hit[0].
hdata[0] << std::endl;
1424 jout <<
" E,t are " << E <<
", " << t << std::endl;
1428 if (nomc2coda == 0) {
1430 if (stat != nhits) {
1431 jerr <<
"?error return from mc2codaWrite() for ST TDC: "
1432 << stat << std::endl << std::endl;
1438 if ((dumphits >= 1) && (hc > 0)) {
1439 jout << std::endl <<
"ST hits: " << hc << std::endl << std::endl;
1444 vector<const DTAGMHit*> dtagmhits;
1445 eventLoop->Get(dtagmhits);
1446 sort(dtagmhits.begin(),dtagmhits.end(),compareDTAGMHits);
1449 for (i=0; i < dtagmhits.size(); i++) {
1450 if (dtagmhits[i]->npix_fadc > 0 &&
1451 ((dtagmhits[i]->t*1000 > tMin && dtagmhits[i]->t*1000 < trigTime) ||
1452 (dtagmhits[i]->time_fadc*1000 > tMin &&
1453 dtagmhits[i]->time_fadc*1000 < trigTime)) )
1455 uint32_t pA = dtagmhits[i]->npix_fadc + 2500;
1456 uint32_t t = dtagmhits[i]->t*1000 -
tMin;
1457 uint32_t tA = dtagmhits[i]->time_fadc*1000 -
tMin;
1459 if(TAGM_time_window > 0.)
1460 if(fabs(dtagmhits[i]->t) > TAGM_time_window)
1464 tagmEnergies->Fill(dtagmhits[i]->npix_fadc);
1466 tagmTimes->Fill(dtagmhits[i]->time_fadc-tMin/1000);
1468 cscRef cscADC = DTAGMHitTranslationADC(dtagmhits[i]);
1469 if (! (cscADC == CSCREF_NULL)) {
1473 hit[0].
hit_id = hitCount;
1477 hit[0].
chan_id = cscADC.channel;
1481 hit[0].
hdata = mcData;
1482 hit[0].
hdata[0] = pA;
1483 hit[0].
hdata[1] =
static_cast<double>(tA)/FADC250tick;
1485 std::cerr <<
"pA too large for tagger microscope: "
1490 jout <<
" Tagger microscope ADC row,column are "
1491 << dtagmhits[i]->row <<
", " << dtagmhits[i]->column << std::endl;
1492 jout <<
" c,s,c are " << cscADC.crate <<
", " << cscADC.slot <<
", "
1493 << cscADC.channel << std::endl;
1494 jout <<
" hdata is: " << hit[0].
hdata[0] <<
", " << hit[0].
hdata[1]
1496 jout <<
" pA,tA are " << pA <<
", " << tA << std::endl;
1500 if (nomc2coda == 0) {
1502 if (stat != nhits) {
1503 jerr <<
"?error return from mc2codaWrite() for TAGGER ADC: "
1504 << stat << std::endl << std::endl;
1510 cscRef cscTDC = DTAGMHitTranslationTDC(dtagmhits[i]);
1511 if (! (cscADC == CSCREF_NULL)) {
1514 hit[0].
hit_id = hitCount;
1518 hit[0].
chan_id = cscTDC.channel;
1522 hit[0].
hdata = mcData;
1523 hit[0].
hdata[0] =
static_cast<double>(t)/F1TDC32tick;
1527 jout <<
" Tagger microscope TDC row,column are "
1528 << dtagmhits[i]->row <<
", " << dtagmhits[i]->column << std::endl;
1529 jout <<
" c,s,c are " << cscTDC.crate <<
", " << cscTDC.slot
1530 <<
", " << cscTDC.channel << std::endl;
1531 jout <<
" hdata is: " << hit[0].
hdata[0] << std::endl;
1532 jout <<
" t is " << t << std::endl;
1536 if (nomc2coda == 0) {
1538 if (stat != nhits) {
1539 jerr <<
"?error return from mc2codaWrite() for Tagger TDC: "
1540 << stat << std::endl << std::endl;
1547 if ((dumphits >= 1) && (hc > 0)) {
1548 jout << std::endl <<
"Tagger microscope hits: " << hc << std::endl << std::endl;
1552 vector<const DTAGHHit*> dtaghhits;
1553 eventLoop->Get(dtaghhits);
1554 sort(dtaghhits.begin(),dtaghhits.end(),compareDTAGHHits);
1557 for (i=0; i < dtaghhits.size(); i++) {
1558 if (dtaghhits[i]->npe_fadc > 0 &&
1559 ((dtaghhits[i]->t*1000 > tMin && dtaghhits[i]->t*1000 < trigTime) ||
1560 (dtaghhits[i]->time_fadc*1000 > tMin &&
1561 dtaghhits[i]->time_fadc*1000 < trigTime)) )
1563 uint32_t pA = dtaghhits[i]->npe_fadc + 2500;
1564 uint32_t t = dtaghhits[i]->t*1000 -
tMin;
1565 uint32_t tA = dtaghhits[i]->time_fadc*1000 -
tMin;
1567 if(TAGH_time_window > 0.)
1568 if(fabs(dtaghhits[i]->t) > TAGH_time_window)
1572 taghEnergies->Fill(dtaghhits[i]->npe_fadc);
1574 taghTimes->Fill(dtaghhits[i]->time_fadc-tMin/1000);
1576 cscRef cscADC = DTAGHHitTranslationADC(dtaghhits[i]);
1577 if (! (cscADC == CSCREF_NULL)) {
1581 hit[0].
hit_id = hitCount;
1585 hit[0].
chan_id = cscADC.channel;
1589 hit[0].
hdata = mcData;
1590 hit[0].
hdata[0] = pA;
1591 hit[0].
hdata[1] =
static_cast<double>(tA)/FADC250tick;
1593 std::cerr <<
"pA too large for tagger hodoscope: " << pA << std::endl;
1597 jout <<
" Tagger hodoscope ADC counter_id is "
1598 << dtaghhits[i]->counter_id << std::endl;
1599 jout <<
" c,s,c are " << cscADC.crate <<
", " << cscADC.slot <<
", "
1600 << cscADC.channel << std::endl;
1601 jout <<
" hdata is: " << hit[0].
hdata[0] <<
", " << hit[0].
hdata[1]
1603 jout <<
" pA,tA are " << pA <<
", " << tA << std::endl;
1607 if (nomc2coda == 0) {
1609 if (stat != nhits) {
1610 jerr <<
"?error return from mc2codaWrite() for TAGGER ADC: "
1611 << stat << std::endl << std::endl;
1617 cscRef cscTDC = DTAGHHitTranslationTDC(dtaghhits[i]);
1618 if (! (cscADC == CSCREF_NULL)) {
1621 hit[0].
hit_id = hitCount;
1625 hit[0].
chan_id = cscTDC.channel;
1629 hit[0].
hdata = mcData;
1630 hit[0].
hdata[0] =
static_cast<double>(t)/F1TDC32tick;
1634 jout <<
" Tagger hodoscope TDC counter_id is "
1635 << dtaghhits[i]->counter_id << std::endl;
1636 jout <<
" c,s,c are " << cscTDC.crate <<
", " << cscTDC.slot
1637 <<
", " << cscTDC.channel << std::endl;
1638 jout <<
" hdata is: " << hit[0].
hdata[0] << std::endl;
1639 jout <<
" t is " << t << std::endl;
1643 if (nomc2coda == 0) {
1645 if (stat != nhits) {
1646 jerr <<
"?error return from mc2codaWrite() for Tagger TDC: "
1647 << stat << std::endl << std::endl;
1654 if ((dumphits >= 1) && (hc > 0)) {
1655 jout << std::endl <<
"Tagger hodoscope hits: " << hc << std::endl << std::endl;
1659 vector<const DPSCHit*> dpschits;
1660 eventLoop->Get(dpschits);
1661 sort(dpschits.begin(),dpschits.end(),compareDPSCHits);
1664 for (i=0; i < dpschits.size(); i++) {
1665 if ((dpschits[i]->npe_fadc > 0) && ((dpschits[i]->t*1000.) >
tMin) &&
1666 (dpschits[i]->t*1000. < trigTime))
1668 if(PSC_time_window > 0.)
1669 if(fabs(dpschits[i]->t) > PSC_time_window)
1672 uint32_t E = dpschits[i]->npe_fadc*PSC_ADCscale;
1673 uint32_t t = dpschits[i]->t*1000.-
tMin;
1678 cscRef cscADC = DPSCHitTranslationADC(dpschits[i]);
1679 hit[0].
hit_id = hitCount;
1683 hit[0].
chan_id = cscADC.channel;
1687 hit[0].
hdata = mcData;
1688 hit[0].
hdata[0] = E;
1689 hit[0].
hdata[1] =
static_cast<double>(t)/PSC_ADCtick;
1691 std::cerr <<
"E too large for PSC: " << E << std::endl;
1695 jout <<
" PSC ADC arm,module is "
1696 << dpschits[i]->arm <<
"," << dpschits[i]->module << std::endl;
1697 jout <<
" c,s,c are " << cscADC.crate <<
", " << cscADC.slot
1698 <<
", " << cscADC.channel << std::endl;
1699 jout <<
" hdata is: " << hit[0].
hdata[0] <<
", "
1700 << hit[0].
hdata[1] << std::endl;
1701 jout <<
" E,t are " << E <<
", " << t << std::endl;
1705 if (nomc2coda == 0) {
1707 if (stat != nhits) {
1708 jerr <<
"?error return from mc2codaWrite() for PSC ADC: "
1709 << stat << std::endl << std::endl;
1716 cscRef cscTDC = DPSCHitTranslationTDC(dpschits[i]);
1717 hit[0].
hit_id = hitCount;
1721 hit[0].
chan_id = cscTDC.channel;
1725 hit[0].
hdata = mcData;
1726 hit[0].
hdata[0] =
static_cast<double>(t)/PSC_TDCtick;
1730 jout <<
" PSC TDC arm,module is "
1731 << dpschits[i]->arm <<
"," << dpschits[i]->module << std::endl;
1732 jout <<
" c,s,c are " << cscTDC.crate <<
", " << cscTDC.slot
1733 <<
", " << cscTDC.channel << std::endl;
1734 jout <<
" hdata is: " << hit[0].
hdata[0] << std::endl;
1735 jout <<
" E,t are " << E <<
", " << t << std::endl;
1739 if (nomc2coda == 0) {
1741 if (stat != nhits) {
1742 jerr <<
"?error return from mc2codaWrite() for PSC TDC: "
1743 << stat << std::endl << std::endl;
1749 if ((dumphits >= 1) && (hc > 0)) {
1750 jout << std::endl <<
"PSC hits: " << hc << std::endl << std::endl;
1755 vector<const DPSHit*> dpshits;
1756 eventLoop->Get(dpshits);
1757 sort(dpshits.begin(),dpshits.end(),compareDPSHits);
1760 for (i=0; i < dpshits.size(); i++) {
1761 if ((dpshits[i]->npix_fadc > 0) && ((dpshits[i]->t*1000.) >
tMin) &&
1762 (dpshits[i]->t*1000. < trigTime))
1764 if(PS_time_window > 0.)
1765 if(fabs(dpshits[i]->t) > PS_time_window)
1768 uint32_t E = dpshits[i]->npix_fadc*PS_ADCscale;
1769 uint32_t t = dpshits[i]->t*1000.-
tMin;
1774 cscRef cscADC = DPSHitTranslationADC(dpshits[i]);
1775 hit[0].
hit_id = hitCount;
1779 hit[0].
chan_id = cscADC.channel;
1783 hit[0].
hdata = mcData;
1784 hit[0].
hdata[0] = E;
1785 hit[0].
hdata[1] =
static_cast<double>(t)/PS_ADCtick;
1787 std::cerr <<
"E too large for PS: " << E << std::endl;
1791 jout <<
" PS ADC arm,column is "
1792 << dpshits[i]->arm <<
"," << dpshits[i]->column << std::endl;
1793 jout <<
" c,s,c are " << cscADC.crate <<
", " << cscADC.slot
1794 <<
", " << cscADC.channel << std::endl;
1795 jout <<
" hdata is: " << hit[0].
hdata[0] <<
", "
1796 << hit[0].
hdata[1] << std::endl;
1797 jout <<
" E,t are " << E <<
", " << t << std::endl;
1801 if (nomc2coda == 0) {
1803 if (stat != nhits) {
1804 jerr <<
"?error return from mc2codaWrite() for PS ADC: "
1805 << stat << std::endl << std::endl;
1811 if ((dumphits >= 1) && (hc > 0)) {
1812 jout << std::endl <<
"PS hits: " << hc << std::endl << std::endl;
1822 hit[0].
hit_id = hitCount;
1831 hit[0].
hdata = mcData;
1832 hit[0].
hdata[0] = t;
1836 jout <<
" F1TDC reference signal" << std::endl;
1838 <<
", " << hit[0].
chan_id << std::endl;
1839 jout <<
" hdata is: " << hit[0].
hdata[0] << std::endl;
1840 jout <<
" E,t are " << E <<
", " << t << std::endl;
1844 if (nomc2coda == 0) {
1846 if (stat != nhits) {
1847 jerr <<
"?error return from mc2codaWrite() for F1TDC reference time: "
1848 << stat << std::endl << std::endl;
1854 if (nomc2coda == 0) {
1857 jerr <<
"?error return from mc2codaCloseEVent(): " << nwords
1858 << std::endl << std::endl;
1864 pthread_mutex_lock(&rawMutex);
1865 chan->write(eventID->
evbuf);
1866 pthread_mutex_unlock(&rawMutex);
1869 cout <<
"Built without EVIO" << endl;
1882 jout << std::endl <<
" erun called for run " << runNumber << std::endl << std::endl;
1894 jout << std::endl <<
" output file " << outputFileName <<
" closed" << std::endl << std::endl;
1926 void JEventProcessor_rawevent::readTranslationTable(
void) {
1928 jout <<
"Reading translation table " << translationTableName << std::endl;
1932 JCalibration *jcalib =
japp->GetJCalibration(1);
1941 if (jcalib && !NO_CCDB) {
1942 map<string,string> tt;
1943 string namepath =
"Translation/DAQ2detector";
1944 jout <<
"Reading translation table from calib DB: " << namepath <<
" ..." << std::endl;
1945 jcalib->GetCalib(namepath, tt);
1946 if (tt.size() != 1) {
1947 jerr <<
" Error: Unexpected translation table format!" << std::endl;
1948 jerr <<
" tt.size()=" << tt.size() <<
" (expected 1)" << std::endl;
1951 map<string,string>::iterator iter = tt.begin();
1952 tt_xml = iter->second;
1957 if (tt_xml.size() == 0) {
1958 if (!NO_CCDB) jout <<
"Unable to get translation table from CCDB." << std::endl;
1959 jout <<
"Will try reading TT from local file: " << XML_FILENAME << std::endl;
1962 ifstream ifs(XML_FILENAME.c_str());
1963 if (! ifs.is_open()) {
1964 jerr <<
" Error: Cannot open file! Translation table unavailable." << std::endl;
1970 while (ifs.good()) {
1972 ifs.getline(line, 4096);
1984 XML_Parser xmlParser = XML_ParserCreate(NULL);
1985 if (xmlParser == NULL) {
1986 jerr <<
"readTranslationTable...unable to create parser" << std::endl;
1992 int status=XML_Parse(xmlParser, tt_xml.c_str(), tt_xml.size(), 1);
1994 jerr <<
" ?readTranslationTable...parseXMLFile parse error for " << XML_FILENAME << std::endl;
1995 jerr << XML_ErrorString(XML_GetErrorCode(xmlParser)) << std::endl;
2001 XML_ParserFree(xmlParser);
2008 int type2detID(
string &type) {
2009 if (type ==
"vmecpu" || type ==
"cpu") {
2011 }
else if (type ==
"tid" || type ==
"ti") {
2013 }
else if (type ==
"fadc250") {
2015 }
else if (type ==
"fadc125") {
2017 }
else if (type ==
"f1tdcv2") {
2019 }
else if (type ==
"f1tdcv3") {
2021 }
else if (type ==
"jldisc" || type ==
"disc") {
2023 }
else if (type ==
"vx1290a") {
2034 static int crate=0, slot=0;
2036 static string type,Type, locSystem;
2042 string ring,straw,plane,bar,gPlane,element;
2043 string package,chamber,view,strip,wire;
2047 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 crateID[nCrate-1]=crate;
2060 nModules[nCrate-1]=0;
2061 if (crate > maxCrateNum) maxCrateNum = crate;
2063 }
else if (strcasecmp(xmlname,
"slot") == 0) {
2064 for (
int i=0; atts[i]; i+=2) {
2065 if (strcasecmp(atts[i],
"number") == 0) {
2066 slot = atoi(atts[i+1]);
2067 }
else if (strcasecmp(atts[i],
"type") == 0) {
2068 Type =
string(atts[i+1]);
2069 type =
string(atts[i+1]);
2070 std::transform(type.begin(), type.end(), type.begin(), (int(*)(int)) tolower);
2082 mc2codaType = type2detID(type);
2084 nModules[nCrate-1]++;
2085 modules[nCrate-1][slot-1] = mc2codaType;
2086 switch(mc2codaType) {
2091 detID[nCrate-1][slot-1] = 1;
2095 detID[nCrate-1][slot-1] = 20;
2098 detID[nCrate-1][slot-1] = 0;
2103 }
else if (strcasecmp(xmlname,
"channel") == 0) {
2105 for (
int i=0; atts[i]; i+=2) {
2106 if (strcasecmp(atts[i],
"number") == 0) {
2107 channel = atoi(atts[i+1]);
2108 }
else if (strcasecmp(atts[i],
"detector") == 0) {
2109 Detector =
string(atts[i+1]);
2110 }
else if (strcasecmp(atts[i],
"id") == 0) {
2112 }
else if (strcasecmp(atts[i],
"row") == 0) {
2114 }
else if (strcasecmp(atts[i],
"column") == 0) {
2115 column =
string(atts[i+1]);
2116 }
else if (strcasecmp(atts[i],
"col") == 0) {
2117 column =
string(atts[i+1]);
2118 }
else if (strcasecmp(atts[i],
"module") == 0) {
2119 module =
string(atts[i+1]);
2120 }
else if (strcasecmp(atts[i],
"sector") == 0) {
2121 sector =
string(atts[i+1]);
2122 }
else if (strcasecmp(atts[i],
"layer") == 0) {
2123 layer =
string(atts[i+1]);
2124 }
else if (strcasecmp(atts[i],
"end") == 0) {
2126 }
else if (strcasecmp(atts[i],
"chan") == 0) {
2127 chan =
string(atts[i+1]);
2128 }
else if (strcasecmp(atts[i],
"ring") == 0) {
2129 ring =
string(atts[i+1]);
2130 }
else if (strcasecmp(atts[i],
"straw") == 0) {
2131 straw =
string(atts[i+1]);
2132 }
else if (strcasecmp(atts[i],
"gPlane") == 0) {
2133 gPlane =
string(atts[i+1]);
2134 }
else if (strcasecmp(atts[i],
"element") == 0) {
2135 element =
string(atts[i+1]);
2136 }
else if (strcasecmp(atts[i],
"plane") == 0) {
2137 plane =
string(atts[i+1]);
2138 }
else if (strcasecmp(atts[i],
"bar") == 0) {
2140 }
else if (strcasecmp(atts[i],
"package") == 0) {
2141 package = string(atts[i+1]);
2142 }
else if (strcasecmp(atts[i],
"chamber") == 0) {
2143 chamber =
string(atts[i+1]);
2144 }
else if (strcasecmp(atts[i],
"view") == 0) {
2145 view =
string(atts[i+1]);
2146 }
else if (strcasecmp(atts[i],
"strip") == 0) {
2147 strip =
string(atts[i+1]);
2148 }
else if (strcasecmp(atts[i],
"wire") == 0) {
2149 wire =
string(atts[i+1]);
2150 }
else if (strcasecmp(atts[i],
"side") == 0) {
2151 side =
string(atts[i+1]);
2152 }
else if (strcasecmp(atts[i],
"system") == 0) {
2153 locSystem =
string(atts[i+1]);
2164 if (type ==
"a1535sn")
2169 cscVal csc = {crate,slot,channel};
2170 string detector = Detector;
2171 std::transform(detector.begin(), detector.end(), detector.begin(),
2172 (int(*)(int)) tolower);
2174 string s=
"unknown::";
2176 if (detector ==
"fcal") {
2177 if (type ==
"fadc250") {
2180 s =
"unknownFCAL::";
2181 jerr << std::endl << std::endl
2182 <<
"?startElement...illegal type for FCAL: "
2183 << Type << std::endl << std::endl;
2189 }
else if (detector ==
"bcal") {
2190 if (type ==
"f1tdcv2") {
2192 }
else if (type ==
"fadc250") {
2195 s =
"unknownBCAL::";
2196 jerr << std::endl << std::endl
2197 <<
"?startElement...illegal type for BCAL: "
2198 << Type <<
" (" << type <<
")" << std::endl << std::endl;
2200 s += module +
":" + sector +
":" + layer +
":" + end;
2203 }
else if (detector ==
"cdc") {
2204 if (type ==
"fadc125") {
2208 jerr << std::endl << std::endl
2209 <<
"?startElement...illegal type for CDC: "
2210 << Type << std::endl << std::endl;
2212 s += ring +
":" + straw;
2216 }
else if (detector ==
"st") {
2217 if (type ==
"f1tdcv2") {
2219 }
else if (type ==
"fadc250") {
2221 }
else if (type ==
"iseg") {
2225 jerr << std::endl << std::endl
2226 <<
"?startElement...illegal type for ST: "
2227 << Type << std::endl << std::endl;
2232 }
else if (detector ==
"fdc_cathodes") {
2233 int ipackage = atoi(package.c_str());
2234 int ichamber = atoi(chamber.c_str());
2235 int igPlane = 1 + (ipackage-1)*6*3 + (ichamber-1)*3 + (view ==
"U" ? 0:2);
2239 if (type ==
"fadc125") {
2242 s =
"unknownFDCCathode::";
2243 jerr << std::endl << std::endl
2244 <<
"?startElement...illegal type for FDC Cathode: "
2245 << Type << std::endl << std::endl;
2247 s += gPlane +
":" + strip;
2251 }
else if (detector ==
"fdc_wires") {
2252 int ipackage = atoi(package.c_str());
2253 int ichamber = atoi(chamber.c_str());
2254 int igPlane = 2 + (ipackage-1)*6*3 + (ichamber-1)*3;
2258 if (type ==
"f1tdcv3") {
2261 s =
"unknownFDCAnode::";
2262 jerr << std::endl << std::endl
2263 <<
"?startElement...illegal type for FDC Anode: "
2264 << Type << std::endl << std::endl;
2266 s += gPlane +
":" + wire;
2269 }
else if (detector ==
"tof") {
2270 if (type ==
"vx1290a") {
2272 }
else if (type ==
"fadc250") {
2276 jerr << std::endl << std::endl
2277 <<
"?startElement...illegal type for TOF: "
2278 << Type << std::endl << std::endl;
2280 s += plane +
":" + bar +
":" + end;
2283 }
else if (detector ==
"tagh") {
2284 if (type ==
"f1tdcv2") {
2286 }
else if (type ==
"fadc250") {
2289 s =
"unknownTagger::";
2290 jerr << std::endl << std::endl
2291 <<
"?startElement...illegal type for TAGH: "
2292 << Type << std::endl << std::endl;
2297 }
else if (detector ==
"tagm") {
2298 if (type ==
"f1tdcv2") {
2300 }
else if (type ==
"fadc250") {
2303 s =
"unknownTagger::";
2304 jerr << std::endl << std::endl
2305 <<
"?startElement...illegal type for TAGM: "
2306 << Type << std::endl << std::endl;
2311 }
else if (detector ==
"psc") {
2312 if (type ==
"f1tdcv2") {
2313 s =
"psctdc::" + id;
2314 }
else if (type ==
"fadc250") {
2315 s =
"pscadc::" + id;
2318 jerr << std::endl << std::endl
2319 <<
"?startElement...illegal type for PSC: "
2320 << Type << std::endl << std::endl;
2325 }
else if (detector ==
"ps") {
2326 if (type ==
"fadc250") {
2331 jerr << std::endl << std::endl
2332 <<
"?startElement...illegal type for PS: "
2333 << Type << std::endl << std::endl;
2336 s += side +
":" + id;
2340 jerr << std::endl << std::endl
2341 <<
"?startElement...unknown detector "
2342 << Detector << std::endl << std::endl;
2345 if (crate < 0 || crate >= MAXDCRATE) {
2346 jerr <<
" Crate value of " << crate
2347 <<
" is not in range 0 <= crate < " << MAXDCRATE << std::endl;
2351 if (slot < 0 || slot >= MAXDSLOT) {
2352 jerr <<
" Slot value of " << slot
2353 <<
" is not in range 0 <= slot < " << MAXDSLOT << std::endl;
2357 if (channel < 0 || channel >= MAXDCHANNEL) {
2358 jerr <<
" Crate value of " << channel
2359 <<
" is not in range 0 <= channel < " << MAXDCHANNEL << std::endl;
2365 detectorMap[crate][slot][channel] = s;
2368 jerr << std::endl << std::endl
2369 <<
"?startElement...unknown xml tag "
2370 << xmlname << std::endl << std::endl;
2395 cscRef JEventProcessor_rawevent::DTOFHitTranslationADC(
const DTOFHit* hit)
const {
2397 if (hit->
plane == 0) {
2398 end = (hit->
end == 0 ?
"UP":
"DW");
2400 end = (hit->
end == 0 ?
"N":
"S");
2402 string s =
"tofadc::" + lexical_cast(hit->
plane) +
":"
2403 + lexical_cast(hit->
bar) +
":" + end;
2404 if (cscMap.count(s) <= 0)
2405 jerr <<
"?unknown map entry " << s << std::endl;
2413 cscRef JEventProcessor_rawevent::DTOFHitTranslationTDC(
const DTOFHit* hit)
const {
2415 if (hit->
plane == 0) {
2416 end = (hit->
end == 0 ?
"UP":
"DW");
2418 end = (hit->
end == 0 ?
"N":
"S");
2420 string s =
"toftdc::" + lexical_cast(hit->
plane) +
":"
2421 + lexical_cast(hit->
bar) +
":" + end;
2422 if (cscMap.count(s) <= 0)
2423 jerr <<
"?unknown map entry " << s << std::endl;
2431 cscRef JEventProcessor_rawevent::DBCALHitTranslationADC(
const DBCALHit *hit)
const {
2432 string end = hit->
end == 0 ?
"U":
"D";
2433 string s =
"bcaladc::" + lexical_cast(hit->
module) +
":"
2434 + lexical_cast(hit->
sector) +
":"
2435 + lexical_cast(hit->
layer) +
":" + end;
2436 if (cscMap.count(s) <= 0)
2437 jerr <<
"?unknown map entry " << s << std::endl;
2446 cscRef JEventProcessor_rawevent::DBCALHitTranslationTDC(
const DBCALTDCHit *hit)
const {
2451 string end = hit->
end == 0 ?
"U":
"D";
2452 string s =
"bcaltdc::" + lexical_cast(hit->
module) +
":"
2453 + lexical_cast(hit->
sector) +
":"
2454 + lexical_cast(hit->
layer) +
":" + end;
2455 if (cscMap.count(s) <= 0)
2456 jerr <<
"?unknown map entry " << s << std::endl;
2464 cscRef JEventProcessor_rawevent::DFCALHitTranslationADC(
const DFCALHit* hit)
const {
2465 string s =
"fcaladc::" + lexical_cast(hit->
row) +
":"
2466 + lexical_cast(hit->
column);
2467 if (cscMap.count(s) <= 0)
2468 jerr <<
"?unknown map entry " << s << std::endl;
2476 cscRef JEventProcessor_rawevent::DFDCAnodeHitTranslation(
const DFDCHit* hit)
const {
2477 string s =
"fdcanode::" + lexical_cast(hit->
gPlane) +
":"
2479 if (cscMap.count(s) <= 0)
2480 jerr <<
"?unknown map entry " << s << std::endl;
2488 cscRef JEventProcessor_rawevent::DFDCCathodeHitTranslation(
const DFDCHit* hit)
const {
2489 string s =
"fdccathode::" + lexical_cast(hit->
gPlane) +
":"
2491 if (cscMap.count(s) <= 0)
2492 jerr <<
"?unknown map entry " << s << std::endl;
2500 cscRef JEventProcessor_rawevent::DCDCHitTranslationADC(
const DCDCHit* hit)
const {
2501 string s =
"cdcadc::" + lexical_cast(hit->
ring) +
":"
2502 + lexical_cast(hit->
straw);
2503 if (cscMap.count(s) <= 0)
2504 jerr <<
"?unknown map entry " << s << std::endl;
2512 cscRef JEventProcessor_rawevent::DSTHitTranslationADC(
const DSCHit* hit)
const {
2513 string s =
"stadc::" + lexical_cast(hit->
sector);
2514 if (cscMap.count(s) <= 0)
2515 jerr <<
"?unknown map entry " << s << std::endl;
2523 cscRef JEventProcessor_rawevent::DSTHitTranslationTDC(
const DSCHit* hit)
const {
2524 string s =
"sttdc::" + lexical_cast(hit->
sector);
2525 if (cscMap.count(s) <= 0)
2526 jerr <<
"?unknown map entry " << s << std::endl;
2534 cscRef JEventProcessor_rawevent::DTAGMHitTranslationTDC(
const DTAGMHit* hit)
const {
2537 string s =
"tagmtdc::" + lexical_cast(hit->
row) +
":"
2538 + lexical_cast(hit->
column);
2539 if (cscMap.count(s) <= 0)
2540 jerr <<
"?unknown map entry " << s << std::endl;
2548 cscRef JEventProcessor_rawevent::DTAGMHitTranslationADC(
const DTAGMHit* hit)
const {
2551 string s =
"tagmadc::" + lexical_cast(hit->
row) +
":"
2552 + lexical_cast(hit->
column);
2553 if (cscMap.count(s) <= 0)
2554 jerr <<
"?unknown map entry " << s << std::endl;
2562 cscRef JEventProcessor_rawevent::DTAGHHitTranslationTDC(
const DTAGHHit* hit)
const {
2565 string s =
"taghtdc::" + lexical_cast(hit->
counter_id);
2566 if (cscMap.count(s) <= 0)
2567 jerr <<
"?unknown map entry " << s << std::endl;
2575 cscRef JEventProcessor_rawevent::DTAGHHitTranslationADC(
const DTAGHHit* hit)
const {
2578 string s =
"taghadc::" + lexical_cast(hit->
counter_id);
2579 if (cscMap.count(s) <= 0)
2580 jerr <<
"?unknown map entry " << s << std::endl;
2587 cscRef JEventProcessor_rawevent::DPSCHitTranslationTDC(
const DPSCHit* hit)
const {
2588 int module_id = 8*hit->
arm + hit->
module;
2589 string s =
"pscadc::" + lexical_cast(module_id);
2590 cerr <<
"checking = " << s << endl;
2591 if (cscMap.count(s) <= 0)
2592 jerr <<
"?unknown map entry " << s << std::endl;
2600 cscRef JEventProcessor_rawevent::DPSCHitTranslationADC(
const DPSCHit* hit)
const {
2601 int module_id = 8*hit->
arm + hit->
module;
2602 string s =
"pscadc::" + lexical_cast(module_id);
2603 cerr <<
"checking = " << s << endl;
2604 if (cscMap.count(s) <= 0)
2605 jerr <<
"?unknown map entry " << s << std::endl;
2612 cscRef JEventProcessor_rawevent::DPSHitTranslationADC(
const DPSHit* hit)
const {
2613 string arm = hit->
arm==0 ?
"A" :
"B";
2614 string s =
"psadc::" + arm +
":" + lexical_cast(hit->
column);
2615 cerr <<
"checking = " << s << endl;
2616 if (cscMap.count(s) <= 0)
2617 jerr <<
"?unknown map entry " << s << std::endl;
CODA_EXP_INFO * mc2codaInitExp(int nCrates, const char *name)
void mc2codaSetRunNumber(unsigned int run_number)
unsigned int mc2codaCloseEvent(CODA_EVENT_INFO *event)
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
JEventProcessor_rawevent()
float SIGMA_COMMON_PEDESTAL
static void EndElement(void *userData, const char *xmlname)
~JEventProcessor_rawevent()
static evioFileChannel * chan
float SIGMA_INDIVIDUAL_PEDESTAL
int mc2codaSetCrate(CODA_EXP_INFO *expID, int crateid, int nmod, int *modules, int *detid)
File: DTOFHit.h Created: Tue Jan 18 16:15:26 EST 2011 Creator: B. Zihlmann Purpose: Container class t...
static void StartElement(void *userData, const char *xmlname, const char **atts)
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
int mc2codaWrite(CODA_EVENT_INFO *event, int nHits, struct coda_hit_info *codaHits)
void mc2codaFree(CODA_EXP_INFO *expID)
int mc2codaResetEvent(CODA_EVENT_INFO *eventID, uint64_t eventNum, uint64_t trigTime, unsigned short eventType)
class DFDCHit: definition for a basic FDC hit data type.
CODA_EVENT_INFO * mc2codaOpenEvent(CODA_EXP_INFO *expID, uint64_t eventNum, uint64_t trigTime, unsigned short eventType, int maxSize)