FairRoot/PandaRoot
RhoParticleSelectorBase.cxx
Go to the documentation of this file.
1 // //
3 // RhoParticleSelectorBase //
4 // //
5 // Selector classes for particle identification //
6 // Particle masses are set from the TDatabasePDG class //
7 // //
8 // Author: Marcel Kunze, RUB, Feb. 99 //
9 // Copyright (C) 1999-2001, Ruhr-University Bochum. //
10 // Ralf Kliemt, HIM/GSI Feb.2013 (Cleanup & Restructuring) //
11 // //
13 
14 #include "TDatabasePDG.h"
16 #include "RhoBase/RhoCandidate.h"
17 #include "PndPidCandidate.h"
18 #include "RhoBase/RhoCandList.h"
19 
21 
22 #include <iostream>
23 using namespace std;
24 
25 //TParm VAbsPidSelector::fParms;
26 //TAssociator *VAbsPidSelector::fAssociator=0;
27 
28 RhoParticleSelectorBase::RhoParticleSelectorBase ( const char* name, const char* type ) :
29  TNamed ( name,name ),fTypePlus ( 0 ),fTypeMinus ( 0 ),fCriterion ( loose )//,fQC ( 0 )
30 {
31 // SetParm("criteria","loose"); // The default setting
32 
33  // Set the particle type (plus, minus, neutral)
34 
35  if ( type != 0 ) {
36  TDatabasePDG* pdg = TDatabasePDG::Instance();
37  // TDatabasePDG *pdg = TDatabasePDG::Instance();
38  TString sType ( type );
39  if ( sType.Index ( "+" ) >0 || sType=="p+" || sType=="proton" ) {
40  fTypePlus = pdg->GetParticle ( type );
42  //cout <<sType<<" "<<pdg->GetParticle(sType)->PdgCode()<<" is fTypePlus "<<pdg->GetParticle(sType)->Charge()<<endl;
43  } else if ( sType.Index ( "-" ) >0 || sType=="anti-p-" || sType=="antiproton" ) {
44  fTypeMinus = pdg->GetParticle ( type );
46  } else {
47  fTypeMinus = fTypePlus = pdg->GetParticle ( type );
48  }
49  }
50 }
51 
53 {}
54 
55 // void VAbsPidSelector::Initialize()
56 // {
57 // TString criterion = fParms.GetString("criteria",this);
58 // SetCriterion(criterion.Data());
59 // }
60 
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 }
88 
90 {
91  fCriterion = crit;
92 }
93 
95 {
96  l.Select(this);
97  // RhoCandList tmp ( l );
98  // Select ( tmp,l );
99 }
100 
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 }
114 
115 // Parameter setting
116 
117 //
118 // TAssociator* VAbsPidSelector::GetAssociator() const
119 // {
120 // return fAssociator;
121 // }
122 
123 // void VAbsPidSelector::SetAssociator(TAssociator *assoc)
124 // {
125 // fAssociator = assoc;
126 // }
127 
128 TParticlePDG*
129 RhoParticleSelectorBase::CPConjugate ( TParticlePDG* thePart )
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 }
141 
142 void
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 }
void Cleanup()
Definition: RhoCandList.cxx:62
Double_t GetCharge() const
Definition: RhoCandidate.h:183
Int_t i
Definition: run_full.C:25
TTree * b
criterion fCriterion
Particle type to accept.
Int_t GetLength() const
Definition: RhoCandList.h:46
int n
virtual Bool_t Accept(RhoCandidate *)=0
TParticlePDG * fTypeMinus
Particle type to accept.
TParticlePDG * CPConjugate(TParticlePDG *aPart)
void SetType(const TParticlePDG *pdt)
RhoParticleSelectorBase(const char *name="VAbsPidSelector", const char *type=0)
void Select(RhoParticleSelectorBase *pidmgr)
TFile * out
Definition: reco_muo.C:20
void SetMass(Double_t mass)
void SetTypeAndMass(RhoCandidate *b)
TString name
virtual void SetCriterion(const char *crit)
ClassImp(PndAnaContFact)
void Put(const RhoCandidate *, Int_t i=-1)
Definition: RhoCandList.cxx:77