StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEventHelper.h
1 // Author: Victor Perev 08/04/01
2 #ifndef ROOT_StEventHelper
3 #define ROOT_StEventHelper
4 
5 
7 // //
8 // StEventHelper //
9 // //
10 // //
12 
13 #include "TNamed.h"
14 #include "TString.h"
15 #include "Gtypes.h"
16 #include "TPoints3DABC.h"
17 #include "StThreeVectorF.hh"
18 #include "StMCTruth.h"
19 #include "StHelixD.hh"
20 #include "StPhysicalHelixD.hh"
21 #include "StPhysicalHelixD.hh"
22 #include "StHelixHelper.h"
23 #include "StEnumerations.h"
24 #include <cassert>
25 
26 class StEvent;
27 class StTrack;
28 class StGlobalTrack;
29 class StHit;
30 class StVertex;
31 class StarClassLibrary;
32 class TExMap;
33 class TObjArray;
34 class StRefArray;
35 class StPtrVecHit;
36 class BetheBloch;
37 class THelixTrack;
38 
39 
40 //................................................................................
41 class StVertexHelper: public TObject
42 {
43 public:
44  StVertexHelper(const StVertex *vtx=0);
45  StVertexHelper(const StEvent *evt);
46  ~StVertexHelper(){};
47  void SetVertex(const StVertex *vtx);
48  int IsValid(){ return fVtx!=0;}
49  int GetType();
50  int GetFlag();
51 const float *GetErrMtx();
52 const StThreeVectorF &GetPoint();
53 
54  int GetNTracks(); //excluding parent
55 const StTrack *GetTrack(int idx); // -1=parent track
56 const StTrack *GetParent() {return GetTrack(-1);}
57 private:
58 const StVertex *fVtx;
59 float fErrMtx[6];
60 ClassDef(StVertexHelper,0)
61 };
62 
63 //................................................................................
65 {
66 public:
67  StTrackHelper(const StTrack *trk=0);
68  StTrackHelper(const StGlobalTrack *trk);
69  ~StTrackHelper();
70  int GetType() const;
71  int GetFlag() const;
72  int GetCharge() const;
73 const StVertex *GetParent() const;
74  float GetImpact() const;
75  float GetCurv() const;
76  int numberOfFitPoints(int detid=0) const;
77 const StThreeVectorF &GetFirstPoint() const;
78 const StThreeVectorF &GetLastPoint() const;
79 const StThreeVectorF &GetMom() const;
80  float GetPsi() const {return GetMom().phi();}
81  float GetDip() const {return atan2(GetMom().z(),GetMom().perp());}
82 
83  int GetNHits() const;
84 const StHit *GetHit(int idx) const;
85 const StPtrVecHit *GetHits() const;
86 StMCTruth GetTruth(int byCount=0,double rXYMin=0.,double rXYMax=1000.) const;
87 
88 
89 private:
90 const StTrack *fTrk;
91 mutable const StPtrVecHit *fHits;
92 ClassDef(StTrackHelper,0)
93 };
94 
95 //................................................................................
96 class StHitHelper: public TObject
97 {
98 public:
99  StHitHelper(const StHit *hit=0);
100  void SetHit(const StHit *hit);
101  int GetDetId();
102  int GetFlag();
103  float GetCharge();
104  int IsUsed();
105  int IsFit();
106 const StThreeVectorF &GetPoint();
107 
108 private:
109 const StHit *fHit;
110 ClassDef(StHitHelper,0)
111 };
112 
113 
114 //................................................................................
115 class TExMap;
116 class TArrayI;
117 class StErrorHelper: public TObject
118 {
119 public:
120  StErrorHelper();
121  ~StErrorHelper();
122  void Add(int errn);
123  void Print(const char* option="") const;
124  int GetNTot() {return fNTot;}
125  int GetNErr() {return fNErr ;}
126 static TString Say(int errn,const char *klas="StTrack");
127 
128 private:
129  void MakeArray();
130 private:
131 
132 int fNTot;
133 int fNErr;
134 int fKErr;
135 TExMap *fMap;
136 TArrayI *fArr;
137 ClassDef(StErrorHelper,0)
138 };
139 
140 
141 
142 
143 
144 //................................................................................
145 enum EHKind {kUDF = 0
146  ,kVTX = BIT( 1),kTRK = BIT( 2),kHIT = BIT( 3),kHRR = BIT( 4)//StEvent types
147  ,kPRM = BIT( 5),kKNK = BIT( 6),kV0 = BIT( 7),kXI = BIT( 8)//Vertex types
148  ,kTGB = BIT(10),kTPR = BIT(11),kTPT = BIT(12),kTSY = BIT(13)//Track types
149  ,kEGB = BIT(14),kEPR = BIT(15) //Track types
150  ,kUSE = BIT(20),kUNU = BIT(21),kFIT = BIT(22),kTHT = BIT(23)//Hit types
151  ,kTRR = BIT(30)}; //TObjArray
152 
153 //#ifndef ..EVENTHELPER_ONLY..
154 extern const char *EHKindN[];
155 extern const int EHKindS[];
156 //#endif
157 #ifdef __EVENTHELPER_ONLY__
158 const char *EHKindN[] = {"undefined"
159  ,"Vertex" ,"Tracks" ,"Hits" ,"HitArr"
160  ,"Primary" ,"Kink" ,"V0" ,"Xi"
161  ,"Global" ,"PRIMARY" ,"Tpt" ,"SECONDARY"
162  ,"estGlobal","estPrimary"
163  ,"Used" ,"Unused" ,"Fitted","Track Hits"
164  ,"TObjArray",0};
165 const int EHKindS[]= {kUDF
166  ,kVTX,kTRK,kHIT,kHRR
167  ,kPRM,kKNK,kV0 ,kXI
168  ,kTGB,kTPR,kTPT,kTSY
169  ,kEGB,kEPR
170  ,kUSE,kUNU,kFIT,kTHT
171  ,kTRR,-1};
172 #endif
173 
174 
175 //................................................................................
176 class StEventHelper : public TNamed{
177 
178 protected:
179 TObject *fObject;
180 TExMap *fMap;
181 
182 public:
183  StEventHelper(const TObject *evt=0,const char *opt="");
184  virtual ~StEventHelper();
185  TObjArray *SelConts (const char *sel=".*");
186  TObjArray *SelTracks(const char *sel=0, Int_t th=0);
187  TObjArray *SelHits (const char *RegEx, Int_t un=0,Int_t flag=0);
188  TObjArray *SelVertex(const char *sel, Int_t th=0);
189  TObjArray *ExpandAndFilter(const TObject *evobjs,int flag,TObjArray *out=0);
190  TObjArray *MakePoints ( TObjArray *evobjs,int flag);
191  virtual void ls(Option_t* option="") const;
192  virtual void Clear(Option_t *opt="");
193  void Reset(const TObject *evt=0,const char *opt="");
194 static int Kind(const TObject *to);
195 static void Remove(StEvent *ev,const char *className);
196 static void Break(int kase);
197 private:
198 
199 ClassDef(StEventHelper,0)
200 };
201 //................................................................................
202 class StPoints3DABC : public TPoints3DABC
203 {
204 public:
205  StPoints3DABC(const char *name="",const char *title="",const TObject *obj=0)
206  { fSize=0; fXYZ=0;
207  char buf[200];
208  if (obj && (!name || !name[0])) {
209  sprintf(buf,"%s(%p)",obj->GetName(),(void*)obj);name = buf;}
210  fName=name;fTitle=title;fObj = obj;}
211 
212  ~StPoints3DABC(){delete [] fXYZ;};
213 
214  virtual const char *GetName () const {return fName.Data();}
215  virtual const char *GetTitle() const {return fTitle.Data();}
216  virtual Float_t GetX(Int_t idx) const {return fXYZ[idx*3+0];}
217  virtual Float_t GetY(Int_t idx) const {return fXYZ[idx*3+1];}
218  virtual Float_t GetZ(Int_t idx) const {return fXYZ[idx*3+2];}
219  virtual Int_t Size() const {return fSize;}
220  virtual Int_t Kind() const {return 0;}
221  virtual const TObject *GetObject() const {return fObj;}
222  void Add(StPoints3DABC *add);
223  Int_t Add(float x, float y, float z){return TPoints3DABC::Add(x,y,z);} //WarnOff
224 // Dummies
225  virtual Int_t DistancetoPrimitive(Int_t/* px */, Int_t /* py */){return -1;}
226  virtual Int_t GetLastPosition() const {return 0;}
227  virtual Option_t* GetOption() const{return 0;}
228  virtual const Float_t* GetXYZ(Int_t idx) {return fXYZ+3*idx;}
229  virtual Float_t *GetXYZ(Float_t *xyz,Int_t idx,Int_t num=1) const
230  {return TPoints3DABC::GetXYZ(xyz,idx,num);}
231  virtual void PaintPoints(Int_t /* n */, Float_t* /* p */, Option_t* /* option */){}
232  virtual Int_t SetLastPosition(Int_t /* idx */){return 0;}
233  virtual Int_t SetNextPoint(Float_t /* x */, Float_t /* y */, Float_t /* z */){return 0;}
234  virtual void SetOption(Option_t* /* option */){}
235  virtual Int_t SetPoints(Int_t , Float_t * /* = 0 */, const Option_t * /* = "" */){return 0;}
236  virtual Int_t SetPoint(Int_t /* POINT */, Float_t /* x */, Float_t /* y */, Float_t /* z */){return 0;}
237 private:
238  void Init() const;
239 
240 // data members
241 protected:
242  TString fName;
243  TString fTitle;
244  Int_t fSize;
245  Int_t fN;
246  Float_t *fXYZ;
247  const TObject *fObj;
248  ClassDef(StPoints3DABC,0)
249 };
250 
251 
252 //................................................................................
254 {
255 public:
256  StTrackPoints(const StTrack *st,const char *name="",const char *title="");
257  ~StTrackPoints(){};
258 virtual Int_t Kind() const {return 2;}
259 virtual Int_t DistancetoPrimitive(Int_t px, Int_t py);
260 
261 private:
262  void Init() ;
263  StTrackPoints (const StTrackPoints &);
264  void operator=(const StTrackPoints &);
265 
266 // data members
267 private:
268  ClassDef(StTrackPoints,0)
269 };
270 
271 //................................................................................
273 {
274 public:
275  StVertexPoints(const StVertex *sv,const char *name="",const char *title="");
276  ~StVertexPoints(){};
277 virtual Int_t Kind() const {return 1;}
278 private:
280  void operator=(const StVertexPoints&);
281 // data members
282 private:
283  ClassDef(StVertexPoints,0)
284 };
285 //................................................................................
287 {
288 public:
289  StInnOutPoints(const StTrack *sv,int inout,const char *name="",const char *title="");
290  ~StInnOutPoints(){};
291 virtual Int_t Kind() const {return 4+fInnOut;}
292 private:
294  void operator=(const StInnOutPoints&);
295 // data members
296 private:
297  int fInnOut;
298  ClassDef(StInnOutPoints,0)
299 };
300 
301 
302 //..............................................................................
303 class StHitPoints : public StPoints3DABC
304 {
305 public:
306  StHitPoints(const StHit *sh,const char *name="",const char *title="");
307  StHitPoints(const StRefArray *arr,const char *name="",const char *title="");
308  ~StHitPoints(){};
309 virtual Int_t Kind() const {return 3;}
310 private:
311  void Init() ;
312 
313 // data members
314 private:
315  ClassDef(StHitPoints,0)
316 };
317 
318 //..............................................................................
319 class StFilterABC : public TNamed { //base class for StEvent filters
320 public:
321  StFilterABC(const char *name,bool active=true);
322  ~StFilterABC(){};
323 
324  virtual float *GetPars() const = 0;
325  virtual const float *GetDefs() const = 0;
326  virtual const char **GetNams() const = 0;
327  bool *GetActive() { return &fActive;}
328  void SetDefs();
329  bool Active() const {return fActive;}
330  void SetActive(bool active){fActive = active;}
331  virtual Int_t Accept(StPoints3DABC *pnt, Color_t&, Size_t&, Style_t&)=0;
332 protected:
333  bool fActive;// the flag whether the filter is "on"
334 
335 private:
336  static int fgDial;
337  ClassDef(StFilterABC,0)
338 };
339 //..............................................................................
340 
341 class StFilterDef : public StFilterABC { // An example of default filter
342 public:
343  StFilterDef(const char *name,bool active=true);
344  ~StFilterDef(){};
345 virtual float *GetPars() const {return (float*)(&fFirst+1);}
346 virtual const float *GetDefs() const;
347 virtual const char **GetNams() const;
348  Int_t Accept(StPoints3DABC *pnt, Color_t&, Size_t&, Style_t&);
349 
350 protected:
351 
352 private:
353  float fFirst;
354  float fRandomSelect;
355  float fRxyMin ;
356  float fRxyMax ;
357  float fZMin ;
358  float fZMax ;
359  float fPhiMin ;
360  float fPhiMax ;
361  float fLenMin ;
362  float fLenMax ;
363  float fPtMin ;
364  float fPtMax ;
365  float fPsMin ;
366  float fPsMax ;
367  float fQMin ;
368  float fQMax ;
369  float fEncodedMethod; // encoding method
370  float fLast;
371 
372 ClassDef(StFilterDef,0)
373 };
374 //..............................................................................
375 
376 class StMuDstFilterHelper : public StFilterABC { // An example of default filter
377 public:
378  StMuDstFilterHelper(const char *name,bool active=true);
380 virtual float *GetPars() const {return (float*)(&fFirst+1);}
381 virtual const float *GetDefs() const;
382 virtual const char **GetNams() const;
383  Int_t Accept(StPoints3DABC *pnt, Color_t&, Size_t&, Style_t&)
384  { return Accept(pnt); }
385 
386 protected:
387  Int_t Accept(const StTrack *track); // proxy for /StMuDSTMaker/COMMON/StMStMuL3Filter
388  Int_t Accept(StPoints3DABC *pnt);
389 
390 protected:
391  BetheBloch* mBB;
392 
393 private:
394  float fFirst; // do not touch this data member
395 
396  // --
397  // This filter custom data members go here:
398  // --
399  float fpCutHigh; // high momentum cut for RICH/Upsilon candidates
400  float fnHitsCutHighP; // nHits cut for all tracks
401 
402  // following cuts apply only for tracks with pCutLow < p <pHigh
403  float fpCutLow; // low momentum cut
404  float fnHitsCutLowP;
405  float fchargeForLowP; // charge for tracks with pCutLow < p < pCutHigh, set to 0 for all tracks
406  float fdEdxMassCutHigh; // cut below BetheBloch(p/dEdxMassCutHigh), e.g. proton-band
407  float fdEdxFractionCutHigh; // cut fraction of dEdx-band, i.e. dEdxFractionCut * BetheBloch(p/dEdxMassCut)
408  float fdEdxMassCutLow; // cut above BetheBloch(p/dEdxMassCutLow), e.g. kaon-band
409  float fdEdxFractionCutLow;
410  // -- the last custom data-member --
411 
412  float fLast; // do not touch this data member
413 
414  ClassDef(StMuDstFilterHelper,0)
415 };
416 
417 //..............................................................................
418  class StTpcDedxPidAlgorithm;
419  class StElectron;
420  class StPionPlus;
421  class StKaonPlus;
422  class StProton;
423 
424 
425 class StColorFilterHelper : public StFilterABC { // An example of default coloring filter
426 public:
427  StColorFilterHelper(const char *name,bool active=true);
429 virtual float *GetPars() const {return (float*)(&fFirst+1);}
430 virtual const float *GetDefs() const;
431 virtual const char **GetNams() const;
432 
433 protected:
434  virtual Int_t Accept(StPoints3DABC *pnt, Color_t&, Size_t&, Style_t&);
435  Int_t Accept(const StTrack *track, Color_t&, Size_t&, Style_t&);
436  Int_t Accept(StPoints3DABC */* pnt */){return 1;}
437 
438 protected:
439  StTpcDedxPidAlgorithm *fPidAlgorithm;
440  StElectron *fElectron;
441  StPionPlus *fPion;
442  StKaonPlus *fKaon;
443  StProton *fProton;
444 
445 private:
446  float fFirst; // do not touch this data member
447 
448  // --
449  // This filter custom data members go here:
450  // --
451  float fNSigmaElectron ; // nSigna cut for electron
452  float fNColorElectron ; // the color index for electron
453  float fNSigmaPion ; // nSigna cut for electron
454  float fNColorPion ; // the color index for pion
455  float fNSigmaKaon ; // nSigna cut for pion
456  float fNColorKaon ; // the color index for kaon
457  float fNSigmaProton ; // nSigna cut for kaon
458  float fNColorProton ; // the color index kaon
459 
460  float fNSigmaOther ; // nSigna cut for other types
461  float fNColorOther ; // the color index for other types
462 
463  // -- the last custom data-member --
464 
465  float fLast; // do not touch this data member
466 
467  ClassDef(StColorFilterHelper,0)
468 };
469 
470 
471 
472 
473 
474 #endif //ROOT_StEventHelper
Definition: StHit.h:125
const float * GetErrMtx()