FairRoot/PandaRoot
run_ana_llbar_evtgen.C
Go to the documentation of this file.
1 // root macro to analyze the clusterization output
2 {
3  int nEvents = 10000;
4  bool verbose = false;
5 
6  // ----- Load libraries ------------------------------------------------
7  gROOT->LoadMacro("$VMCWORKDIR/gconfig/rootlogon.C");
8  rootlogon();
9  gROOT->LoadMacro("../Tools.C");
11 
12  // ----- Timer --------------------------------------------------------
13  TStopwatch timer;
14  timer.Start();
15  // ------------------------------------------------------------------------
16 
17 
18 // PndFileNameCreator namecreator("sim_complete.root");
19 // std::string inFile = namecreator.GetSimFileName(false);
20 // std::string digiFile = namecreator.GetDigiFileName(false);
21 // std::string parfile = "../data/mvddpm6GeV_digipar.root";
22 // TString picture = namecreator.GetDigiFileName(false);
23 
24  std::string inFile = "llbar_sim_evtgen.root";
25  std::string digiFile = "llbar_digi_evtgen.root";
26  std::string recoFile = "llbar_reco_evtgen.root";
27  TString picture = "digi_complete.root";
28 
29  picture.ReplaceAll(".root",".ps");
30 
31  TFile* f = new TFile(inFile.c_str()); // the sim file you want to analyse
32  TTree *t=(TTree *) f->Get("pndsim") ;
33  t->AddFriend("pndsim",digiFile.c_str()); // the digi file
34  t->AddFriend("pndsim",recoFile.c_str()); // the reco file
35 
36  TClonesArray* mc_array=new TClonesArray("PndSdsMCPoint");
37  t->SetBranchAddress("MVDPoint",&mc_array);//Branch names
38 
39  TClonesArray* digiPixel_array=new TClonesArray("PndSdsDigiPixel");
40  t->SetBranchAddress("MVDPixelDigis",&digiPixel_array);//Branch names
41 
42  TClonesArray* digiStrip_array=new TClonesArray("PndSdsDigiStrip");
43  t->SetBranchAddress("MVDStripDigis", &digiStrip_array);//Branch names
44 
45  // TClonesArray* recoPixel_array=new TClonesArray("PndSdsDigiPixel");
46  // t->SetBranchAddress("MVDDigisCorr",&recoPixel_array);//Branch names
47 
48 // TClonesArray* digiStrip_array=new TClonesArray("PndSdsDigiStrip");
49 // t->SetBranchAddress("MVDStripDigis",&digiStrip_array);//Branch names
50 
51 // TGeoManager *geoMan = (TGeoManager*) gDirectory->Get("FAIRGeom");
52 
53 
54  // --------- HISTOS ---------
55 
56  TH1I* hNumberTrackPointsLambda = new TH1I("hNumberTrackPointsLambda","", 10, -0.5, 9.5);
57  TH1I* hNumberTrackPointsLambdaBar = new TH1I("hNumberTrackPointsLambdaBar","", 10, -0.5, 9.5);
58 
59 
60 /* TH2D* hisxy = new TH2D("hisxy","",400,-15.,15.,400,-15.,15.);
61  hisxy->SetTitle("MVD MC Point, xy view;x / cm;y / cm");
62 
63  TH2D* hisrz = new TH2D("hisrz","",400,-20.,20.,400,-15.,25.);
64  hisrz->SetTitle("MVD MC Point, rz view;z / cm;r/ cm");
65 
66  TH1D* hisde = new TH1D("hisde","MVD MC Points, Energyloss",100,0.,0.002);
67 
68  TH1D* hismom = new TH1D("hismom","MVD MC Points, momentum",100,0.,1.5);
69 
70  int n = 100; int low = 0;
71 
72  TH1I* hisPixelCol = new TH1I("hispixelcol","Pixel column channel number on FE",n,low,low+n);
73 
74  TH1I* hisPixelRow = new TH1I("hispixelrow","Pixel row channel number on FE",n,low,low+n);
75 
76  TH1I* hisPixelFE = new TH1I("hispixelfe","Pixel FE number",n,low,low+n);
77 
78  TH1I* hisCol = new TH1I("hiscol","column number",1200,0,1200);
79 
80  TH1I* hisRow = new TH1I("hisrow","row number",1200,0,1200);
81 
82  TH1D* hisPixelCharge = new TH1D("hispixelcharge","Pixel Charge content",100,0.,1e5);
83 
84  TH2I* hisStripTop = new TH2I("hisstriptop","Strip Top channel&fe numbers",20,0,20,130,0,130);
85 
86  TH2I* hisStripBot = new TH2I("hisstripbot","Strip Bot channel&fe numbers",20,0,20,130,0,130);
87 
88  TH1I* hisStripStrip = new TH1I("hisstripstrip","Strip numbers",15*128,0,15*128);
89 
90  TH1D* hisStripCharge = new TH1D("hisstripcharge","Strip Charge content",100,0.,1e5);
91 
92  TH1D* hisStripChargeTop = new TH1D("hisstripchargetop","Strip Charge content",100,0.,1e5);
93  hisStripChargeTop->SetLineColor(kBlue);
94 
95  TH1D* hisStripChargeBot = new TH1D("hisstripchargebot","Strip Charge content",100,0.,1e5);
96 
97  TH2F* hisDiffTimeWalk = new TH2F("hisDiffTimeWalk","Differenz digiTimeWalk and RecoTimeWalk", 400, 0.,200,400,0.,200 );
98 
99  // TH1F* fHChgDiff = new TH1F("hchgdiff","#color[2]{StripMC}, #color[6]{PixelMC},\#color[4]{StripNoise}, #color[30]{PixelNoise}, #color[1]{All};C/e^{-}; "
100 */
101  //----- AnaTask -----
102 
103  // PndMvdEventAnaTask* anatask = new PndMvdEventAnaTask();
104  // fRun->AddTask(anatask);",150,0.,1e4);
105  TH1F* fHChgMC = new TH1F("hchgmc",";#DeltaC/e^{-} MC;",150,0.,1e4);
106  TH1F* fHChgFake = new TH1F("hchgfake",";#DeltaC/e^{-} fake;",150,0.,1e4);
107  TH1F* fHChgMCPix = new TH1F("hchgmcPix",";#DeltaC/e^{-} MC;",150,0.,1e4);
108  TH1F* fHChgFakePix = new TH1F("hchgfakePix",";#DeltaC/e^{-} fake;",150,0.,1e4);
109 
110  hisStripChargeBot->SetLineColor(kRed);
111  // --------- HISTOS ---------
112 
113 
114  TVector3 vecmc, mommc;
117  int col, row, fe;
118  double x,y;
119 
120 // TFile* parDB = new TFile(parfile.c_str());
121 // PndMvdStripDigiPar* par = (PndMvdStripDigiPar*)gROOT->FindObject("MVDStripDigiParRect");
122 // PndMvdCalcFePixel pixelcalc(100, 100, 10);
123 
124 // int nrFeChannels=par->GetNrFECh();
125 // int nrStrips=par->GetNrTopFE()*nrFeChannels;
126 
127  for (Int_t j=0; j<nEvents && j<t->GetEntriesFast(); j++)
128  {
129  t->GetEntry(j);
130  if(verbose) cout<<"Event No "<<j<<endl;
131 
132  // ----- MC Points -----
133  for (Int_t i=0; i<mc_array->GetEntriesFast(); i++)
134  {
135  if(verbose) cout<<"Point No "<<i<<endl;
136  PndSdsMCPoint *point=(PndSdsMCPoint*)mc_array->At(i);
137  // vecmc.SetXYZ(point->GetX(),point->GetY(),point->GetZ());
138  // mommc.SetXYZ(point->GetPx(),point->GetPy(),point->GetPz());
139  // hisxy->Fill(vecmc.x(),vecmc.y());
140  // if(vecmc.y() > 0.) hisrz->Fill(vecmc.z(),vecmc.Perp());
141  // else hisrz->Fill(vecmc.z(),-1.*vecmc.Perp());
142  // hisde->Fill(point->GetEnergyLoss());
143  // hismom->Fill(mommc.Mag());
144  }
145 
146  // ----- PIXEL DIGIS -----
147  for (Int_t i=0; i<digiPixel_array->GetEntriesFast(); i++)
148  {
149  PndSdsDigiPixel *pixeldigi = (PndSdsDigiPixel*) digiPixel_array->At(i);
150 // PndSdsDigiPixel *pixelreco = (PndSdsDigiPixel*) recoPixel_array->At(i);
151  fe = pixeldigi->GetFE();
152  col = pixeldigi->GetPixelColumn();
153  row = pixeldigi->GetPixelRow();
154  // hisPixelCol->Fill(col);
155 // hisPixelRow->Fill(row);
156 // hisPixelFE->Fill(fe);
157  // hisPixelCharge->Fill(pixeldigi->GetCharge());
158  // pixelcalc.CalcSensorColRow(col,row,fe);
159  // hisCol->Fill(col);
160  // hisRow->Fill(row);
161  // hisDiffTimeWalk->Fill(pixelreco->GetTimeWalk(),pixeldigi->GetTimeWalk());
162 
163  // printf("reco TimeWalk %d - digi TimeWalk %d \n",pixelreco->GetTimeWalk(),pixeldigi->GetTimeWalk());
164  // fHChgDiff->Fill(pixeldigi->GetCharge());
165  // if( pixeldigi->GetIndex() == -1 ) fH//
166  // R. Kliemt
167  // ----- STRIP DIGIS -----
168  // for (Int_t i=0; i<digiStrip_array->GetEntriesFast(); i++)
169  // {
170  // PndSdsDigiStrip *stripdigi = digiStrip_array->At(i);
171  // fe = stripdigi->GetFE();
172  // col = stripdigi->GetChannel();
173  // int strip = fe * nrFeChannels + col;
174  // hisStripStrip->Fill(strip);
175  // hisStripCharge->Fill(stripdigi->GetCharge());
176  // if (strip <= nrStrips)
177  // {
178  // hisStripTop->Fill(fe,col);
179  // hisStripChargeTop->Fill(stripdigi->GetCharge());
180  // } else {
181  // hisStripBot->Fill(fe,col);
182  // hisStripChargeBot->Fill(stripdigi->GetCharge());
183  // }
184  // fHChgDiff->Fill(stripdigi->GetCharge());
185  // if( stripdigi->GetIndex() == -1 ) fHChgFake->Fill(stripdigi->GetCharge());
186  // else fHChgMC->Fill(stripdigi->GetCharge());
187  // }ChgFakePix->Fill(pixeldigi->GetCharge());
188  // else fHChgMCPix->Fill(pixeldigi->GetCharge());
189 // }
190 
191  // ----- STRIP DIGIS -----
192  for (Int_t i=0; i<digiStrip_array->GetEntriesFast(); i++)
193  {
194  PndSdsDigiStrip *stripdigi = digiStrip_array->At(i);
195 // fe = stripdigi->GetFE();
196 // col = stripdigi->GetChannel();
197 // int strip = fe * nrFeChannels + col;
198 // hisStripStrip->Fill(strip);
199 // hisStripCharge->Fill(stripdigi->GetCharge());
200 // if (strip <= nrStrips)
201 // {
202 // hisStripTop->Fill(fe,col);
203 // hisStripChargeTop->Fill(stripdigi->GetCharge());
204 // } else {
205 // hisStripBot->Fill(fe,col);
206 // hisStripChargeBot->Fill(stripdigi->GetCharge());
207 // }
208 // fHChgDiff->Fill(stripdigi->GetCharge());
209 // if( stripdigi->GetIndex() == -1 ) fHChgFake->Fill(stripdigi->GetCharge());
210 // else fHChgMC->Fill(stripdigi->GetCharge());
211  }
212 
213  }// end for j (events)
214  gROOT->SetStyle("Plain");
215 
216 // gStyle->SetTextFont(22);
217 // gStyle->SetLabelFont(22,"x");
218 // gStyle->SetLabelFont(22,"y");
219 // gStyle->SetLabelFont(22,"z");
220 
221 Int_t a = 2, b = 2, res=475;
222 TCanvas* can1 = new TCanvas("MvdTestPlot","MCHit view in MVD",0,0,a*res,b*res);
223 can1->Divide(a,b);
224 TPad* mypad=0;
225 
226 //can1->cd(1);
227 //mypad=gPad;
228 //mypad.Divide(2,2);
229 //mypad->cd(1);DrawNice2DHisto(hisxy);
230 //mypad->cd(2);DrawNice2DHisto(hisrz);
231 //mypad->cd(3);gPad->SetLogy();hisde->DrawCopy();
232 //mypad->cd(4);hismom->DrawCopy();
233 
234 can1->cd(2);
235 //hisDiffTimeWalk->DrawCopy();
236 //DrawNice2DHisto(hisDiffTimeWalk);
237 //gPad->SetLogy();
239 //fHChgMC->SetLineColor(kRed);
240 //fHChgMC->DrawCopy("same");
241 //fHChgFake->SetLineColor(kBlue);
242 //fHChgFake->DrawCopy("same");
243 //fHChgMCPix->SetLineColor(6);
244 //fHChgMCPix->DrawCopy("same");
245 //fHChgFakePix->SetLineColor(30);
246 //fHChgFakePix->DrawCopy("same");
247 
248 
249 //can1->cd(3);
250 //mypad=gPad;
251 //mypad.Divide(2,2);
252 //mypad->cd(1);DrawNice2DHisto(hisStripTop);
253 //mypad->cd(2);DrawNice2DHisto(hisStripBot);
254 //mypad->cd(3);hisStripStrip->DrawCopy();
255 //mypad->cd(4);gPad->SetLogy();
256 //hisStripCharge->DrawCopy();
257 //hisStripChargeTop->DrawCopy("sames");
258 //hisStripChargeBot->DrawCopy("sames");
259 //can1->Update();mypad=(TPad*)gPad; BetterStatBox(mypad);
260 
261 //can1->cd(4);
262 //mypad=gPad;
263 //mypad.Divide(2,3);
264 //mypad->cd(1);hisPixelCol->DrawCopy();
265 //mypad->cd(2);hisPixelRow->DrawCopy();
266 //mypad->cd(3);hisCol->DrawCopy();
267 //mypad->cd(4);hisRow->DrawCopy();
268 //mypad->cd(5);hisPixelFE->DrawCopy();
269 //mypad->cd(6);gPad->SetLogy();hisPixelCharge->DrawCopy();
270 
271 // can1->Update();
272 can1->Print(picture.Data());
273 
274 
275  // ----- Finish -------------------------------------------------------
276  timer.Stop();
277  Double_t rtime = timer.RealTime();
278  Double_t ctime = timer.CpuTime();
279  cout << endl << endl;
280  cout << "Macro finished succesfully." << endl;
281  cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
282  cout << endl;
283  // ------------------------------------------------------------------------
284 
285 }
Int_t GetPixelRow() const
TH1F * fHChgFakePix
TVector2 localmc
Int_t res
Definition: anadigi.C:166
Double_t tmpz
Int_t i
Definition: run_full.C:25
TTree * b
TStopwatch timer
Int_t GetPixelColumn() const
Class for digitised strip hits.
TClonesArray * mc_array
TVector3 vecmc
Int_t GetFE() const
Definition: PndSdsDigi.h:57
Double_t tmpx
TVector2 locals
TClonesArray * digiStrip_array
TH1D * hisStripChargeBot
Definition: anaLmdDigi.C:60
Double_t tmpy
TVector2 localdiff
Int_t a
Definition: anaLmdDigi.C:126
bool verbose
Double_t
Int_t nEvents
Definition: hit_dirc.C:11
TH1F * fHChgMC
double x
TClonesArray * point
Definition: anaLmdDigi.C:29
TH1F * fHChgMCPix
TVector3 mommc
TPad * mypad
TTree * t
LoadPandaStyle()
TH1F * fHChgFake
double y
Double_t ctime
Definition: hit_dirc.C:114
TH1I * hNumberTrackPointsLambda
std::string recoFile
std::string inFile
TH1I * hNumberTrackPointsLambdaBar
Data class to store the digi output of a pixel module.
TFile * f
std::string digiFile
TCanvas * can1
Double_t rtime
Definition: hit_dirc.C:113
TClonesArray * digiPixel_array
TString picture