3 #include <TClassTable.h>
7 #include <TClonesArray.h>
12 #include "AliITSgeom.h"
13 #include "AliITSRecPoint.h"
15 Int_t AliITSStoreFindableTracksCompiled
16 (Int_t nMinClusters = 5, const Text_t *evname = "galice", Int_t evnum = 0)
18 // Make sure that ALICE objects are loaded
24 // Define the names of all involved files
25 TString strEventFile(evname);
26 TString strOutputFile(evname);
27 strEventFile.Append(".root");
28 strOutputFile.Append("_tracks_");
29 strOutputFile += evnum;
30 strOutputFile.Append(".root");
32 // Connect the Root Galice file containing Geometry, Kine and Hits
33 TFile *fileEvent = (TFile*)gROOT->GetListOfFiles()->FindObject(strEventFile);
34 if (!fileEvent) fileEvent = new TFile(strEventFile,"UPDATE");
36 // Get AliRun object from file
37 gAlice = (AliRun*)fileEvent->Get("gAlice");
38 if (gAlice) cout << "OK, found an AliRun object in file" << endl;
40 // Get ITS related objects and data
41 AliITS* ITS =(AliITS *)gAlice->GetDetector("ITS");
43 cerr << "ITS object not found!" << endl;
46 AliITSgeom *geometry = ITS->GetITSgeom();
48 cerr << "ITS geometry object not found!" << endl;
52 // Count the number of modules per layer
53 Int_t nLadders, nDetectors, mod_min[6], mod_max[6];
54 for(Int_t i = 0; i < 6; i++) {
55 nLadders = geometry->GetNladders(i + 1);
56 nDetectors = geometry->GetNdetectors(i + 1);
57 mod_min[i] = geometry->GetModuleIndex(i + 1, 1, 1);
58 mod_max[i] = geometry->GetModuleIndex(i + 1, nLadders, nDetectors);
61 // Load event and ITS recpoints
62 Int_t nParticles = gAlice->GetEvent(evnum);
63 cout << "Event number: " << evnum << endl;
64 cout << "# particles : " << nParticles <<endl;
65 if (nParticles <= 0) {
66 cerr << "Can't have <= 0 particles!" << endl;
69 AliITSRecPoint *recp = 0;
70 TClonesArray *recPoints = ITS->RecPoints();
71 TObjArray *particles = gAlice->Particles();
72 Int_t nTracks = gAlice->GetNtrack(); //FCA correction
73 Bool_t *hitITSLayer[6];
74 for (Int_t i = 0; i < 6; i++) {
75 hitITSLayer[i] = new Bool_t[nTracks];
76 for (Int_t j = 0; j < nTracks; j++) hitITSLayer[i][j] = kFALSE;
79 // Load recpoints in event
80 TTree *TR = gAlice->TreeR();
82 cerr << "TreeR object not found!" << endl;
86 // Scan recpoints and define findable tracks
87 Int_t nModules = (Int_t)TR->GetEntries(), nPoints = 0, nEmpty = 0;
88 cout << "Found " << nModules;
89 cout << " entries in the TreeR (must be one per module!)" << endl;
90 for (Int_t layer = 1; layer <= 6; layer++) {
91 for (Int_t mod = mod_min[layer - 1]; mod <= mod_max[layer - 1]; mod++) {
92 ITS->ResetRecPoints();
94 nPoints = recPoints->GetEntries();
99 for (Int_t point = 0; point < nPoints; point++) {
100 recp = (AliITSRecPoint*)recPoints->UncheckedAt(point);
101 for (Int_t it = 0; it < 3; it++) {
102 Int_t track = recp->GetLabel(it);
103 if(track < 0) continue;
104 if(track > nTracks) {
105 cout << "Found track index " << track;
106 cout << " whilw gAlice->GetNtrack() = " << nTracks << endl;
109 hitITSLayer[layer - 1][track] = kTRUE;
110 } // loop over recpoint labels
112 } //loop over modules
114 cout << "Found " << nEmpty << " empty modules" << endl;
116 // Scan the file of tracks in TPC to retrieve the findable TPC tracks
117 TString strLabelsTPC;
118 Int_t label, pdg_code, nFindablesTPC = 0;
120 ifstream tpc("good_tracks_tpc");
121 while (tpc >> label >> pdg_code) {
122 for (Int_t i = 0; i < 6; i++) tpc >> dummy;
124 strLabelsTPC.Append(Form("[%d]", label));
127 // Define the TTree with tracks data by means of a set of variables
128 Int_t nFindablesITS = 0, nFindablesITSTPC = 0;
129 Int_t nhits, tpc_ok, mother, entry = 0;
131 Double_t px, py, pz, pt;
133 TTree *tree = new TTree("Tracks", "Findable tracks in ITS");
135 tree->Branch("vx", &vx, "vx/D");
136 tree->Branch("vy", &vy, "vy/D");
137 tree->Branch("vz", &vz, "vz/D");
138 tree->Branch("px", &px, "px/D");
139 tree->Branch("py", &py, "py/D");
140 tree->Branch("pz", &pz, "pz/D");
141 tree->Branch("pt", &pt, "pt/D");
142 tree->Branch("label", &label, "label/I");
143 tree->Branch("entry", &entry, "entry/I");
144 tree->Branch("mother", &mother, "mother/I");
145 tree->Branch("pdg_code", &pdg_code, "pdg_code/I");
146 tree->Branch("nhits", &nhits, "nhits/I");
147 tree->Branch("tpc_ok", &tpc_ok, "tpc_ok/I");
152 for (Int_t i = 0; i < nTracks; i++) {
154 for (Int_t j = 0; j < 6; j++) if (hitITSLayer[j][i]) nhits++;
155 if (nhits < nMinClusters) continue;
156 p = gAlice->Particle(i);
164 mother = p->GetFirstMother();
165 cout << "Track " << i << " stored\r" << flush;
166 tpc_ok = (strLabelsTPC.Contains(Form("[%d]", i)));
167 pdg_code = p->GetPdgCode();
170 if (tpc_ok) nFindablesITSTPC++;
176 TFile *fileOutput = new TFile(strOutputFile, "recreate");
180 cout << "# findable tracks in TPC : " << nFindablesTPC << endl;
181 cout << "# findable tracks in ITS : " << nFindablesITS << endl;
182 cout << "# findable tracks in ITS+TPC : " << nFindablesITSTPC << endl;