FairRoot/PandaRoot
Functions
TrackHits.C File Reference

Go to the source code of this file.

Functions

int TrackHits ()
 

Function Documentation

int TrackHits ( )

Definition at line 8 of file TrackHits.C.

References can1, can2, can3, can4, can5, directory, f, fGeoH, geomFile, PndSdsHit::GetEloss(), PndGeoHandling::GetPath(), h, h1, h2, h3, h4, h5, h6, h7, h8, name, point, t, TString, and y.

Referenced by PndRiemannTrackFinder::FindTracks(), and PndMvdSttGemRiemannTrackFinder::FindTracks().

8  {
9 
10  // Customize
11 
12  const Int_t numSens = 6;
13  const Int_t maxEvents = 1000000;
14 
15  TString SensName[numSens];
16 
17  SensName[0] = "/TS_1/TTVol_0/TTDouble_0/StripActiveTD1_0";
18  SensName[1] = "/TS_1/TTVol_0/TTSingle_0/StripActiveTS3a_0";
19  SensName[2] = "/TS_1/TTVol_0/TTSingle_0/StripActiveTS3b_0";
20  SensName[3] = "/TS_1/TTVol_0/TTSingle_0/StripActiveTS4a_0";
21  SensName[4] = "/TS_1/TTVol_0/TTSingle_0/StripActiveTS4b_0";
22  SensName[5] = "/TS_1/TTVol_0/TTDouble_0/StripActiveTD2_0";
23 
24 
25  // load libs
26 
27  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
28 
29  //
30 
31  TString directory = gSystem->Getenv("VMCWORKDIR");
32  TString geomFile = directory + "/geometry/TrackingStation.root";
33  TString HitsFile = "hits.root";
34 
35 
36  // Loading the geometry and defining the geo handler
37 
38  TFile *geo = new TFile(geomFile);
39 
40  TGeoManager *myGeo = geo->Get("FAIRGeom");
41 
42  fGeoH = new PndGeoHandling();
43 
44 
45  TH1F *test = new TH1F("Det","Det",5,0.5,numSens + 0.5);
46 
47  TH2F *h1 = new TH2F("Det1","Det1",385,-0.96,+0.96,385,-0.96,+0.96);
48  TH2F *h2 = new TH2F("Det2","Det2",385,-0.96,+0.96,385,-0.96,+0.96);
49  TH2F *h3 = new TH2F("Det3","Det3",385,-0.96,+0.96,385,-0.96,+0.96);
50  TH2F *h4 = new TH2F("Det4","Det4",385,-0.96,+0.96,385,-0.96,+0.96);
51 
52  TH1F *h5 = new TH1F("eloss1","eloss1",1000,0.,100.);
53  TH1F *h6 = new TH1F("eloss2","eloss2",1000,0.,100.);
54  TH1F *h7 = new TH1F("eloss3","eloss3",1000,0.,100.);
55  TH1F *h8 = new TH1F("eloss4","eloss4",1000,0.,100.);
56 
57  TCanvas *can0 = new TCanvas();
58  TCanvas *can1 = new TCanvas();
59  TCanvas *can2 = new TCanvas();
60  TCanvas *can3 = new TCanvas();
61  TCanvas *can4 = new TCanvas();
62  TCanvas *can5 = new TCanvas();
63  TCanvas *can6 = new TCanvas();
64  TCanvas *can7 = new TCanvas();
65  TCanvas *can8 = new TCanvas();
66 
67  TString name = "";
68 
69 
70  // Load the hits
71  TFile *f = new TFile(HitsFile);
72 
73  TTree *t=(TTree *) f->Get("pndsim");
74 
75  TClonesArray* tr_array=new TClonesArray("PndSdsHit");
76  t->SetBranchAddress("MVDHitsStrip",&tr_array);//Branch names
77 
78  cout << "Events: " << t->GetEntries() << endl;
79 
80  int nrHits1=0;
81  int nrHits2=0;
82  int nrHits3=0;
83  int nrHits4=0;
84 
85  for (Int_t j = 0 ; j < t->GetEntries() && j<maxEvents ; j++) // loop on events
86  {
87  t->GetEvent(j);
88 
89  if (j%10000 == 0) cout << "Ev. " << j << endl;
90 
91  TObjArray TS3[2];
92  TObjArray TS4[2];
93 
94  for (Int_t y = 0 ; y < tr_array->GetEntries() ; y++) // loop on hits
95  {
96 
97  PndSdsHit* point = (PndSdsHit*)tr_array->At(y);
98  //cout<< "index: "<<point->GetClusterIndex() << endl;
99  //cout<<" (x,y)=("<<point->GetX()<<","<<point->GetY()<<") charge="<<point->GetEloss()<<endl;
100  name = fGeoH->GetPath(point->GetDetName());
101 
102  if (j < 10) cout << name << endl;
103 
104  for (Int_t h = 0 ; h < numSens ; h++) // loop on sensors
105  {
106  if (name == SensName[h]) test->Fill(h+1);
107  }
108 
109  // plotting Z of hits on the first sensor
110  if (name == SensName[0]) {
111  h1->Fill(point->GetX(),point->GetY());
112  h5->Fill(point->GetEloss()*1e+6);
113  nrHits1++;
114  }
115  if (name == SensName[5]) {
116  h4->Fill(point->GetX(),point->GetY());
117  h8->Fill(point->GetEloss()*1e+6);
118  nrHits4++;
119  }
120 
121  if (name == SensName[1]) TS3[0].Add(point);
122  if (name == SensName[2]) TS3[1].Add(point);
123  if (name == SensName[3]) TS4[0].Add(point);
124  if (name == SensName[4]) TS4[1].Add(point);
125  }
126 // cout<<"entries in TSn:"<<endl;
127 
128  Int_t n1,n2,n3,n4;
129  n1=TS3[0].GetEntries();
130  n2=TS3[1].GetEntries();
131  n3=TS4[0].GetEntries();
132  n4=TS4[1].GetEntries();
133 // if (n1!=n2) cout<<"unequal nr. of hits on sensor TS3 ("<<n1<<"/"<<n2<<")"<<endl;
134 // if (n3!=n4) cout<<"unequal nr. of hits on sensor TS4 ("<<n3<<"/"<<n4<<")"<<endl;
135  if (n1 && n1==n2) {
136  if (n1==1) {
137  h2->Fill(((PndSdsHit*)(TS3[0][0]))->GetX(),((PndSdsHit*)(TS3[1][0]))->GetY());
138  h6->Fill(((PndSdsHit*)(TS3[0][0]))->GetEloss()*1e+6);
139  h6->Fill(((PndSdsHit*)(TS3[1][0]))->GetEloss()*1e+6);
140  }
141  else cout<<"multiple hits on sensor TS3"<<endl;
142  nrHits2+=n1+n2;
143  }
144  if (n3 && n3==n4) {
145  if (n3==1) {
146  h3->Fill(((PndSdsHit*)(TS4[0][0]))->GetX(),((PndSdsHit*)(TS4[1][0]))->GetY());
147  h7->Fill(((PndSdsHit*)(TS4[0][0]))->GetEloss()*1e+6);
148  h7->Fill(((PndSdsHit*)(TS4[1][0]))->GetEloss()*1e+6);
149  }
150  else cout<<"multiple hits on sensor TS4"<<endl;
151  nrHits3+=n3+n4;
152  }
153 
154 /*
155  cout<<" TS3a:"<<n1<<endl;
156  cout<<" TS3b:"<<n2<<endl;
157  cout<<" TS4a:"<<n3<<endl;
158  cout<<" TS4b:"<<n4<<endl;
159 */
160 /*
161  TS3[0].clear();
162  TS3[1].clear();
163  TS4[0].clear();
164  TS4[1].clear();
165 */
166  } // end loop on events
167 
168  cout<<"nr of hits on first station : "<<nrHits1<<endl;
169  cout<<"nr of hits on second station : "<<nrHits2<<endl;
170  cout<<"nr of hits on third station : "<<nrHits3<<endl;
171  cout<<"nr of hits on fourth station : "<<nrHits4<<endl;
172 
173  can0->cd();
174 
175  test->Draw();
176  test->GetXaxis()->SetTitle("Sensor");
177  test->GetYaxis()->SetTitle("Clusters");
178 
179  can1->cd();
180 
181  gStyle->SetPalette(1);
182  h1->Draw("COLZ");
183  h1->GetXaxis()->SetTitle("x [cm]");
184  h1->GetYaxis()->SetTitle("y [cm]");
185 
186  can2->cd();
187 
188  gStyle->SetPalette(1);
189  h2->Draw("COLZ");
190  h2->GetXaxis()->SetTitle("x [cm]");
191  h2->GetYaxis()->SetTitle("y [cm]");
192 
193  can3->cd();
194 
195  gStyle->SetPalette(1);
196  h3->Draw("COLZ");
197  h3->GetXaxis()->SetTitle("x [cm]");
198  h3->GetYaxis()->SetTitle("y [cm]");
199 
200  can4->cd();
201 
202  gStyle->SetPalette(1);
203  h4->Draw("COLZ");
204  h4->GetXaxis()->SetTitle("x [cm]");
205  h4->GetYaxis()->SetTitle("y [cm]");
206 
207  can5->cd();
208 
209  h5->Draw("");
210  h5->GetXaxis()->SetTitle("eloss [keV]");
211  h5->GetYaxis()->SetTitle("counts");
212 
213  can6->cd();
214 
215  h6->Draw("");
216  h6->GetXaxis()->SetTitle("eloss [keV]");
217  h6->GetYaxis()->SetTitle("counts");
218 
219  can6->cd();
220 
221  h6->Draw("");
222  h6->GetXaxis()->SetTitle("eloss [keV]");
223  h6->GetYaxis()->SetTitle("counts");
224 
225  can7->cd();
226 
227  h7->Draw("");
228  h7->GetXaxis()->SetTitle("eloss [keV]");
229  h7->GetYaxis()->SetTitle("counts");
230 
231  can8->cd();
232 
233  h8->Draw("");
234  h8->GetXaxis()->SetTitle("eloss [keV]");
235  h8->GetYaxis()->SetTitle("counts");
236  return 0;
237 }
PndGeoHandling * fGeoH
Definition: anasim.C:34
TH1F * h4
TCanvas * can4
Definition: anaLmdReco.C:203
Double_t GetEloss() const
Definition: PndSdsHit.h:97
TString GetPath(Int_t shortID)
for a given shortID the path is returned
TH1F * h8
Definition: runPULL1.C:34
TString geomFile
Class to access the naming information of the MVD.
TH2F * h5
Definition: draw_bands.C:19
TCanvas * can5
Definition: anaLmdReco.C:211
TClonesArray * point
Definition: anaLmdDigi.C:29
TFile * f
Definition: bump_analys.C:12
TH1F * h3
TString name
TCanvas * can2
TH1F * h7
Definition: runPULL1.C:33
TTree * t
Definition: bump_analys.C:13
TH1F * h6
Definition: runPULL1.C:32
Double_t y
TCanvas * can1
TString directory
TCanvas * can3