Jpp  19.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JTriggerMXShower.hh
Go to the documentation of this file.
1 #ifndef __JTRIGGER__JTRIGGERMXSHOWER__
2 #define __JTRIGGER__JTRIGGERMXSHOWER__
3 
4 #include "JTrigger/JAlgorithm.hh"
5 #include "JTrigger/JMatch3G.hh"
8 #include "JTrigger/JTimeslice.hh"
12 #include "JDetector/JDetector.hh"
14 #include "JMath/JMathToolkit.hh"
15 #include "JPhysics/JConstants.hh"
16 
17 
18 /**
19  * \author mdejong
20  */
21 
22 namespace JTRIGGER {}
23 namespace JPP { using namespace JTRIGGER; }
24 
25 namespace JTRIGGER {
26 
27  using JDETECTOR::JModule;
31 
32 
33  /**
34  * Module attributes.
35  */
36  struct JAttributes {
37  double Tmin_ns; //!< minimal time difference [ns]
38  double Tmax_ns; //!< maximal time difference [ns]
39  };
40 
41 
42  /**
43  * Set module attributes.
44  *
45  * \param first first module
46  * \param second second module
47  * \param attributes module attributes
48  */
49  inline void setAttributes(const JModule& first,
50  const JModule& second,
51  JAttributes& attributes)
52  {
53  using namespace JPP;
54 
55  typedef JTriggerMXShower_t::JParameters JParameters_t;
56 
57  // get trigger parameters
58 
60 
61  const double d = getDistance(first.getPosition(), second.getPosition());
62 
63  double t1 = 0.0;
64 
65  if (d <= 0.5 * parameters.DMax_m)
66  t1 = d * getIndexOfRefraction() * getInverseSpeedOfLight() + parameters.TMaxExtra_ns;
67  else if (d <= parameters.DMax_m)
68  t1 = (parameters.DMax_m - d) * getIndexOfRefraction() * getInverseSpeedOfLight() + parameters.TMaxExtra_ns;
69 
70  attributes.Tmin_ns = -t1;
71  attributes.Tmax_ns = +t1;
72  }
73 
74 
75  /**
76  * Shower trigger.
77  */
79  public JTriggerMXShower_t,
80  public JTriggerInterface
81  {
82  public:
83 
84  /**
85  * Type definition of module mapper.
86  */
88 
89 
90  /**
91  * Constructor.
92  *
93  * \param input trigger parameters
94  * \param detector detector;
95  */
97  const JDetector& detector) :
98  parameters(input),
99  mapper(detector, JMaximalDistance(parameters.DMax_m)),
100  match(parameters.DMax_m, parameters.TMaxExtra_ns)
101  {
102  using namespace JPP;
103 
105 
106  if (parameters.numberOfHits == 0) {
107  parameters.numberOfHits = 1;
108  }
109 
110  if (parameters.numberOfHits == 1) {
111  parameters.factoryLimit = 1;
112  }
113 
114  if (parameters.numberOfModules < 1) {
115  parameters.numberOfModules = 1;
116  }
117  }
118 
119 
120  /**
121  * Process trigger.
122  *
123  * \param inputL1 input L1 data
124  * \param inputL0 input L0 data
125  * \param out output data
126  */
127  template<class JElement_t>
128  void operator()(const JTriggerInput& inputL1,
129  const JTimeslice<JElement_t> inputL0,
130  std::back_insert_iterator<JTriggerOutput> out) const
131  {
132  typedef JTimesliceClone<JElement_t> JTimeslice_t;
133  typedef typename JTimeslice_t::value_type JFrame_t;
134  typedef typename JModuleMapper_t::container_type container_type;
135 
136  if (parameters.enabled) {
137 
138  JTimeslice_t clone(inputL0, mapper);
139 
140  for (JTriggerInput::const_iterator root = inputL1.begin(); root != inputL1.end(); ++root) {
141 
142  buffer.clear();
143 
144  const container_type& zip = mapper.getList(root->getModuleID());
145 
146  for (typename container_type::const_iterator mod = zip.begin(); mod != zip.end(); ++mod) {
147 
148  const double Tmin = root->getT() + mod->Tmin_ns;
149  const double Tmax = root->getT() + mod->Tmax_ns;
150 
151  JFrame_t& frame = clone[mod->first];
152 
153  if (!frame.empty()) {
154 
155  frame.fast_forward(root->getT() - TMaxEvent_ns);
156 
157  for (typename JFrame_t::const_iterator i = frame.get(); *i <= Tmax; ++i) {
158 
159  if (*i >= Tmin) {
160  buffer.push_back(JHitR1(frame.getModuleID(),
161  frame.getPosition(),
162  frame.getJHit(*i)));
163  }
164  }
165  }
166  }
167 
168  if (distance (buffer.begin(), buffer.end()) >= parameters.numberOfHits - 1 &&
169  getNumberOfModules(buffer.begin(), buffer.end()) >= parameters.numberOfModules - 1) {
170 
171  if (distance(buffer.begin(), buffer.end()) < parameters.factoryLimit) {
172 
173  JTriggerInput::iterator q = clusterize(buffer.begin(), buffer.end(), match, parameters.numberOfHits - 1);
174 
175  if (distance (buffer.begin(), q) >= parameters.numberOfHits - 1 &&
176  getNumberOfModules(buffer.begin(), q) >= parameters.numberOfModules - 1) {
177  *out = JEvent(inputL1.getDAQChronometer(), *root, buffer.begin(), q, this->getTriggerBit());
178  ++out;
179  }
180 
181  } else {
182 
183  // Anomalous large event
184 
185  JEvent event(inputL1.getDAQChronometer(), *root, buffer.begin(), buffer.end(), this->getTriggerBit());
186 
188 
189  *out = event;
190  ++out;
191  }
192  }
193  }
194  }
195  }
196 
197  private:
202  double TMaxEvent_ns;
203  };
204 }
205 
206 #endif
Data frame with end marker.
Definition: JFrame_t.hh:27
3G match criterion.
Definition: JMatch3G.hh:29
Auxiliary methods for geometrical methods.
Data structure for a composite optical module.
Definition: JModule.hh:67
Shower trigger parameters.
Algorithms for hit clustering and sorting.
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
double getIndexOfRefraction()
Get average index of refraction of water corresponding to group velocity.
Detector data structure.
Definition: JDetector.hh:89
static const JParameters_t & getParameters()
Get latest parameters.
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
static const int FACTORY_LIMIT
Bit indicating max nhits reached in trigger.
Definition: trigger.hh:16
static const JModuleCounter getNumberOfModules
Function object to count unique modules.
Data structure for detector geometry and calibration.
do JPlot2D f $WORKDIR canberra[${EMITTER}\] root
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
double getDistance(const JFirst_t &first, const JSecond_t &second)
Get distance between objects.
double Tmin_ns
minimal time difference [ns]
JFIT::JEvent JEvent
Definition: JHistory.hh:353
Auxiliary class to match modules according maximal distance.
JModuleMapper< JAttributes > JModuleMapper_t
Type definition of module mapper.
Detector file.
Definition: JHead.hh:226
std::vector< JHitR1 > buffer
const JDAQChronometer & getDAQChronometer() const
Get DAQ chronometer.
Physics constants.
Module attributes.
JDAQTriggerMask & addTriggerBit(const unsigned int bit)
Add trigger bit.
const JPosition3D & getPosition() const
Get position.
Definition: JPosition3D.hh:130
const container_type & getList(const JObjectID &id) const
Get list with module data matching given module.
void setAttributes(const JModule &first, const JModule &second, JAttributes_t &attributes)
Template method to set module attributes.
double Tmax_ns
maximal time difference [ns]
then JMuonMCEvt f $INPUT_FILE o $INTERMEDIATE_FILE d
Definition: JMuonStart.sh:47
void operator()(const JTriggerInput &inputL1, const JTimeslice< JElement_t > inputL0, std::back_insert_iterator< JTriggerOutput > out) const
Process trigger.
JParametersHelper< JParameters > parameters
Mapper for directly addressing of associated modules in the detector data structure.
Map of associated modules in detector.
Clone of JTimeslice.
const double getInverseSpeedOfLight()
Get inverse speed of light.
JTriggerbit_t getTriggerBit() const
Get the trigger bit.
Reduced data structure for L1 hit.
Definition: JHitR1.hh:31
Data structure for input to trigger algorithm.
static struct JTRIGGER::clusterize clusterize
JTriggerMXShower(const JParameters &input, const JDetector &detector)
Constructor.
Match operator for Cherenkov light from shower in any direction.
Triggered event.
Time slice with calibrated data.
Definition: JTimeslice.hh:26