22 vector<double> new_t0s(DIRC_MAX_CHANNELS);
23 vector<int> new_status(DIRC_MAX_CHANNELS);
25 time_offsets.push_back(new_t0s); time_offsets.push_back(new_t0s);
26 channel_status.push_back(new_status); channel_status.push_back(new_status);
37 static pthread_mutex_t print_mutex = PTHREAD_MUTEX_INITIALIZER;
38 static set<int> runs_announced;
39 pthread_mutex_lock(&print_mutex);
40 bool print_messages =
false;
41 if(runs_announced.find(runnumber) == runs_announced.end()){
42 print_messages =
true;
43 runs_announced.insert(runnumber);
45 pthread_mutex_unlock(&print_mutex);
47 if(print_messages) jout <<
"In DDIRCPmtHit_factory, loading constants..." << endl;
50 map<string,double> base_time_offset;
51 if (eventLoop->GetCalib(
"/DIRC/base_time_offset",base_time_offset))
52 jout <<
"Error loading /DIRC/base_time_offset !" << endl;
53 else if (base_time_offset.find(
"t0_North") != base_time_offset.end() && base_time_offset.find(
"t0_South") != base_time_offset.end()) {
54 t_base[0] = base_time_offset[
"t0_North"];
55 t_base[1] = base_time_offset[
"t0_South"];
58 jerr <<
"Unable to get t0s from /DIRC/base_time_offset !" << endl;
61 if (eventLoop->GetCalib(
"/DIRC/North/timing_offsets", time_offsets[0]))
62 jout <<
"Error loading /DIRC/North/timing_offsets !" << endl;
63 if (eventLoop->GetCalib(
"/DIRC/North/channel_status", channel_status[0]))
64 jout <<
"Error loading /DIRC/North/channel_status !" << endl;
65 if (eventLoop->GetCalib(
"/DIRC/South/timing_offsets", time_offsets[1]))
66 jout <<
"Error loading /DIRC/South/timing_offsets !" << endl;
67 if (eventLoop->GetCalib(
"/DIRC/South/channel_status", channel_status[1]))
68 jout <<
"Error loading /DIRC/South/channel_status !" << endl;
88 vector<const DDIRCTriggerTime*> timestamps;
89 loop->Get(timestamps);
90 if(timestamps.size() > 0) {
91 for (
unsigned int i=0; i < timestamps.size()-1; i++) {
92 if(timestamps[i]->time != timestamps[i+1]->time)
97 vector<const DCODAROCInfo*> locCODAROCInfos;
98 eventLoop->Get(locCODAROCInfos);
99 uint64_t locReferenceClockTime = 0;
100 for (
const auto& locCODAROCInfo : locCODAROCInfos) {
101 if(locCODAROCInfo->rocid == 92) {
102 locReferenceClockTime = locCODAROCInfo->timestamp;
106 vector<const DDIRCTDCDigiHit*> digihits;
110 for (
unsigned int i=0; i < digihits.size(); i++) {
112 if(digihit_lead->
edge == 0)
continue;
115 double timeOverThreshold = 0.;
119 for (
unsigned int j=0; j < digihits.size(); j++) {
120 digihit_trail = digihits[j];
121 if(i==j || digihit_trail->
edge == 1)
continue;
126 int channel = digihit_lead->
channel;
127 int box = (channel < DIRC_MAX_CHANNELS) ? 1 : 0;
130 timeOverThreshold = (double)digihit_trail->
time - (
double)digihit_lead->
time;
133 if(timeOverThreshold < 0 || timeOverThreshold > 100)
continue;
137 if ( (status==BAD) || (status==NOISY) )
continue;
142 hit->
tot = timeOverThreshold;
145 double T = (double)digihit_lead->
time;
147 if(locReferenceClockTime%2 == 0)
150 applyTimeOffset =
true;
151 applyTimewalk =
true;
153 double timeOverThresholdPeak = 50;
154 if(applyTimeOffset) {
155 hit->
t = hit->
t - time_offsets[box][channel] +
t_base[box];
158 hit->
t += slope*(timeOverThreshold - timeOverThresholdPeak);
161 hit->AddAssociatedObject(digihit_lead);
162 hit->AddAssociatedObject(digihit_trail);
163 _data.push_back(hit);
uint32_t edge
0=leading edge 1=trailing edge
uint32_t time
16 bit relative to beginning of defined readout window
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
jerror_t fini(void)
Called after last event of last event source has been processed.
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
jerror_t init(void)
Called once at program start.2.
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.