FairRoot/PandaRoot
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
PndAnaPidSelector Class Reference

#include <PndAnaPidSelector.h>

Inheritance diagram for PndAnaPidSelector:
RhoParticleSelectorBase

Public Member Functions

 PndAnaPidSelector (const char *name="PndAnaPidSelector", const char *type="", const char *paramid="Default")
 
virtual ~PndAnaPidSelector ()
 
virtual Bool_t Accept (RhoCandidate *b)
 
virtual Bool_t Accept (PndPidCandidate *b)
 
Bool_t SetCriterion (TString &crit)
 
Bool_t SetSelection (TString &crit)
 
virtual void SetCriterion (const char *crit)
 
void SetCriterion (criterion crit)
 
void Select (RhoCandList &l)
 
void Select (RhoCandList &in, RhoCandList &out)
 

Protected Member Functions

TParticlePDG * CPConjugate (TParticlePDG *aPart)
 
void SetTypeAndMass (RhoCandidate *b)
 

Protected Attributes

PndAnaSelectorParfSelectPar
 
Double_t fChargeCrit
 Pointer to the current parameter object. More...
 
Int_t fPidSelect
 
TParticlePDG * fTypePlus
 
TParticlePDG * fTypeMinus
 Particle type to accept. More...
 
criterion fCriterion
 Particle type to accept. More...
 

Detailed Description

Definition at line 21 of file PndAnaPidSelector.h.

Constructor & Destructor Documentation

PndAnaPidSelector::PndAnaPidSelector ( const char *  name = "PndAnaPidSelector",
const char *  type = "",
const char *  paramid = "Default" 
)

Definition at line 40 of file PndAnaPidSelector.cxx.

References fSelectPar, and rtdb.

40  : // paramid //[R.K.03/2017] unused variable(s)
41  RhoParticleSelectorBase ( name,type ) ,
42  fChargeCrit ( 0.0 ),
43  fPidSelect ( 99 ) // some silly default number here
44 
45 {
46  // reading parameters from RTDB
47  FairRun* ana = FairRun::Instance();
48  FairRuntimeDb* rtdb=ana->GetRuntimeDb();
49  fSelectPar = ( PndAnaSelectorPar* ) ( rtdb->getContainer ( "ANAPidSelections" ) );
50 
51  if ( ! fSelectPar ) {
52  Fatal ( "PndAnaPidSelector","No ANAPidSelections* parameter found: %s","ANAPidSelections" );
53  }
54 
55  // PndAnaFluxPar* fFluxPar = (PndAnaFluxPar*)(rtdb->getContainer("ANAPidSelectionFlux"));
56  // if ( ! fFluxPar ) Fatal("SetParContainers","No ANAPidFlux parameter found: %s",parsetname.Data());
57  // }
58 
59  // Caution: The Parameter Set is not filled from the DB IO, yet.
60  Int_t runID = ana->GetRunId();
61 
62  // actually fill the containers.
63  //We might want to do that at another point, because multiple
64  //instnces will multiply call the RTDB init. That's bad in a loop!
65  rtdb->initContainers ( runID );
66 }
Double_t fChargeCrit
Pointer to the current parameter object.
PndAnaSelectorPar * fSelectPar
RhoParticleSelectorBase(const char *name="VAbsPidSelector", const char *type=0)
FairRuntimeDb * rtdb
Definition: hit_dirc.C:66
TString name
virtual PndAnaPidSelector::~PndAnaPidSelector ( )
inlinevirtual

Definition at line 28 of file PndAnaPidSelector.h.

28 {}

Member Function Documentation

Bool_t PndAnaPidSelector::Accept ( RhoCandidate b)
virtual

Implements RhoParticleSelectorBase.

Definition at line 180 of file PndAnaPidSelector.cxx.

References all, best, fabs(), fChargeCrit, RhoParticleSelectorBase::fCriterion, fPidSelect, RhoCandidate::GetCharge(), RhoCandidate::GetPidInfo(), loose, RhoParticleSelectorBase::SetTypeAndMass(), tight, variable, veryLoose, and veryTight.

181 {
182  // Accept or reject one candidate based on it's PID hypothesis, the pid
183  // pdf values and the selection criterion.
184  // This might be not performant, since each time we access an object to
185  // read the criterion value. Is a field of values faster?
186 
187  if ( b == 0 ) {
188  Error ( "PndAnaPidSelector::Accept","Candiate missing." ); return kFALSE;
189  }
190  //Info("PndAnaPidSelector::Accept","Request: Q=%g pid=%i crit=%i",fChargeCrit,fPidSelect,fCriterion);
191  // too stringent on charge with +-1. ??
192  if ( fChargeCrit!=0 && fChargeCrit!=b->GetCharge() ) {
193  //std::cout<<"PndAnaPidSelector::Accept: charge reject. fChargeCrit="<<fChargeCrit<<" b.GetCharge()"<<b.GetCharge() <<std::endl;
194  return kFALSE;
195  }
196 
197  if ( fPidSelect==99 ) {
198  return kTRUE;
199  } // no PID requested? Fine!
200 
201  // if e, mu, pi, k or p (but no + or -) is requested we reject neutrals
202  if ( fPidSelect!=99 && fabs ( b->GetCharge() ) <0.001 ) {
203  return kFALSE;
204  }
205 
206  SetTypeAndMass ( b );
207 
208  double Lcheck = b->GetPidInfo ( fPidSelect );
209  //std::cout<<"PndAnaPidSelector::Accept: Lcheck="<<Lcheck<<" fPidSelect="<<fPidSelect<<std::endl;
210 
211  if ( fCriterion == veryLoose ) {
212  if ( Lcheck<fSelectPar->GetVeryLooseCrit ( fPidSelect ) ) {
213  return kFALSE;
214  }
215  } else if ( fCriterion == loose ) {
216  if ( Lcheck<fSelectPar->GetLooseCrit ( fPidSelect ) ) {
217  return kFALSE;
218  }
219  } else if ( fCriterion == tight ) {
220  if ( Lcheck<fSelectPar->GetTightCrit ( fPidSelect ) ) {
221  return kFALSE;
222  }
223  } else if ( fCriterion == veryTight ) {
224  if ( Lcheck<fSelectPar->GetVeryTightCrit ( fPidSelect ) ) {
225  return kFALSE;
226  }
227  } else if ( fCriterion == variable ) {
228  if ( Lcheck<fSelectPar->GetVariableCrit ( fPidSelect ) ) {
229  return kFALSE;
230  }
231  } else if ( fCriterion == all ) {
232  return kTRUE;
233  } else if ( fCriterion == best ) {
234  double Le = b->GetPidInfo ( 0 );
235  double Lmu = b->GetPidInfo ( 1 );
236  double Lpi = b->GetPidInfo ( 2 );
237  double Lk = b->GetPidInfo ( 3 );
238  double Lp = b->GetPidInfo ( 4 );
239 
240  if ( Lcheck<Le || Lcheck<Lmu || Lcheck<Lpi || Lcheck<Lk || Lcheck<Lp ) {
241  return kFALSE;
242  }
243  }
244 
245  return kTRUE;
246 }
Double_t fChargeCrit
Pointer to the current parameter object.
Double_t GetCharge() const
Definition: RhoCandidate.h:183
criterion fCriterion
Particle type to accept.
friend F32vec4 fabs(const F32vec4 &a)
Definition: P4_F32vec4.h:47
void SetTypeAndMass(RhoCandidate *b)
double GetPidInfo(int hypo)
Bool_t PndAnaPidSelector::Accept ( PndPidCandidate b)
virtual

Implements RhoParticleSelectorBase.

Definition at line 248 of file PndAnaPidSelector.cxx.

249 {
250  Warning ( "PndAnaPidSelector::Accept(VAbsMicroCandidate&)","No implementation for this. Please use PndAnaPidSelector::Accept(RhoCandidate&)" );
251  return kFALSE;
252 }
TParticlePDG * RhoParticleSelectorBase::CPConjugate ( TParticlePDG *  aPart)
protectedinherited

Definition at line 129 of file RhoParticleSelectorBase.cxx.

References name, and TString.

Referenced by RhoParticleSelectorBase::RhoParticleSelectorBase(), and SetSelection().

130 {
131  // TDatabasePDG *pdt = TDatabasePDG::Instance();
132  TDatabasePDG* pdt = TDatabasePDG::Instance();
133  Int_t theCode = thePart->PdgCode();
134  TString name = thePart->GetName();
135 
136  // Is it a charged particle ?
137  if ( name.Index ( "-" ) >0 || name.Index ( "+" ) >0 || abs ( theCode ) ==2212 ) { theCode = -theCode; }
138 
139  return pdt->GetParticle ( theCode );
140 }
TString name
void RhoParticleSelectorBase::Select ( RhoCandList l)
inherited

Definition at line 94 of file RhoParticleSelectorBase.cxx.

References RhoCandList::Select().

95 {
96  l.Select(this);
97  // RhoCandList tmp ( l );
98  // Select ( tmp,l );
99 }
void Select(RhoParticleSelectorBase *pidmgr)
void RhoParticleSelectorBase::Select ( RhoCandList in,
RhoCandList out 
)
inherited

Definition at line 101 of file RhoParticleSelectorBase.cxx.

References RhoParticleSelectorBase::Accept(), c, RhoCandList::Cleanup(), RhoCandList::GetLength(), i, n, and RhoCandList::Put().

102 {
103  out.Cleanup();
104  Int_t n = in.GetLength();
105  for ( Int_t i=0; i<n; i++ ) {
106  RhoCandidate* c = in[i];
107 
108  if ( Accept ( c ) ) {
109  //printf("selector \"%s\" accepted i=%i\n",fName.Data(),i);
110  out.Put ( c );
111  } //else printf("selector \"%s\" rejected i=%i\n",fName.Data(),i);
112  }
113 }
void Cleanup()
Definition: RhoCandList.cxx:62
Int_t i
Definition: run_full.C:25
Int_t GetLength() const
Definition: RhoCandList.h:46
int n
virtual Bool_t Accept(RhoCandidate *)=0
void Put(const RhoCandidate *, Int_t i=-1)
Definition: RhoCandList.cxx:77
Bool_t PndAnaPidSelector::SetCriterion ( TString crit)
inline

Definition at line 33 of file PndAnaPidSelector.h.

References SetSelection().

Referenced by PndAnalysis::FillList().

33 {return SetSelection(crit);};
Bool_t SetSelection(TString &crit)
void RhoParticleSelectorBase::SetCriterion ( const char *  crit)
virtualinherited

Reimplemented in RhoGoodTrackSelector, RhoGoodPhotonSelector, and PndGoodTrackSelector.

Definition at line 61 of file RhoParticleSelectorBase.cxx.

References all, best, loose, tight, TString, variable, veryLoose, and veryTight.

Referenced by PndSimpleAnalysis::Exec(), PndSimpleAnalysis::FillGenericLists(), PndPidListMaker::FillList(), PndAnalysisTaskExample::Init(), PndAnalysisTask::Init(), PndHypSimpleAna::Init(), PndHypFullAna::Init(), PndHypFullIdealAna::Init(), PndGoodTrackSelector::SetCriterion(), RhoGoodPhotonSelector::SetCriterion(), and SetSelection().

62 {
63  TString crit ( c );
64  crit.ToLower();
65 
66  if ( crit=="best" ) {
67  SetCriterion ( best );
68  } else if ( crit=="veryloose" ) {
70  } else if ( crit=="loose" ) {
71  SetCriterion ( loose );
72  } else if ( crit=="tight" ) {
73  SetCriterion ( tight );
74  } else if ( crit=="verytight" ) {
76  } else if ( crit=="variable" ) {
78  } else if ( crit=="all" ) {
79  SetCriterion ( all );
80  } else {
81  cerr << GetName() << ": Unknown criterion " << crit.Data() << endl;
82  return;
83  }
84 
85 // fParms.Set("criteria",crit,"Selector criterion",this);
86  //cout << this->ClassName() << "::SetCriterion " << c << " for " << GetName() << endl;
87 }
virtual void SetCriterion(const char *crit)
void RhoParticleSelectorBase::SetCriterion ( criterion  crit)
inherited

Definition at line 89 of file RhoParticleSelectorBase.cxx.

References RhoParticleSelectorBase::fCriterion.

90 {
91  fCriterion = crit;
92 }
criterion fCriterion
Particle type to accept.
Bool_t PndAnaPidSelector::SetSelection ( TString crit)

Definition at line 68 of file PndAnaPidSelector.cxx.

References all, best, RhoParticleSelectorBase::CPConjugate(), fChargeCrit, fPidSelect, RhoParticleSelectorBase::fTypeMinus, RhoParticleSelectorBase::fTypePlus, loose, RhoParticleSelectorBase::SetCriterion(), tight, TString, variable, veryLoose, and veryTight.

Referenced by SetCriterion().

69 {
70  //Default setting for criterion
72  TString critcopy(crit);
73 
74  // parse criterion string to criteria flags...
75 
76  if ( crit.Contains ( "VeryLoose" ) ) {
78  critcopy.ReplaceAll("VeryLoose","");
79  } else if ( crit.Contains ( "Loose" ) ) {
81  critcopy.ReplaceAll("Loose","");
82  } else if ( crit.Contains ( "VeryTight" ) ) {
84  critcopy.ReplaceAll("VeryTight","");
85  } else if ( crit.Contains ( "Tight" ) ) {
87  critcopy.ReplaceAll("Tight","");
88  } else if ( crit.Contains ( "Variable" ) ) {
90  critcopy.ReplaceAll("Variable","");
91  } else if ( crit.Contains ( "Best" ) ) {
93  critcopy.ReplaceAll("Best","");
94  } else if ( crit.Contains ( "All" ) ) {
96  critcopy.ReplaceAll("All","");
97  } // well, that's default anyway
98 
99  //TODO: make a 2d array of the criterion numbers for faster access
100 
101  fTypePlus=0;
102 
103  fTypeMinus=0;
104 
105  // Name convention for TDatabsePDG found at $ROOTSYS/etc/pdg_table.txt
106  fPidSelect=99;// some silly number here
107 
108  if ( crit.Contains ( "Proton" ) ) {
109  fTypePlus=TDatabasePDG::Instance()->GetParticle ( "p+" );
110  if ( 0==fTypePlus ) {
111  fTypePlus=TDatabasePDG::Instance()->GetParticle ( "proton" );
112  }
113  if ( 0==fTypePlus ) {
114  fTypePlus=TDatabasePDG::Instance()->GetParticle (2212);
115  }
116  fPidSelect=4;
117  critcopy.ReplaceAll("Proton","");
118  } else if ( crit.Contains ( "Kaon" ) ) {
119  fTypePlus=TDatabasePDG::Instance()->GetParticle ( "K+" );
120  if ( 0==fTypePlus ) {
121  fTypePlus=TDatabasePDG::Instance()->GetParticle (321);
122  }
123  fPidSelect=3;
124  critcopy.ReplaceAll("Kaon","");
125  } else if ( crit.Contains ( "Pion" ) ) {
126  fTypePlus=TDatabasePDG::Instance()->GetParticle ( "pi+" );
127  if ( 0==fTypePlus ) {
128  fTypePlus=TDatabasePDG::Instance()->GetParticle (211);
129  }
130  fPidSelect=2;
131  critcopy.ReplaceAll("Pion","");
132  } else if ( crit.Contains ( "Muon" ) ) {
133  fTypePlus=TDatabasePDG::Instance()->GetParticle ( "mu+" );
134  if ( 0==fTypePlus ) {
135  fTypePlus=TDatabasePDG::Instance()->GetParticle (-13);
136  }
137  fPidSelect=1;
138  critcopy.ReplaceAll("Muon","");
139  } else if ( crit.Contains ( "Electron" ) ) {
140  fTypePlus=TDatabasePDG::Instance()->GetParticle ( "e+" );
141  if ( 0==fTypePlus ) {
142  fTypePlus=TDatabasePDG::Instance()->GetParticle (-11);
143  }
144  fPidSelect=0;
145  critcopy.ReplaceAll("Electron","");
146  }
147 
148 //std::cout<<"PndAnaPidSelector: fPidSelect="<<fPidSelect<<std::endl;
149 
150  if ( fTypePlus!=0 ) {
152  }
153 
154  if ( crit.Contains ( "Plus" ) ) {
155  fChargeCrit=1.;
156  critcopy.ReplaceAll("Plus","");
157  } else if ( crit.Contains ( "Minus" ) ) {
158  fChargeCrit=-1.;
159  critcopy.ReplaceAll("Minus","");
160  } else {
161  fChargeCrit=0;
162  }
163 
164  if(critcopy.Length()>0){
165  std::cout<<"Analysis PID selection criteria setting failed. "<<std::endl;
166  std::cout<<"Selection String: \""<<crit.Data()<<"\""<<std::endl;
167  std::cout<<"Invalid piece: \""<<critcopy.Data()<<"\""<<std::endl;
168  std::cout<<"Viable optios are:"<<std::endl;
169  std::cout<<"\tProton,Kaon,Pion,Muon,Electron"<<std::endl;
170  std::cout<<"\tVeryLoose,Loose,Tight,VeryTight,Variable,Best,All"<<std::endl;
171  std::cout<<"\tPlus,Minus,Charged,Neutral,(All)"<<std::endl;
172  Error("SetSelection()","Invalid selection string.");
173  return kFALSE;
174  }
175 
176  return kTRUE;
177 }
Double_t fChargeCrit
Pointer to the current parameter object.
TParticlePDG * fTypeMinus
Particle type to accept.
TParticlePDG * CPConjugate(TParticlePDG *aPart)
virtual void SetCriterion(const char *crit)
void RhoParticleSelectorBase::SetTypeAndMass ( RhoCandidate b)
protectedinherited

Definition at line 143 of file RhoParticleSelectorBase.cxx.

References RhoParticleSelectorBase::fTypeMinus, RhoParticleSelectorBase::fTypePlus, RhoCandidate::GetCharge(), RhoCandidate::SetMass(), and RhoCandidate::SetType().

Referenced by Accept(), RhoGoodPhotonSelector::Accept(), RhoEnergyParticleSelector::Accept(), RhoSimpleMuonSelector::Accept(), RhoSimpleKaonSelector::Accept(), RhoSimpleElectronSelector::Accept(), RhoPlusParticleSelector::Accept(), RhoNeutralParticleSelector::Accept(), RhoMomentumParticleSelector::Accept(), RhoMinusParticleSelector::Accept(), RhoMassParticleSelector::Accept(), RhoSimpleProtonSelector::Accept(), and RhoSimplePionSelector::Accept().

144 {
145  if ( b == 0 ) { return; }
146  // Set the particle type
147  if ( b->GetCharge() >0.1 ) {
148  if ( fTypePlus == 0 ) { return; }
149  b->SetType ( fTypePlus );
150  b->SetMass ( fTypePlus->Mass() );
151  } else {
152  if ( fTypeMinus == 0 ) { return; }
153  b->SetType ( fTypeMinus );
154  b->SetMass ( fTypeMinus->Mass() );
155  }
156 }
Double_t GetCharge() const
Definition: RhoCandidate.h:183
TParticlePDG * fTypeMinus
Particle type to accept.
void SetType(const TParticlePDG *pdt)
void SetMass(Double_t mass)

Member Data Documentation

Double_t PndAnaPidSelector::fChargeCrit
protected

Pointer to the current parameter object.

Definition at line 42 of file PndAnaPidSelector.h.

Referenced by Accept(), and SetSelection().

criterion RhoParticleSelectorBase::fCriterion
protectedinherited
Int_t PndAnaPidSelector::fPidSelect
protected

Definition at line 44 of file PndAnaPidSelector.h.

Referenced by Accept(), and SetSelection().

PndAnaSelectorPar* PndAnaPidSelector::fSelectPar
protected

Definition at line 38 of file PndAnaPidSelector.h.

Referenced by PndAnaPidSelector().

TParticlePDG* RhoParticleSelectorBase::fTypeMinus
protectedinherited
TParticlePDG* RhoParticleSelectorBase::fTypePlus
protectedinherited

The documentation for this class was generated from the following files: