CbmRoot
PairAnalysisPairLegCuts.cxx
Go to the documentation of this file.
1 // //
3 // //
4 // Authors:
5 // * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
6 // Julian Book <Julian.Book@cern.ch>
7 /*
8  Cut class providing cuts for both legs in the PairAnalysisPair
9  Add any number of leg cuts using e.g. for leg 1
10  GetFilterLeg1().AddCuts(mycut)
11  where mycut has to inherit from AnalysisCuts.
12 
13  the following cut types are defined and selected via SetCutType():
14  kBothLegs, kAnyLeg, kMixLegs, kOneLeg
15 
16 */
17 // //
19 
20 #include <TList.h>
21 
22 #include "PairAnalysisPairLV.h"
23 #include "PairAnalysisTrack.h"
24 
26 
28 
29 
31  : PairAnalysisPairLegCuts("pairlegcut", "pairlegcut") {
32  //
33  // Default contructor
34  //
35 }
36 
37 //________________________________________________________________________
39  const char* title)
40  : AnalysisCuts(name, title)
41  , fFilterLeg1("PairFilterLeg1", "PairFilterLeg1")
42  , fFilterLeg2("PairFilterLeg2", "PairFilterLeg2") {
43  //
44  // Named contructor
45  //
46 }
47 
48 
49 //________________________________________________________________________
50 Bool_t PairAnalysisPairLegCuts::IsSelected(TObject* track) {
51  //
52  // check if cuts are fulfilled
53  //
54 
55  //check if we have a PairAnalysisPair
56  PairAnalysisPair* pair = dynamic_cast<PairAnalysisPair*>(track);
57  if (!pair) return kFALSE;
58 
59  //get both legs
60  PairAnalysisTrack* leg1 = pair->GetFirstDaughter();
61  PairAnalysisTrack* leg2 = pair->GetSecondDaughter();
62 
63  //mask used to require that all cuts are fulfilled
64  UInt_t selectedMaskLeg1 = (1 << fFilterLeg1.GetCuts()->GetEntries()) - 1;
65  UInt_t selectedMaskLeg2 = (1 << fFilterLeg2.GetCuts()->GetEntries()) - 1;
66 
67  //test cuts
68  Bool_t isLeg1selected = (fFilterLeg1.IsSelected(leg1) == selectedMaskLeg1);
69  if (fCutType == kBothLegs && !isLeg1selected) {
70  SetSelected(isLeg1selected);
71  return isLeg1selected;
72  }
73  //skip further checks if first leg passes cuts and cuttype is any
74  if (fCutType == kAnyLeg && isLeg1selected) {
75  SetSelected(isLeg1selected);
76  return isLeg1selected;
77  }
78 
79  Bool_t isLeg2selected = (fFilterLeg2.IsSelected(leg2) == selectedMaskLeg2);
80  Bool_t isSelected = isLeg1selected && isLeg2selected;
81  if (fCutType == kAnyLeg) {
82  isSelected = isLeg1selected || isLeg2selected;
83  SetSelected(isSelected);
84  return isSelected;
85  }
86  if (fCutType == kOneLeg) {
87  isSelected = (isLeg1selected != isLeg2selected);
88  SetSelected(isSelected);
89  return isSelected;
90  }
91 
92  if (fCutType == kMixLegs) {
93  Bool_t isLeg1selectedMirror =
94  (fFilterLeg1.IsSelected(leg2) == selectedMaskLeg1);
95  Bool_t isLeg2selectedMirror =
96  (fFilterLeg2.IsSelected(leg1) == selectedMaskLeg2);
97  isSelected = (isLeg1selected && isLeg2selected)
98  || (isLeg1selectedMirror && isLeg2selectedMirror);
99  SetSelected(isSelected);
100  }
101  return isSelected;
102 }
103 
104 //________________________________________________________________________
105 void PairAnalysisPairLegCuts::Print(const Option_t* /*option*/) const {
106  //
107  // Print cuts and the range
108  //
109  printf("------------------------------------------\n");
110  printf("pair-leg cut ranges for '%s'\n", GetTitle());
111  switch (fCutType) {
112  case kBothLegs: printf("Both legs have to fulfill the cuts\n"); break;
113  case kAnyLeg: printf("Any leg have to fulfill the cuts\n"); break;
114  case kMixLegs:
115  printf(
116  "Leg1(leg2) has to fullfill the leg1(2)- or leg2(1)-cuts (mix mode)\n");
117  break;
118  case kOneLeg:
119  printf("Only one of legs is allowed to fulfill the cuts\n");
120  break;
121  }
122 
123  printf("Leg filter1: \n");
124  TIter listIterator(fFilterLeg1.GetCuts());
125  while (AnalysisCuts* thisCut = (AnalysisCuts*) listIterator()) {
126  thisCut->Print();
127  }
128 
129  printf("Leg filter2: \n");
130  TIter listIterator2(fFilterLeg2.GetCuts());
131  while (AnalysisCuts* thisCut = (AnalysisCuts*) listIterator2()) {
132  thisCut->Print();
133  }
134  printf("------------------------------------------\n");
135 }
PairAnalysisPair::GetFirstDaughter
PairAnalysisTrack * GetFirstDaughter() const
Definition: PairAnalysisPair.h:140
PairAnalysisPairLegCuts
Definition: PairAnalysisPairLegCuts.h:20
PairAnalysisPairLegCuts::IsSelected
virtual Bool_t IsSelected(TObject *track)
Definition: PairAnalysisPairLegCuts.cxx:50
PairAnalysisPairLegCuts::kOneLeg
@ kOneLeg
Definition: PairAnalysisPairLegCuts.h:22
PairAnalysisPairLegCuts::kBothLegs
@ kBothLegs
Definition: PairAnalysisPairLegCuts.h:22
PairAnalysisTrack
Definition: PairAnalysisTrack.h:37
PairAnalysisPair
Definition: PairAnalysisPair.h:25
PairAnalysisPairLegCuts::fCutType
CutType fCutType
Definition: PairAnalysisPairLegCuts.h:47
PairAnalysisPairLegCuts::fFilterLeg1
AnalysisFilter fFilterLeg1
Definition: PairAnalysisPairLegCuts.h:44
AnalysisCuts::SetSelected
virtual void SetSelected(Bool_t dec)
Definition: AnalysisCuts.h:25
PairAnalysisPairLV.h
AnalysisFilter::GetCuts
TList * GetCuts() const
Definition: AnalysisFilter.h:28
ClassImp
ClassImp(PairAnalysisPairLegCuts) PairAnalysisPairLegCuts
Definition: PairAnalysisPairLegCuts.cxx:27
AnalysisFilter::IsSelected
virtual UInt_t IsSelected(Double_t *const values)
Definition: AnalysisFilter.cxx:103
PairAnalysisTrack.h
PairAnalysisPairLegCuts::kAnyLeg
@ kAnyLeg
Definition: PairAnalysisPairLegCuts.h:22
PairAnalysisPairLegCuts.h
PairAnalysisPairLegCuts::Print
virtual void Print(const Option_t *option="") const
Definition: PairAnalysisPairLegCuts.cxx:105
PairAnalysisPairLegCuts::kMixLegs
@ kMixLegs
Definition: PairAnalysisPairLegCuts.h:22
PairAnalysisPairLegCuts::fFilterLeg2
AnalysisFilter fFilterLeg2
Definition: PairAnalysisPairLegCuts.h:45
AnalysisCuts
Definition: AnalysisCuts.h:12
PairAnalysisPair::GetSecondDaughter
PairAnalysisTrack * GetSecondDaughter() const
Definition: PairAnalysisPair.h:143
PairAnalysisPairLegCuts::PairAnalysisPairLegCuts
PairAnalysisPairLegCuts()