Jpp  18.4.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 
7 #include "JTrigger/JTimeslice.hh"
9 #include "JDetector/JDetector.hh"
11 #include "JMath/JMathToolkit.hh"
12 #include "JPhysics/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 
58 
59  const double d = getDistance(first.getPosition(), second.getPosition());
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  if (!frame.empty()) {
152 
153  frame.fast_forward(root->getT() - TMaxEvent_ns);
154 
155  for (typename JFrame_t::const_iterator i = frame.get(); *i <= Tmax; ++i) {
156 
157  if (*i >= Tmin) {
158  buffer.push_back(JHitR1(frame.getModuleID(),
159  frame.getPosition(),
160  frame.getJHit(*i)));
161  }
162  }
163  }
164  }
165 
166  if (distance (buffer.begin(), buffer.end()) >= parameters.numberOfHits - 1 &&
167  getNumberOfModules(buffer.begin(), buffer.end()) >= parameters.numberOfModules - 1) {
168 
169  if (distance(buffer.begin(), buffer.end()) < parameters.factoryLimit) {
170 
171  JTriggerInput::iterator q = clusterize(buffer.begin(), buffer.end(), match, parameters.numberOfHits - 1);
172 
173  if (distance (buffer.begin(), q) >= parameters.numberOfHits - 1 &&
174  getNumberOfModules(buffer.begin(), q) >= parameters.numberOfModules - 1) {
175  *out = JEvent(inputL1.getDAQChronometer(), *root, buffer.begin(), q, this->getTriggerBit());
176  ++out;
177  }
178 
179  } else {
180 
181  // Anomalous large event
182 
183  JEvent event(inputL1.getDAQChronometer(), *root, buffer.begin(), buffer.end(), this->getTriggerBit());
184 
186 
187  *out = event;
188  ++out;
189  }
190  }
191  }
192  }
193  }
194 
195  private:
200  double TMaxEvent_ns;
201  };
202 }
203 
204 #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.
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.
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
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: JMuonPath.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.
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.
do JPlot2D f $WORKDIR canberra[${EMITTER}] root
Definition: JCanberra.sh:136
Triggered event.
Time slice with calibrated data.
Definition: JTimeslice.hh:26
JTriggerbit_t getTriggerBit()
Get the trigger bit.