FairRoot/PandaRoot
anaLmdDigi.C
Go to the documentation of this file.
1 // root macro to analyze the clusterization output
2 {
3 #include "TCanvas.h"
4  std::cout;
5  int nEvents = 1e4;
6  bool verbose = false;
7 
8  // ----- Load libraries ------------------------------------------------
9  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
10  gROOT->LoadMacro("Tools.C");
11  rootlogon();
12  // gSystem->Load("libLmd");
13 
14  // ----- Timer --------------------------------------------------------
15  TStopwatch timer;
16  timer.Start();
17  // ------------------------------------------------------------------------
18  std::string inFile = "/private/huagen/simdata/Lmd_DPM_elastic_6.2_1.9mrad_5M_1.root";
19  std::string digiFile = "/private/huagen/simdata/Lmd_Digi_DPM_elastic_6.2_1.9mrad_5M_1.root";
20  std::string parfile = "/private/huagen/simdata/LmdParams.root";
21 
22  TFile* Digis = new TFile(digiFile.c_str(),"READ"); // the sim file you want to analyse
23  TTree* tree=(TTree *) Digis->Get("pndsim") ;
24 
25  TFile* MCPoint = new TFile(inFile.c_str(),"READ");
26  TTree* tree2 = (TTree*)MCPoint->Get("pndsim");
27  // tree->AddFriend("pndsim",inFile.c_str()); // the digi file
28 
29  TClonesArray* point=new TClonesArray("PndSdsMCPoint");
30  tree2->SetBranchAddress("LMDPoint",&point);//Branch names
31 
32  TClonesArray* digiStrip_array=new TClonesArray("PndSdsDigiStrip");
33  tree->SetBranchAddress("LMDStripDigis",&digiStrip_array);//Branch names
34 
35 // TGeoManager *geoMan = (TGeoManager*) gDirectory->Get("FAIRGeom");
36 
37  // --------- HISTOS ---------
38  TH2D* hisxy = new TH2D("hisxy","",100,-10.,10.,100,-10.,10.);
39  hisxy->SetTitle("LMD MC Points, X vs Y view;X (cm);X (cm)");
40 
41  TH2D* hisrz = new TH2D("hisrz","",100,1070.,1150.,100,1070.,1150.);
42  hisrz->SetTitle("LMD MC Point, rz view;z / cm;r/ cm");
43 
44  TH1D* hisde = new TH1D("hisde","LMD MC Points, Energyloss",1000,0.,1000);
45  hisde->SetTitle("Lmd MC Energy Loss; X / keV ; Y / count");
46 // TH1D* hismom = new TH1D("hismom","LMD MC Points, momentum",100,3.,10.);
47 
48  TH2I* hisStripTop = new TH2I("StripFront","Strip Front channel & front end numbers",20,0,40,130,0,130);
49  hisStripTop->SetTitle("FE numbers vs Channels counts; X / FE; Y / channel");
50  TH2I* hisStripBot = new TH2I("StripBack","Strip Back channel & front end numbers",20,0,40,130,0,130);
51  hisStripBot->SetTitle("FE numbers vs Channels counts; X / FE; Y / channel");
52 
53  TH1I* hisStripStrip = new TH1I("hisstripstrip","Strip numbers",2330,-10,4650);
54  hisStripStrip->SetTitle("Strips on Front/Back side; X / channels; Y / count");
55 
56  TH1D* hisStripCharge = new TH1D("StripChargeTotal","Strip Charge content",1000,0.,2.5e5);
57 
58  TH1D* hisStripChargeTop = new TH1D("StripChargeFront","Strip Charge content",1000,0.,2.5e5);
59  hisStripChargeTop->SetLineColor(kBlue);
60  TH1D* hisStripChargeBot = new TH1D("StripChargeBack","Strip Charge content",1000,0.,2.5e5);
61  hisStripChargeBot->SetLineColor(kRed);
62 
63  // --------- HISTOS ---------
64  TVector3 vecmc, mommc;
66  TVector2 locals, localmc, localdiff;
67  int col, row, fe;
68  double x,y,X=0,Y=0,Z=0,de=0;
69 
70  TFile* parDB = new TFile(parfile.c_str());
71  PndSdsStripDigiPar* par = (PndSdsStripDigiPar*)gROOT->FindObject("LmdStripDigiParTrap");
72 
73 // Int_t nrFeChannels = par->GetNrFECh();
74 // Int_t nrStrips = par->GetNrFrontFE()*nrFeChannels;
75  int nrFeChannels = 128;//par->GetNrFECh();
76  int nrStrips = 1280;
77  if(verbose) cout<<"the nrFeChannels and Strips are :"<< nrFeChannels<<","<<nrStrips<<endl;
78 
79  for (Int_t j=0; j<nEvents&&j<tree->GetEntriesFast(); j++)
80  {
81  if(verbose) std::cout<< "the number of "<< j <<"event is been processed"<<std::endl;
82  tree->GetEntry(j);
83  tree2->GetEntry(j);
84  if(verbose) cout<<"Event No "<<j<<endl;
85 
86  // ----- MC Points -----
87  for (Int_t i=0; i<point->GetEntriesFast(); i++)
88  {
89  if(verbose) cout<<"Point No "<<i<<endl;
90  PndSdsMCPoint *Mypoint=(PndSdsMCPoint*)point->At(i);
91  X = Mypoint->GetPosition().X();
92  Y = Mypoint->GetPosition().Y();
93  Z = Mypoint->GetPosition().Z();
94  hisxy->Fill(X,Y);
95  de = Mypoint->GetEnergyLoss()*1000000;
96  // de = Mypoint->GetEnergyLoss();
97  hisde->Fill(de);
98  if(verbose) cout<<"the energy loss is "<<de<<endl;
99  }
100 
101  // ----- STRIP DIGIS -----
102  for (Int_t i=0; i<digiStrip_array->GetEntriesFast(); i++)
103  {
104  PndSdsDigiStrip *stripdigi = digiStrip_array->At(i);
105  fe = stripdigi->GetFE();
106  col = stripdigi->GetChannel();
107  // std::cout<<"the fe and channel are:"<<fe<<","<<col<<std::endl;
108 
109  int strip = fe * nrFeChannels + col;
110  hisStripStrip->Fill(strip);
111  hisStripCharge->Fill(stripdigi->GetCharge());
112  // std::cout<<"the strip charge is :"<<stripdigi->GetCharge()<<std::endl;
113 
114  if (strip <= nrStrips)
115  {
116  hisStripTop->Fill(fe,col);
117  hisStripChargeTop->Fill(stripdigi->GetCharge());
118  } else {
119  hisStripBot->Fill(fe,col);
120  hisStripChargeBot->Fill(stripdigi->GetCharge());
121  }
122  }
123 
124  }// end for j (events)
125 
126 Int_t a = 2, b = 3;
127 
128 TCanvas* can1 = new TCanvas("Lmd MC point & Digis Plot","MCHit view in LMD",0,0,2*400,2*400);
129 can1->Divide(a,b);
130 TPad* mypad=0;
131 
132 can1->cd(1);
133 mypad=gPad;
134 //mypad.Divide(2,1);
135 mypad->cd(1);
136 DrawNice2DHisto(hisxy);
137 can1->cd(2);
138 gPad->SetLogy();
139 hisde->DrawCopy();
140 
141 can1->cd(3);
142 mypad=gPad;
143 //mypad.Divide(2,2);
144 //hisStripTop->DrawCopy();
145 DrawNice2DHisto(hisStripTop);
146 can1->cd(4); //hisStripBot->DrawCopy();
147 DrawNice2DHisto(hisStripBot);
148 can1->cd(5);hisStripStrip->DrawCopy();
149 can1->cd(6);//gPad->SetLogy();
150 hisStripCharge->DrawCopy();
151 hisStripChargeTop->DrawCopy("sames");
152 hisStripChargeBot->DrawCopy("sames");
153 can1->Update(); mypad = (TPad*)gPad; BetterStatBox(mypad);
154 
155 /*
156 TCanvas* can2 = new TCanvas("Lmd MC energy & Digis charge","Eloss vs Digi Charge",0,0,300,600);
157 can2->Divide(1,2);
158 can2->cd(1);
159 gPad->SetLogy();
160 hisde->DrawCopy();
161 can2->cd(2);
162 gPad->SetLogy();
163 hisStripChargeTop->DrawCopy();
164 //hisStripCharge->DrawCopy();
165 */
166 //can1->cd(3);
167 //mypad=gPad;
168 //mypad.Divide(1,2);
169 //mypad->cd(1);
170 //mypad->cd(2);
171 //mypad->cd(3);
172 //mypad->cd(4);
173 
174 // can1->Update();
175 //can1->Print(picture.Data());
176 //can2->Print(picture.Data());
177 
178  // ----- Finish -------------------------------------------------------
179  timer.Stop();
180  Double_t rtime = timer.RealTime();
181  Double_t ctime = timer.CpuTime();
182  cout << endl << endl;
183  cout << "Macro finished succesfully." << endl;
184  cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
185  cout << endl;
186  // ------------------------------------------------------------------------
187 
188 }
int row
Definition: anaLmdDigi.C:67
TH1D * hisde
Definition: anaLmdDigi.C:44
Int_t i
Definition: run_full.C:25
TTree * b
TTree * tree
Definition: plot_dirc.C:12
#define verbose
int col
Definition: anaLmdDigi.C:67
Class for digitised strip hits.
DrawNice2DHisto(hisxy)
Double_t par[3]
TString digiFile
Definition: bump_emc.C:20
Double_t GetCharge() const
Definition: PndSdsDigi.h:60
TFile * MCPoint
Definition: anaLmdDigi.C:25
TVector2 localdiff
Definition: anaLmdDigi.C:66
TVector3 mommc
Definition: anaLmdDigi.C:64
double de
Definition: anaLmdDigi.C:68
Int_t GetFE() const
Definition: PndSdsDigi.h:57
int nrStrips
Definition: anaLmdDigi.C:76
double Y
Definition: anaLmdDigi.C:68
TFile * Digis
Definition: anaLmdDigi.C:22
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
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
Digitization Parameter Class for MVD-Strip part.
TH1D * hisStripChargeTop
Definition: anaLmdDigi.C:58
TPad * mypad
TVector3 vecmc
Definition: anaLmdCluster.C:52
TH1D * hisStripCharge
Definition: anaLmdDigi.C:56
TH2D * hisxy
Definition: anaLmdDigi.C:38
Double_t ctime
Definition: hit_dirc.C:114
TH2D * hisrz
Definition: anaLmdDigi.C:41
TH1I * hisStripStrip
Definition: anaLmdDigi.C:53
TVector3 GetPosition() const
Definition: PndSdsMCPoint.h:90
double X
Definition: anaLmdDigi.C:68
Double_t tmpx
Definition: anaLmdDigi.C:65
Double_t x
int fe
Definition: anaLmdDigi.C:67
double Z
Definition: anaLmdDigi.C:68
std::string parfile
Definition: anaLmdDigi.C:20
TTree * tree2
Definition: anaLmdCluster.C:33
TClonesArray * digiStrip_array
Definition: anaLmdDigi.C:32
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
Double_t tmpz
Definition: anaLmdDigi.C:65
TH2I * hisStripTop
Definition: anaLmdDigi.C:48
PndSdsMCPoint * point
Definition: anaLmdCluster.C:72