]>
Commit | Line | Data |
---|---|---|
e615b5b5 | 1 | Int_t AliTOFSDigits2Digits(Int_t numberOfEvents = 0) { |
2 | ||
3 | ///////////////////////////////////////////////////////////////////////// | |
4 | // | |
5 | // Creates TOF digits from the summable digits for all event in the header file | |
6 | // | |
7 | // Use case: | |
8 | // start root | |
9 | // // load the macro | |
10 | // root[0] .L AliTOFSDigits2Digits.C | |
11 | // root[1] AliTOFSDigits2Digits() | |
12 | // | |
13 | // By default, it creates digits for all the events in the header file. | |
14 | // | |
15 | // If you want create digits only the firts event | |
16 | // you can use the following lines: | |
17 | // | |
18 | // root[0] .L AliTOFSDigits2Digits.C | |
19 | // root[1] AliTOFSDigits2Digits(1) | |
20 | // | |
21 | // Created by: F. Pierella | |
22 | // Updated to the new I/O: I.Belikov (Jouri.Belikov@cern.ch) | |
23 | // | |
24 | // Report problems to decaro@sa.infn.it | |
25 | // | |
26 | ///////////////////////////////////////////////////////////////////////// | |
ca4508a6 | 27 | |
32bd3eb5 | 28 | Int_t rc = 0; |
29 | ||
30 | if (gAlice) | |
31 | { | |
33c3c91a | 32 | delete AliRunLoader::Instance(); |
32bd3eb5 | 33 | delete gAlice; |
c630aafd | 34 | gAlice = 0x0; |
32bd3eb5 | 35 | } |
e615b5b5 | 36 | |
32bd3eb5 | 37 | AliRunLoader* rl = AliRunLoader::Open("galice.root"); |
38 | if (rl == 0x0) | |
39 | { | |
c630aafd | 40 | cerr<<"Can not open session"<<endl; |
32bd3eb5 | 41 | rc = 1; |
42 | return rc; | |
43 | } | |
e615b5b5 | 44 | |
32bd3eb5 | 45 | if (rl->LoadgAlice()) |
46 | { | |
e615b5b5 | 47 | cerr<<"Error occured while loading gAlice \n"; |
32bd3eb5 | 48 | rc = 2; |
49 | return rc; | |
50 | } | |
e615b5b5 | 51 | |
32bd3eb5 | 52 | AliLoader *tofl = rl->GetLoader("TOFLoader"); |
53 | if (tofl == 0x0) | |
54 | { | |
e615b5b5 | 55 | cerr<<"Can not get the TOF Loader \n"; |
32bd3eb5 | 56 | rc = 3; |
57 | return rc; | |
58 | } | |
e615b5b5 | 59 | |
c630aafd | 60 | gAlice=rl->GetAliRun(); |
32bd3eb5 | 61 | if (!gAlice) |
62 | { | |
63 | cerr<<"Can't get gAlice !\n"; | |
64 | rc = 4; | |
65 | return rc; | |
66 | } | |
e615b5b5 | 67 | |
c630aafd | 68 | tofl->LoadSDigits("read"); |
69 | tofl->LoadDigits("recreate"); | |
e615b5b5 | 70 | |
c630aafd | 71 | Int_t totndig=0; // total number of digits |
72 | Int_t tottracks=0; // total number of tracks contributing to totndig | |
e615b5b5 | 73 | |
74 | if (numberOfEvents==0) numberOfEvents=rl->GetNumberOfEvents(); | |
75 | ||
c630aafd | 76 | TClonesArray *fSDigits=new TClonesArray("AliTOFSDigit", 1000); |
77 | TClonesArray *fDigits =new TClonesArray("AliTOFdigit", 1000); | |
78 | TClonesArray &da=*fDigits; | |
79 | ||
e615b5b5 | 80 | for (Int_t ievent = 0; ievent < numberOfEvents; ievent++) { |
c630aafd | 81 | rl->GetEvent(ievent); |
32bd3eb5 | 82 | |
c630aafd | 83 | TTree *sTree=tofl->TreeS(); |
32bd3eb5 | 84 | if (sTree == 0) |
85 | { | |
86 | cerr<<"Can't get the sdigit tree !\n"; | |
87 | rc = 5; | |
88 | return rc; | |
89 | } | |
c630aafd | 90 | TBranch *branch=sTree->GetBranch("TOF"); |
32bd3eb5 | 91 | if (!branch) |
92 | { | |
93 | cerr<<"Cant' get the branch !\n"; | |
94 | rc = 6; | |
95 | return rc; | |
96 | } | |
e615b5b5 | 97 | branch->SetAddress(&fSDigits); |
98 | ||
c630aafd | 99 | TTree *dTree=tofl->TreeD(); |
100 | if (dTree == 0) { | |
101 | tofl->MakeTree("D"); | |
102 | dTree=tofl->TreeD(); | |
103 | } | |
104 | branch=dTree->GetBranch("TOF"); | |
105 | if (!branch) dTree->Branch("TOF",&fDigits); | |
106 | else branch->SetAddress(&fDigits); | |
107 | ||
108 | Int_t nEntries = sTree->GetEntries(); | |
ca4508a6 | 109 | for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) { |
c630aafd | 110 | sTree->GetEvent(iEntry); |
e615b5b5 | 111 | |
ca4508a6 | 112 | Int_t ndig = fSDigits->GetEntriesFast(); |
e615b5b5 | 113 | cout << "----------------<AliTOFSDigits2Digits>---------------- \n"; |
ca4508a6 | 114 | cout << "Found " << ndig << " TOF SDigits for event " << ievent << endl; |
e615b5b5 | 115 | cout << "------------------------------------------------------ \n"; |
ca4508a6 | 116 | |
ca4508a6 | 117 | for (Int_t k = 0; k < ndig; k++) { |
ca4508a6 | 118 | Int_t vol[5]; // location for a digit |
e615b5b5 | 119 | |
ca4508a6 | 120 | // Get the information for this digit |
c630aafd | 121 | AliTOFSDigit *tofsdigit = (AliTOFSDigit *)fSDigits->UncheckedAt(k); |
ca4508a6 | 122 | |
123 | Int_t nslot=tofsdigit->GetNDigits(); // get the number of slots | |
124 | // for current sdigit | |
125 | ||
126 | // TOF sdigit volumes (always the same for all slots) | |
da3d3acd | 127 | Int_t sector = tofsdigit->GetSector(); // range [0-17] |
128 | Int_t plate = tofsdigit->GetPlate(); // range [0- 4] | |
129 | Int_t strip = tofsdigit->GetStrip(); // range [0-19] | |
130 | Int_t padz = tofsdigit->GetPadz(); // range [0- 1] | |
131 | Int_t padx = tofsdigit->GetPadx(); // range [0-47] | |
ca4508a6 | 132 | |
133 | vol[0] = sector; | |
134 | vol[1] = plate; | |
135 | vol[2] = strip; | |
136 | vol[3] = padx; | |
137 | vol[4] = padz; | |
138 | ||
139 | //--------------------- QA section ---------------------- | |
140 | // in the while, I perform QA | |
da3d3acd | 141 | Bool_t isSDigitBad = (sector<0 || sector>17 || |
142 | plate<0 || plate >4 || | |
143 | padz<0 || padz>1 || | |
144 | padx<0 || padx>47); | |
ca4508a6 | 145 | |
32bd3eb5 | 146 | if (isSDigitBad) |
147 | { | |
e615b5b5 | 148 | cout << "<AliTOFSDigits2Digits> strange sdigit found \n"; |
32bd3eb5 | 149 | rc = 7; |
150 | return rc; | |
151 | } | |
ca4508a6 | 152 | //------------------------------------------------------- |
153 | ||
ca4508a6 | 154 | // start loop on number of slots for current sdigit |
155 | for (Int_t islot = 0; islot < nslot; islot++) { | |
e615b5b5 | 156 | Float_t digit[2]; // TOF digit variables |
157 | const Int_t kMAXDIGITS = 3; // number 3 is a legacy from AliDigit object | |
158 | ||
159 | Int_t tracknum[kMAXDIGITS]; //contributing tracks for the current slot | |
160 | ||
ca4508a6 | 161 | Float_t tdc=tofsdigit->GetTdc(islot); digit[0]=tdc; |
162 | Float_t adc=tofsdigit->GetAdc(islot); digit[1]=adc; | |
163 | ||
164 | tracknum[0]=tofsdigit->GetTrack(islot,0); | |
165 | tracknum[1]=tofsdigit->GetTrack(islot,1); | |
166 | tracknum[2]=tofsdigit->GetTrack(islot,2); | |
167 | ||
168 | for (Int_t i = 0; i < kMAXDIGITS; i++) { | |
169 | tottracks++; | |
170 | // search for the first empty location | |
171 | if(tracknum[i]==-1){ | |
172 | tottracks--; | |
173 | break; | |
174 | } | |
175 | } | |
176 | ||
177 | // adding a TOF digit for each slot | |
c630aafd | 178 | { |
179 | Int_t ndigits=da.GetEntriesFast(); | |
c630aafd | 180 | new (da[ndigits]) AliTOFdigit(tracknum, vol, digit); |
181 | } | |
ca4508a6 | 182 | totndig++; |
183 | } | |
184 | ||
ca4508a6 | 185 | } // end loop on sdigits |
c630aafd | 186 | fSDigits->Clear(); |
e615b5b5 | 187 | |
ca4508a6 | 188 | } // end loop on entries |
189 | ||
c630aafd | 190 | dTree->Fill(); |
191 | tofl->WriteDigits("OVERWRITE"); | |
ca4508a6 | 192 | |
c630aafd | 193 | // free used memory |
194 | fDigits->Clear(); | |
ca4508a6 | 195 | |
196 | } // end loop on events | |
197 | ||
c630aafd | 198 | delete fSDigits; |
199 | delete fDigits; | |
e615b5b5 | 200 | |
32bd3eb5 | 201 | tofl->UnloadDigits(); |
202 | tofl->UnloadSDigits(); | |
203 | rl->UnloadHeader(); | |
204 | rl->UnloadgAlice(); | |
e615b5b5 | 205 | |
206 | cout << "---------------------------------------------------------- \n"; | |
207 | cout << "<AliTOFSDigits2Digits> Summary \n"; | |
208 | cout << "contributing tracks to " << totndig << " digits: " << tottracks << endl; | |
209 | cout << "---------------------------------------------------------- \n"; | |
ca4508a6 | 210 | |
32bd3eb5 | 211 | if (gAlice) |
212 | { | |
33c3c91a | 213 | delete AliRunLoader::Instance(); |
32bd3eb5 | 214 | delete gAlice; |
215 | gAlice = 0x0; | |
216 | } | |
217 | ||
218 | return rc; | |
ca4508a6 | 219 | |
220 | } |