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 }
double y
Definition: anadigi.C:94
Int_t GetPixelRow() const
TH1D * hisStripChargeBot
Definition: anadigi.C:77
LoadPandaStyle()
int n
Definition: anadigi.C:52
int nrFeChannels
Definition: anadigi.C:100
DrawNice2DHisto(hisxy)
BetterStatBox(mypad)
Int_t res
Definition: anadigi.C:166
Int_t i
Definition: run_full.C:25
int nrStrips
Definition: anadigi.C:101
Int_t GetIndex(int i=0) const
Definition: PndSdsDigi.h:63
TH1F * fHChgMCPix
Definition: anadigi.C:83
Int_t GetPixelColumn() const
TString picture
Definition: anadigi.C:22
TH2D * hisxy
Definition: anadigi.C:42
Class for digitised strip hits.
std::string GetDigiFileName(std::string addon="", bool cut=false)
Double_t GetCharge() const
Definition: PndSdsDigi.h:60
TH2I * hisStripTop
Definition: anadigi.C:66
TH1I * hisStripStrip
Definition: anadigi.C:70
TFile * parDB
Definition: anadigi.C:96
Int_t GetFE() const
Definition: PndSdsDigi.h:57
TStopwatch timer
Definition: anadigi.C:13
TH1F * fHChgMC
Definition: anadigi.C:81
std::string GetSimFileName(std::string addon="", bool cut=false)
TH1I * hisPixelFE
Definition: anadigi.C:58
TVector3 vecmc
Definition: anadigi.C:90
int low
Definition: anadigi.C:52
std::string digiFile
Definition: anadigi.C:20
TH1D * hisStripChargeTop
Definition: anadigi.C:74
std::string parfile
Definition: anadigi.C:21
TVector3 mommc
Definition: anadigi.C:90
TH2D * hisrz
Definition: anadigi.C:45
TVector2 localmc
Definition: anadigi.C:92
double x
Definition: anadigi.C:94
TClonesArray * digiStrip_array
Definition: anadigi.C:35
Double_t ctime
Definition: anadigi.C:221
PndMvdStripDigiPar * par
Definition: anadigi.C:97
A simple class which adds the corresponding file extensions to a given base class.
Double_t
TH1D * hisStripCharge
Definition: anadigi.C:72
TH1F * fHChgFake
Definition: anadigi.C:82
int row
Definition: anadigi.C:93
Int_t nEvents
Definition: hit_dirc.C:11
Double_t tmpy
Definition: anadigi.C:91
TClonesArray * point
Definition: anaLmdDigi.C:29
TH1D * hisde
Definition: anadigi.C:48
Double_t rtime
Definition: anadigi.C:220
TH1F * fHChgFakePix
Definition: anadigi.C:84
TH1I * hisPixelRow
Definition: anadigi.C:56
PndFileNameCreator namecreator("../data/mvddpm6GeV.root")
TCanvas * can1
Definition: anadigi.C:167
Double_t tmpx
Definition: anadigi.C:91
TGeoManager * geoMan
Definition: anadigi.C:38
TH1D * hisPixelCharge
Definition: anadigi.C:64
TTree * t
Definition: anadigi.C:26
TH2I * hisStripBot
Definition: anadigi.C:68
PndMvdCalcFePixel pixelcalc(100, 100, 10)
TH1F * fHChgDiff
Definition: anadigi.C:79
int fe
Definition: anadigi.C:93
TVector2 localdiff
Definition: anadigi.C:92
TH1I * hisCol
Definition: anadigi.C:60
TPad * mypad
Definition: anadigi.C:169
TH1D * hismom
Definition: anadigi.C:50
int col
Definition: anadigi.C:93
TH1I * hisRow
Definition: anadigi.C:62
Data class to store the digi output of a pixel module.
TClonesArray * digiPixel_array
Definition: anadigi.C:32
Int_t GetChannel() const
Int_t b
Definition: anadigi.C:166
bool verbose
Definition: anadigi.C:4
TClonesArray * mc_array
Definition: anadigi.C:29
TH1I * hisPixelCol
Definition: anadigi.C:54
std::string inFile
Definition: anadigi.C:19
Int_t a
Definition: anadigi.C:166
TFile * f
Definition: anadigi.C:25
Double_t tmpz
Definition: anadigi.C:91
TVector2 locals
Definition: anadigi.C:92