HYDRA_development_version
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
hparticletracksorter.h
Go to the documentation of this file.
1 //*-- Author : Jochen Markert 18.07.2007
2 
3 #ifndef __HPARTICLETRACKSORTER_H__
4 #define __HPARTICLETRACKSORTER_H__
5 
6 #include "hcategory.h"
7 #include "hiterator.h"
8 #include "hrecevent.h"
9 #include "hparticledef.h"
10 
11 #include <vector>
12 #include "TString.h"
13 #include "TFile.h"
14 #include "TNtuple.h"
15 
16 
17 using std::vector;
18 using std::iostream;
19 
20 # define SORTER_NUMBER_OF_INDEX 7
21 # define SORTER_NUMBER_OF_QUALITY_CRITERIA 7
22 
23 class HParticleCand;
24 
25 
26 
27 typedef struct {
29  Short_t ind_Cand;
30  Short_t ind_RICH ;
31  Short_t ind_innerMDC;
32  Short_t ind_outerMDC;
33  Short_t ind_TOF;
34  Short_t ind_SHOWER;
35  Short_t ind_RPC;
36  Short_t selectedMeta;
37  Int_t nPadsRich;
38  Short_t sec;
39  Short_t MetaModule;
40  Short_t MetaCell;
41  Float_t mom;
42  Float_t beta;
43  Float_t MDC_dEdx;
44  Float_t innerMDCChi2;
45  Float_t outerMDCChi2;
50  Float_t RK_META_dx;
51  Float_t RK_META_dy;
54  Float_t RK_Chi2;
55  Bool_t RICH_RK_Corr;
56  Int_t userSort1;
57  Int_t userSort2;
58  Int_t userSort3;
59  Float_t innerMDCTheta;
60  Float_t innerMDCPhi;
61  Float_t outerMDCTheta;
62  Float_t outerMDCPhi;
64 
65 class sorter_setup : public TObject {
66 
67 public:
68 
70  Float_t fRICHMDCWindow ;
71  Bool_t kIsFieldOn ;
72  Bool_t kIgnoreRICH ;
73  Bool_t kIgnoreInnerMDC ;
74  Bool_t kIgnoreOuterMDC ;
75  Bool_t kIgnoreMETA ;
78  Bool_t kUseYMatching ;
80  Float_t fMetaBoundary ;
81  Bool_t kUseBeta ;
82  Float_t fBetaLepCut ;
84  Bool_t kUseMETAQA ;
85  Float_t fMETAQACut ;
86  Float_t fTOFMAXCut ;
87  Float_t fDeltaSegCut ;
88 
89  void setDefault(){
90 
91  kSwitchRICHMatching = Particle::kUseRKRICHWindowSorter;
92  fRICHMDCWindow = 4.;
93  kIsFieldOn = kTRUE;
94  kIgnoreRICH = kFALSE;
95  kIgnoreInnerMDC = kFALSE;
96  kIgnoreOuterMDC = kFALSE;
97  kIgnoreMETA = kFALSE;
98  kIgnorePreviousIndex = kFALSE;
99  pUserSort = NULL;
100  kUseYMatching = kTRUE;
101  kUseYMatchingScaling = kTRUE;
102  fMetaBoundary = 4.0;
103  kUseBeta = kTRUE;
104  fBetaLepCut = 0.9;
105  kUseFakeRejection = kTRUE;
106  kUseMETAQA = kTRUE;
107  fMETAQACut = 3.0;
108  fTOFMAXCut = 60.0;
109  fDeltaSegCut = 2.0;
110  } ;
111 
112  void copyFromStatic();
113  void copyToStatic();
114 
116 
117  kSwitchRICHMatching = s.kSwitchRICHMatching;
118  fRICHMDCWindow = s.fRICHMDCWindow;
119  kIsFieldOn = s.kIsFieldOn;
120  kIgnoreRICH = s.kIgnoreRICH;
121  kIgnoreInnerMDC = s.kIgnoreInnerMDC;
122  kIgnoreOuterMDC = s.kIgnoreOuterMDC;
123  kIgnoreMETA = s.kIgnoreMETA;
124  kIgnorePreviousIndex = s.kIgnorePreviousIndex;
125  pUserSort = s.pUserSort;
126  kUseYMatching = s.kUseYMatching;
127  kUseYMatchingScaling = s.kUseYMatchingScaling;
128  fMetaBoundary = s.fMetaBoundary;
129  kUseBeta = s.kUseBeta;
130  fBetaLepCut = s.fBetaLepCut;
131  kUseFakeRejection = s.kUseFakeRejection;
132  kUseMETAQA = s.kUseMETAQA;
133  fMETAQACut = s.fMETAQACut;
134  fTOFMAXCut = s.fTOFMAXCut;
135  fDeltaSegCut = s.fDeltaSegCut;
136  };
137 
139 
148  d.pUserSort = pUserSort;
152  d.kUseBeta = kUseBeta;
159  };
160 
161  void print(){
162 
163  cout<<"--------------------------------------------------------------------"<<endl;
164  cout<<"sorter_setup:"<<endl;
165  cout<<"kSwitchRICHMatching "<<kSwitchRICHMatching <<endl;
166  cout<<"fRICHMDCWindow "<<fRICHMDCWindow <<endl;
167  cout<<"kIsFieldOn "<<kIsFieldOn <<endl;
168  cout<<"kIgnoreRICH "<<kIgnoreRICH <<endl;
169  cout<<"kIgnoreInnerMDC "<<kIgnoreInnerMDC <<endl;
170  cout<<"kIgnoreOuterMDCB "<<kIgnoreOuterMDC <<endl;
171  cout<<"kIgnoreMETA "<<kIgnoreMETA <<endl;
172  cout<<"kIgnorePreviousIndex "<<kIgnorePreviousIndex<<endl;
173  cout<<"pUserSort "<<pUserSort <<endl;
174  cout<<"kUseYMatching "<<kUseYMatching <<endl;
175  cout<<"kUseYMatchingScaling "<<kUseYMatchingScaling<<endl;
176  cout<<"fMetaBoundary "<<fMetaBoundary <<endl;
177  cout<<"kUseBeta "<<kUseBeta <<endl;
178  cout<<"fBetaLepCut "<<fBetaLepCut <<endl;
179  cout<<"kUseFakeRejection "<<kUseFakeRejection <<endl;
180  cout<<"kUseMETAQA "<<kUseMETAQA <<endl;
181  cout<<"fMetaBoundary "<<fMetaBoundary <<endl;
182  cout<<"fMETAQACut "<<fMETAQACut <<endl;
183  cout<<"fTOFMAXCut "<<fTOFMAXCut <<endl;
184  cout<<"fDeltaSegCut "<<fDeltaSegCut <<endl;
185  cout<<"--------------------------------------------------------------------"<<endl;
186 
187 
188 
189  }
190 
191  ClassDef(sorter_setup,0)
192 
193 };
194 
195 class HParticleTrackSorter : public TNamed {
196 
197 friend class sorter_setup;
198 
199 
200 public:
201 
202 
203 protected:
204 
205  sorter_setup setup; //! store copy of setup params local
206  sorter_setup setup_backup; //! store a copy of the static setup parameters local to restore them later
207 
208  static Bool_t kDebug; //!
209  static Int_t printLevel; //! higher -> more prints (1,2,3) (no setup)
210  static Int_t kSwitchIndex; //! switch to select sort by index (no setup)
211  static Int_t kSwitchQuality; //! switch to select sort by quality algorithms (no setup)
212  static Int_t kSwitchParticle; //! switch to select leptons/hadrons (no setup)
213 
214 
215  static Int_t kSwitchRICHMatching; //! switch to select RICH/MDC matching in lepton selection
216  static Float_t fRICHMDCWindow ; //! matching window RICH/MDC in phi/theta (symmetric, degree)
217  static Bool_t kIsFieldOn; //! switch selections accoording B-Field
218  static Bool_t kIgnoreRICH; //! switch to ignore RICH hits for Double_t hit counting
219  static Bool_t kIgnoreInnerMDC; //! switch to ignore InnerMDC hits for Double_t hit counting
220  static Bool_t kIgnoreOuterMDC; //! switch to ignore OuterMDC hits for Double_t hit counting
221  static Bool_t kIgnoreMETA; //! switch to ignore META hits for Double_t hit counting
222  static Bool_t kIgnorePreviousIndex; //! switch to ignore indices from previoius marked ued objects
223  static Bool_t kUseYMatching; //! switch to use Y matching to meta cell (default kTRUE)
224  static Bool_t kUseYMatchingScaling; //! switch to use 1/p scaling of Y matching to meta cell (default kTRUE)
225  static Bool_t kUseBeta; //! switch to use Beta (in lepton select use fBetaLepCut, in hadron beta>0) (default kTRUE)
226  static Bool_t kUseFakeRejection; //! switch to use fakerejection in build in select functions (default kTRUE)
227  static Bool_t kUseMETAQA; //! switch to use metaqa (normed dx) in build in select functions (default kTRUE)
228  static Float_t fMetaBoundary; //! matching window when using Y matching with metacell [mm] (default 3): fabs(dy) < (halfcell+metaBoundary)
229  static Float_t fBetaLepCut; //! lower beta cut for lepton selection (default 0.9)
230  static Float_t fMETAQACut; //! meta qa (normed dx) cut (default 3.)
231  static Float_t fTOFMAXCut; //! max tof [ns] allowed to match (when beta is used)
232  static Float_t fDeltaSegCut; //! max delta in phi,theta [deg] between inner/outer seg used in B-Field off
233 
234 
235  Int_t fill_Iteration; //! remember the number of fill() calls
236  Int_t selectBest_Iteration; //! remember the number of selectBest() calls
237  UInt_t currentEvent; //! find new event
238 
239  vector < candidateSort *> all_candidates; //!
240 
241  vector < Int_t > index_RICH; //!
242  vector < Int_t > index_InnerMDC; //!
243  vector < Int_t > index_OuterMDC; //!
244  vector < Int_t > index_SHOWER; //!
245  vector < Int_t > index_TOFHit; //!
246  vector < Int_t > index_TOFClst; //!
247  vector < Int_t > index_RPC; //!
248  vector < Int_t > old_flags; //! remember the old flags of HParticleCand for restoring
249  vector < Int_t > old_flags_emc; //! remember the old flags of HEmcCluster for restoring
250 
251  TString* nameIndex ; //!
252  TString* nameQuality; //!
253 
254  Bool_t isSimulation; //!
255  TFile* fout; //!
256  TNtuple* nt; //!
257  HCategory* pParticleCandCat; //! HParticleCand category
258  HCategory* pEmcClusterCat; //! HEmcCluster category
259  HIterator* iterParticleCandCat; //! iterator on HParticleCand
260  HRecEvent* fEvent; //! pointer to local event under reconstruction
261 
262 
263  static Bool_t (*pUserSort)(candidateSort*, candidateSort*); //! user provided function pointer to sort algo
264 
265  void printCand (candidateSort*, Int_t, TString spacer = " ");
266  static Bool_t cmpIndex (candidateSort*, candidateSort*);
267  static Bool_t cmpQuality(candidateSort*, candidateSort*);
268  Bool_t rejectIndex (candidateSort*, Particle::ESwitch, Int_t&);
270  Int_t flagAccepted (vector<candidateSort*>&, Particle::ESwitch);
271  Int_t flagDouble (vector<candidateSort*>&, Particle::ESwitch);
272  Int_t setFlagsDouble (vector<candidateSort*>&, Particle::ESwitch);
273  Int_t clearVector (vector<candidateSort*>&);
274  Int_t fillInput (vector<candidateSort*>&);
275  void selection(Bool_t (*function)(HParticleCand* ));
276  Int_t fillAndSetFlags ();
277  Bool_t flagEmcClusters();
278  static Bool_t isDeltaSegOk(HParticleCand*);
279 
280  void clear(void);
281 public:
282  HParticleTrackSorter(void);
283  HParticleTrackSorter(TString name,TString title);
284  ~HParticleTrackSorter(void);
285  Bool_t init (HRecEvent* evt=0);
286  Bool_t finalize (void);
287  // setup selections
288  static void setDebug (Bool_t debug = kTRUE) { kDebug = debug;}
289  static void setPrintLevel (Int_t level) { printLevel = level;}
290 
291  void setIsFieldOn (Bool_t field = kTRUE) { kIsFieldOn = field; setup.kIsFieldOn = field;}
292  void setIgnoreRICH (Bool_t ignore = kTRUE) { kIgnoreRICH = ignore;setup.kIgnoreRICH = ignore;}
293  void setIgnoreInnerMDC (Bool_t ignore = kTRUE) { kIgnoreInnerMDC = ignore;setup.kIgnoreInnerMDC = ignore;}
294  void setIgnoreOuterMDC (Bool_t ignore = kTRUE) { kIgnoreOuterMDC = ignore;setup.kIgnoreOuterMDC = ignore;}
295  void setIgnoreMETA (Bool_t ignore = kTRUE) { kIgnoreMETA = ignore;setup.kIgnoreMETA = ignore;}
296  void setIgnorePreviousIndex(Bool_t ignore = kTRUE) { kIgnorePreviousIndex = ignore;setup.kIgnorePreviousIndex = ignore;}
297  void setUseYMatching (Bool_t use = kTRUE) { kUseYMatching = use ;setup.kUseYMatching = use ;}
298  void setUseYMatchingScaling(Bool_t use = kTRUE) { kUseYMatchingScaling = use ;setup.kUseYMatchingScaling = use ;}
299  void setUseBeta (Bool_t use = kTRUE) { kUseBeta = use ;setup.kUseBeta = use ;}
300  void setUseFakeRejection (Bool_t use = kTRUE) { kUseFakeRejection = use ;setup.kUseFakeRejection = use ;}
301  void setUseMETAQA (Bool_t use = kTRUE) { kUseMETAQA = use ;setup.kUseMETAQA = use ;}
302  void setUserSort(Bool_t (*function)(candidateSort*, candidateSort*)){ pUserSort = function;setup.pUserSort = function;}
303  void setRICHMatching (Particle::ERichMatch match, Float_t window = 4.);
304  void setMetaBoundary (Float_t savety = 3.5) { fMetaBoundary = savety;setup.fMetaBoundary = savety;}
305  void setBetaLeptonCut (Float_t cut = .9) { fBetaLepCut = cut; setup.fBetaLepCut = cut;}
306  void setMETAQACut (Float_t cut = 3.) { fMETAQACut = cut; setup.fMETAQACut = cut;}
307  void setTOFMAXCut (Float_t cut = 60.) { fTOFMAXCut = cut; setup.fTOFMAXCut = cut;}
308  void setDeltaSegCut (Float_t cut = 2.) { fDeltaSegCut = cut; setup.fDeltaSegCut = cut;}
309 
310  Float_t getMetaBoundary() {return fMetaBoundary;}
311  Float_t getBetaLeptonCut() {return fBetaLepCut;}
312 
313  // control selections
314  void resetFlags(Bool_t flag = kTRUE,Bool_t reject = kTRUE,Bool_t used = kTRUE,Bool_t lepton = kTRUE);
315  void cleanUp(Bool_t final = kTRUE);
316  Int_t fill(Bool_t (*function)(HParticleCand* ));
317  void backupFlags(Bool_t onlyFlags=kTRUE);
318  Bool_t restoreFlags(Bool_t onlyFlags=kTRUE);
319  void backupSetup();
320  Bool_t restoreSetup();
322  Int_t selectBest(Particle::ESwitch byQuality, Int_t byParticle);
323  static Bool_t selectLeptons (HParticleCand* pcand = 0);
324  static Bool_t selectHadrons (HParticleCand* pcand = 0);
325  static Bool_t selectLeptonsNoOuterFit(HParticleCand* pcand = 0);
326  static Bool_t selectHadronsNoOuterFit(HParticleCand* pcand = 0);
327  vector < candidateSort *>& getCandidates() { return all_candidates;}
328  void printEvent(TString comment);
329  void printSetup();
331 };
332 #endif /* !__HPARTICLETRACKSORTER_H__ */
333 
334 
335 
336 
337 
338 
339 
void resetFlags(Bool_t flag=kTRUE, Bool_t reject=kTRUE, Bool_t used=kTRUE, Bool_t lepton=kTRUE)
void setMetaBoundary(Float_t savety=3.5)
static Int_t kSwitchParticle
switch to select sort by quality algorithms (no setup)
static void setPrintLevel(Int_t level)
void cleanUp(Bool_t final=kTRUE)
vector< Int_t > index_InnerMDC
static Bool_t(* pUserSort)(candidateSort *, candidateSort *)
pointer to local event under reconstruction
HRecEvent * fEvent
iterator on HParticleCand
void setIgnorePreviousIndex(Bool_t ignore=kTRUE)
void setIgnoreOuterMDC(Bool_t ignore=kTRUE)
static Bool_t kIgnoreInnerMDC
switch to ignore RICH hits for Double_t hit counting
static Float_t fMETAQACut
lower beta cut for lepton selection (default 0.9)
static Bool_t kIgnoreRICH
switch selections accoording B-Field
static Float_t fDeltaSegCut
max tof [ns] allowed to match (when beta is used)
static void setDebug(Bool_t debug=kTRUE)
static Bool_t kUseYMatchingScaling
switch to use Y matching to meta cell (default kTRUE)
Int_t selectBest_Iteration
remember the number of fill() calls
HIterator * iterParticleCandCat
HEmcCluster category.
vector< candidateSort * > & getCandidates()
Bool_t rejectQuality(candidateSort *, Particle::ESwitch)
Bool_t restoreFlags(Bool_t onlyFlags=kTRUE)
vector< Int_t > index_OuterMDC
Int_t flagDouble(vector< candidateSort * > &, Particle::ESwitch)
Float_t RK_META_match_Radius
vector< candidateSort * > all_candidates
find new event
void setBetaLeptonCut(Float_t cut=.9)
Int_t clearVector(vector< candidateSort * > &)
static Bool_t selectHadrons(HParticleCand *pcand=0)
static Int_t kSwitchIndex
higher -> more prints (1,2,3) (no setup)
static Int_t kSwitchRICHMatching
switch to select leptons/hadrons (no setup)
HCategory * pEmcClusterCat
HParticleCand category.
Int_t fill(Bool_t(*function)(HParticleCand *))
TString * nameIndex
remember the old flags of HEmcCluster for restoring
HParticleCand * cand
Int_t setFlagsDouble(vector< candidateSort * > &, Particle::ESwitch)
static Bool_t cmpIndex(candidateSort *, candidateSort *)
vector< Int_t > old_flags_emc
remember the old flags of HParticleCand for restoring
void printCand(candidateSort *, Int_t, TString spacer=" ")
user provided function pointer to sort algo
void printEvent(TString comment)
static Float_t fRICHMDCWindow
switch to select RICH/MDC matching in lepton selection
vector< Int_t > index_TOFHit
static Bool_t isDeltaSegOk(HParticleCand *)
void setTOFMAXCut(Float_t cut=60.)
static Bool_t kIgnoreOuterMDC
switch to ignore InnerMDC hits for Double_t hit counting
static Bool_t kUseBeta
switch to use 1/p scaling of Y matching to meta cell (default kTRUE)
void setUseYMatching(Bool_t use=kTRUE)
ClassDef(HParticleTrackSorter, 0)
Int_t fillInput(vector< candidateSort * > &)
vector< Int_t > index_TOFClst
Float_t RK_META_match_Quality
void setDeltaSegCut(Float_t cut=2.)
vector< Int_t > index_SHOWER
static Bool_t selectHadronsNoOuterFit(HParticleCand *pcand=0)
void setIgnoreRICH(Bool_t ignore=kTRUE)
void setUseBeta(Bool_t use=kTRUE)
void setUseYMatchingScaling(Bool_t use=kTRUE)
void selection(Bool_t(*function)(HParticleCand *))
void setIgnoreMETA(Bool_t ignore=kTRUE)
void setIgnoreInnerMDC(Bool_t ignore=kTRUE)
void copyFrom(sorter_setup &s)
void setRICHMatching(Particle::ERichMatch match, Float_t window=4.)
static Bool_t kIsFieldOn
matching window RICH/MDC in phi/theta (symmetric, degree)
void setIsFieldOn(Bool_t field=kTRUE)
static Float_t fMetaBoundary
switch to use metaqa (normed dx) in build in select functions (default kTRUE)
static Bool_t kUseFakeRejection
switch to use Beta (in lepton select use fBetaLepCut, in hadron beta>0) (default kTRUE) ...
static Float_t fBetaLepCut
matching window when using Y matching with metacell [mm] (default 3): fabs(dy) < (halfcell+metaBounda...
void setUseMETAQA(Bool_t use=kTRUE)
Float_t RK_META_match_Shr_Quality
static Bool_t kUseMETAQA
switch to use fakerejection in build in select functions (default kTRUE)
Int_t selectBest(Particle::ESwitch byQuality, Int_t byParticle)
void backupFlags(Bool_t onlyFlags=kTRUE)
static Int_t kSwitchQuality
switch to select sort by index (no setup)
void copyTo(sorter_setup &d)
void setUserSort(Bool_t(*function)(candidateSort *, candidateSort *))
UInt_t currentEvent
remember the number of selectBest() calls
static Bool_t cmpQuality(candidateSort *, candidateSort *)
Bool_t(* pUserSort)(candidateSort *, candidateSort *)
void setUseFakeRejection(Bool_t use=kTRUE)
Bool_t init(HRecEvent *evt=0)
Float_t RK_RICH_match_Quality
void setMETAQACut(Float_t cut=3.)
Bool_t rejectIndex(candidateSort *, Particle::ESwitch, Int_t &)
static Bool_t selectLeptons(HParticleCand *pcand=0)
static Bool_t kUseYMatching
switch to ignore indices from previoius marked ued objects
Int_t fill_Iteration
max delta in phi,theta [deg] between inner/outer seg used in B-Field off
static Bool_t kIgnoreMETA
switch to ignore OuterMDC hits for Double_t hit counting
static Bool_t selectLeptonsNoOuterFit(HParticleCand *pcand=0)
Int_t flagAccepted(vector< candidateSort * > &, Particle::ESwitch)
static Float_t fTOFMAXCut
meta qa (normed dx) cut (default 3.)
sorter_setup setup_backup
store copy of setup params local
static Bool_t kIgnorePreviousIndex
switch to ignore META hits for Double_t hit counting
static Bool_t kDebug
store a copy of the static setup parameters local to restore them later