Diana Software
MFlagCoincidence.cc
Go to the documentation of this file.
1 #include "MFlagCoincidence.hh"
2 #include "QEvent.hh"
3 #include "QRawEvent.hh"
4 #include "QFiltersData.hh"
5 
6 
8 
10 {
11  // called once in a sequence
12 }
13 
15 {
16  // called once in a sequence
17 }
18 
20 {
22 
23  if(fIteration == 1)
24  {
25  fWindow = GetDouble("Window", 100.);
26  fWindow *= 1000000.0; // Convert to ns
27 
28  fFlagName = GetString("FlagName", "coincidence");
29  Info("Coincidence flag will be stored in AuxData variable %s",
30  fFlagName.c_str());
31 
32  fMultName = GetString("MultiplicityName", "multiplicity");
33  Info("Multiplicity will be stored in AuxData variable %s", fMultName.c_str());
34  }
35  else
36  {
38 
39  if(fnCoincidences == 0)
40  Panic("No coincidences!");
41 
42  Debug("%d elements in coincidence multiset.", fnCoincidences);
43  }
44 }
45 
47 {
48 
50 
51  if(fIteration == 1)
52  {
53  if(!(ev->GetFilters().GetPassed())) return ev;
54 
55  const QRawEvent& raw = ev->GetRawEvent();
56  QTime t;
57  t = raw.GetTime();
59  bool isSignal = raw.GetPulse().GetIsSignal();
60 
61  //Only include real events -- no heaters or noise acquisitions
62  if(isSignal)
63  {
65  int i = fPreviousEvents.size()-1;
66  if(i>=0)
67  {
68  while((fCurrentTime-fPreviousTimes[i]) < fWindow)
69  {
72  i--;
73  if(i<0) break;
74  }
75  }
76  fPreviousEvents.push_back(fCurrentEvent);
77  fPreviousTimes.push_back(fCurrentTime);
78  }
79  }
80  else
81  {
82  int multiplicity = fCoincidentEvents.count(fCurrentEvent);
83  ev->AuxData().SetInt(fMultName, multiplicity, "save");
84 
85  if(multiplicity>1)
86  ev->AuxData().SetInt(fFlagName, 1, "save");
87  else
88  ev->AuxData().SetInt(fFlagName, 0, "save");
89  }
90  return ev;
91 }
92 
94 {
95  if(fIteration == 1)
96  SetRunAgain(true);
97  else
98  SetRunAgain(false);
99 }
100 
#define REGISTER_MODULE(clazz)
Definition: QDriver.hh:133
A quick module to flag coincidences.
std::vector< unsigned long long > fPreviousTimes
Time of previous events.
unsigned int fCurrentEvent
Event number of current event.
~MFlagCoincidence()
destructor
std::string fFlagName
Name of variable to store in AuxData.
int fnCoincidences
Number of coincidences identified.
int fIteration
What iteration are we on?
std::string fMultName
Name of multiplicity variable in AuxData.
unsigned long long fCurrentTime
Time of current event.
void Init()
Init method.
std::multiset< int > fCoincidentEvents
Vector of coincident event numbers.
void Done()
Done method.
QEvent * Do(QEvent *ev)
Do method.
std::vector< unsigned int > fPreviousEvents
Event number of previous events.
double fWindow
Time window to be considered coincident (in nanoseconds)
const std::string & GetString(const std::string &parname, const std::string &defVal, bool warnCfg=true) const
Get a string parameter from config file ( see GetDouble() )
Definition: QBaseModule.cc:297
void Debug(const char *descr,...) const
Send a debug message (used to debug the module) with printf syntax.
Definition: QBaseModule.hh:208
unsigned int GetIteration() const
Get Current sequence iteration.
Definition: QBaseModule.hh:122
void Info(const char *descr,...) const
Send an info message (information) with printf syntax.
Definition: QBaseModule.hh:218
double GetDouble(const std::string &parname, double defVal, bool warnCfg=true) const
Get a double parameter from config file.
Definition: QBaseModule.cc:184
void Panic(const char *descr,...) const
Send a panic message (stops the framework) with printf syntax.
Definition: QBaseModule.hh:248
void SetRunAgain(bool b)
Set that the sequence will be reiterated.
Definition: QBaseModule.hh:120
diana event
Definition: QEvent.hh:46
unsigned int GetReadNumber() const
return the event number as read by the current reader.
Definition: QEvent.hh:60
Base class for diana modules.
Definition: QModule.hh:54
Diana Reconstruction program.
Definition: QSequence.hh:40
Diana time.
Definition: QTime.hh:17
unsigned long long GetFromStartRunNs() const
retrieve time from start of run in ns
Definition: QTime.hh:38