FairRoot/PandaRoot
ana_etac_3pi0.C
Go to the documentation of this file.
1 int ana_etac_3pi0(TString fname="etac_3pi0.root",int num=0)
2 {
3  TStopwatch timer;
4  timer.Start();
5 
6  gROOT->LoadMacro("$VMCWORKDIR/gconfig/basiclibs.C");
7  basiclibs();
8 
9  // **** the library is needed in order to use the TCandidate and TCandList etc
10  gSystem->Load("libRho");
11 
12  TCanvas *c1=new TCanvas("c1","c1",600,300);
13  c1->Divide(2,1);
14 
15  // **** access the datastructure holding the particle lists
16  //
17  TFile* f = new TFile(fname.Data());
18  TTree *t=f->Get("pndsim") ;
19 
20  // **** for every event, a TCLonesArray with the candidates is stored in pndsim
21  //
22  TClonesArray *fChrgCands=new TClonesArray("TCandidate");
23  TClonesArray *fNeutCands=new TClonesArray("TCandidate");
24  TClonesArray *fMcCands=new TClonesArray("TCandidate");
25 
26  t->SetBranchAddress("PndChargedCandidates",&fChrgCands);
27  t->SetBranchAddress("PndNeutralCandidates",&fNeutCands);
28  t->SetBranchAddress("PndMcTracks",&fMcCands);
29 
30  TCandidate *tc;
31 
32  // **** create and setup some histos for QA plots
33  //
34  TH1F *pi0mass = new TH1F("pi0mass","pi0 cands",100,0.135-0.03,0.135+0.03);
35  TH1F *ppmass = new TH1F("ppmass","pbarp cands",100,2.979-0.2,2.979+0.2);
36 
37  TH1F *nmult=new TH1F("nmult","# neutrals",15,0,15);
38 
39  TH1F *pdiff=new TH1F("pdiff","momentum difference",100,-0.05,0.05);
40 
41  pi0mass->SetMinimum(0);
42  ppmass->SetMinimum(0);
43 
44  if (num==0) num= t->GetEntriesFast();
45  cout <<"\n####### Processing "<<num <<" events...\n"<<endl;
46 
47  // **** create all the particle lists we'll need for rebuilding the decay tree
48  //
49  TCandList mcCands;
50 
51  TCandList allCands,neutralCands,chargedCands;
52 
53  TCandList pi0pi0Cands,pi0Cands,ppCands;
54 
55  // **** create and configure the selectors/filters we'd like to use later
56  //
57  TPidChargedSelector *chargedSel = new TPidChargedSelector;
58  TPidNeutralSelector *neutralSel = new TPidNeutralSelector;
59 
60  // **** mass selectors for the resonances/composites
61  //
62  TPidMassSelector *pi0MSel = new TPidMassSelector("pi0Selector" , 0.135 , 0.005);
63 
64  int i1,i2;
65 
66  // **** loop over all _events_
67  //
68  for (Int_t j=0; j< num;j++)
69  {
70  if ((j%100)==0) cout <<"evt "<<j<<endl;
71 
72  t->GetEntry(j);
73  TFactory::Instance()->Reset();
74 
75  mcCands.Cleanup();
76  chargedCands.Cleanup();
77  neutralCands.Cleanup();
78 
79  // **** loop over all Candidates and add them to the list allCands
80  //
81 
82  for (i1=0; i1<fChrgCands->GetEntriesFast(); i1++){
83  tc = (TCandidate *)fChrgCands->At(i1);
84  chargedCands.Add(*tc);
85  }
86 
87  for (i1=0; i1<fNeutCands->GetEntriesFast(); i1++){
88  tc = (TCandidate *)fNeutCands->At(i1);
89  neutralCands.Add(*tc);
90  }
91 
92  for (i1=0; i1<fMcCands->GetEntriesFast(); i1++){
93  tc = (TCandidate *)fMcCands->At(i1);
94  mcCands.Add(*tc);
95  }
96 
97 
98  // **** select all the basic list
99  //
100 
101  //cout <<"c:"<<chargedCands.GetLength()<<" n:"<<neutralCands.GetLength()<<endl;
102 
103 
104  pi0Cands.Combine(neutralCands,neutralCands);
105 
106  TCandListIterator iterPi0(pi0Cands);
107  while (tc=iterPi0.Next()) pi0mass->Fill(tc->M());
108  //pi0Cands.Select(pi0MSel);
109 
110  pi0pi0Cands.Combine(pi0Cands,pi0Cands);
111 
112  ppCands.Combine(pi0pi0Cands,pi0Cands);
113 
114  TCandListIterator iterPp(ppCands);
115 
116  while (tc=iterPp.Next())
117  {
118  ppmass->Fill(tc->M());
119  //printTree(tc);
120  }
121  }
122  // **** plot all that stuff
123  //
124  c1->cd(1);
125  pi0mass->Draw();
126  c1->cd(2);
127  ppmass->Draw();
128 
129 
130  timer.Stop();
131  Double_t rtime = timer.RealTime();
132  Double_t ctime = timer.CpuTime();
133 
134  printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
135 
136  return 0;
137 }
138 
139 /*void printTree(TCandidate *tc, int level=0)
140 {
141  int i=0;
142  int nd=tc->NDaughters();
143  if (nd==0) return;
144  cout <<tc->Uid()<<"("<<level<<") -> ";
145  for (i=0;i<nd;i++) cout<<tc->Daughter(i)->Uid()<<" ";
146  cout <<endl;
147  for (i=0;i<nd;i++) printTree(tc->Daughter(i),level+1);
148  if (level==0) cout <<endl;
149 }
150 */
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
basiclibs()
int num[96]
Definition: ranlxd.cxx:381
TClonesArray * fMcCands
Definition: poormantracks.C:26
Double_t
TStopwatch timer
Definition: hit_dirc.C:51
TFile * f
Definition: bump_analys.C:12
c1
Definition: plot_dirc.C:35
Double_t ctime
Definition: hit_dirc.C:114
TTree * t
Definition: bump_analys.C:13
Double_t rtime
Definition: hit_dirc.C:113
int ana_etac_3pi0(TString fname="etac_3pi0.root", int num=0)
Definition: ana_etac_3pi0.C:1