FairRoot/PandaRoot
anadigi.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("../data/mvddpm6GeV.root");
19  std::string inFile = namecreator.GetSimFileName(false);
20  std::string digiFile = namecreator.GetDigiFileName(false);
21  std::string parfile = "../data/mvddpm6GeV_digipar.root";
23  picture.ReplaceAll(".root",".ps");
24 
25  TFile* f = new TFile(inFile.c_str()); // the sim file you want to analyse
26  TTree *t=(TTree *) f->Get("pndsim") ;
27  t->AddFriend("pndsim",digiFile.c_str()); // the digi file
28 
29  TClonesArray* mc_array=new TClonesArray("PndSdsMCPoint");
30  t->SetBranchAddress("MVDPoint",&mc_array);//Branch names
31 
32  TClonesArray* digiPixel_array=new TClonesArray("PndSdsDigiPixel");
33  t->SetBranchAddress("MVDPixelDigis",&digiPixel_array);//Branch names
34 
35  TClonesArray* digiStrip_array=new TClonesArray("PndSdsDigiStrip");
36  t->SetBranchAddress("MVDStripDigis",&digiStrip_array);//Branch names
37 
38  TGeoManager *geoMan = (TGeoManager*) gDirectory->Get("FAIRGeom");
39 
40 
41  // --------- HISTOS ---------
42  TH2D* hisxy = new TH2D("hisxy","",400,-15.,15.,400,-15.,15.);
43  hisxy->SetTitle("MVD MC Point, xy view;x / cm;y / cm");
44 
45  TH2D* hisrz = new TH2D("hisrz","",400,-20.,20.,400,-15.,25.);
46  hisrz->SetTitle("MVD MC Point, rz view;z / cm;r/ cm");
47 
48  TH1D* hisde = new TH1D("hisde","MVD MC Points, Energyloss",100,0.,0.002);
49 
50  TH1D* hismom = new TH1D("hismom","MVD MC Points, momentum",100,0.,1.5);
51 
52  int n = 100; int low = 0;
53 
54  TH1I* hisPixelCol = new TH1I("hispixelcol","Pixel column channel number on FE",n,low,low+n);
55 
56  TH1I* hisPixelRow = new TH1I("hispixelrow","Pixel row channel number on FE",n,low,low+n);
57 
58  TH1I* hisPixelFE = new TH1I("hispixelfe","Pixel FE number",n,low,low+n);
59 
60  TH1I* hisCol = new TH1I("hiscol","column number",1200,0,1200);
61 
62  TH1I* hisRow = new TH1I("hisrow","row number",1200,0,1200);
63 
64  TH1D* hisPixelCharge = new TH1D("hispixelcharge","Pixel Charge content",100,0.,1e5);
65 
66  TH2I* hisStripTop = new TH2I("hisstriptop","Strip Top channel&fe numbers",20,0,20,130,0,130);
67 
68  TH2I* hisStripBot = new TH2I("hisstripbot","Strip Bot channel&fe numbers",20,0,20,130,0,130);
69 
70  TH1I* hisStripStrip = new TH1I("hisstripstrip","Strip numbers",15*128,0,15*128);
71 
72  TH1D* hisStripCharge = new TH1D("hisstripcharge","Strip Charge content",100,0.,1e5);
73 
74  TH1D* hisStripChargeTop = new TH1D("hisstripchargetop","Strip Charge content",100,0.,1e5);
75  hisStripChargeTop->SetLineColor(kBlue);
76 
77  TH1D* hisStripChargeBot = new TH1D("hisstripchargebot","Strip Charge content",100,0.,1e5);
78 
79  TH1F* fHChgDiff = new TH1F("hchgdiff","#color[2]{StripMC}, #color[6]{PixelMC},\
80  #color[4]{StripNoise}, #color[30]{PixelNoise}, #color[1]{All};C/e^{-};",150,0.,1e4);
81  TH1F* fHChgMC = new TH1F("hchgmc",";#DeltaC/e^{-} MC;",150,0.,1e4);
82  TH1F* fHChgFake = new TH1F("hchgfake",";#DeltaC/e^{-} fake;",150,0.,1e4);
83  TH1F* fHChgMCPix = new TH1F("hchgmcPix",";#DeltaC/e^{-} MC;",150,0.,1e4);
84  TH1F* fHChgFakePix = new TH1F("hchgfakePix",";#DeltaC/e^{-} fake;",150,0.,1e4);
85 
86  hisStripChargeBot->SetLineColor(kRed);
87  // --------- HISTOS ---------
88 
89 
90  TVector3 vecmc, mommc;
92  TVector2 locals, localmc, localdiff;
93  int col, row, fe;
94  double x,y;
95 
96  TFile* parDB = new TFile(parfile.c_str());
97  PndMvdStripDigiPar* par = (PndMvdStripDigiPar*)gROOT->FindObject("MVDStripDigiParRect");
98  PndMvdCalcFePixel pixelcalc(100, 100, 10);
99 
100  int nrFeChannels=par->GetNrFECh();
101  int nrStrips=par->GetNrTopFE()*nrFeChannels;
102 
103  for (Int_t j=0; j<nEvents && j<t->GetEntriesFast(); j++)
104  {
105  t->GetEntry(j);
106  if(verbose) cout<<"Event No "<<j<<endl;
107 
108  // ----- MC Points -----
109  for (Int_t i=0; i<mc_array->GetEntriesFast(); i++)
110  {
111  if(verbose) cout<<"Point No "<<i<<endl;
112  PndSdsMCPoint *point=(PndSdsMCPoint*)mc_array->At(i);
113  vecmc.SetXYZ(point->GetX(),point->GetY(),point->GetZ());
114  mommc.SetXYZ(point->GetPx(),point->GetPy(),point->GetPz());
115  hisxy->Fill(vecmc.x(),vecmc.y());
116  if(vecmc.y() > 0.) hisrz->Fill(vecmc.z(),vecmc.Perp());
117  else hisrz->Fill(vecmc.z(),-1.*vecmc.Perp());
118  hisde->Fill(point->GetEnergyLoss());
119  hismom->Fill(mommc.Mag());
120  }
121 
122  // ----- PIXEL DIGIS -----
123  for (Int_t i=0; i<digiPixel_array->GetEntriesFast(); i++)
124  {
125  PndSdsDigiPixel *pixeldigi = digiPixel_array->At(i);
126  fe = pixeldigi->GetFE();
127  col = pixeldigi->GetPixelColumn();
128  row = pixeldigi->GetPixelRow();
129  hisPixelCol->Fill(col);
130  hisPixelRow->Fill(row);
131  hisPixelFE->Fill(fe);
132  hisPixelCharge->Fill(pixeldigi->GetCharge());
133  pixelcalc.CalcSensorColRow(col,row,fe);
134  hisCol->Fill(col);
135  hisRow->Fill(row);
136  fHChgDiff->Fill(pixeldigi->GetCharge());
137  if( pixeldigi->GetIndex() == -1 ) fHChgFakePix->Fill(pixeldigi->GetCharge());
138  else fHChgMCPix->Fill(pixeldigi->GetCharge());
139  }
140 
141  // ----- STRIP DIGIS -----
142  for (Int_t i=0; i<digiStrip_array->GetEntriesFast(); i++)
143  {
144  PndSdsDigiStrip *stripdigi = digiStrip_array->At(i);
145  fe = stripdigi->GetFE();
146  col = stripdigi->GetChannel();
147  int strip = fe * nrFeChannels + col;
148  hisStripStrip->Fill(strip);
149  hisStripCharge->Fill(stripdigi->GetCharge());
150  if (strip <= nrStrips)
151  {
152  hisStripTop->Fill(fe,col);
153  hisStripChargeTop->Fill(stripdigi->GetCharge());
154  } else {
155  hisStripBot->Fill(fe,col);
156  hisStripChargeBot->Fill(stripdigi->GetCharge());
157  }
158  fHChgDiff->Fill(stripdigi->GetCharge());
159  if( stripdigi->GetIndex() == -1 ) fHChgFake->Fill(stripdigi->GetCharge());
160  else fHChgMC->Fill(stripdigi->GetCharge());
161  }
162 
163  }// end for j (events)
164 
165 
166 Int_t a = 2, b = 2, res=475;
167 TCanvas* can1 = new TCanvas("MvdTestPlot","MCHit view in MVD",0,0,a*res,b*res);
168 can1->Divide(a,b);
169 TPad* mypad=0;
170 
171 can1->cd(1);
172 mypad=gPad;
173 mypad.Divide(2,2);
174 mypad->cd(1);DrawNice2DHisto(hisxy);
175 mypad->cd(2);DrawNice2DHisto(hisrz);
176 mypad->cd(3);gPad->SetLogy();hisde->DrawCopy();
177 mypad->cd(4);hismom->DrawCopy();
178 
179 can1->cd(2);
180 gPad->SetLogy();
181 fHChgDiff->DrawCopy();
182 fHChgMC->SetLineColor(kRed);
183 fHChgMC->DrawCopy("same");
184 fHChgFake->SetLineColor(kBlue);
185 fHChgFake->DrawCopy("same");
186 fHChgMCPix->SetLineColor(6);
187 fHChgMCPix->DrawCopy("same");
188 fHChgFakePix->SetLineColor(30);
189 fHChgFakePix->DrawCopy("same");
190 
191 
192 can1->cd(3);
193 mypad=gPad;
194 mypad.Divide(2,2);
195 mypad->cd(1);DrawNice2DHisto(hisStripTop);
196 mypad->cd(2);DrawNice2DHisto(hisStripBot);
197 mypad->cd(3);hisStripStrip->DrawCopy();
198 mypad->cd(4);gPad->SetLogy();
199 hisStripCharge->DrawCopy();
200 hisStripChargeTop->DrawCopy("sames");
201 hisStripChargeBot->DrawCopy("sames");
202 can1->Update();mypad=(TPad*)gPad; BetterStatBox(mypad);
203 
204 can1->cd(4);
205 mypad=gPad;
206 mypad.Divide(2,3);
207 mypad->cd(1);hisPixelCol->DrawCopy();
208 mypad->cd(2);hisPixelRow->DrawCopy();
209 mypad->cd(3);hisCol->DrawCopy();
210 mypad->cd(4);hisRow->DrawCopy();
211 mypad->cd(5);hisPixelFE->DrawCopy();
212 mypad->cd(6);gPad->SetLogy();hisPixelCharge->DrawCopy();
213 
214 // can1->Update();
215 can1->Print(picture.Data());
216 
217 
218  // ----- Finish -------------------------------------------------------
219  timer.Stop();
220  Double_t rtime = timer.RealTime();
221  Double_t ctime = timer.CpuTime();
222  cout << endl << endl;
223  cout << "Macro finished succesfully." << endl;
224  cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
225  cout << endl;
226  // ------------------------------------------------------------------------
227 
228 }
int row
Definition: anaLmdDigi.C:67
Int_t GetPixelRow() const
TH1D * hisde
Definition: anaLmdDigi.C:44
Int_t res
Definition: anadigi.C:166
Int_t i
Definition: run_full.C:25
int low
Definition: anaMvdDigi.C:51
TTree * b
#define verbose
Int_t GetIndex(int i=0) const
Definition: PndSdsDigi.h:63
TH1F * fHChgMCPix
Definition: anadigi.C:83
Int_t GetPixelColumn() const
TGeoManager * geoMan
TH1I * hisCol
Definition: anaMvdDigi.C:59
int col
Definition: anaLmdDigi.C:67
Class for digitised strip hits.
std::string GetDigiFileName(std::string addon="", bool cut=false)
int n
DrawNice2DHisto(hisxy)
Double_t par[3]
TString digiFile
Definition: bump_emc.C:20
Double_t GetCharge() const
Definition: PndSdsDigi.h:60
TVector2 localdiff
Definition: anaLmdDigi.C:66
TVector3 mommc
Definition: anaLmdDigi.C:64
TClonesArray * mc_array
Definition: anaLmdCluster.C:25
TH1I * hisPixelCol
Definition: anaMvdDigi.C:53
Int_t GetFE() const
Definition: PndSdsDigi.h:57
int nrStrips
Definition: anaLmdDigi.C:76
TH1F * fHChgMC
Definition: anadigi.C:81
std::string GetSimFileName(std::string addon="", bool cut=false)
TH1D * hisStripChargeBot
Definition: anaLmdDigi.C:60
TString inFile
Definition: hit_dirc.C:8
Int_t a
Definition: anaLmdDigi.C:126
int strip
Definition: anaMvdDigi.C:135
TFile * parDB
Definition: anaLmdDigi.C:70
TVector2 localmc
Definition: anaLmdDigi.C:66
A simple class which adds the corresponding file extensions to a given base class.
Double_t
TH1F * fHChgFake
Definition: anadigi.C:82
TVector2 locals
Definition: anaLmdDigi.C:66
Int_t nEvents
Definition: hit_dirc.C:11
BetterStatBox(mypad)
TStopwatch timer
Definition: hit_dirc.C:51
int nrFeChannels
Definition: anaLmdDigi.C:75
PndMvdCalcFePixel pixelcalc(76, 84, 10)
TH1D * hismom
Definition: anaMvdDigi.C:49
TFile * f
Definition: bump_analys.C:12
TH1D * hisStripChargeTop
Definition: anaLmdDigi.C:58
TH1F * fHChgFakePix
Definition: anadigi.C:84
TString picture
Definition: anaMvdDigi.C:21
TPad * mypad
TH1I * hisPixelFE
Definition: anaMvdDigi.C:57
TVector3 vecmc
Definition: anaLmdCluster.C:52
TH1D * hisStripCharge
Definition: anaLmdDigi.C:56
TH2D * hisxy
Definition: anaLmdDigi.C:38
PndFileNameCreator namecreator("../data/Lars/MvdDtsSim.root")
Double_t ctime
Definition: hit_dirc.C:114
TH2D * hisrz
Definition: anaLmdDigi.C:41
TH1I * hisStripStrip
Definition: anaLmdDigi.C:53
TH1I * hisPixelRow
Definition: anaMvdDigi.C:55
TClonesArray * digiPixel_array
Definition: anaMvdDigi.C:31
Double_t tmpx
Definition: anaLmdDigi.C:65
Double_t x
TH1F * fHChgDiff
Definition: anadigi.C:79
int fe
Definition: anaLmdDigi.C:67
std::string parfile
Definition: anaLmdDigi.C:20
TTree * t
Definition: bump_analys.C:13
TClonesArray * digiStrip_array
Definition: anaLmdDigi.C:32
Data class to store the digi output of a pixel module.
Double_t y
Int_t GetChannel() const
TCanvas * can1
Double_t tmpy
Definition: anaLmdDigi.C:65
TH2I * hisStripBot
Definition: anaLmdDigi.C:50
Double_t rtime
Definition: hit_dirc.C:113
TH1I * hisRow
Definition: anaMvdDigi.C:61
LoadPandaStyle()
Double_t tmpz
Definition: anaLmdDigi.C:65
TH2I * hisStripTop
Definition: anaLmdDigi.C:48
PndSdsMCPoint * point
Definition: anaLmdCluster.C:72
TH1D * hisPixelCharge
Definition: anaMvdDigi.C:63