Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DTTabUtilities_factory.cc
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: DTTabUtilities_factory.cc
4 // Created: Mon Apr 6 09:41:29 EDT 2015
5 // Creator: pmatt (on Linux pmattdesktop.jlab.org 2.6.32-504.12.2.el6.x86_64 x86_64)
6 //
7 
9 
10 jerror_t DTTabUtilities_factory::brun(jana::JEventLoop* locEventLoop, int32_t runnumber)
11 {
12  //Early Commissioning Data: Code & CCDB constants
13  //BCAL, RF: none
14  //SC, TAGH, TAGM: Uses F1TDC rollover
15  //FDC: is bad (tdc_scale fixed at 0.115, no ref time or tframe). Use F1TDC rollover x 2
16  //PSC: Uses F1TDC rollover; if run = 0 change run = 2012 (same as old hardcoded)
17 
18  // F1TDC tframe(ns) and rollover count
19  map<string, int> tdc_parms;
20  if(locEventLoop->GetCalib("/F1TDC/rollover", tdc_parms))
21  jout << "Error loading /F1TDC/rollover !" << endl;
22 
23  map<string, int>::const_iterator locMapIterator = tdc_parms.find("tframe");
24  dRolloverTimeWindowLength = (locMapIterator != tdc_parms.end()) ? uint64_t(tdc_parms["tframe"]) : 0;
25 
26  locMapIterator = tdc_parms.find("count");
27  dNumTDCTicksInRolloverTimeWindow = (locMapIterator != tdc_parms.end()) ? uint64_t(tdc_parms["count"]) : 0;
28 
29  if(locEventLoop->GetJEvent().GetRunNumber() == 0) //PSC data with bad run number. Use hard-coded values from run 2012
30  {
33  }
34 
35  //CAEN1290/TI Phase Difference
37  map<string, double> tof_tdc_shift;
38  if(!eventLoop->GetCalib("/TOF/tdc_shift", tof_tdc_shift))
39  dCAENTIPhaseDifference = tof_tdc_shift["TOF_TDC_SHIFT"];
40 
41  return NOERROR;
42 }
43 
44 jerror_t DTTabUtilities_factory::evnt(jana::JEventLoop *locEventLoop, uint64_t eventnumber)
45 {
46  vector<const DMCThrown*> locMCThrowns;
47  locEventLoop->Get(locMCThrowns);
48 
49  DTTabUtilities* locTTabUtilities = new DTTabUtilities();
52  locTTabUtilities->dHasBadOrNoF1TDCConfigInfoFlag = ((locEventLoop->GetJEvent().GetRunNumber() <= 2965) || (!locMCThrowns.empty()));
54 
55  // Get DCODAROCInfo's, put into map
56  vector<const DCODAROCInfo*> locCODAROCInfos;
57  locEventLoop->Get(locCODAROCInfos);
58 
59  map<uint32_t, const DCODAROCInfo*> locCODAROCInfoMap;
60  for(size_t loc_i = 0; loc_i < locCODAROCInfos.size(); ++loc_i)
61  locCODAROCInfoMap[locCODAROCInfos[loc_i]->rocid] = locCODAROCInfos[loc_i];
62  locTTabUtilities->dCODAROCInfoMap = locCODAROCInfoMap;
63 
64  //get the trigger reference signal ("Beni-cable")
65  //hard-coded crate/slot/channel, but whatever. This isn't intended to be long-term-code anyway.
66 
67  vector<const DF1TDCHit*> locF1TDCHits;
68  locEventLoop->Get(locF1TDCHits);
69 
70  bool locFoundFlag = false;
71  for(size_t loc_i = 0; loc_i < locF1TDCHits.size(); ++loc_i)
72  {
73  if((locF1TDCHits[loc_i]->rocid != 51) || (locF1TDCHits[loc_i]->slot != 17) || (locF1TDCHits[loc_i]->channel != 8))
74  continue;
75  locTTabUtilities->dTriggerReferenceSignal = locF1TDCHits[loc_i]->time; //in TDC clicks
76  locTTabUtilities->dTriggerReferenceSignalIsLowResTDC = (locF1TDCHits[loc_i]->modtype == DModuleType::F1TDC48);
77  locFoundFlag = true;
78  break;
79  }
80  if(!locFoundFlag)
81  locTTabUtilities->dTriggerReferenceSignal = 0;
82 
83  _data.push_back(locTTabUtilities);
84  return NOERROR;
85 }
uint64_t dNumTDCTicksInRolloverTimeWindow
bool dHasBadOrNoF1TDCConfigInfoFlag
int dCAENTIPhaseDifference
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
bool dTriggerReferenceSignalIsLowResTDC
jerror_t brun(jana::JEventLoop *loop, int32_t runnumber)
map< uint32_t, const DCODAROCInfo * > dCODAROCInfoMap
uint64_t dRolloverTimeWindowLength
uint64_t dTriggerReferenceSignal