Jpp
JTriggerMXShower.hh
Go to the documentation of this file.
1 #ifndef __JTRIGGER__JTRIGGERMXSHOWER__
2 #define __JTRIGGER__JTRIGGERMXSHOWER__
3 
7 #include "JTrigger/JTimeslice.hh"
9 #include "JDetector/JDetector.hh"
11 #include "JMath/JMathToolkit.hh"
12 #include "JTools/JConstants.hh"
13 
14 
15 /**
16  * \author mdejong
17  */
18 
19 namespace JTRIGGER {}
20 namespace JPP { using namespace JTRIGGER; }
21 
22 namespace JTRIGGER {
23 
24  using JDETECTOR::JModule;
28 
29 
30  /**
31  * Module attributes.
32  */
33  struct JAttributes {
34  double Tmin_ns; //!< minimal time difference [ns]
35  double Tmax_ns; //!< maximal time difference [ns]
36  };
37 
38 
39  /**
40  * Set module attributes.
41  *
42  * \param first first module
43  * \param second second module
44  * \param attributes module attributes
45  */
46  inline void setAttributes(const JModule& first,
47  const JModule& second,
48  JAttributes& attributes)
49  {
50  using namespace JMATH;
51  using namespace JTOOLS;
52 
53  typedef JTriggerMXShower_t::JParameters JParameters_t;
54 
55  // get trigger parameters
56 
57  const JParameters_t& parameters = JParametersHelper<JParameters_t>::getParameters();
58 
59  const double d = getDistance(first, second);
60 
61  double t1 = 0.0;
62 
63  if (d <= 0.5 * parameters.DMax_m)
64  t1 = d * getIndexOfRefraction() * getInverseSpeedOfLight() + parameters.TMaxExtra_ns;
65  else if (d <= parameters.DMax_m)
66  t1 = (parameters.DMax_m - d) * getIndexOfRefraction() * getInverseSpeedOfLight() + parameters.TMaxExtra_ns;
67 
68  attributes.Tmin_ns = -t1;
69  attributes.Tmax_ns = +t1;
70  }
71 
72 
73  /**
74  * Shower trigger.
75  */
77  public JTriggerMXShower_t,
78  public JTriggerInterface
79  {
80  public:
81 
82  /**
83  * Type definition of module mapper.
84  */
86 
87 
88  /**
89  * Constructor.
90  *
91  * \param input trigger parameters
92  * \param detector detector;
93  */
95  const JDetector& detector) :
96  parameters(input),
97  mapper(detector, JMaximalDistance(parameters.DMax_m)),
98  match(parameters.DMax_m, parameters.TMaxExtra_ns)
99  {
100  using namespace JTOOLS;
101 
102  TMaxEvent_ns = parameters.DMax_m * getIndexOfRefraction() * getInverseSpeedOfLight() + parameters.TMaxExtra_ns;
103 
104  if (parameters.numberOfHits == 0) {
105  parameters.numberOfHits = 1;
106  }
107 
108  if (parameters.numberOfHits == 1) {
109  parameters.factoryLimit = 1;
110  }
111 
112  if (parameters.numberOfModules < 1) {
113  parameters.numberOfModules = 1;
114  }
115  }
116 
117 
118  /**
119  * Process trigger.
120  *
121  * \param inputL1 input L1 data
122  * \param inputL0 input L0 data
123  * \param out output data
124  */
125  template<class JElement_t>
126  void operator()(const JTriggerInput& inputL1,
127  const JTimeslice<JElement_t> inputL0,
128  std::back_insert_iterator<JTriggerOutput> out) const
129  {
130  typedef JTimesliceClone<JElement_t> JTimeslice_t;
131  typedef typename JTimeslice_t::value_type JFrame_t;
132  typedef typename JModuleMapper_t::container_type container_type;
133 
134  if (parameters.enabled) {
135 
136  JTimeslice_t clone(inputL0, mapper);
137 
138  for (JTriggerInput::const_iterator root = inputL1.begin(); root != inputL1.end(); ++root) {
139 
140  buffer.clear();
141 
142  const container_type& zip = mapper.getList(root->getModuleID());
143 
144  for (typename container_type::const_iterator mod = zip.begin(); mod != zip.end(); ++mod) {
145 
146  const double Tmin = root->getT() + mod->Tmin_ns;
147  const double Tmax = root->getT() + mod->Tmax_ns;
148 
149  JFrame_t& frame = clone[mod->first];
150 
151  frame.fast_forward(root->getT() - TMaxEvent_ns);
152 
153  for (typename JFrame_t::const_iterator i = frame.get(); *i <= Tmax; ++i) {
154 
155  if (*i >= Tmin) {
156  buffer.push_back(JHitR1(frame.getModuleID(),
157  frame.getPosition(),
158  frame.getJHit(*i)));
159  }
160  }
161  }
162 
163  if (distance (buffer.begin(), buffer.end()) >= parameters.numberOfHits - 1 &&
164  getNumberOfModules(buffer.begin(), buffer.end()) >= parameters.numberOfModules - 1) {
165 
166  if (distance(buffer.begin(), buffer.end()) < parameters.factoryLimit) {
167 
168  JTriggerInput::iterator q = clusterize(buffer.begin(), buffer.end(), match, parameters.numberOfHits - 1);
169 
170  if (distance (buffer.begin(), q) >= parameters.numberOfHits - 1 &&
171  getNumberOfModules(buffer.begin(), q) >= parameters.numberOfModules - 1) {
172  *out = JEvent(inputL1.getDAQChronometer(), *root, buffer.begin(), q, this->getTriggerBit());
173  ++out;
174  }
175 
176  } else {
177 
178  // Anomalous large event
179 
180  *out = JEvent(inputL1.getDAQChronometer(), *root, buffer.begin(), buffer.end(), this->getTriggerBit());
181  ++out;
182  }
183  }
184  }
185  }
186  }
187 
188  private:
193  double TMaxEvent_ns;
194  };
195 }
196 
197 #endif
JTRIGGER::getTriggerBit
JTriggerbit_t getTriggerBit()
Get the trigger bit.
Definition: JTriggerInterface.hh:212
JTRIGGER::JTriggerMXShower_t::JParameters
Trigger parameters.
Definition: JTriggerMXShower_t.hh:24
JTRIGGER::JTriggerMXShower::JModuleMapper_t
JModuleMapper< JAttributes > JModuleMapper_t
Type definition of module mapper.
Definition: JTriggerMXShower.hh:85
JTRIGGER::JTriggerMXShower::buffer
std::vector< JHitR1 > buffer
Definition: JTriggerMXShower.hh:191
JTRIGGER::JAttributes::Tmin_ns
double Tmin_ns
minimal time difference [ns]
Definition: JTriggerMXShower.hh:34
JTRIGGER::JAttributes::Tmax_ns
double Tmax_ns
maximal time difference [ns]
Definition: JTriggerMXShower.hh:35
JTRIGGER::setAttributes
void setAttributes(const JModule &first, const JModule &second, JAttributes &attributes)
Set module attributes.
Definition: JTriggerMXShower.hh:46
JTimeslice.hh
JDETECTOR::JModuleMapper
Mapper for directly addressing of associated modules in the detector data structure.
Definition: JModuleMapper.hh:161
JTRIGGER::JEvent
Triggered event.
Definition: JEvent.hh:31
std::vector
Definition: JSTDTypes.hh:12
JTRIGGER::clusterize
JHitIterator_t clusterize(JHitIterator_t __begin, JHitIterator_t __end, const JMatch< JHit_t > &match, const int Nmin=1)
Partition data according given binary match operator.
Definition: JAlgorithm.hh:45
JTRIGGER::JParametersHelper::getParameters
static const JParameters_t & getParameters()
Get latest parameters.
Definition: JParametersHelper.hh:49
distance
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Definition: PhysicsEvent.hh:434
JTRIGGER::JAttributes
Module attributes.
Definition: JTriggerMXShower.hh:33
JTRIGGER::JTriggerInput
Data structure for input to trigger algorithm.
Definition: JTriggerInput.hh:32
JTriggerMXShower_t.hh
JTRIGGER::JTriggerMXShower::parameters
JParametersHelper< JParameters > parameters
Definition: JTriggerMXShower.hh:189
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JTRIGGER::JTriggerMXShower::JTriggerMXShower
JTriggerMXShower(const JParameters &input, const JDetector &detector)
Constructor.
Definition: JTriggerMXShower.hh:94
JMathToolkit.hh
JParametersHelper.hh
JTriggerInterface.hh
JTOOLS::getInverseSpeedOfLight
const double getInverseSpeedOfLight()
Get inverse speed of light.
Definition: JConstants.hh:100
JDETECTOR::getNumberOfModules
int getNumberOfModules(const JDetector &detector)
Get number of modules.
Definition: JDetectorToolkit.hh:452
JConstants.hh
JTRIGGER::JTriggerInterface
Trigger interface.
Definition: JTriggerInterface.hh:36
JTRIGGER::JTriggerMXShower::match
JMatch3G< JHitR1 > match
Definition: JTriggerMXShower.hh:192
JTOOLS::getIndexOfRefraction
double getIndexOfRefraction()
Get average index of refraction of water.
Definition: JConstants.hh:111
JTRIGGER::JTimeslice
Time slice with calibrated data.
Definition: JTimeslice.hh:26
JDETECTOR::JModule
Data structure for a composite optical module.
Definition: JModule.hh:49
JMATH::getDistance
double getDistance(const JFirst_t &first, const JSecond_t &second)
Get distance between objects.
Definition: JMathToolkit.hh:116
JTRIGGER::JMatch3G
3G match criterion.
Definition: JMatch3G.hh:29
JMATH
Auxiliary classes and methods for mathematical operations.
Definition: JCalculator.hh:9
JDETECTOR::JMaximalDistance
Auxiliary class to match modules according maximal distance.
Definition: JModuleMapper.hh:116
JTRIGGER::JTriggerMXShower::TMaxEvent_ns
double TMaxEvent_ns
Definition: JTriggerMXShower.hh:193
JModuleMapper.hh
JTRIGGER::JHitR1
Reduced data structure for L1 hit.
Definition: JHitR1.hh:31
JTRIGGER::JTriggerMXShower::operator()
void operator()(const JTriggerInput &inputL1, const JTimeslice< JElement_t > inputL0, std::back_insert_iterator< JTriggerOutput > out) const
Process trigger.
Definition: JTriggerMXShower.hh:126
JTRIGGER::JTimesliceClone
Clone of JTimeslice.
Definition: JTimesliceClone.hh:33
JDETECTOR::JDetector
Detector data structure.
Definition: JDetector.hh:80
JAANET::detector
Detector file.
Definition: JHead.hh:130
KM3NETDAQ::JDAQChronometer::getDAQChronometer
const JDAQChronometer & getDAQChronometer() const
Get DAQ chronometer.
Definition: JDAQChronometer.hh:88
JTRIGGER::JTriggerMXShower_t
Shower trigger parameters.
Definition: JTriggerMXShower_t.hh:19
JTRIGGER::JTriggerMXShower::mapper
JModuleMapper_t mapper
Definition: JTriggerMXShower.hh:190
JTRIGGER::JTriggerInput::end
const_iterator end() const
get iterator to end of data (without end marker)
Definition: JTriggerInput.hh:74
JDetector.hh
JTRIGGER::JTriggerMXShower
Shower trigger.
Definition: JTriggerMXShower.hh:76
JTRIGGER
Checksum.
Definition: JSupport/JSupport.hh:35
JTOOLS
Auxiliary classes and methods for multi-dimensional interpolations and histograms.
Definition: JAbstractCollection.hh:9
JTimesliceClone.hh
JTRIGGER::JParametersHelper< JParameters >