Belle II Software  release-08-01-10
Segment.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 //-----------------------------------------------------------------------------
10 // Description : A class to represent a wire in CDC.
11 //-----------------------------------------------------------------------------
12 
13 #ifndef TRGCDCSegment_FLAG_
14 #define TRGCDCSegment_FLAG_
15 
16 #include <vector>
17 #include "trg/cdc/LUT.h"
18 #include "trg/cdc/Cell.h"
19 
20 #ifdef TRGCDC_SHORT_NAMES
21 #define TCSegment TRGCDCSegment
22 #endif
23 
24 namespace Belle2 {
30  class TRGSignal;
31  class TRGCDCWire;
32  class TRGCDCLayer;
33  class TRGCDCLUT;
34  class TRGCDCWireHit;
35  class TRGCDCSegmentHit;
36  class CDCTriggerSegmentHit;
37 
39  class TRGCDCSegment : public TRGCDCCell {
40 
41  public:
42 
44  TRGCDCSegment(unsigned id,
45  const TRGCDCLayer& layer,
46  const TRGCDCWire& w,
47  const TRGClock& clock,
48  const std::string& TSLUTFile,
49  const std::vector<const TRGCDCWire*>& wires);
50 
52  virtual ~TRGCDCSegment();
53 
54  public:// Selectors
55 
57  const std::vector<const TRGCDCWire*>& wires(void) const;
58 
60  std::string name(void) const override;
61 
63  const TRGCDCWire* operator[](unsigned id) const;
64 
66  const TRGCDCWire& center(void) const;
67 
69  const TRGCDCWire& priority(void) const;
70 
72  const TRGSignal& signal(void) const override;
73 
75  const TRGCDCSegmentHit* hit(void) const;
76 
78  const std::vector<const CDCTriggerSegmentHit*> storeHits(void) const;
79 
81  unsigned hitPattern(void) const;
83  unsigned hitPattern(int clk0, int clk1) const;
85  unsigned lutPattern(void) const;
87  unsigned lutPattern(int clk0, int clk1) const;
88 
90  float fastestTime(void) const;
92  float fastestTime(int clk0) const;
93 
95  float foundTime(void)const;
96 
98  float priorityTime(void) const;
99 
101  int priorityPosition(void)const;
103  int priorityPosition(int clk0, int clk1)const;
104 
106  const TRGCDCLUT* LUT(void) const;
107 
109  void dump(const std::string& message = std::string(""),
110  const std::string& prefix = std::string("")) const override;
111 
112 
114  void initialize(void);
116  void initialize(bool fevtTime);
117 
118  public:// Utility functions
119 
121  /* static const std::vector<const TRGCDCSegment *> */
122  /* axial(const std::vector<const TRGCDCSegment *> & list); */
123 
125  static unsigned
126  nStereo(const std::vector<const TRGCDCSegment*>& list);
127 
129  virtual bool hasMember(const std::string& a) const override;
130 
131  public:// Modifiers
132 
134  void clear(void) override;
135 
137  void simulate(bool clockSimulation, bool logicLUTFlag,
138  const std::string& cdcCollectionName = std::string(""),
139  const std::string& tsCollectionName = std::string(""));
140 
142  const TRGCDCSegmentHit* hit(const TRGCDCSegmentHit*);
143 
145  void addStoreHit(const CDCTriggerSegmentHit*);
146 
147  public:
148 
150  void simulateWithoutClock(bool logicLUTFlag);
151 
153  void simulateWithClock(std::string cdcCollectionName,
154  std::string tsCollectionName);
155 
156  private:
157 
159  TRGCDCLUT* m_TSLUT = nullptr;
160 
162 // const TRGCDCLUT * const _lut; //Will be Removed.
163 
165  std::vector<const TRGCDCWire*> _wires;
166 
169 
172 
174  std::vector<const TRGCDCWireHit*> _hits;
175 
177  std::vector<const CDCTriggerSegmentHit*> _storeHits;
178 
180  std::string m_TSLUTFileName;
181 
182  // Friends
183  friend class TRGCDC;
184  };
185 
186 //-----------------------------------------------------------------------------
187 
188  inline
189  const std::vector<const TRGCDCWire*>&
191  {
192  return _wires;
193  }
194 
195  inline
196  const TRGCDCWire*
197  TRGCDCSegment::operator[](unsigned id) const
198  {
199  if (id < _wires.size())
200  return _wires[id];
201  return 0;
202  }
203 
204  inline
205  const TRGSignal&
207  {
208  return _signal;
209  }
210 
211  inline
212  const TRGCDCSegmentHit*
214  {
215  //TODO only this strong retyping work, is it OK?
216  return reinterpret_cast<const TRGCDCSegmentHit*>(TRGCDCCell::hit(reinterpret_cast<const TRGCDCCellHit*>(h)));
217  }
218 
219  inline
220  const TRGCDCSegmentHit*
221  TRGCDCSegment::hit(void) const
222  {
223  //TODO only this strong retyping work, is it OK?
224  return reinterpret_cast<const TRGCDCSegmentHit*>(TRGCDCCell::hit());
225  }
226 
227  inline
228  void
230  {
231  _storeHits.push_back(h);
232  }
233 
234  inline
235  const std::vector<const CDCTriggerSegmentHit*>
237  {
238  return _storeHits;
239  }
240 
241  inline
242  const TRGCDCLUT*
243  TRGCDCSegment::LUT(void) const
244  {
245  return m_TSLUT;
246  }
247 
248  inline
249  const TRGCDCWire&
251  {
252  if (_wires.size() == 15)
253  return * _wires[0];
254  return * _wires[5];
255  }
256 
258 } // namespace Belle2
259 
260 #endif /* TRGCDCSegment_FLAG_ */
Combination of several CDCHits to a track segment hit for the trigger.
A class to represent a wire hit in CDC.
Definition: CellHit.h:74
A class to represent a wire in CDC.
Definition: Cell.h:40
A class to use LUTs for TRGCDC.
Definition: LUT.h:39
A class to represent a cell layer.
Definition: Layer.h:33
A class to represent a track segment hit in CDC.
Definition: SegmentHit.h:31
A class to represent a wire in CDC.
Definition: Segment.h:39
std::vector< const TRGCDCWire * > _wires
LookUp Table.
Definition: Segment.h:165
std::vector< const CDCTriggerSegmentHit * > _storeHits
list of DataStore hits.
Definition: Segment.h:177
TRGSignal _signal
Trigger signal.
Definition: Segment.h:171
void initialize(bool fevtTime)
initilize variables.
std::vector< const TRGCDCWireHit * > _hits
Wire hits.
Definition: Segment.h:174
std::string m_TSLUTFileName
TS LUT file name.
Definition: Segment.h:180
TRGCDCLUT * m_TSLUT
LookUp Table. 0: no hit, 1: right, 2: left, 3: not determined.
Definition: Segment.h:159
static unsigned nStereo(const std::vector< const TRGCDCSegment * > &list)
returns axial segments.
const TRGCDCWire * _center
Center wire.
Definition: Segment.h:168
A class to represent a wire in CDC.
Definition: Wire.h:56
The instance of TRGCDC is a singleton.
Definition: TRGCDC.h:69
A class to represent a digitized signal. Unit is nano second.
Definition: Clock.h:38
A class to represent a digitized signal. Unit is nano second.
Definition: Signal.h:23
virtual bool hasMember(const std::string &a) const override
returns true this has member named a.
Definition: Segment.cc:579
const TRGCDCWire & center(void) const
returns a center wire.
Definition: Segment.h:250
int priorityPosition(void) const
return priority cell position in TSHit. 0: no hit, 3: 1st priority, 1: 2nd right, 2: 2nd left
Definition: Segment.cc:473
float fastestTime(void) const
return fastest time in TSHit.
Definition: Segment.cc:387
unsigned id(void) const
returns id.
Definition: Cell.h:197
void addStoreHit(const CDCTriggerSegmentHit *)
sets a pointer to a CDCTriggerSegmentHit.
Definition: Segment.h:229
virtual ~TRGCDCSegment()
Destructor.
Definition: Segment.cc:60
void simulateWithoutClock(bool logicLUTFlag)
simulates time-indegrated TF hit
Definition: Segment.cc:176
void simulateWithClock(std::string cdcCollectionName, std::string tsCollectionName)
simulates TF hit time-dependently
Definition: Segment.cc:291
unsigned hitPattern(void) const
returns hit pattern.
Definition: Segment.cc:535
const TRGCDCCellHit * hit(void) const
returns a pointer to a TRGCDCCellHit.
Definition: Cell.h:362
const TRGSignal & signal(void) const override
returns trigger output. Null will returned if no signal.
Definition: Segment.h:206
const TRGCDCWire & priority(void) const
returns priority wire.
Definition: Segment.cc:525
TRGCDCSegment(unsigned id, const TRGCDCLayer &layer, const TRGCDCWire &w, const TRGClock &clock, const std::string &TSLUTFile, const std::vector< const TRGCDCWire * > &wires)
Constructor.
Definition: Segment.cc:40
void initialize(void)
initilize variables.
Definition: Segment.cc:65
std::string name(void) const override
returns name.
Definition: Segment.cc:141
unsigned lutPattern(void) const
hit pattern containing bit for priority position
Definition: Segment.cc:559
void simulate(bool clockSimulation, bool logicLUTFlag, const std::string &cdcCollectionName=std::string(""), const std::string &tsCollectionName=std::string(""))
simulates TF hit using wire information.
Definition: Segment.cc:154
const TRGCDCWire * operator[](unsigned id) const
returns a wire.
Definition: Segment.h:197
const TRGCDCLUT * LUT(void) const
returns LUT
Definition: Segment.h:243
void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const override
dumps debug information.
Definition: Segment.cc:71
void clear(void) override
clears information.
Definition: Segment.cc:132
const std::vector< const CDCTriggerSegmentHit * > storeHits(void) const
returns a pointer to a CDCTriggerSegmentHit.
Definition: Segment.h:236
const TRGCDCLayer & layer(void) const
returns a pointer to a layer.
Definition: Cell.h:232
const std::vector< const TRGCDCWire * > & wires(void) const
returns a vector containing pointers to a wire.
Definition: Segment.h:190
float priorityTime(void) const
return priority time in TSHit.
Definition: Segment.cc:463
float foundTime(void) const
return found time in TSHit.
Definition: Segment.cc:423
const TRGCDCSegmentHit * hit(void) const
returns a pointer to a TRGCDCSegmentHit.
Definition: Segment.h:221
Abstract base class for different kinds of events.