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