FairRoot/PandaRoot
PndAnaTask.cxx
Go to the documentation of this file.
1 #include "PndAnaTask.h"
2 
3 #include <string>
4 #include <iostream>
5 
6 using std::cout;
7 using std::endl;
8 
9 //FAIR headers
10 #include "FairRootManager.h"
11 #include "FairRunAna.h"
12 #include "FairRuntimeDb.h"
13 #include "FairRun.h"
14 
15 // ROOT headers
16 #include "TTree.h"
17 #include "TChain.h"
18 #include "TClonesArray.h"
19 
20 // RHO headers
21 #include "RhoFactory.h"
22 #include "RhoCandidate.h"
23 #include "RhoCandList.h"
25 #include "PndPidCandidate.h"
26 
27 #include "PndPidCandidate.h"
28 #include "PndPidProbability.h"
29 #include "PndPidListMaker.h"
30 
32 
34  fPidListMaker(0),
35  fEventRead(kFALSE)
36 //fCurrentEventInfo(0)
37 {
38 }
39 
41 {
42  if(0!=fPidListMaker) { delete fPidListMaker; }
43 }
44 
45 InitStatus PndAnaTask::Init()
46 {
47  return kSUCCESS;
48 }
49 
50 void PndAnaTask::Exec(Option_t*)
51 {
52 }
53 
55 {
56 }
57 
58 
60 {
61  std::cout << "-I- PndAnaTask: Initialization" << std::endl;
62 
63  FairRootManager* fRootManager = FairRootManager::Instance();
64 
65  if ( 0 == fRootManager ) {
66  std::cout << "-E- PndAnaTask: No FairRootManager found!" << std::endl;
67  return;
68  }
69 
70  //read
71  fChargedCands = (TClonesArray*) fRootManager->GetObject("PidChargedCand");
72  fNeutralCands = (TClonesArray*) fRootManager->GetObject("PidNeutralCand");
73  fChargedProbability = (TClonesArray*) fRootManager->GetObject("PidChargedProbability");
74  fNeutralProbability = (TClonesArray*) fRootManager->GetObject("PidNeutralProbability");
75  fMcCands = (TClonesArray*) fRootManager->GetObject("PndMcTracks");
76 
78 
79 }
80 
82 {
84 
89 
90  return 0;
91 }
92 
93 bool PndAnaTask::FillList(RhoCandList& l, std::string listkey)
94 {
95  // Reads the specified List for the current event
96 
97  l.Cleanup();
98  UInt_t uid=1;
99 
100  // when the first list is requested read in the event
101  /*
102  if (!fEventRead)
103  {
104  fRootManager->ReadEvent(fEvtCount-1);
105  fEventRead=true;
106  }
107  */
108 
109  if (listkey=="McTruth") {
110  if (fMcCands) {
111  //cout <<"PndAnaTask::FillList: "<<fMcCands->GetEntriesFast()<<" mc cands"<<endl;
112  for (int i1=0; i1<fMcCands->GetEntriesFast(); i1++) {
113  RhoCandidate* tc = (RhoCandidate*)fMcCands->At(i1);
114  l.Add(tc);
115  }
116  return true;
117  } else { return false; }
118  }
119 
120  // fill all, neutral and charged from the PndPidCandidate Array
121 // if (fMicroCands && allCands.GetLength()==0)
122 // {
123 // for (int i1=0; i1<fMicroCands->GetEntriesFast(); i1++)
124 // {
125 // VAbsMicroCandidate *mic = (VAbsMicroCandidate *)fMicroCands->At(i1);
126 // RhoCandidate tc(*mic,i1+1);
127 //
128 // allCands.Add(tc);
129 //
130 // if (fabs(tc.Charge())>0.01)
131 // chargedCands.Add(tc);
132 // else
133 // neutralCands.Add(tc);
134 // }
135 // }
136  //else
137  if (fLAllCands.GetLength() == 0) { // do only when we didn't read something yet.
138  // removed now compatibility to RhoCandidate readin ... instead read PndPidCandidates
140  for (int i1=0; i1<fNeutralCands->GetEntriesFast(); i1++) {
142  RhoCandidate tc(*mic,uid++);
143 
144  // TODO: Do we want to set something here? It is neutrals anyway.
145  if(0!=fNeutralProbability && i1<fNeutralProbability->GetEntriesFast()) {
147  // numbering see PndPidListMaker
148  tc.SetPidInfo(0,neuProb->GetElectronPidProb());
149  tc.SetPidInfo(1,neuProb->GetMuonPidProb());
150  tc.SetPidInfo(2,neuProb->GetPionPidProb());
151  tc.SetPidInfo(3,neuProb->GetKaonPidProb());
152  tc.SetPidInfo(4,neuProb->GetProtonPidProb());
153  }
154  fLNeutralCands.Add(&tc);
155  fLAllCands.Add(&tc);
156  }
157 
158  if (fChargedCands && fLChargedCands.GetLength()==0) {
159  for (int i1=0; i1<fChargedCands->GetEntriesFast(); i1++) {
161  RhoCandidate tc(*mic,uid++);
162 
163  if(0!=fChargedProbability && i1<fChargedProbability->GetEntriesFast()) {
165  // numbering see PndPidListMaker
166  tc.SetPidInfo(0,chProb->GetElectronPidProb());
167  tc.SetPidInfo(1,chProb->GetMuonPidProb());
168  tc.SetPidInfo(2,chProb->GetPionPidProb());
169  tc.SetPidInfo(3,chProb->GetKaonPidProb());
170  tc.SetPidInfo(4,chProb->GetProtonPidProb());
171  }
172  fLChargedCands.Add(&tc);
173  fLAllCands.Add(&tc);
174  }
175  }
176  }
177 
178 
179  // set the base list for the PID list maker
181 
182  if (listkey=="All" ) {
183  l=fLAllCands;
184  return true;
185  }
186 
187  if (listkey=="Neutral") {
188  l=fLNeutralCands;
189  return true;
190  }
191 
192  if (listkey=="Charged") {
193  l=fLChargedCands;
194  return true;
195  }
196 
197  return fPidListMaker->FillList(l,listkey);
198 }
199 
200 
201 
202 
203 //const PndEventInfo* PndAnaTask::GetEventInfo()
204 //{
205 // if (fCurrentEventInfo) return fCurrentEventInfo;
206 //
207 // TClonesArray* aArray = (TClonesArray*) fRootManager->GetObject("PndEventSummary");
208 // fRootManager->ReadEvent(fEvtCount-1);
209 //
210 // if (aArray){
211 // fCurrentEventInfo = (PndEventInfo*) aArray->At(0);
212 // }
213 // return fCurrentEventInfo;
214 //}
215 //
216 //Float_t PndAnaTask::GetTag(const char* bname)
217 //{
218 // TChain* theChain = fRootManager->GetInChain();
219 // Long64_t localEntry = theChain->LoadTree(fEvtCount-1);
220 // theChain = fRootManager->GetInChain();
221 // TBranch *b=theChain->GetBranch(bname);
222 //
223 // Float_t val=0;
224 // if (b)
225 // {
226 // Float_t *tmpad=(Float_t*)b->GetAddress();
227 // b->GetEntry(localEntry);
228 // val=*tmpad;
229 // }
230 // return val;
231 //}
232 //
233 //Int_t PndAnaTask::GetTagI(const char* bname)
234 //{
235 // TChain* theChain = fRootManager->GetInChain();
236 // Long64_t localEntry = theChain->LoadTree(fEvtCount-1);
237 // TBranch *b=theChain->GetBranch(bname);
238 //
239 // Int_t val=0;
240 // if (b)
241 // {
242 // Int_t *tmpad=(Int_t*)b->GetAddress();
243 // b->GetEntry(localEntry);
244 // val=*tmpad;
245 // }
246 // return val;
247 //}
248 //
249 
TClonesArray * fMcCands
Definition: PndAnaTask.h:51
void Add(const RhoCandidate *c)
Definition: RhoCandList.h:49
Double_t GetProtonPidProb(PndPidProbability *flux=NULL) const
void InitArrays()
Definition: PndAnaTask.cxx:59
void Cleanup()
Definition: RhoCandList.cxx:62
Double_t GetKaonPidProb(PndPidProbability *flux=NULL) const
RhoCandList fLMcCands
Definition: PndAnaTask.h:56
virtual void Finish()
Definition: PndAnaTask.cxx:54
Int_t GetLength() const
Definition: RhoCandList.h:46
static void Reset()
Definition: RhoFactory.cxx:28
virtual InitStatus Init()
Definition: PndAnaTask.cxx:45
ClassImp(PndAnaTask)
TClonesArray * fChargedProbability
Definition: PndAnaTask.h:49
cout<< "POINTs for new FwEndCap == "<< tsim-> GetEntriesFast()
int GetEvent()
Definition: PndAnaTask.cxx:81
RhoCandList fLChargedCands
Definition: PndAnaTask.h:54
TClonesArray * fNeutralProbability
Definition: PndAnaTask.h:50
RhoCandList fLNeutralCands
Definition: PndAnaTask.h:55
int uid(int lev, int lrun, int lmode)
Definition: autocutx.C:122
void SetBaseList(RhoCandList &l)
void SetPidInfo(double *pidinfo=0)
Double_t GetMuonPidProb(PndPidProbability *flux=NULL) const
virtual void Exec(Option_t *opt)
Definition: PndAnaTask.cxx:50
TClonesArray * fNeutralCands
Definition: PndAnaTask.h:48
static RhoFactory * Instance()
Definition: RhoFactory.cxx:34
PndPidListMaker * fPidListMaker
Definition: PndAnaTask.h:58
TClonesArray * fChargedCands
Definition: PndAnaTask.h:47
bool FillList(RhoCandList &l, std::string listkey="All")
RhoCandList fLAllCands
Definition: PndAnaTask.h:53
Double_t GetElectronPidProb(PndPidProbability *flux=NULL) const
bool FillList(RhoCandList &l, std::string listkey="All")
Definition: PndAnaTask.cxx:93
Double_t GetPionPidProb(PndPidProbability *flux=NULL) const