FairRoot/PandaRoot
ana_dsdsj2_EvtLoop.C
Go to the documentation of this file.
1 int ana_dsdsj2_EvtLoop(TString fname="dsds_10k.evt.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",900,600);
13  c1->Divide(3,2);
14 
15  // **** access the datastructure holding the particle lists
16  //
17 
18  PndEventReader evl(fname);
19 
20 
21  // **** create and setup some histos for QA plots
22  //
23  TH1F *phimass = new TH1F("phimass","phi cands",100,0.98,1.06);
24  TH1F *pi0mass = new TH1F("pi0mass","pi0 cands",100,0.0,0.3);
25  TH1F *dsmass = new TH1F("dsmass","Ds cands",100,1.868,2.068);
26  TH1F *ds0mass = new TH1F("ds0mass","Ds0 cands",100,2.217,2.417);
27  TH1F *ppmass = new TH1F("ppmass","pbarp cands",100,4.185,4.385);
28 
29  TH1F *nmult=new TH1F("nmult","# neutrals",15,0,15);
30 
31  TH1F *pdiff=new TH1F("pdiff","momentum difference",100,-0.05,0.05);
32 
33  phimass->SetMinimum(0);
34  pi0mass->SetMinimum(0);
35  dsmass->SetMinimum(0);
36  ds0mass->SetMinimum(0);
37  ppmass->SetMinimum(0);
38 
39  if (num==0) num= evl->GetEntries();
40  cout <<"\n####### Processing "<<num <<" events...\n"<<endl;
41 
42  // **** create all the particle lists we'll need for rebuilding the decay tree
43  //
44  TCandList mcCands;
45  TCandList chargedCands, neutralCands, gammaCands, kpCands,kmCands,pipCands,pimCands;
46 
47  TCandList phiCands,pi0Cands,dspCands,dsmCands,ds0pCands,ds0mCands,ppCands;
48 
49  // **** mass selectors for the resonances/composites
50  //
51  TPidMassSelector *phiMSel = new TPidMassSelector("phiSelector" , 1.0195 , 0.03);
52  TPidMassSelector *pi0MSel = new TPidMassSelector("pi0Selector" , 0.135 , 0.04);
53  TPidMassSelector *dsMSel = new TPidMassSelector("dsSelector" , 1.9685 , 0.04);
54 
55  int i1,i2;
56 
57  // **** loop over all _events_
58  //
59 
60  int cnt=0,currev=0;
61 
62  TCandidate *tc;
63 
64  while (evl.GetEvent() && cnt<num)
65  {
66  if ((cnt%100)==0) cout <<"evt "<<cnt<<endl;
67  cnt++;
68 
69  evl.FillList(chargedCands,"Charged");
70  evl.FillList(mcCands,"McTruth");
71 
72  evl.FillList(neutralCands,"Neutral");
73  evl.FillList(kpCands,"KaonVeryLoosePlus");
74  evl.FillList(kmCands,"KaonVeryLooseMinus");
75  evl.FillList(pipCands,"PionVeryLoosePlus");
76  evl.FillList(pimCands,"PionVeryLooseMinus");
77 
78  gammaCands.Cleanup();
79  for (i1=0;i1<neutralCands.GetLength();i1++)
80  {
81  double minang=10;
82  for (i2=0;i2<chargedCands.GetLength();i2++)
83  {
84  double ang=neutralCands[i1].P3().Angle(chargedCands[i2].P3());
85  if (ang<minang) minang=ang;
86  }
87  if (( neutralCands[i1].GetMicroCandidate()->GetEmcNumberOfCrystals()>=3
88  && minang>0.3))
89  gammaCands.Add(neutralCands[i1]);
90  }
91 
92  nmult->Fill(neutralCands.GetLength());
93 
94 
95  // **** now start combining all composits; inbetween plot masses
96  // before using the mass selectors
97  //
98  phiCands.Combine(kpCands,kmCands);
99 
100  //TCandListIterator iterPhi(phiCands);
101  phiCands.Select(phiMSel);
102  for (i1=0;i1<phiCands.GetLength();i1++) phimass->Fill(phiCands[i1].M());
103 
104  dspCands.Combine(phiCands,pipCands);
105  dsmCands.Combine(phiCands,pimCands);
106 
107  for (i1=0;i1<dspCands.GetLength();i1++) dsmass->Fill(dspCands[i1].M());
108  for (i1=0;i1<dsmCands.GetLength();i1++) dsmass->Fill(dsmCands[i1].M());
109  dspCands.Select(dsMSel);
110  dsmCands.Select(dsMSel);
111 
112  pi0Cands.Combine(gammaCands,gammaCands);
113 
114  for (i1=0;i1<pi0Cands.GetLength();i1++) pi0mass->Fill(pi0Cands[i1].M());
115  pi0Cands.Select(pi0MSel);
116 
117  ds0pCands.Combine(dspCands,pi0Cands);
118  ds0mCands.Combine(dsmCands,pi0Cands);
119 
120  for (i1=0;i1<ds0pCands.GetLength();i1++) ds0mass->Fill(ds0pCands[i1].M());
121  for (i1=0;i1<ds0mCands.GetLength();i1++) ds0mass->Fill(ds0mCands[i1].M());
122 
123  ppCands.Combine(ds0pCands,dsmCands);
124  ppCands.CombineAndAppend(ds0mCands,dspCands);
125 
126  for (i1=0;i1<ppCands.GetLength();i1++) ppmass->Fill(ppCands[i1].M());
127 
128  for (i1=0;i1<chargedCands.GetLength();i1++)
129  {
130  int idx=chargedCands[i1].GetMcIdx();
131  if (idx!=-1) pdiff->Fill(chargedCands[i1].P()-mcCands[idx].P());
132  }
133 
134 
135  }
136 
137  // **** plot all that stuff
138  //
139  c1->cd(1);
140  phimass->Draw();
141  c1->cd(2);
142  pi0mass->Draw();
143  c1->cd(3);
144  dsmass->Draw();
145  c1->cd(4);
146  ds0mass->Draw();
147  c1->cd(5);
148  ppmass->Draw();
149  c1->cd(6);
150  pdiff->Draw();
151 
152  timer.Stop();
153  Double_t rtime = timer.RealTime();
154  Double_t ctime = timer.CpuTime();
155 
156  printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
157  return 0;
158 
159 }
160 
161 /*void printTree(TCandidate *tc, int level=0)
162 {
163  int i=0;
164  int nd=tc->NDaughters();
165  if (nd==0) return;
166  cout <<tc->Uid()<<"("<<level<<") -> ";
167  for (i=0;i<nd;i++) cout<<tc->Daughter(i)->Uid()<<" ";
168  cout <<endl;
169  for (i=0;i<nd;i++) printTree(tc->Daughter(i),level+1);
170  if (level==0) cout <<endl;
171 }
172 */
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
basiclibs()
int num[96]
Definition: ranlxd.cxx:381
int idx[MAX]
Definition: autocutx.C:38
Double_t
TStopwatch timer
Definition: hit_dirc.C:51
c1
Definition: plot_dirc.C:35
Double_t ctime
Definition: hit_dirc.C:114
GeV c P
Int_t cnt
Definition: hist-t7.C:106
Double_t rtime
Definition: hit_dirc.C:113
int ana_dsdsj2_EvtLoop(TString fname="dsds_10k.evt.root", int num=0)