WCSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
WCSimWCTrigger.cc
Go to the documentation of this file.
1 #include "WCSimWCTrigger.hh"
2 #include "WCSimWCPMT.hh"
3 #include "WCSimWCDigi.hh"
4 #include "WCSimWCHit.hh"
5 #include "G4EventManager.hh"
6 #include "G4Event.hh"
7 #include "G4SDManager.hh"
8 #include "G4DigiManager.hh"
9 #include "G4ios.hh"
10 #include "G4RotationMatrix.hh"
11 #include "G4ThreeVector.hh"
12 
14 #include "WCSimPmtInfo.hh"
16 
17 #include <vector>
18 // for memset
19 #include <cstring>
20 
21 
22 
23 // *******************************************
24 // BASE CLASS
25 // *******************************************
26 
27 #ifndef WCSIMWCTRIGGER_VERBOSE
28 //#define WCSIMWCTRIGGER_VERBOSE
29 #endif
30 #ifndef HYPER_VERBOSITY
31 //#define HYPER_VERBOSITY
32 #endif
33 
34 const double WCSimWCTriggerBase::offset = 950.0; // ns. apply offset to the digit time in triggers
35 const double WCSimWCTriggerBase::LongTime = 40E9; // ns = 40s. loooong time for SN simulations
36 
37 
39  WCSimDetectorConstruction* inDetector,
40  WCSimWCDAQMessenger* myMessenger,
41  G4String detectorElement)
42  :G4VDigitizerModule(name), DAQMessenger(myMessenger), myDetector(inDetector), triggerClassName(""), detectorElement(detectorElement)
43 {
44  G4String colName;
45  if(detectorElement=="tank") colName = "WCDigitizedCollection";
46  else if(detectorElement=="OD") colName = "WCDigitizedCollection_OD";
47  collectionName.push_back(colName);
48 
49 #ifdef HYPER_VERBOSITY
50  if(detectorElement=="OD")
51  G4cout << "WCSimWCTriggerBase::WCSimWCTriggerBase ☆ recording collection name "<< colName << " for " << detectorElement << G4endl;
52 #endif
53 
54  ReInitialize();
55 
56  if(DAQMessenger == NULL) {
57  G4cerr << "WCSimWCDAQMessenger pointer is NULL when passed to WCSimWCTriggerBase constructor. Exiting..."
58  << G4endl;
59  exit(-1);
60  }
61 
62  digitizeCalled = false;
63 }
64 
66 }
67 
68 
70 {
71  //set the options to class-specific defaults
77 
78  //read the .mac file to override them
79  if(DAQMessenger != NULL) {
82  }
83  else {
84  G4cerr << "WCSimWCDAQMessenger pointer is NULL when used in WCSimWCTriggerBase::GetVariables(). Exiting..."
85  << G4endl;
86  exit(-1);
87  }
88 
89  G4cout << (multiDigitsPerTrigger ? "Using mutiple digits per PMT per trigger" : "Using a maximum of 1 digit per PMT per trigger" ) << G4endl
90  << "Using NDigits threshold " << ndigitsThreshold
91  << (ndigitsAdjustForNoise ? " (will be adjusted for noise)" : "") << G4endl
92  << "Using NDigits trigger window " << ndigitsWindow << " ns" << G4endl
93  << "Using NDigits event pretrigger window " << ndigitsPreTriggerWindow << " ns" << G4endl
94  << "Using NDigits event posttrigger window " << ndigitsPostTriggerWindow << " ns" << G4endl;
95  if(saveFailuresMode == 0)
96  G4cout << "Saving only triggered digits" << G4endl;
97  else if(saveFailuresMode == 1)
98  G4cout << "Saving both triggered and not-triggered digits" << G4endl;
99  else if(saveFailuresMode == 2)
100  G4cout << "Saving only not-triggered digits" << G4endl;
101  if(saveFailuresMode > 0)
102  G4cout << "Using SaveFailures trigger time" << saveFailuresTime << " ns" << G4endl
103  << "Using SaveFailures event pretrigger window " << saveFailuresPreTriggerWindow << " ns" << G4endl
104  << "Using SaveFailures event posttrigger window " << saveFailuresPostTriggerWindow << " ns" << G4endl;
105 }
106 
108 {
109  switch(t) {
110  case kTriggerNoTrig:
112  break;
113  case kTriggerNDigits:
114  case kTriggerNDigitsTest:
116  break;
117  case kTriggerFailure:
119  break;
120  default:
121  G4cerr << "WCSimWCTriggerBase::GetPreTriggerWindow() Unknown trigger type " << t
122  << "\t" << WCSimEnumerations::EnumAsString(t) << G4endl;
123  exit(-1);
124  break;
125  }
126 }
127 
129 {
130  switch(t) {
131  case kTriggerNoTrig:
133  break;
134  case kTriggerNDigits:
135  case kTriggerNDigitsTest:
137  break;
138  case kTriggerFailure:
140  break;
141  default:
142  G4cerr << "WCSimWCTriggerBase::GetPostTriggerWindow() Unknown trigger type " << t
143  << "\t" << WCSimEnumerations::EnumAsString(t) << G4endl;
144  exit(-1);
145  break;
146  }
147 }
148 
150 {
151  int npmts;
152  if(detectorElement=="tank") npmts = this->myDetector->GetTotalNumPmts();
153  else if(detectorElement=="OD") npmts = this->myDetector->GetTotalNumODPmts();
154  double trigger_window_seconds = ndigitsWindow * 1E-9;
155  double dark_rate_Hz = PMTDarkRate * 1000;
156  double average_occupancy = dark_rate_Hz * trigger_window_seconds * npmts;
157 
158  G4cout << "Average number of PMTs in detector active in a " << ndigitsWindow
159  << "ns window with a dark noise rate of " << PMTDarkRate
160  << "kHz is " << average_occupancy
161  << " (" << npmts << " total PMTs)"
162  << G4endl
163  << "Updating the NDigits threshold, from " << ndigitsThreshold
164  << " to " << ndigitsThreshold + round(average_occupancy) << G4endl;
165  ndigitsThreshold += round(average_occupancy);
166 }
167 
169 {
172  digitizeCalled = true;
173  }
174 
175 #ifdef HYPER_VERBOSITY
176  if(detectorElement=="OD")
177  G4cout << "WCSimWCTriggerBase::Digitize ☆ adjusting threshold for average occupancy" << G4endl;
178 #endif
179 
180  //Input is collection of all digitized hits that passed the threshold
181  //Output is all digitized hits which pass the trigger
182 
183  ReInitialize();
184 
185  //This is the output digit collection
186  G4String collectiondetectorname;
187  if(detectorElement=="tank") collectiondetectorname="/WCSim/glassFaceWCPMT";
188  else if(detectorElement=="OD") collectiondetectorname="/WCSim/glassFaceWCPMT_OD";
189  DigitsCollection = new WCSimWCTriggeredDigitsCollection (collectiondetectorname,collectionName[0]);
190 
191  G4DigiManager* DigiMan = G4DigiManager::GetDMpointer();
192 
193  // Get the Digitized hits collection ID
194  G4String untriggeredcollectionname;
195  if(detectorElement=="tank") untriggeredcollectionname="WCDigitizedStoreCollection";
196  else if(detectorElement=="OD") untriggeredcollectionname = "WCDigitizedStoreCollection_OD";
197  G4int WCDCID = DigiMan->GetDigiCollectionID(untriggeredcollectionname);
198  // Get the PMT Digits Collection
199  WCSimWCDigitsCollection* WCDCPMT =
200  (WCSimWCDigitsCollection*)(DigiMan->GetDigiCollection(WCDCID));
201 
202 #ifdef HYPER_VERBOSITY
203  if(detectorElement=="OD"){
204  G4cout<<"WCSimWCTriggerBase::Digitize ☆ making triggered digits collection "<<collectionName[0]<<" for "<<detectorElement
205  <<" and calling DoTheWork on "<<untriggeredcollectionname<<" to fill it."<<G4endl;
206  }
207 #endif
208 
209  // Do the work
210  if (WCDCPMT) {
211  DoTheWork(WCDCPMT);
212  } else {
213  G4cout<<"could not find trigger PMT digits collection for "<<detectorElement<<G4endl;
214  }
215 
216 #ifdef HYPER_VERBOSITY
217  if(detectorElement=="OD"){
218  G4cout<<"WCSimWCTriggerBase::Digitize ☆ storing the triggered digits collection "<<collectionName[0]
219  <<" which has "<<DigitsCollection->entries()<<" entries"<<G4endl;
220  }
221 #endif
222 
223  StoreDigiCollection(DigitsCollection);
224 }
225 
226 void WCSimWCTriggerBase::AlgNDigits(WCSimWCDigitsCollection* WCDCPMT, bool remove_hits, bool test)
227 {
228 
229  //if test is true, we run the algorithm with 1/2 the threshold, and kTriggerNDigitsTest
230  //for testing multiple trigger algorithms at once
231  int this_ndigitsThreshold = ndigitsThreshold;
232  TriggerType_t this_triggerType = kTriggerNDigits;
233  if(test) {
234  this_ndigitsThreshold /= 2;
235  this_triggerType = kTriggerNDigitsTest;
236  }
237 
238  //Now we will try to find triggers
239  //loop over PMTs, and Digits in each PMT. If ndigits > Threshhold in a time window, then we have a trigger
240 
241  int ntrig = 0;
242  int window_step_size = 5; //step the search window along this amount if no trigger is found
243 
244  //loop over all digits once to get the range to loop over
245  double firsthit = +WCSimWCTriggerBase::LongTime;
246  double lasthit = -WCSimWCTriggerBase::LongTime;
247  //Loop over PMTs
248  for (G4int i = 0 ; i < WCDCPMT->entries() ; i++) {
249  //Loop over each Digit in this PMT
250  for ( G4int ip = 0 ; ip < (*WCDCPMT)[i]->GetTotalPe() ; ip++) {
251  G4double digit_time = (*WCDCPMT)[i]->GetTime(ip);
252  // Add some sanity. Hit times larger than some limit (WCSimWCTriggerBase::LongTime) are ignored
253  if(digit_time > lasthit && digit_time<WCSimWCTriggerBase::LongTime )
254  lasthit = digit_time;
255  if(digit_time < firsthit)
256  firsthit = digit_time;
257  }//loop over Digits
258  }//loop over PMTs
259  int window_start_time = firsthit;
260  window_start_time -= window_start_time % 5;
261  int window_end_time = lasthit - ndigitsWindow + window_step_size;
262  window_end_time -= window_end_time % 5;
263 #ifdef WCSIMWCTRIGGER_VERBOSE
264  G4cout << "WCSimWCTriggerBase::AlgNDigits. Found first/last hits. Looping from "
265  << window_start_time
266  << " to " << window_end_time
267  << " in steps of " << window_step_size << G4endl;
268 #endif
269 
270  std::vector<G4double> digit_times;
271 
272  G4cout << "WCSimWCTriggerBase::AlgNDigits. Number of entries in input digit collection: " << WCDCPMT->entries() << G4endl;
273 #ifdef WCSIMWCTRIGGER_VERBOSE
274  int temp_total_pe = 0;
275  for (G4int i = 0 ; i < WCDCPMT->entries() ; i++) {
276  temp_total_pe += (*WCDCPMT)[i]->GetTotalPe();
277  }
278  G4cout << "WCSimWCTriggerBase::AlgNDigits. " << temp_total_pe << " total p.e. input" << G4endl;
279 #endif
280 
281  // the upper time limit is set to the final possible full trigger window
282  while(window_start_time <= window_end_time) {
283  int n_digits = 0;
284  double triggertime; //save each digit time, because the trigger time is the time of the first hit above threshold
285  bool triggerfound = false;
286  digit_times.clear();
287 
288  //Loop over each PMT
289  for (G4int i = 0 ; i < WCDCPMT->entries() ; i++) {
290  //int tube=(*WCDCPMT)[i]->GetTubeID();
291  //Loop over each Digit in this PMT
292  for ( G4int ip = 0 ; ip < (*WCDCPMT)[i]->GetTotalPe() ; ip++) {
293  G4double digit_time = (*WCDCPMT)[i]->GetTime(ip);
294  //hit in trigger window?
295  if(digit_time >= window_start_time && digit_time <= (window_start_time + ndigitsWindow)) {
296  n_digits++;
297  digit_times.push_back(digit_time);
298  }
299  //G4cout << digit_time << G4endl;
300  }//loop over Digits
301  }//loop over PMTs
302 
303  //if over threshold, issue trigger
304  if(n_digits > this_ndigitsThreshold) {
305  ntrig++;
306  //The trigger time is the time of the first hit above threshold
307  std::sort(digit_times.begin(), digit_times.end());
308  triggertime = digit_times[this_ndigitsThreshold];
309  triggertime -= (int)triggertime % 5;
310  TriggerTimes.push_back(triggertime);
311  TriggerTypes.push_back(this_triggerType);
312  TriggerInfos.push_back(std::vector<Float_t>(1, n_digits));
313  triggerfound = true;
314  }
315 
316 #ifdef WCSIMWCTRIGGER_VERBOSE
317  if(n_digits)
318  G4cout << n_digits << " digits found in 200nsec trigger window ["
319  << window_start_time << ", " << window_start_time + ndigitsWindow
320  << "]. Threshold is: " << this_ndigitsThreshold << G4endl;
321 #endif
322 
323  //move onto the next go through the timing loop
324  if(triggerfound) {
325  window_start_time = triggertime + GetPostTriggerWindow(TriggerTypes.back());
326  }//triggerfound
327  else {
328  window_start_time += window_step_size;
329  }
330  }
331 
332  G4cout << "Found " << ntrig << " NDigit triggers" << G4endl;
333  //call FillDigitsCollection() whether any triggers are found or not
334  // (what's saved depends on saveFailuresMode)
335  FillDigitsCollection(WCDCPMT, remove_hits, this_triggerType);
336 }
337 
338 void WCSimWCTriggerBase::FillDigitsCollection(WCSimWCDigitsCollection* WCDCPMT, bool remove_hits, TriggerType_t save_triggerType)
339 {
340  //Adds the digits within the trigger window to the output WCSimWCDigitsCollection
341  // optionally removes digits from the input digits collection (when running different Alg* methods concurently)
342  // so they are not used in subsequent trigger decisions or saved twice
343  //Also, only save digits of a specific type (again for when running different Alg* methods concurently)
344 
345  // Add dummy triggers / exit without saving triggers as required
346  //
347  //saveFailuresMode = 0 - save only triggered events
348  //saveFailuresMode = 1 - save both triggered & not triggered events
349  //saveFailuresMode = 2 - save only not triggered events
350  if(TriggerTimes.size()) {
351  if(saveFailuresMode == 2)
352  return;
353  }
354  else {
355  if(saveFailuresMode == 0)
356  return;
357  TriggerTypes.push_back(kTriggerFailure);
358  TriggerTimes.push_back(saveFailuresTime);
359  TriggerInfos.push_back(std::vector<Float_t>(1, -1));
360  save_triggerType = kTriggerFailure;
361  }
362 
363  //make sure the triggers are in time order
365 
366  //Loop over trigger times
367  for(unsigned int itrigger = 0; itrigger < TriggerTimes.size(); itrigger++) {
368  TriggerType_t triggertype = TriggerTypes[itrigger];
369  //check if we've already saved this trigger
370  if(triggertype != save_triggerType && save_triggerType != kTriggerUndefined)
371  continue;
372  double triggertime = TriggerTimes[itrigger];
373  std::vector<Float_t> triggerinfo = TriggerInfos[itrigger];
374 
375  //these are the boundary of the trigger gate: we want to add all digits within these bounds to the output collection
376  double lowerbound = triggertime + GetPreTriggerWindow(triggertype);
377  double upperbound = triggertime + GetPostTriggerWindow(triggertype);
378  //need to check for double-counting - check if the previous upperbound is above the lowerbound
379  if(itrigger) {
380  double upperbound_previous = TriggerTimes[itrigger - 1] + GetPostTriggerWindow(TriggerTypes[itrigger - 1]);
381  if(upperbound_previous > lowerbound) {
382  //also need to check whether the previous upperbound is above the lowerbound
383  //(different trigger windows for different trigger types can mean this trigger is completely contained within another)
384  // if it is, we skip it
385  if(upperbound_previous >= upperbound)
386  continue;
387  lowerbound = upperbound_previous;
388  }
389  }
390 
391 #ifdef WCSIMWCTRIGGER_VERBOSE
392  G4cout << "Saving trigger " << itrigger << " of type " << WCSimEnumerations::EnumAsString(triggertype)
393  << " in time range [" << lowerbound << ", " << upperbound << "]"
394  << " with trigger time " << triggertime
395  << " and additional trigger info";
396  for(std::vector<Float_t>::iterator it = triggerinfo.begin(); it != triggerinfo.end(); ++it)
397  G4cout << " " << *it;
398  G4cout << G4endl;
399 #endif
400 
401  //loop over PMTs
402  for (G4int i = 0; i < WCDCPMT->entries(); i++) {
403  int tube=(*WCDCPMT)[i]->GetTubeID();
404  //loop over digits in this PMT
405  for ( G4int ip = 0; ip < (*WCDCPMT)[i]->GetTotalPe(); ip++){
406  G4double digit_time = (*WCDCPMT)[i]->GetTime(ip);
407  if(digit_time >= lowerbound && digit_time <= upperbound) {
408  //hit in event window
409  //add it to DigitsCollection
410 
411  //first apply time offsets
412  double peSmeared = (*WCDCPMT)[i]->GetPe(ip);
413  G4double digihittime = digit_time;
414  if(triggertype != kTriggerNoTrig)
415  digihittime += WCSimWCTriggerBase::offset - triggertime;
416 
417  //get the composition information for the triggered digit
418  std::vector<int> triggered_composition = (*WCDCPMT)[i]->GetDigiCompositionInfo(ip);
419 
420 #ifdef WCSIMWCTRIGGER_VERBOSE
421  G4cout << "Saving digit on PMT " << tube
422  << " time " << digihittime
423  << " pe " << peSmeared
424  << " digicomp";
425  for(unsigned int iv = 0; iv < triggered_composition.size(); iv++)
426  G4cout << " " << triggered_composition[iv];
427  G4cout << G4endl;
428 #endif
429  assert(triggered_composition.size());
430 
431  //add hit
432  if ( DigiHitMap[tube] == 0) {
433  //this PMT has no digits saved yet; create a new WCSimWCDigiTrigger
435  Digi->SetTubeID(tube);
436  Digi->AddGate (itrigger);
437  Digi->SetTime (itrigger,digihittime);
438  Digi->SetPe (itrigger,peSmeared);
439  Digi->AddPe ();
440  Digi->AddDigiCompositionInfo(itrigger,triggered_composition);
441  DigiHitMap[tube] = DigitsCollection->insert(Digi);
442  }
443  else {
444  //this PMT has digits saved already; add information to the WCSimWCDigiTrigger
445  (*DigitsCollection)[DigiHitMap[tube]-1]->AddGate(itrigger);
446  (*DigitsCollection)[DigiHitMap[tube]-1]->SetTime(itrigger, digihittime);
447  (*DigitsCollection)[DigiHitMap[tube]-1]->SetPe (itrigger, peSmeared);
448  (*DigitsCollection)[DigiHitMap[tube]-1]->AddPe ();
449  (*DigitsCollection)[DigiHitMap[tube]-1]->AddDigiCompositionInfo(itrigger,triggered_composition);
450  }
451  if(remove_hits)
452  (*WCDCPMT)[i]->RemoveDigitizedGate(ip);
453 
454  //we've found a digit on this PMT. If we're restricting to just 1 digit per trigger window (e.g. SKI)
455  // then ignore later digits and break. This takes us to the next PMT
456  if(!multiDigitsPerTrigger && triggertype != kTriggerNoTrig)
457  break;
458  }//digits within trigger window
459  }//loop over Digits
460  }//loop over PMTs
461  }//loop over Triggers
462  G4cout << "WCSimWCTriggerBase::FillDigitsCollection. Number of entries in output digit collection: " << DigitsCollection->entries() << G4endl;
463 
464 }
465 
466 void WCSimWCTriggerBase::AlgNoTrigger(WCSimWCDigitsCollection* WCDCPMT, bool remove_hits, bool test) {
467 
468  //Does not doanything, just writes out all hits
469  TriggerType_t this_triggerType = kTriggerNoTrig;
470  std::vector<Float_t> triggerinfo;
471  Int_t Ndigits=0;
472  for (G4int i = 0 ; i < WCDCPMT->entries() ; i++) {
473  Ndigits += (*WCDCPMT)[i]->GetTotalPe();
474  }
475  triggerinfo.push_back(Ndigits);
476  TriggerTypes.push_back(kTriggerNoTrig);
477  TriggerInfos.push_back(triggerinfo);
478  TriggerTimes.push_back(0.);
479 
480  FillDigitsCollection(WCDCPMT, remove_hits, this_triggerType);
481 }
482 
484 {
487  //ndigits
493  //savefailures
498 }
499 
500 
501 
502 // *******************************************
503 // CONTAINER CLASS
504 // *******************************************
505 
506 G4Allocator<WCSimWCDigiTrigger> WCSimWCDigiTriggerAllocator;
507 
509 {
510  Gates.clear();
511  tubeID = 0;
512  pe.clear();
513  time.clear();
514  fDigiComp.clear();
515  totalPe = 0;
516 }
517 
519 
521  :G4VDigi()
522 {
523  // in principle assignment = is defined for containers...
524  Gates = right.Gates;
525  tubeID = right.tubeID;
526  pe = right.pe;
527  time = right.time;
528  fDigiComp = right.fDigiComp;
529  totalPe = right.totalPe;
530 }
531 
533 {
534  Gates = right.Gates;
535  tubeID = right.tubeID;
536  pe = right.pe;
537  time = right.time;
538  fDigiComp = right.fDigiComp;
539  totalPe = right.totalPe;
540  return *this;
541 }
542 
544 {
545  G4cout << "TubeID: " << tubeID
546  << ", Number of Gates: " << NumberOfGates()
547  << G4endl;
548  std::multimap<int,double>::iterator it_pe = pe.begin();
549  std::multimap<int,double>::iterator it_time = time.begin();
550  for( ; it_pe != pe.end(), it_time != time.end(); ++it_pe, ++it_time) {
551  if(it_pe->first != it_time->first) {
552  G4cerr << "WCSimWCDigiTrigger::Print() pe and time gate counters disagree!" << G4endl;
553  exit(-1);
554  }
555  G4cout << "Gate = " << it_pe->first
556  << " PE: " << it_pe->second
557  << " Time: " << it_time->second
558  << G4endl;
559  }
560 }
561 
562 
563 
564 // *******************************************
565 // DERIVED CLASS
566 // *******************************************
567 
569  WCSimDetectorConstruction* myDetector,
570  WCSimWCDAQMessenger* myMessenger,
571  G4String detectorElement)
572  :WCSimWCTriggerBase(name, myDetector, myMessenger, detectorElement)
573 {
574  triggerClassName = "NDigits";
575  GetVariables();
576 }
577 
579 {
580 }
581 
583  //Apply an NDigits trigger
584  bool remove_hits = false;
585  AlgNDigits(WCDCPMT, remove_hits);
586 }
587 
588 // *******************************************
589 // DERIVED CLASS
590 // *******************************************
591 
592 
594  WCSimDetectorConstruction* myDetector,
595  WCSimWCDAQMessenger* myMessenger,
596  G4String detectorElement)
597  :WCSimWCTriggerBase(name, myDetector, myMessenger, detectorElement)
598 {
599  triggerClassName = "NoTrigger";
600  GetVariables();
601 }
602 
604 {
605 }
606 
608  //Apply an NDigits trigger
609  bool remove_hits = false;
612  AlgNoTrigger(WCDCPMT, remove_hits);
613 }
614 
615 
616 // *******************************************
617 // DERIVED CLASS
618 // *******************************************
619 
621  WCSimDetectorConstruction* myDetector,
622  WCSimWCDAQMessenger* myMessenger,
623  G4String detectorElement)
624  :WCSimWCTriggerBase(name, myDetector, myMessenger, detectorElement)
625 {
626  triggerClassName = "NDigits2";
627  GetVariables();
628 }
629 
631 }
632 
633 
635  //This calls 2 trigger algorithms; the second algorithm is called on hits that failed the first algorithm
636  //(for a second trigger working on hits that passed a pretrigger, FillDigitsCollection() needs to have a new option)
637 
638  //Make a copy of the input DigitsCollection, so we can remove hits from the copy
639  WCSimWCDigitsCollection* WCDCPMTCopy = new WCSimWCDigitsCollection(*WCDCPMT);
640 
641  //Apply an NDigits trigger
642  bool remove_hits = true;
643  AlgNDigits(WCDCPMTCopy, remove_hits);
644 
645  //Apply an NDigits trigger with a lower threshold & different saved trigger type
646  remove_hits = false;
647  bool ndigits_test = true;
648  AlgNDigits(WCDCPMTCopy, remove_hits, ndigits_test);
649 }
std::vector< std::vector< Float_t > > TriggerInfos
Additional information associated with each trigger.
void SetTubeID(G4int tube)
G4int saveFailuresPreTriggerWindow
The pretrigger window to save before an SaveFailures trigger.
std::multimap< int, double > time
Digit time.
virtual ~WCSimWCTriggerBase()
enum ETriggerType TriggerType_t
std::vector< Double_t > TriggerTimes
The times of the triggers.
void SaveOptionsToOutput(WCSimRootOptions *wcopt)
Save current values of options.
void AddGate(G4int gate)
G4String triggerClassName
Save the name of the trigger class.
void SortTriggersByTime()
sort the Trigger vectors (Time, Type, Info) by Trigger Time
std::map< int, int > DigiHitMap
Keeps track of the PMTs that have been added to the output WCSimWCTriggeredDigitsCollection.
void TellMeAboutTheTrigger(WCSimWCTriggerBase *trigger)
void AlgNoTrigger(WCSimWCDigitsCollection *WCDCPMT, bool remove_hits, bool test=false)
void SetNDigitsWindow(int indigitsWindow)
void DoTheWork(WCSimWCDigitsCollection *WCDCPMT)
This should call the trigger algorithms, and handle any temporary DigitsCollection&#39;s.
void SetTime(G4int gate, G4double T)
void SetSaveFailuresPreTriggerWindow(int isaveFailuresPreTriggerWindow)
void SetSaveFailuresMode(int isaveFailuresMode)
virtual int GetDefaultNDigitsThreshold()
Set the default trigger class specific NDigits threshold (in ns) (overridden by .mac) ...
std::multimap< int, double > pe
Digit charge.
void AddDigiCompositionInfo(G4int gate, std::vector< int > &digi_comp)
Add a whole vector for one digit to fDigiComp. Clear input vector once added.
void DoTheWork(WCSimWCDigitsCollection *WCDCPMT)
Calls the workhorse of this class: AlgNDigits.
void SetSaveFailuresPostTriggerWindow(int isaveFailuresPostTriggerWindow)
void SetNDigitsPreTriggerWindow(int indigitsPreTriggerWindow)
void SetTriggerClassName(string itriggerClassName)
void SetNDigitsThreshold(int indigitsThreshold)
virtual void DoTheWork(WCSimWCDigitsCollection *WCDCPMT)=0
This should call the trigger algorithms, and handle any temporary DigitsCollection&#39;s.
WCSimWCTriggerNoTrigger(G4String name, WCSimDetectorConstruction *, WCSimWCDAQMessenger *, G4String detectorElement)
Create WCSimWCTriggerNoTrigger instance with knowledge of the detector and DAQ options.
double PMTDarkRate
Dark noise rate of the PMTs.
void SetMultiDigitsPerTrigger(G4bool allow_multi)
Set whether to allow the number of digits per PMT per trigger to go &gt; 1.
G4TDigiCollection< WCSimWCDigi > WCSimWCDigitsCollection
Definition: WCSimWCDigi.hh:214
double GetPreTriggerWindow(TriggerType_t t)
Get the pretrigger window for a given trigger algorithm.
G4TDigiCollection< WCSimWCDigiTrigger > WCSimWCTriggeredDigitsCollection
G4int ndigitsPostTriggerWindow
The posttrigger window to save after an NDigits trigger.
G4bool multiDigitsPerTrigger
Allow the number of digits per PMT saved in each trigger window to go &gt; 1?
void ReInitialize()
Clear the Trigger* vectors and DigiHitMap.
The base class for WCSim triggering algorithms.
G4bool ndigitsAdjustForNoise
Automatically adjust the NDigits trigger threshold based on the average dark noise rate...
void SetMultiDigitsPerTrigger(bool imultiDigitsPerTrigger)
std::vector< TriggerType_t > TriggerTypes
The type of the triggers.
void SetNDigitsPostTriggerWindow(int indigitsPostTriggerWindow)
G4int saveFailuresMode
The mode for saving events which don&#39;t pass triggers.
void AlgNDigits(WCSimWCDigitsCollection *WCDCPMT, bool remove_hits, bool test=false)
An NDigits trigger algorithm.
void AdjustNDigitsThresholdForNoise()
modify the NDigits threshold based on the average dark noise rate
WCSimWCTriggerNDigits(G4String name, WCSimDetectorConstruction *, WCSimWCDAQMessenger *, G4String detectorElement)
Create WCSimWCTriggerNDigits instance with knowledge of the detector and DAQ options.
G4int ndigitsThreshold
The threshold for the NDigits trigger.
virtual int GetDefaultNDigitsWindow()
Set the default trigger class specific NDigits window (in ns) (overridden by .mac) ...
G4int saveFailuresPostTriggerWindow
The posttrigger window to save after an SaveFailures trigger.
G4int ndigitsPreTriggerWindow
The pretrigger window to save before an NDigits trigger.
static const double LongTime
An arbitrary long time to use in loops (ns)
G4int tubeID
PMT id of the digit.
double t[MAX_N_ACTIVE_TUBES]
Definition: jhfNtuple.h:40
bool digitizeCalled
Has Digitize() been called yet?
G4int totalPe
Total charge on digit.
const WCSimWCDigiTrigger & operator=(const WCSimWCDigiTrigger &)
G4int ndigitsWindow
The time window for the NDigits trigger.
WCSimDetectorConstruction * myDetector
Know about the detector, so can add appropriate PMT time smearing.
std::multimap< int, std::vector< int > > fDigiComp
Stores the unique IDs of each photon making up a digit.
static std::string EnumAsString(DigitizerType_t d)
virtual int GetDefaultNDigitsPostTriggerWindow()
Set the default trigger class specific NDigits posttrigger window (in ns) (overridden by ...
WCSimWCTriggerNDigits2(G4String name, WCSimDetectorConstruction *, WCSimWCDAQMessenger *, G4String detectorElement)
std::set< int > Gates
&#39;Gates&#39; specifies subevent
void SetPe(G4int gate, G4double Q)
void SetNDigitsAdjustForNoise(bool indigitsAdjustForNoise)
void SetSaveFailuresMode(G4int mode)
Set the mode for saving failed triggers (0:save only triggered events, 1:save both triggered events &amp;...
WCSimWCTriggeredDigitsCollection * DigitsCollection
The main output of the class - collection of digits in the trigger window.
virtual int GetDefaultNDigitsPreTriggerWindow()
Set the default trigger class specific NDigits pretrigger window (in ns) (overridden by ...
G4Allocator< WCSimWCDigiTrigger > WCSimWCDigiTriggerAllocator
void SetSaveFailuresTime(double isaveFailuresTime)
void DoTheWork(WCSimWCDigitsCollection *WCDCPMT)
Calls the workhorse of this class: AlgNoTrigger.
WCSimWCTriggerBase(G4String name, WCSimDetectorConstruction *, WCSimWCDAQMessenger *, G4String)
Create WCSimWCTriggerBase instance with knowledge of the detector and DAQ options.
void FillDigitsCollection(WCSimWCDigitsCollection *WCDCPMT, bool remove_hits, TriggerType_t save_triggerType)
takes all trigger times, then loops over all Digits &amp; fills the output DigitsCollection ...
static const double offset
Hit time offset (ns)
double GetPostTriggerWindow(TriggerType_t t)
Get the posttrigger window for a given trigger algorithm.
virtual bool GetDefaultMultiDigitsPerTrigger()
Set the default trigger class specific decision of whether to save multiple digits per PMT per trigge...
double E[MAX_N_PRIMARIES]
Definition: jhfNtuple.h:24
void GetVariables()
Get the default threshold, etc. from the derived class, and override with read from the ...
WCSimWCDAQMessenger * DAQMessenger
Get the options from the .mac file.
void Digitize()
The main user-callable routine of the class. Gets the input &amp; creates the output WCSimWCTriggeredDigi...
G4double saveFailuresTime
The dummy trigger time for failed events.