HYDRA_development_version
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
hmdcstoreevents.h
Go to the documentation of this file.
1 #ifndef HMDCSTOREEVENTS_H
2 #define HMDCSTOREEVENTS_H
3 
4 #include "TObject.h"
5 #include "hgeomvector.h"
6 #include "hseqarr.h"
7 
9 class HMdcClus;
10 
11 class HMdcStoreWires : public TObject {
12  protected:
13  HSeqArr nDTPerEvent; // array of indexis of events
14  HSeqArrIter* iterEvents; // pointer to iterator of events
15  HSeqArr mdcWireAddr; // array of addresses of fired wires
16  HSeqArrIter* iterWires; // pointer to iterator of wires in event
17 
18  UInt_t maxMemSize; // upper limit for memory
19 
20  UInt_t nEvents; // number of events in array (for filling only)
21  UShort_t nDrTimes; // number of wires in current event (for filling)
22 
23  UShort_t nDrTmPerEv; // number of wires in current event (for reading)
24  UInt_t nRdEvents; // number of read events (for reading)
25  UShort_t nRdDrTimes; // number of read wires (for reading)
26 
27  public:
28  HMdcStoreWires(void);
29  ~HMdcStoreWires(void);
30  void setMaxMemSize(UInt_t mSize); // mSize - in Mb!
31  virtual UInt_t getMemSize(void) const;
32  Bool_t testMemSize(void) const;
33 
34  // Storing functions:
35  void addWireAddr(Int_t s, Int_t m, Int_t l, Int_t c);
36  void setEndEvent(void);
37 
38  // Getting functions:
39  virtual void resetIter(void);
40  Bool_t getNextEvent(void);
41  Bool_t getNextWireAddr(Int_t& s, Int_t& m, Int_t& l, Int_t& c);
42  inline static UShort_t packAddress(Int_t s, Int_t m, Int_t l, Int_t c);
43  inline static void unpackAddress(UShort_t& addr, Int_t& s, Int_t& m,
44  Int_t& l, Int_t& c);
45 
46  // Storing and getting events:
47  void addEvent(const HMdcEvntListCells& event);
48  Bool_t getNextEvent(HMdcEvntListCells& event);
49  protected:
50 
51  ClassDef(HMdcStoreWires,0)
52 };
53 
54 inline UShort_t HMdcStoreWires::packAddress(Int_t s,Int_t m,Int_t l,Int_t c) {
55  return UShort_t((( ((s&7)<<5) + ((m&3)<<3) + (l&7) ) <<8) + (c&255));
56 }
57 
58 inline void HMdcStoreWires::unpackAddress(UShort_t& addr, Int_t& s,
59  Int_t& m, Int_t& l, Int_t& c) {
60  s=(Int_t)((addr>>13)&7); // 13=5+8
61  m=(Int_t)((addr>>11)&3); // 11=3+8
62  l=(Int_t)((addr>>8)&7);
63  c=(Int_t)(addr&255);
64 }
65 
66 //----------------------------------------------
67 
68 class HMdcStoreEvents : public TObject {
69  protected:
70  HSeqArr nDTPerEvent; // array of indexis of events
71  HSeqArrIter* iterEvents; // pointer to iterator of events
72  HSeqArr mdcCells; // array of addresses & dr.times of fired wires
73  HSeqArrIter* iterWires; // pointer to iterator of wires in event
74 
75  UInt_t maxMemSize; // upper limit for memory
76 
77  UInt_t nEvents; // number of events in array (for filling only)
78  UShort_t nDrTimes; // number of wires in current event (for filling)
79 
80  UShort_t nDrTmPerEv; // number of wires in current event (for reading)
81  UInt_t nRdEvents; // number of read events (for reading)
82  UShort_t nRdDrTimes; // number of read wires (for reading)
83 
84  public:
85  HMdcStoreEvents(void);
86  ~HMdcStoreEvents(void);
87  void setMaxMemSize(UInt_t mSize); // mSize - in Mb!
88  virtual UInt_t getMemSize(void) const;
89  Bool_t testMemSize(void) const;
90 
91  // Storing functions:
92  void addWire(Int_t s,Int_t m,Int_t l,Int_t c,Float_t tm, Bool_t flag=kTRUE);
93  void setEndEvent(void);
94 
95  // Getting functions:
96  virtual void resetIter(void);
97  Bool_t getNextEvent(void);
98  Bool_t getNextCell(Int_t& s, Int_t& m, Int_t& l, Int_t& c, Float_t& tm);
99  Bool_t getNextCell(Int_t& s, Int_t& m, Int_t& l, Int_t& c, Float_t& tm,
100  Bool_t& flag);
101  Bool_t getNextCell(Int_t& s, Int_t& m, Int_t& l, Int_t& c, Float_t& tm,
102  Bool_t& flag,UInt_t** addr);
103  inline static UInt_t packCell(Int_t s, Int_t m, Int_t l, Int_t c,
104  Float_t tm, Bool_t flag=kTRUE);
105  inline static Bool_t unpackCell(UInt_t& addr, Int_t& s, Int_t& m,
106  Int_t& l, Int_t& c, Float_t& tm);
107  static void unsetFlag(UInt_t& addr) {addr &= 0xFFFEFFFF;}
108  static void setFlag(UInt_t& addr) {addr |= 0x10000;} // 0x10000=1<<16;
109 
110  // Storing and getting events:
111  void addEvent(const HMdcEvntListCells& event);
112  Bool_t getNextEvent(HMdcEvntListCells& event,Bool_t checkFlag=kFALSE);
113  protected:
114 
115  ClassDef(HMdcStoreEvents,0)
116 };
117 
118 inline UInt_t HMdcStoreEvents::packCell(Int_t s,Int_t m,Int_t l,Int_t c,
119  Float_t tm,Bool_t flag) {
120  UInt_t sign = tm>0 ? 0 : 0x4000; // 0x4000 = 1<<14
121  if(sign) tm = -tm;
122  UInt_t dt = UInt_t(tm*10. + 0.5);
123  if(dt > 0x3FFF) dt=0x3FFF;
124  dt = (dt|sign)<<17;
125  if(flag) setFlag(dt);
126  return UInt_t((( ((s&7)<<5) + ((m&3)<<3) + (l&7) ) <<8) + (c&0xFF)) +dt;
127 }
128 
129 inline Bool_t HMdcStoreEvents::unpackCell(UInt_t& addr, Int_t& s,
130  Int_t& m, Int_t& l, Int_t& c, Float_t& tm) {
131  // return user flag
132  s = (Int_t)((addr>>13)&7); // 13=5+8
133  m = (Int_t)((addr>>11)&3); // 11=3+8
134  l = (Int_t)((addr>>8)&7);
135  c = (Int_t)(addr&0xFF);
136  tm = ((addr>>17)&0x3FFF)*0.1;
137  if(addr&0x80000000) tm = -tm; // negative dr.time.
138  return (addr&0x10000) > 0; // 0x10000=1<<16
139 }
140 
141 //----------------------------------------------
142 
143 class HMdcStoreTracks : public TObject {
144  protected:
145  HSeqArr address; // keep sector and mod.for x1,y1 (mod1)
146  // and mod.for x2,y2 (mod2) and flag
147  // if mod1=mod2 - x1,y1 - layer 1, x2,y2 - layer 6
148  HSeqArr trackPos; // array of cluster positions
149  HSeqArr nTracksEvent; // array of numbers of tracks per event
150  HSeqArrIter* iterAddress; // pointer to iterator of track address
151  HSeqArrIter* iterTrackPos; // pointer to iterator of clusters positions
152  HSeqArrIter* iterNTrckEv; // pointer to iterator of num.of clusters/event
153  UChar_t flagAddress; // trackFlag and address for current track
154  Float_t x1,y1; // current cluster parameters:
155  Float_t x2,y2; // two points in coor.sys. mdc's
156  UShort_t nEventTracks; // num. tracks in one event (<=32767)
157  UShort_t nReadTracks; // counter of the read tracks in this event
158  Bool_t eventFlag; // event flag
159  Bool_t arrayEnd; // end of array flag
160  public:
161  HMdcStoreTracks(void);
162  ~HMdcStoreTracks(void);
163  virtual UInt_t getMemSize(void) const;
164 
165  // Storing functions:
166  Bool_t setEndTrack(void);
167  void setEndEvent(Bool_t flag=kTRUE);
168  void setTrackPar(UChar_t s, UChar_t m1, Float_t xf, Float_t yf,
169  UChar_t m2, Float_t xl, Float_t yl, UChar_t flag=1);
170 
171  // Getting functions:
172  virtual void resetIter(void); // must be called ones per clusters loop
173  Bool_t nextEvent(void);
174  Bool_t nextTrack(void);
175 
176  Bool_t getEventFlag(void) {return eventFlag;}
177  Bool_t getTrackFlag(void) {return (flagAddress&128) > 0;}
178  UChar_t getSector(void) {return flagAddress&7;}
179  UChar_t getMod1(void) {return (flagAddress>>3)&3;}
180  UChar_t getMod2(void) {return (flagAddress>>5)&3;}
181  Int_t getNumEventTracks(void) const {return nEventTracks;}
182  Float_t getX1(void) const {return x1;}
183  Float_t getY1(void) const {return y1;}
184  Float_t getZ1(void) const {return 0.;}
185  Float_t getX2(void) const {return x2;}
186  Float_t getY2(void) const {return y2;}
187  Float_t getZ2(void) const {return 0.;}
188  void getTrackPar(Float_t& xf,Float_t& yf, Float_t& xl,Float_t& yl) const;
189  void getPoint1(HGeomVector& p1) const {p1.setXYZ(x1,y1,0.);}
190  void getPoint2(HGeomVector& p2) const {p2.setXYZ(x2,y2,0.);}
192  getPoint1(p1); getPoint2(p2);}
193 
194  // Use this function at the reading data only!!!
195  void resetEventIter(void); // for reading the same event again
196  Bool_t resetTrackPar(Float_t xt,Float_t yt,Float_t xp,Float_t yp);
197  Bool_t resetTrackFlag(Bool_t flag);
198  Bool_t resetEventFlag(Bool_t flag);
199  Bool_t isEnd(void) {return arrayEnd;}
200 
201  protected:
202  void clear();
203  Bool_t getTrackPar(void);
204 
205  ClassDef(HMdcStoreTracks,0) // storage of track parameters
206 };
207 
208 //----------------------------------------------
209 
211  protected:
212  HMdcStoreEvents wires; // storage of cluster(track) wires
213 
214  UInt_t* wiresListPack[1200]; // list of packed wires for current cluster
215  Int_t numWires;
216  public:
219  virtual UInt_t getMemSize(void) const;
220 
221  // Storing functions:
222  void setEndCluster(void);
223 
224  // Getting functions:
225  virtual void resetIter(void); // must be called ones per clusters loop
226  Bool_t getNextCluster(void);
227  Bool_t getNextCell(Int_t& s, Int_t& m, Int_t& l, Int_t& c, Float_t& tm) {
228  return wires.getNextCell(s,m,l,c,tm);}
229  Bool_t getNextCell(Int_t& s, Int_t& m, Int_t& l, Int_t& c, Float_t& tm,
230  Bool_t& flag) {
231  return wires.getNextCell(s,m,l,c,tm,flag);}
232 
233  // Storing and getting clusters:
234  void addClustWires(const HMdcEvntListCells& event,
235  const HMdcClus* cl); // store wires list only
236  void addClustWires(const HMdcEvntListCells& event,
237  const HMdcClus* cl1, const HMdcClus* cl2); // store wires list only
238  Bool_t getNextCluster(HMdcEvntListCells& event,Bool_t checkFlag=kFALSE);
239  Bool_t unsetFlag(Int_t si,Int_t mi,Int_t li,Int_t ci);
240  Bool_t setFlag(Int_t si,Int_t mi,Int_t li,Int_t ci);
241 
242  protected:
243 
244  ClassDef(HMdcStoreClusters,0) // storage of track param. and wires
245 };
246 
247 #endif /*!HMDCSTOREEVENTS_H*/
static void unpackAddress(UShort_t &addr, Int_t &s, Int_t &m, Int_t &l, Int_t &c)
virtual void resetIter(void)
Bool_t nextTrack(void)
virtual UInt_t getMemSize(void) const
void getPoint1(HGeomVector &p1) const
Bool_t isEnd(void)
HMdcStoreWires(void)
virtual UInt_t getMemSize(void) const
Bool_t resetEventFlag(Bool_t flag)
UChar_t getSector(void)
void setMaxMemSize(UInt_t mSize)
void setTrackPar(UChar_t s, UChar_t m1, Float_t xf, Float_t yf, UChar_t m2, Float_t xl, Float_t yl, UChar_t flag=1)
static Bool_t unpackCell(UInt_t &addr, Int_t &s, Int_t &m, Int_t &l, Int_t &c, Float_t &tm)
Bool_t resetTrackPar(Float_t xt, Float_t yt, Float_t xp, Float_t yp)
Bool_t setEndTrack(void)
UChar_t getMod1(void)
static void unsetFlag(UInt_t &addr)
Bool_t getNextWireAddr(Int_t &s, Int_t &m, Int_t &l, Int_t &c)
Float_t getZ1(void) const
static UInt_t packCell(Int_t s, Int_t m, Int_t l, Int_t c, Float_t tm, Bool_t flag=kTRUE)
HSeqArrIter * iterTrackPos
Bool_t getNextEvent(void)
UInt_t * wiresListPack[1200]
TGraph p2(xdim, pgrid, respme)
Int_t m2
Definition: drawAccCuts.C:11
void setEndEvent(Bool_t flag=kTRUE)
Int_t m1
Definition: drawAccCuts.C:11
void setMaxMemSize(UInt_t mSize)
void resetEventIter(void)
virtual void resetIter(void)
Bool_t getNextCell(Int_t &s, Int_t &m, Int_t &l, Int_t &c, Float_t &tm, Bool_t &flag)
UChar_t getMod2(void)
virtual void resetIter(void)
HSeqArrIter * iterAddress
Float_t getX2(void) const
void setEndCluster(void)
void setXYZ(const Double_t xx, const Double_t yy, const Double_t zz)
Definition: hgeomvector.h:25
HSeqArrIter * iterWires
UShort_t nRdDrTimes
Bool_t nextEvent(void)
Bool_t setFlag(Int_t si, Int_t mi, Int_t li, Int_t ci)
Bool_t getEventFlag(void)
HSeqArrIter * iterEvents
void addWireAddr(Int_t s, Int_t m, Int_t l, Int_t c)
void setEndEvent(void)
Bool_t getNextEvent(void)
Bool_t getNextCluster(void)
Bool_t testMemSize(void) const
Float_t getY2(void) const
virtual UInt_t getMemSize(void) const
Bool_t resetTrackFlag(Bool_t flag)
Float_t getX1(void) const
Bool_t unsetFlag(Int_t si, Int_t mi, Int_t li, Int_t ci)
static UShort_t packAddress(Int_t s, Int_t m, Int_t l, Int_t c)
TGraph p1(xdim, pgrid, resplo)
Float_t getZ2(void) const
virtual void resetIter(void)
Bool_t getNextCell(Int_t &s, Int_t &m, Int_t &l, Int_t &c, Float_t &tm)
HSeqArrIter * iterEvents
virtual UInt_t getMemSize(void) const
void addEvent(const HMdcEvntListCells &event)
Bool_t getTrackFlag(void)
void getPoints(HGeomVector &p1, HGeomVector &p2) const
Bool_t getTrackPar(void)
void addEvent(const HMdcEvntListCells &event)
void addWire(Int_t s, Int_t m, Int_t l, Int_t c, Float_t tm, Bool_t flag=kTRUE)
Float_t getY1(void) const
UShort_t nDrTmPerEv
Bool_t getNextCell(Int_t &s, Int_t &m, Int_t &l, Int_t &c, Float_t &tm)
HMdcStoreEvents wires
void setEndEvent(void)
void addClustWires(const HMdcEvntListCells &event, const HMdcClus *cl)
HSeqArrIter * iterWires
Int_t getNumEventTracks(void) const
void getPoint2(HGeomVector &p2) const
Bool_t testMemSize(void) const
HSeqArrIter * iterNTrckEv
static void setFlag(UInt_t &addr)