FairRoot/PandaRoot
Functions
ReadHits.C File Reference

Go to the source code of this file.

Functions

int ReadHits ()
 

Function Documentation

int ReadHits ( )

Definition at line 8 of file ReadHits.C.

References can1, can2, directory, f, fGeoH, geomFile, PndGeoHandling::GetPath(), h, name, point, t, TString, and y.

8  {
9 
10  // Customize
11 
12 
13  const Int_t numSens = 6;
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 = "test.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 *histOne = new TH2F("Det1","Det1",100,-1,+1,100,-1,1);
48 
49  TCanvas *can1 = new TCanvas();
50 
51  TCanvas *can2 = new TCanvas();
52 
53  TString name = "";
54 
55 
56  // Load the hits
57 
58 
59  TFile *f = new TFile(HitsFile);
60 
61  TTree *t=(TTree *) f->Get("pndsim") ;
62 
63  TClonesArray* tr_array=new TClonesArray("PndSdsHit");
64  t->SetBranchAddress("MVDHitsStrip",&tr_array);//Branch names
65 
66  cout << "Events: " << t->GetEntries() << endl;
67 
68  for (Int_t j = 0 ; j < t->GetEntries() ; j++) // loop on events
69 
70  {
71 
72  t->GetEvent(j);
73 
74  if (j%10000 == 0) cout << "Ev. " << j << endl;
75 
76  for (Int_t y = 0 ; y < tr_array->GetEntries() ; y++) // loop on hits
77  {
78 
79  PndSdsHit*point = (PndSdsHit*)tr_array->At(y);
80 
81  name = fGeoH->GetPath(point->GetDetName());
82 
83  if (j < 10) cout << name << endl;
84 
85  for (Int_t h = 0 ; h < numSens ; h++) // loop on sensors
86  {
87 
88  if (name == SensName[h]) test->Fill(h+1);
89 
90  }
91 
92  // plotting Z of hits on the first sensor
93 
94  if (name == SensName[0])
95  {
96 
97  histOne->Fill(point->GetX(),point->GetY());
98 
99  }
100  }
101 
102  } // end loop on events
103 
104  can1->cd();
105 
106  test->Draw();
107  test->GetXaxis()->SetTitle("Sensor");
108  test->GetYaxis()->SetTitle("Clusters");
109 
110  can2->cd();
111 
112  gStyle->SetPalette(1);
113  histOne->Draw("COLZ");
114  histOne->GetXaxis()->SetTitle("x [cm]");
115  histOne->GetYaxis()->SetTitle("y [cm]");
116  return 0;
117 
118 }
PndGeoHandling * fGeoH
Definition: anasim.C:34
TString GetPath(Int_t shortID)
for a given shortID the path is returned
TString geomFile
Class to access the naming information of the MVD.
TClonesArray * point
Definition: anaLmdDigi.C:29
TFile * f
Definition: bump_analys.C:12
TString name
TCanvas * can2
TTree * t
Definition: bump_analys.C:13
Double_t y
TCanvas * can1
TString directory