FairRoot/PandaRoot
Public Member Functions | Private Member Functions | Private Attributes | List of all members
PndParticleQATask Class Reference

#include <PndParticleQATask.h>

Inheritance diagram for PndParticleQATask:

Public Member Functions

 PndParticleQATask (bool fastsim=false, bool dumpchrg=true, bool dumpneut=true, bool dumpmc=true, int mode=0)
 
 ~PndParticleQATask ()
 
virtual InitStatus Init ()
 
virtual void Exec (Option_t *opt)
 
virtual void Finish ()
 
void SetFastSim (bool fsim=true)
 
void SetPidArrayNames (TString names)
 

Private Member Functions

int SelectTruePid (PndAnalysis *ana, RhoCandList &l)
 
int SplitString (TString s, TString delim, StringList &toks)
 
virtual void SetParContainers ()
 
 ClassDef (PndParticleQATask, 1)
 

Private Attributes

int fEvtCount
 
TString fPidArrayNames
 
RhoTuplenmc
 
RhoTuplentp
 
RhoTuplentpn
 
PndAnalysisfAnalysis
 
bool fFastSim
 
bool fDumpChrg
 
bool fDumpNeut
 
bool fDumpMc
 
int fMode
 
StringList fPidList
 

Detailed Description

Definition at line 24 of file PndParticleQATask.h.

Constructor & Destructor Documentation

PndParticleQATask::PndParticleQATask ( bool  fastsim = false,
bool  dumpchrg = true,
bool  dumpneut = true,
bool  dumpmc = true,
int  mode = 0 
)

Definition at line 34 of file PndParticleQATask.cxx.

References fDumpChrg, fDumpMc, fDumpNeut, fFastSim, fMode, fPidArrayNames, and mode.

34  :
35  FairTask("Panda Tutorial Analysis Task") {
36  fFastSim = fastsim;
37  fDumpChrg = dumpchrg;
38  fDumpNeut = dumpneut;
39  fDumpMc = dumpmc;
40  fMode = mode;
41  fPidArrayNames = "";
42 }
Int_t mode
Definition: autocutx.C:47
PndParticleQATask::~PndParticleQATask ( )

Definition at line 47 of file PndParticleQATask.cxx.

47 { }

Member Function Documentation

PndParticleQATask::ClassDef ( PndParticleQATask  ,
 
)
private
void PndParticleQATask::Exec ( Option_t *  opt)
virtual

Definition at line 164 of file PndParticleQATask.cxx.

References RhoTuple::Column(), RhoTuple::DumpData(), f, fAnalysis, fDumpChrg, fDumpMc, fDumpNeut, fEvtCount, PndAnalysis::FillList(), fMode, fPidList, PndAnalysis::GetEventInTask(), RhoCandList::GetLength(), i, mclist, nmc, ntp, ntpn, RhoCandidate::P4(), RhoCandidate::PdgCode(), PndRhoTupleQA::qaDrc(), PndRhoTupleQA::qaDsc(), PndRhoTupleQA::qaEmc(), PndRhoTupleQA::qaMcList(), PndRhoTupleQA::qaMuo(), PndRhoTupleQA::qaMvd(), PndRhoTupleQA::qaP4(), PndRhoTupleQA::qaPid(), PndRhoTupleQA::qaPull(), PndRhoTupleQA::qaRich(), PndRhoTupleQA::qaStt(), PndRhoTupleQA::qaTof(), PndRhoTupleQA::qaTrk(), RhoCandidate::TheMother(), and TString.

165 {
166  // *** some variables
167  //int i=0,j=0, k=0, l=0;
168  int i=0,j=0;
169  TLorentzVector dummy;
170 
171  // necessary to read the next event
173 
174  if (!(++fEvtCount%100)) cout << "[PndParticleQATask] evt "<<fEvtCount<<endl;
175 
176  // *** RhoCandLists for the analysis
177  RhoCandList chrpid[50];
178 
179  //RhoCandList chr, chr1emc, chr2drc, chr3dsc, chr4mvd, chr5mdt, chr6stt, chr7rch, chr8chk, chr9idl;
180  //RhoCandList chr1nemc, chr2ndrc, chr3ndsc, chr4nmvd, chr5nmdt, chr6nstt, chr7nrch;
181  //RhoCandList chr16, chr126, chr1256, chr12356, chr1236, chr26, chr123456, chr1234567;
182  RhoCandList neut, mclist;
183 
184  PndRhoTupleQA qa(fAnalysis,15.0);
185 
186  // *** store MC truth info
187  if (fDumpMc)
188  {
189  fAnalysis->FillList(mclist, "McTruth");
190  nmc->Column("ev", (Int_t) fEvtCount);
191  qa.qaMcList("", mclist, nmc, 20);
192  nmc->DumpData();
193  }
194 
195  if (fDumpChrg)
196  {
197 
198  // *** Fill the lists with different pid algos
199  // *** the first element should contain the full combination exept element 0
200 
201  int nalgos = fPidList.size();
202  for (i=0;i<nalgos;++i)
203  fAnalysis->FillList(chrpid[i], "Charged", fPidList[i]);
204 
205 
206  int ntrk = chrpid[0].GetLength();
207 
208  TLorentzVector chrgP4=dummy;
209 
210  // *******************************
211  // *** Loop over CHARGED particles
212  // *******************************
213  for (j=0; j<ntrk; ++j)
214  {
215  RhoCandidate *truth = chrpid[0][j]->GetMcTruth();
216 
217  ntp->Column("mode", (Int_t) fMode, 0 );
218  ntp->Column("ev", (Int_t) fEvtCount, 0 );
219  ntp->Column("trk", (Int_t) j, 0 );
220  ntp->Column("ntrk", (Int_t) ntrk, 0 );
221  ntp->Column("chrg", (Float_t) chrpid[0][j]->Charge(), 0.0f );
222 
223  qa.qaP4( "", chrpid[0][j]->P4(), ntp);
224  qa.qaPull( "" , chrpid[0][j] , ntp);
225 
226  // all the pid stuff now
227  qa.qaPid("idl", chrpid[0][j], ntp);
228  qa.qaPid("", chrpid[nalgos-1][j], ntp);
229 
230  for (i=1; i<nalgos-1; ++i)
231  {
232  int nidx = (nalgos-2)/2;
233  int algidx = (i-1)%nidx;
234  TString algname = fPidList[algidx+1];
235 
236  //cout <<nalgos<<" "<<nidx<<" ";
237 
238  if (algname.Contains(";")) algname.Remove(algname.First(";"),1000);
239  algname.ReplaceAll("Pid","");
240  algname.ReplaceAll("Algo","");
241  algname.ReplaceAll("Probability","");
242  algname.ToLower();
243  algname=algname(0,10);
244 
245  TString smpname = Form("a%d",algidx);
246  if ((i-1)>=nidx)
247  {
248  smpname = "n" + smpname;
249  algname = "n" + algname;
250  }
251 
252  //cout <<i<<" idx:"<<algidx<<" "<<smpname<<" / "<<algname<<endl;
253 
254  qa.qaPid(smpname, chrpid[i][j], ntp);
255  qa.qaPid(algname, chrpid[i][j], ntp);
256  }
257 
258  qa.qaEmc( "", chrpid[0][j], ntp);
259  qa.qaMvd( "", chrpid[0][j], ntp);
260  qa.qaStt( "", chrpid[0][j], ntp);
261  qa.qaDrc( "", chrpid[0][j], ntp);
262  qa.qaDsc( "", chrpid[0][j], ntp);
263  qa.qaTof( "", chrpid[0][j], ntp);
264  qa.qaMuo( "", chrpid[0][j], ntp);
265  qa.qaTrk( "", chrpid[0][j], ntp);
266  qa.qaRich("", chrpid[0][j], ntp);
267 
268  float mct = 0.0;
269  float prim = 0.0;
270 
271  if (truth)
272  {
273  mct = 1.0;
274  RhoCandidate *moth = truth->TheMother();
275  if (!moth || abs(moth->PdgCode()-88850)<100 )
276  {
277  prim = 1.0;
278  chrgP4 = truth->P4();
279  }
280 
281  qa.qaP4( "tr", chrgP4, ntp);
282  ntp->Column("trpdg", (Float_t) truth->PdgCode(), 0.0f );
283  }
284  else
285  {
286  qa.qaP4( "tr", dummy, ntp, true);
287  ntp->Column("trpdg", (Float_t) 0., 0.0f );
288  }
289 
290  ntp->Column("prim", (Float_t) prim, 0.0f );
291  ntp->Column("mct", (Float_t) mct, 0.0f );
292 
293  ntp->DumpData();
294  }
295  }
296 
297  // *******************************
298  // *** Loop over NEUTRAL particles
299  // *******************************
300 
301  if (fDumpNeut)
302  {
303  // *** Select with no PID info ('All'); type and mass are set
304  fAnalysis->FillList( neut, "Neutral" );
305 
306  int ntrk = neut.GetLength();
307  for (j=0; j<ntrk; ++j)
308  {
309  RhoCandidate *truth = neut[j]->GetMcTruth();
310 
311  ntpn->Column("mode", (Int_t) fMode, 0 );
312  ntpn->Column("ev", (Int_t) fEvtCount, 0 );
313  ntpn->Column("trk", (Int_t) j, 0 );
314  ntpn->Column("ntrk", (Int_t) ntrk, 0 );
315  ntpn->Column("chrg", (Float_t) neut[j]->Charge(), 0.0f );
316 
317  qa.qaP4( "", neut[j]->P4(), ntpn);
318  qa.qaEmc( "", neut[j], ntpn);
319  //qa.qaP4( "primlv", chrgP4, ntpn);
320 
321  float mct = 0.0;
322  float prim = 0.0;
323 
324  if (truth)
325  {
326  mct = 1.0;
327  RhoCandidate *moth = truth->TheMother();
328  if (!moth || abs(moth->PdgCode()-88850)<100 ) prim = 1.0;
329  if (moth)
330  {
331  qa.qaP4( "moth", moth->P4(), ntpn);
332  ntpn->Column("mothpdg", (Float_t) moth->PdgCode(), -999.f);
333  }
334  else
335  {
336  qa.qaP4( "moth", dummy, ntpn, true);
337  ntpn->Column("mothpdg", (Float_t) -1., -999.f);
338  }
339 
340  qa.qaP4( "tr", truth->P4(), ntpn);
341  ntpn->Column("trpdg", (Float_t) truth->PdgCode(), 0.0f );
342  }
343  else
344  {
345  qa.qaP4( "moth", dummy, ntpn, true);
346  qa.qaP4( "tr", dummy, ntpn, true);
347  ntpn->Column("trpdg", (Float_t) 0., 0.0f );
348  ntpn->Column("mothpdg", (Float_t) -1, -999.f);
349  }
350 
351  ntpn->Column("prim", (Float_t) prim, 0.0f );
352  ntpn->Column("mct", (Float_t) mct, 0.0f );
353 
354  ntpn->DumpData();
355  }
356  }
357 }
CandList mclist
Int_t i
Definition: run_full.C:25
Int_t GetLength() const
Definition: RhoCandList.h:46
Bool_t FillList(RhoCandList &l, TString listkey="All", TString pidTcaNames="", int trackHypothesis=-1)
void GetEventInTask()
TFile * f
Definition: bump_analys.C:12
TLorentzVector P4() const
Definition: RhoCandidate.h:195
void Column(const char *label, Bool_t value, Bool_t defval=0, const char *block=0)
Definition: RhoTuple.cxx:56
void DumpData()
Definition: RhoTuple.cxx:391
PndAnalysis * fAnalysis
const RhoCandidate * TheMother() const
Definition: RhoCandidate.h:272
void PndParticleQATask::Finish ( )
virtual

Definition at line 360 of file PndParticleQATask.cxx.

References fDumpChrg, fDumpMc, fDumpNeut, RhoTuple::GetInternalTree(), nmc, ntp, and ntpn.

361 {
362  if (fDumpMc) nmc->GetInternalTree()->Write();
363  if (fDumpChrg) ntp->GetInternalTree()->Write();
364  if (fDumpNeut) ntpn->GetInternalTree()->Write();
365 }
TTree * GetInternalTree()
Definition: RhoTuple.h:207
InitStatus PndParticleQATask::Init ( )
virtual

Definition at line 92 of file PndParticleQATask.cxx.

References fAnalysis, fDumpChrg, fDumpMc, fDumpNeut, fEvtCount, fFastSim, fPidArrayNames, fPidList, i, nmc, ntp, ntpn, SplitString(), and TString.

93 {
94  // initialize analysis object
95  fAnalysis = new PndAnalysis();
96 
97  // reset the event counter
98  fEvtCount = 0;
99 
100  // if fPidArrayNames not set, set it to defaults
101  // The 'PID-units' are separated by ':', whereas the algo names within a unit are separated with ';'
102  // *** The first algo should be an ideal algo! If there is non, just put the first algo twice ***
103  if ("" == fPidArrayNames)
104  {
105  if (fFastSim)
106  {
107  fPidArrayNames = "IdealPidProbability : ScEmcPidBarrelProbability;ScEmcPidFwCapProbability;ScEmcPidBwCapProbability : DrcBarrelProbability:";
108  fPidArrayNames += "DrcDiscProbability : MvdPidProbability : ScMdtPidBarrelProbability;ScMdtPidForwardProbability : SttPidProbability : RichProbability";
109  }
110  else
111  {
112  fPidArrayNames = "PidAlgoIdealCharged : PidAlgoEmcBayes : PidAlgoDrc : PidAlgoDisc : PidAlgoMvd : PidAlgoMdtHardCuts : PidAlgoStt : PidAlgoRich : PidAlgoSciT : ";
113  //fPidArrayNames += "PidAlgoMdtPdf";
114  }
115  }
116 
117  fPidArrayNames.ReplaceAll(" ","");
118 
119  // Now cut the fPidArrayNames string into units(groups) of algos
120 
121  fPidList.clear();
122  int nalgos = SplitString(fPidArrayNames,":",fPidList);
123 
124  fPidArrayNames.Remove(0,fPidArrayNames.First(":")+1); // remove the first (ideal) algo
125  fPidArrayNames.ReplaceAll(":",";"); // turn string to a correct algo combination
126 
127 
128  for (int i=1;i<nalgos;++i)
129  {
130  TString nonalgo = fPidArrayNames;
131  nonalgo.ReplaceAll(fPidList[i],"");
132  nonalgo.ReplaceAll(";;",";");
133 
134  cout <<"[PndParticleQATask] Algo["<<i<<"] : "<<fPidList[i]<<" Non-Algo : "<<nonalgo<<endl;
135  fPidList.push_back(nonalgo);
136  }
137 
138  // we want also the combination of all algos, except the 0-th (being the ideal element)
139  fPidList.push_back(fPidArrayNames);
140 
141  // create ntuple
142  nmc = ntp = ntpn = 0;
143 
144  if (fDumpMc) nmc = new RhoTuple("nmc", "Particle QA MC truth");
145  if (fDumpChrg) ntp = new RhoTuple("ntp", "Particle QA charged");
146  if (fDumpNeut) ntpn = new RhoTuple("ntpn","Particle QA neutrals");
147 
148  return kSUCCESS;
149 }
Int_t i
Definition: run_full.C:25
int SplitString(TString s, TString delim, StringList &toks)
PndAnalysis * fAnalysis
int PndParticleQATask::SelectTruePid ( PndAnalysis ana,
RhoCandList l 
)
private

Definition at line 73 of file PndParticleQATask.cxx.

References RhoCandList::GetLength(), PndAnalysis::McTruthMatch(), and RhoCandList::Remove().

74 {
75  int removed = 0;
76 
77  for (int ii=l.GetLength()-1;ii>=0;--ii)
78  {
79  if ( !(ana->McTruthMatch(l[ii])) )
80  {
81  l.Remove(l[ii]);
82  removed++;
83  }
84  }
85 
86  return removed;
87 }
Int_t GetLength() const
Definition: RhoCandList.h:46
Int_t Remove(RhoCandidate *)
Bool_t McTruthMatch(RhoCandidate *cand, Int_t level=2, bool verbose=false)
void PndParticleQATask::SetFastSim ( bool  fsim = true)
inline

Definition at line 44 of file PndParticleQATask.h.

References fFastSim, and fsim.

void PndParticleQATask::SetParContainers ( )
privatevirtual

Definition at line 153 of file PndParticleQATask.cxx.

154 {
155  // Get run and runtime database
156  //FairRun* run = FairRun::Instance();
157  //if ( ! run ) Fatal("SetParContainers", "No analysis run");
158 }
void PndParticleQATask::SetPidArrayNames ( TString  names)
inline

Definition at line 45 of file PndParticleQATask.h.

References fPidArrayNames.

Referenced by prod_ana(), and quickana().

45 {fPidArrayNames = names;}
int PndParticleQATask::SplitString ( TString  s,
TString  delim,
StringList toks 
)
private

Definition at line 53 of file PndParticleQATask.cxx.

References i, and TString.

Referenced by Init().

54 {
55  toks.clear();
56 
57  TObjArray *tok = s.Tokenize(delim);
58  int N = tok->GetEntries();
59 
60  for (int i=0;i<N;++i)
61  {
62  TString st = ((TObjString*)tok->At(i))->String();
63  st.ReplaceAll("\t","");
64  st = st.Strip(TString::kBoth);
65  if (st != "") toks.push_back(st);
66  }
67 
68  return toks.size();
69 }
Int_t i
Definition: run_full.C:25
TLorentzVector s
Definition: Pnd2DStar.C:50

Member Data Documentation

PndAnalysis* PndParticleQATask::fAnalysis
private

Definition at line 65 of file PndParticleQATask.h.

Referenced by Exec(), and Init().

bool PndParticleQATask::fDumpChrg
private

Definition at line 68 of file PndParticleQATask.h.

Referenced by Exec(), Finish(), Init(), and PndParticleQATask().

bool PndParticleQATask::fDumpMc
private

Definition at line 70 of file PndParticleQATask.h.

Referenced by Exec(), Finish(), Init(), and PndParticleQATask().

bool PndParticleQATask::fDumpNeut
private

Definition at line 69 of file PndParticleQATask.h.

Referenced by Exec(), Finish(), Init(), and PndParticleQATask().

int PndParticleQATask::fEvtCount
private

Definition at line 52 of file PndParticleQATask.h.

Referenced by Exec(), and Init().

bool PndParticleQATask::fFastSim
private

Definition at line 67 of file PndParticleQATask.h.

Referenced by Init(), PndParticleQATask(), and SetFastSim().

int PndParticleQATask::fMode
private

Definition at line 71 of file PndParticleQATask.h.

Referenced by Exec(), and PndParticleQATask().

TString PndParticleQATask::fPidArrayNames
private

Definition at line 53 of file PndParticleQATask.h.

Referenced by Init(), PndParticleQATask(), and SetPidArrayNames().

StringList PndParticleQATask::fPidList
private

Definition at line 73 of file PndParticleQATask.h.

Referenced by Exec(), and Init().

RhoTuple* PndParticleQATask::nmc
private

Definition at line 60 of file PndParticleQATask.h.

Referenced by Exec(), Finish(), and Init().

RhoTuple* PndParticleQATask::ntp
private

Definition at line 61 of file PndParticleQATask.h.

Referenced by Exec(), Finish(), and Init().

RhoTuple* PndParticleQATask::ntpn
private

Definition at line 62 of file PndParticleQATask.h.

Referenced by Exec(), Finish(), and Init().


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