]>
Commit | Line | Data |
---|---|---|
cd82ed2f | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
18 | ///////////////////////////////////////////////////////////////////// | |
ee51d470 | 19 | // |
cd82ed2f | 20 | // Class performing TOF Trigger |
21 | // Cosmic_Multi_muon: Cosmic Multi-Muonic Event Trigger (L0) | |
22 | // ppMB: p-p Minimum Bias Event Trigger (L0) | |
23 | // UltraPer_Coll: Ultra-Peripheral Collision Event Trigger (L0) | |
24 | // High_Mult: High Multiplicity Event Trigger (L0) | |
25 | // Jet: Events with Jet Topology Trigger (L1) | |
26 | // | |
ee51d470 | 27 | // A.Silenzi: added CTTM map, |
28 | // method to fill LTM matrix from raw data, | |
29 | // method to retrieve the TOF pre-trigger for TRD detector | |
30 | // | |
31 | // | |
cd82ed2f | 32 | ///////////////////////////////////////////////////////////////////// |
33 | ||
7ca4655f | 34 | #include <TClonesArray.h> |
c93255fe | 35 | #include <TTree.h> |
372be75e | 36 | #include <TMath.h> |
7ca4655f | 37 | |
cd82ed2f | 38 | #include "AliLoader.h" |
0e46b9ae | 39 | #include "AliLog.h" |
cd82ed2f | 40 | #include "AliRunLoader.h" |
0e46b9ae | 41 | #include "AliRun.h" |
cd82ed2f | 42 | #include "AliTriggerInput.h" |
ee51d470 | 43 | #include "AliRawReader.h" |
0e46b9ae | 44 | |
ee51d470 | 45 | #include "AliTOFRawStream.h" |
46 | #include "AliTOFrawData.h" | |
cd82ed2f | 47 | #include "AliTOFdigit.h" |
ee51d470 | 48 | #include "AliTOFGeometry.h" |
0e46b9ae | 49 | #include "AliTOFTrigger.h" |
c06f660b | 50 | #include "AliTOFTriggerMask.h" |
cd82ed2f | 51 | |
c11d3763 | 52 | #include "AliCDBManager.h" |
53 | #include "AliCDBEntry.h" | |
54 | ||
55 | ||
0e46b9ae | 56 | extern AliRun* gAlice; |
cd82ed2f | 57 | |
372be75e | 58 | AliTOFGeometry* AliTOFTrigger::fgTofGeo = NULL; // TOF geometry needed to get the minimial arrival time for each channel |
59 | ||
cd82ed2f | 60 | //------------------------------------------------------------------------- |
61 | ClassImp(AliTOFTrigger) | |
62 | ||
63 | //---------------------------------------------------------------------- | |
ee51d470 | 64 | AliTOFTrigger::AliTOFTrigger() : |
65 | AliTriggerDetector(), | |
cd82ed2f | 66 | fHighMultTh(1000), |
c06f660b | 67 | fppMBTh(4),//4::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: |
68 | fMultiMuonTh(4), | |
cd82ed2f | 69 | fUPTh(2), |
c06f660b | 70 | fdeltaminpsi(150), //150 |
71 | fdeltamaxpsi(170), //170 | |
cd82ed2f | 72 | fdeltaminro(70), |
73 | fdeltamaxro(110), | |
c06f660b | 74 | fstripWindow(2), |
75 | fSel1(0), | |
76 | fSel2(0), | |
77 | fSel3(0), | |
78 | fSel4(0), | |
79 | fNCrateOn(0), | |
80 | fNMaxipadOn(0), | |
81 | fNMaxipadOnAll(0), | |
372be75e | 82 | fTOFTrigMask(0), |
83 | fStartTimeHit(0.0), | |
84 | fTimeWidthTrigger(25.0) | |
85 | ||
cd82ed2f | 86 | { |
87 | //main ctor | |
8104fec9 | 88 | for (Int_t i=0;i<kNCTTM;i++) fLTMarray[i] = kFALSE; |
89 | ||
cd82ed2f | 90 | for (Int_t i=0;i<kNLTM;i++){ |
8104fec9 | 91 | |
cd82ed2f | 92 | for (Int_t j=0;j<kNLTMchannels;j++){ |
93 | fLTMmatrix[i][j]=kFALSE; | |
94 | } | |
95 | if (i<kNCTTM){ | |
96 | for (Int_t j=0;j<kNCTTMchannels;j++){ | |
97 | fCTTMmatrixFront[i][j]=kFALSE; | |
98 | fCTTMmatrixBack[i][j]=kFALSE; | |
99 | } | |
100 | } | |
101 | } | |
c06f660b | 102 | |
103 | fPowerMask[0] = 1; | |
104 | for(Int_t i=1;i <= kNCTTMchannels;i++){ | |
105 | fPowerMask[i] = fPowerMask[i-1]*2; | |
106 | } | |
107 | ||
cd82ed2f | 108 | SetName("TOF"); |
109 | CreateInputs(); | |
c06f660b | 110 | |
cd82ed2f | 111 | } |
ee51d470 | 112 | |
cd82ed2f | 113 | //---------------------------------------------------------------------- |
ee51d470 | 114 | |
372be75e | 115 | AliTOFTrigger::AliTOFTrigger(Int_t HighMultTh, Int_t ppMBTh, Int_t MultiMuonTh, Int_t UPTh, Float_t deltaminpsi, Float_t deltamaxpsi, Float_t deltaminro, Float_t deltamaxro, Int_t stripWindow,Float_t startTimeWindow,Float_t widthTimeWindow) : |
ee51d470 | 116 | AliTriggerDetector(), |
655e379f | 117 | fHighMultTh(HighMultTh), |
118 | fppMBTh(ppMBTh), | |
119 | fMultiMuonTh(MultiMuonTh), | |
120 | fUPTh(UPTh), | |
121 | fdeltaminpsi(deltaminpsi), | |
122 | fdeltamaxpsi(deltamaxpsi), | |
123 | fdeltaminro(deltaminro), | |
124 | fdeltamaxro(deltamaxro), | |
c06f660b | 125 | fstripWindow(stripWindow), |
126 | fSel1(0), | |
127 | fSel2(0), | |
128 | fSel3(0), | |
129 | fSel4(0), | |
130 | fNCrateOn(0), | |
131 | fNMaxipadOn(0), | |
132 | fNMaxipadOnAll(0), | |
372be75e | 133 | fTOFTrigMask(0), |
134 | fStartTimeHit(startTimeWindow), | |
135 | fTimeWidthTrigger(widthTimeWindow) | |
cd82ed2f | 136 | { |
137 | //ctor with thresholds for triggers | |
8104fec9 | 138 | for (Int_t i=0;i<kNCTTM;i++) fLTMarray[i] = kFALSE; |
cd82ed2f | 139 | for (Int_t i=0;i<kNLTM;i++){ |
140 | for (Int_t j=0;j<kNLTMchannels;j++){ | |
141 | fLTMmatrix[i][j]=kFALSE; | |
142 | } | |
143 | if (i<kNCTTM){ | |
144 | for (Int_t j=0;j<kNCTTMchannels;j++){ | |
145 | fCTTMmatrixFront[i][j]=kFALSE; | |
146 | fCTTMmatrixBack[i][j]=kFALSE; | |
147 | } | |
148 | } | |
149 | } | |
c06f660b | 150 | |
151 | fPowerMask[0] = 1; | |
152 | for(Int_t i=1;i <= kNCTTMchannels;i++){ | |
153 | fPowerMask[i] = fPowerMask[i-1]*2; | |
154 | } | |
155 | ||
cd82ed2f | 156 | SetName("TOF"); |
157 | CreateInputs(); | |
158 | } | |
159 | ||
9a838fb7 | 160 | |
161 | #if 0 /*** COPY CONSTRUCTOR SUPPRESSED **/ | |
ee51d470 | 162 | //____________________________________________________________________________ |
cd82ed2f | 163 | |
655e379f | 164 | AliTOFTrigger::AliTOFTrigger(const AliTOFTrigger & tr): |
8a190ba2 | 165 | AliTriggerDetector(tr), |
166 | fHighMultTh(tr.fHighMultTh), | |
167 | fppMBTh(tr.fppMBTh), | |
168 | fMultiMuonTh(tr.fMultiMuonTh), | |
169 | fUPTh(tr.fUPTh), | |
170 | fdeltaminpsi(tr.fdeltaminpsi), | |
171 | fdeltamaxpsi(tr.fdeltamaxpsi), | |
172 | fdeltaminro(tr.fdeltaminro), | |
173 | fdeltamaxro(tr.fdeltamaxro), | |
c06f660b | 174 | fstripWindow(tr.fstripWindow), |
175 | fSel1(tr.fSel1), | |
176 | fSel2(tr.fSel2), | |
177 | fSel3(tr.fSel3), | |
178 | fSel4(tr.fSel4), | |
179 | fNCrateOn(tr.fNCrateOn), | |
180 | fNMaxipadOn(tr.fNMaxipadOn), | |
181 | fNMaxipadOnAll(tr.fNMaxipadOnAll), | |
182 | fTOFTrigMask(0) | |
cd82ed2f | 183 | { |
184 | //copy ctor | |
8104fec9 | 185 | for (Int_t i=0;i<kNCTTM;i++) fLTMarray[i] = kFALSE; |
cd82ed2f | 186 | for (Int_t i=0;i<kNLTM;i++){ |
187 | for (Int_t j=0;j<kNLTMchannels;j++){ | |
188 | fLTMmatrix[i][j]=tr.fLTMmatrix[i][j]; | |
189 | } | |
190 | if (i<kNCTTM){ | |
191 | for (Int_t j=0;j<kNCTTMchannels;j++){ | |
ee51d470 | 192 | fCTTMmatrixFront[i][j]=tr.fCTTMmatrixFront[i][j]; |
193 | fCTTMmatrixBack[i][j]=tr.fCTTMmatrixBack[i][j]; | |
cd82ed2f | 194 | } |
195 | } | |
196 | } | |
c06f660b | 197 | |
198 | fPowerMask[0] = 1; | |
199 | for(Int_t i=1;i <= kNCTTMchannels;i++){ | |
200 | fPowerMask[i] = fPowerMask[i-1]*2; | |
201 | } | |
202 | ||
203 | if(tr.fTOFTrigMask){ | |
204 | fTOFTrigMask = new AliTOFTriggerMask(); | |
205 | fTOFTrigMask->SetTriggerMaskArray(tr.fTOFTrigMask->GetTriggerMaskArray()); | |
206 | } | |
207 | ||
cd82ed2f | 208 | SetName(tr.GetName()); |
ee51d470 | 209 | //fInputs=&(tr.GetInputs()); |
c06f660b | 210 | CreateInputs(); |
211 | ||
cd82ed2f | 212 | } |
9a838fb7 | 213 | #endif /*** COPY CONTRUCTOR SUPPRESSED ***/ |
cd82ed2f | 214 | |
215 | //---------------------------------------------------------------------- | |
216 | ||
217 | void AliTOFTrigger::CreateInputs() | |
218 | { | |
ee51d470 | 219 | // creating inputs |
cd82ed2f | 220 | // Do not create inputs again!! |
ee51d470 | 221 | if( fInputs.GetEntriesFast() > 0 ) return; |
222 | ||
c06f660b | 223 | LoadActiveMask(); |
224 | ||
ee51d470 | 225 | fInputs.AddLast(new AliTriggerInput("TOF_Cosmic_MultiMuon_L0","TOF",0)); |
226 | fInputs.AddLast(new AliTriggerInput("0OIN","TOF",0)); // was "TOF_pp_MB_L0" | |
c06f660b | 227 | fInputs.AddLast(new AliTriggerInput("0OM2","TOF",0)); // was "TOF_PbPb_MB2_L0" |
228 | fInputs.AddLast(new AliTriggerInput("0OM3","TOF",0)); // was "TOF_PbPb_MB3_L0" | |
229 | fInputs.AddLast(new AliTriggerInput("0OUP","TOF",0)); // was "TOF_UltraPer_Coll_L0" | |
ee51d470 | 230 | |
231 | fInputs.AddLast(new AliTriggerInput("0OHM","TOF",0)); // was "TOF_High_Mult_L0" | |
232 | fInputs.AddLast(new AliTriggerInput("TOF_Jet_L1","TOF",0)); | |
233 | ||
cd82ed2f | 234 | } |
235 | ||
236 | //---------------------------------------------------------------------- | |
ee51d470 | 237 | void AliTOFTrigger::Trigger() { |
cd82ed2f | 238 | //triggering method |
c06f660b | 239 | fSel1=0; |
240 | fSel2=0; | |
241 | fSel3=0; | |
242 | fSel4=0; | |
c6eeb5c9 | 243 | |
cd82ed2f | 244 | CreateLTMMatrix(); |
372be75e | 245 | |
cd82ed2f | 246 | Int_t nchonFront = 0; |
247 | Int_t nchonBack = 0; | |
248 | Int_t nchonTot = 0; | |
c06f660b | 249 | Int_t nSectOn = 0; // °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° |
250 | Int_t DeSlots = -1;// °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° | |
251 | Int_t AntiDeSlots = -1;// °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° | |
cd82ed2f | 252 | Int_t nchonFrontBack = 0; |
253 | Int_t nchonFront1 = 0; | |
254 | Int_t nchonBack1 = 0; | |
255 | Int_t nchonFrontBack1 = 0; | |
256 | Int_t mindeltapsi = (Int_t)fdeltaminpsi/10; | |
257 | Int_t maxdeltapsi = (Int_t)fdeltamaxpsi/10; | |
258 | Int_t mindeltaro = (Int_t)fdeltaminro/10; | |
259 | Int_t maxdeltaro = (Int_t)fdeltamaxro/10; | |
ee51d470 | 260 | |
cd82ed2f | 261 | for (Int_t i=0;i<kNCTTM;i++){ |
262 | for (Int_t j=0;j<kNCTTMchannels;j++){ | |
ee51d470 | 263 | if (fCTTMmatrixFront[i][j]) nchonFront++; |
cd82ed2f | 264 | } |
265 | } | |
266 | ||
267 | for (Int_t i=kNCTTM;i<(kNCTTM*2);i++){ | |
268 | for (Int_t j=0;j<kNCTTMchannels;j++){ | |
ee51d470 | 269 | if (fCTTMmatrixBack[i-kNCTTM][j]) nchonBack++; |
cd82ed2f | 270 | } |
271 | } | |
272 | ||
273 | nchonTot = nchonFront + nchonBack; | |
c06f660b | 274 | // fNMaxipadOn = nchonTot; |
275 | for(Int_t i=0;i<kNCTTM;i++) { if(fLTMarray[i]) nSectOn++; } | |
cd82ed2f | 276 | |
277 | //pp Minimum Bias Trigger | |
278 | if (nchonTot >= fppMBTh) { | |
c6eeb5c9 | 279 | SetInput("0OIN"); |
c06f660b | 280 | fSel1=1; |
281 | //printf("0OIN - MB\n"); | |
282 | } | |
283 | ||
284 | // PbPb MB | |
285 | if (nchonTot >= 2) { | |
286 | SetInput("0OM2"); | |
287 | fSel2=1; | |
288 | } | |
289 | if (nchonTot >= 3) { | |
290 | SetInput("0OM3"); | |
291 | fSel3=1; | |
cd82ed2f | 292 | } |
293 | ||
294 | //High Multiplicity Trigger | |
295 | if (nchonTot >= fHighMultTh) { | |
c6eeb5c9 | 296 | SetInput("0OHM"); |
c06f660b | 297 | //printf("0OHM - High Mult\n"); |
cd82ed2f | 298 | } |
299 | ||
ee51d470 | 300 | |
cd82ed2f | 301 | //MultiMuon Trigger |
302 | nchonFront = 0; | |
303 | nchonBack = 0; | |
304 | nchonFrontBack = 0; | |
305 | ||
306 | Bool_t boolCTTMor = kFALSE; | |
307 | ||
308 | for (Int_t i=0;i<(kNCTTM/2);i++){ | |
309 | Int_t iopp = i+kNCTTM/2; | |
310 | for (Int_t j=0;j<kNCTTMchannels;j++){ | |
311 | if (fCTTMmatrixFront[i][j]){ | |
312 | Int_t minj = j-fstripWindow; | |
313 | Int_t maxj = j+fstripWindow; | |
314 | if (minj<0) minj =0; | |
315 | if (maxj>=kNCTTMchannels) maxj = kNCTTMchannels-1; | |
316 | boolCTTMor = kFALSE; | |
317 | for (Int_t k = minj;k<=maxj;k++){ | |
318 | boolCTTMor |= fCTTMmatrixFront[iopp][k]; | |
ee51d470 | 319 | } |
cd82ed2f | 320 | if (boolCTTMor) { |
321 | nchonFront++; | |
322 | } | |
323 | } | |
ee51d470 | 324 | |
cd82ed2f | 325 | if (fCTTMmatrixBack[i][j]){ |
326 | Int_t minj = j-fstripWindow; | |
327 | Int_t maxj = j+fstripWindow; | |
328 | if (minj<0) minj =0; | |
329 | if (maxj>=kNCTTMchannels) maxj =kNCTTMchannels-1; | |
330 | boolCTTMor = kFALSE; | |
331 | for (Int_t k = minj;k<=maxj;k++){ | |
332 | boolCTTMor |= fCTTMmatrixBack[iopp][k]; | |
333 | } | |
334 | if (boolCTTMor) { | |
335 | nchonBack++; | |
336 | } | |
337 | } | |
338 | } | |
339 | } | |
340 | ||
341 | nchonFrontBack = nchonFront+nchonBack; | |
342 | ||
343 | nchonFront1 = 0; | |
344 | nchonBack1 = 0; | |
345 | nchonFrontBack1 = 0; | |
346 | ||
347 | boolCTTMor = kFALSE; | |
348 | for (Int_t i=0;i<(kNCTTM/2);i++){ | |
349 | Int_t i2max = (kNCTTM-1)-i+1; | |
350 | Int_t i2min = (kNCTTM-1)-i-1; | |
351 | if (i2max >=kNCTTM) i2max = kNCTTM-1; | |
352 | if (i2min==i) i2min = kNCTTM-1-i; | |
353 | for (Int_t j=0;j<kNCTTMchannels;j++){ | |
354 | Int_t j2min = j-fstripWindow; | |
355 | Int_t j2max = j+fstripWindow; | |
356 | if (j2min<0) j2min =0; | |
357 | if (j2max>=kNCTTMchannels) j2max =kNCTTMchannels-1; | |
358 | if (fCTTMmatrixFront[i][j]){ | |
359 | boolCTTMor = kFALSE; | |
360 | for (Int_t i2=i2min;i2<=i2max;i2++){ | |
361 | for (Int_t j2 = j2min;j2<=j2max;j2++){ | |
362 | boolCTTMor |= fCTTMmatrixFront[i2][j2]; | |
ee51d470 | 363 | } |
cd82ed2f | 364 | if (boolCTTMor) { |
365 | nchonFront++; | |
366 | } | |
367 | } | |
368 | } | |
369 | if (fCTTMmatrixBack[i][j]){ | |
c06f660b | 370 | boolCTTMor = kFALSE; |
371 | for (Int_t i2=i2min;i2<=i2max;i2++){ | |
372 | for (Int_t j2 = j2min;j2<=j2max;j2++){ | |
373 | boolCTTMor |= fCTTMmatrixBack[i2][j2]; | |
374 | } | |
375 | } | |
376 | if (boolCTTMor) { | |
377 | nchonBack++; | |
cd82ed2f | 378 | } |
cd82ed2f | 379 | } |
380 | } | |
381 | } | |
c06f660b | 382 | |
cd82ed2f | 383 | nchonFrontBack1 = nchonFront1+nchonBack1; |
c06f660b | 384 | |
cd82ed2f | 385 | if (nchonFrontBack >= fMultiMuonTh || nchonFrontBack1 >= fMultiMuonTh) { |
c06f660b | 386 | SetInput("TOF_Cosmic_MultiMuon_L0"); |
cd82ed2f | 387 | } |
c06f660b | 388 | |
cd82ed2f | 389 | //Ultra-Peripheral collision Trigger |
c06f660b | 390 | |
391 | // °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° | |
392 | // DeSlots = (k+1)_Array Element - k_Array Element | |
393 | // AntiDeSlots = kNCTTM - DeSlots | |
394 | ||
395 | if((!fSel1))// && nchonFront < 4 && nchonBack < 4) | |
396 | { | |
397 | // printf("nHitMaxipad CLASSE: %i \n",fNMaxipadOn); | |
398 | // printf("Total Number per event of Switched-On sectors : %i \n", nSectOn); | |
399 | // printf("mindeltapsi %i \n", mindeltapsi); | |
400 | //printf("maxdeltapsi %i \n", maxdeltapsi); | |
401 | for(Int_t i = 0; i < kNCTTM; i++){ | |
402 | if(fLTMarray[i]){ | |
403 | // printf(" i-sect On: %i\n",i); | |
404 | for(Int_t j = i+1; j < kNCTTM; j++){ | |
405 | if(fLTMarray[j]) { | |
406 | // printf(" j-sect On: %i\n",j); | |
407 | DeSlots = j-i; | |
408 | AntiDeSlots = kNCTTM - DeSlots; | |
409 | //printf("DeSlots = %i \n",DeSlots); | |
410 | //printf("AntiDeSlots = %i \n",AntiDeSlots); | |
411 | if(DeSlots >= mindeltapsi && DeSlots <= maxdeltapsi){ | |
412 | fSel4=1; | |
413 | SetInput("0OUP"); | |
414 | //printf("trigger On with DeSlot \n"); | |
415 | } | |
416 | if(AntiDeSlots >= mindeltapsi && AntiDeSlots <= maxdeltapsi){ | |
417 | fSel4=1; | |
418 | SetInput("0OUP"); | |
419 | //printf("trigger On with AntiDeSlot \n"); | |
420 | } | |
421 | ||
422 | ||
423 | if(DeSlots >= mindeltaro && DeSlots <= maxdeltaro){ | |
424 | fSel4=1; | |
425 | SetInput("0OUP"); | |
426 | //printf("trigger On with DeSlot \n"); | |
427 | } | |
428 | if(AntiDeSlots >= mindeltaro && AntiDeSlots <= maxdeltaro){ | |
429 | fSel4=1; | |
430 | SetInput("0OUP"); | |
431 | //printf("trigger On with AntiDeSlot \n"); | |
432 | } | |
433 | ||
434 | } | |
435 | ||
436 | } | |
cd82ed2f | 437 | } |
cd82ed2f | 438 | } |
c06f660b | 439 | } |
cd82ed2f | 440 | } |
ee51d470 | 441 | |
cd82ed2f | 442 | //----------------------------------------------------------------------------- |
ee51d470 | 443 | void AliTOFTrigger::CreateLTMMatrix() { |
cd82ed2f | 444 | //creating LTMMatrix |
ee51d470 | 445 | //initialization |
446 | CreateLTMMatrixFromDigits(); | |
447 | } | |
448 | ||
449 | //------------------------------------------------------------------------- | |
450 | ||
451 | void AliTOFTrigger::CreateLTMMatrixFromDigits() { | |
452 | // | |
453 | // Create LTM matrix by TOF digits | |
454 | // | |
455 | ||
cd82ed2f | 456 | //initialization |
8104fec9 | 457 | for (Int_t i=0;i<kNCTTM;i++) fLTMarray[i]= kFALSE; |
cd82ed2f | 458 | for (Int_t i=0;i<kNLTM;i++){ |
459 | for (Int_t j=0;j<kNLTMchannels;j++){ | |
460 | fLTMmatrix[i][j]=kFALSE; | |
461 | } | |
462 | } | |
5cd96e39 | 463 | for (Int_t i=0;i<kNCTTM;i++){ |
464 | for (Int_t j=0;j<kNCTTMchannels;j++){ | |
465 | fCTTMmatrixFront[i][j]=kFALSE; | |
466 | fCTTMmatrixBack[i][j]=kFALSE; | |
467 | } | |
468 | } | |
469 | ||
470 | ||
cd82ed2f | 471 | AliRunLoader *rl; |
33c3c91a | 472 | rl = AliRunLoader::Instance(); |
ee51d470 | 473 | |
cd82ed2f | 474 | Int_t ncurrevent = rl->GetEventNumber(); |
475 | rl->GetEvent(ncurrevent); | |
ee51d470 | 476 | |
cd82ed2f | 477 | AliLoader * tofLoader = rl->GetLoader("TOFLoader"); |
ee51d470 | 478 | |
cd82ed2f | 479 | tofLoader->LoadDigits("read"); |
480 | TTree *treeD = tofLoader->TreeD(); | |
8104fec9 | 481 | if (treeD == 0x0) { |
482 | AliFatal("AliTOFTrigger: Can not get TreeD"); | |
483 | return; | |
484 | } | |
ee51d470 | 485 | |
cd82ed2f | 486 | TBranch *branch = treeD->GetBranch("TOF"); |
ee51d470 | 487 | if (!branch) { |
cd82ed2f | 488 | AliError("can't get the branch with the TOF digits !"); |
489 | return; | |
490 | } | |
491 | TClonesArray *tofDigits =new TClonesArray("AliTOFdigit", 1000); | |
492 | branch->SetAddress(&tofDigits); | |
493 | treeD->GetEvent(0); | |
494 | Int_t ndigits = tofDigits->GetEntriesFast(); | |
495 | Int_t detind[5]; //detector indexes: 0 -> sector | |
c06f660b | 496 | // 1 -> plate(modulo) |
cd82ed2f | 497 | // 2 -> strip |
498 | // 3 -> padz | |
499 | // 4 -> padx | |
ee51d470 | 500 | |
372be75e | 501 | if(! fgTofGeo) fgTofGeo = new AliTOFGeometry(); |
502 | ||
503 | ||
cd82ed2f | 504 | for (Int_t i=0;i<ndigits;i++){ |
505 | AliTOFdigit * digit = (AliTOFdigit*)tofDigits->UncheckedAt(i); | |
506 | detind[0] = digit->GetSector(); | |
507 | detind[1] = digit->GetPlate(); | |
508 | detind[2] = digit->GetStrip(); | |
509 | detind[3] = digit->GetPadz(); | |
510 | detind[4] = digit->GetPadx(); | |
ee51d470 | 511 | |
cd82ed2f | 512 | Int_t indexLTM[2] = {-1,-1}; |
513 | GetLTMIndex(detind,indexLTM); | |
514 | ||
372be75e | 515 | Float_t timedigit = digit->GetTdc()*AliTOFGeometry::TdcBinWidth()*1E-3; // time digit in ns |
516 | ||
517 | Float_t pos[3]; | |
518 | fgTofGeo->GetPosPar(detind, pos); | |
519 | Float_t length = 0.; | |
520 | for (Int_t ic = 0; ic < 3; ic++) length += pos[ic] * pos[ic]; | |
521 | length = TMath::Sqrt(length); | |
522 | timedigit -= length * 0.0333564095198152043; // subtract the minimal time in ns for the current channel | |
523 | ||
524 | if(timedigit > fStartTimeHit - 0.5 && timedigit < fStartTimeHit + fTimeWidthTrigger - 0.5) | |
525 | fLTMmatrix[indexLTM[0]][indexLTM[1]] = kTRUE; | |
526 | ||
c11d3763 | 527 | // fLTMarray[indexLTM[0]%36] = kTRUE; //dimensione MAX array 36 = kNCTTM |
372be75e | 528 | } |
c06f660b | 529 | |
cd82ed2f | 530 | |
28751b82 | 531 | tofLoader->UnloadDigits(); |
ee51d470 | 532 | // rl->UnloadgAlice(); |
533 | CreateCTTMMatrix(); | |
534 | ||
cd82ed2f | 535 | } |
ee51d470 | 536 | |
cd82ed2f | 537 | //----------------------------------------------------------------------------- |
ee51d470 | 538 | |
539 | void AliTOFTrigger::CreateLTMMatrixFromRaw(AliRawReader *fRawReader) { | |
540 | // | |
541 | // Create LTM matrix by TOF raw data | |
542 | // | |
543 | ||
544 | //initialization | |
545 | for (Int_t i=0;i<kNLTM;i++){ | |
546 | for (Int_t j=0;j<kNLTMchannels;j++){ | |
547 | fLTMmatrix[i][j]=kFALSE; | |
548 | } | |
549 | } | |
5cd96e39 | 550 | for (Int_t i=0;i<kNCTTM;i++){ |
551 | for (Int_t j=0;j<kNCTTMchannels;j++){ | |
552 | fCTTMmatrixFront[i][j]=kFALSE; | |
553 | fCTTMmatrixBack[i][j]=kFALSE; | |
554 | } | |
555 | } | |
ee51d470 | 556 | |
557 | if(fRawReader){ | |
558 | AliTOFRawStream * tofRawStream = new AliTOFRawStream(); | |
559 | ||
560 | Int_t inholes = 0; | |
561 | ||
562 | //if(!GetLoader()->TreeS()) {MakeTree("S"); MakeBranch("S");} | |
563 | ||
564 | Clear(); | |
565 | tofRawStream->SetRawReader(fRawReader); | |
566 | ||
567 | //ofstream ftxt; | |
568 | //if (fVerbose==2) ftxt.open("TOFsdigitsRead.txt",ios::app); | |
569 | ||
570 | TClonesArray staticRawData("AliTOFrawData",10000); | |
571 | staticRawData.Clear(); | |
572 | TClonesArray * clonesRawData = &staticRawData; | |
573 | ||
574 | Int_t dummy = -1; | |
575 | Int_t detectorIndex[5] = {-1, -1, -1, -1, -1}; | |
576 | Int_t digit[2]; | |
577 | //Int_t track = -1; | |
578 | //Int_t last = -1; | |
579 | ||
580 | Int_t indexDDL = 0; | |
581 | Int_t iRawData = 0; | |
582 | AliTOFrawData *tofRawDatum = 0; | |
583 | for (indexDDL=0; indexDDL<AliDAQ::NumberOfDdls("TOF"); indexDDL++) { | |
584 | ||
585 | fRawReader->Reset(); | |
5cd96e39 | 586 | tofRawStream->LoadRawDataBuffersV2(indexDDL); |
ee51d470 | 587 | |
588 | clonesRawData = tofRawStream->GetRawData(); | |
589 | if (clonesRawData->GetEntriesFast()!=0) AliInfo(Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast())); | |
590 | for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) { | |
591 | ||
592 | tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData); | |
593 | ||
594 | //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue; | |
595 | if (tofRawDatum->GetTOF()==-1) continue; | |
596 | ||
597 | SetBit(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(), | |
598 | tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel()); | |
599 | ||
600 | dummy = detectorIndex[3]; | |
601 | detectorIndex[3] = detectorIndex[4];//padz | |
602 | detectorIndex[4] = dummy;//padx | |
603 | ||
604 | digit[0] = tofRawDatum->GetTOF(); | |
605 | digit[1] = tofRawDatum->GetTOT(); | |
606 | ||
607 | dummy = detectorIndex[3]; | |
608 | detectorIndex[3] = detectorIndex[4];//padx | |
609 | detectorIndex[4] = dummy;//padz | |
610 | ||
611 | // Do not reconstruct anything in the holes | |
612 | if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes | |
613 | if (detectorIndex[1]==2) { // plate with holes | |
614 | inholes++; | |
615 | continue; | |
616 | } | |
617 | } | |
618 | ||
619 | tofRawDatum = 0; | |
620 | } // while loop | |
621 | ||
622 | clonesRawData->Clear(); | |
623 | ||
624 | } // DDL Loop | |
625 | ||
626 | //if (fVerbose==2) ftxt.close(); | |
627 | ||
628 | if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes)); | |
6ec122c0 | 629 | delete tofRawStream; |
630 | tofRawStream = NULL; | |
ee51d470 | 631 | |
632 | } | |
633 | ||
634 | } | |
635 | ||
636 | //----------------------------------------------------------------------------- | |
42e171ac | 637 | void AliTOFTrigger::GetLTMIndex(const Int_t * const detind, Int_t *indexLTM) { |
ee51d470 | 638 | // |
639 | // getting LTMmatrix indexes for current digit | |
640 | // | |
641 | ||
cd82ed2f | 642 | if (detind[1]==0 || detind[1]==1 || (detind[1]==2 && detind[2]<=7)) { |
643 | if (detind[4]<24){ | |
644 | indexLTM[0] = detind[0]*2; | |
645 | } | |
646 | else { | |
647 | indexLTM[0] = detind[0]*2+1; | |
648 | } | |
649 | } | |
650 | else { | |
651 | if (detind[4]<24){ | |
652 | indexLTM[0] = detind[0]*2+36; | |
653 | } | |
654 | else { | |
655 | indexLTM[0] = (detind[0]*2+1)+36; | |
656 | } | |
657 | } | |
658 | ||
ee51d470 | 659 | if (indexLTM[0]<36) { |
cd82ed2f | 660 | if (detind[1] ==0){ |
661 | indexLTM[1] = detind[2]; | |
662 | } | |
663 | else if (detind[1] ==1){ | |
664 | indexLTM[1] = detind[2]+19; | |
665 | } | |
666 | else if (detind[1] ==2){ | |
2901911a | 667 | indexLTM[1] = detind[2]+19*2; |
cd82ed2f | 668 | } |
669 | else{ | |
670 | AliError("Smth Wrong!!!"); | |
671 | } | |
672 | } | |
673 | else { | |
674 | if (detind[1] ==2){ | |
675 | indexLTM[1] = detind[2]-8; | |
676 | } | |
677 | else if (detind[1] ==3){ | |
678 | indexLTM[1] = detind[2]+7; | |
679 | } | |
680 | else if (detind[1] ==4){ | |
681 | indexLTM[1] = detind[2]+26; | |
682 | } | |
683 | else{ | |
684 | AliError("Smth Wrong!!!"); | |
685 | } | |
686 | } | |
ee51d470 | 687 | |
688 | } | |
689 | //------------------------------------------------------------------------- | |
690 | /* | |
691 | // to be checked because of warning problems | |
692 | void AliTOFTrigger::PrintMap() | |
693 | { | |
694 | // | |
695 | // | |
696 | // | |
697 | ||
698 | for(Int_t i = 0; i<kNLTM;i++) { | |
699 | if(i<36) { | |
700 | printf("| %d | %d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |\n", | |
701 | (fCTTMmatrixFront[i][0])?1:0,(fCTTMmatrixFront[i][1])?1:0,(fCTTMmatrixFront[i][2])?1:0, \ | |
702 | (fCTTMmatrixFront[i][3])?1:0,(fCTTMmatrixFront[i][4])?1:0,(fCTTMmatrixFront[i][5])?1:0, \ | |
703 | (fCTTMmatrixFront[i][6])?1:0,(fCTTMmatrixFront[i][7])?1:0,(fCTTMmatrixFront[i][8])?1:0, \ | |
704 | (fCTTMmatrixFront[i][9])?1:0,(fCTTMmatrixFront[i][10])?1:0,(fCTTMmatrixFront[i][11])?1:0, \ | |
705 | (fCTTMmatrixFront[i][12])?1:0,(fCTTMmatrixFront[i][13])?1:0,(fCTTMmatrixFront[i][14])?1:0, \ | |
706 | (fCTTMmatrixFront[i][15])?1:0,(fCTTMmatrixFront[i][16])?1:0,(fCTTMmatrixFront[i][17])?1:0, \ | |
707 | (fCTTMmatrixFront[i][18])?1:0,(fCTTMmatrixFront[i][19])?1:0,(fCTTMmatrixFront[i][20])?1:0, \ | |
708 | (fCTTMmatrixFront[i][21])?1:0,(fCTTMmatrixFront[i][22])?1:0,(fCTTMmatrixFront[i][23])?1:0); | |
709 | } else { | |
710 | printf("| %d | %d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |\n", | |
711 | (fCTTMmatrixBack[i][0])?1:0,(fCTTMmatrixBack[i][1])?1:0,(fCTTMmatrixBack[i][2])?1:0, \ | |
712 | (fCTTMmatrixBack[i][3])?1:0,(fCTTMmatrixBack[i][4])?1:0,(fCTTMmatrixBack[i][5])?1:0, \ | |
713 | (fCTTMmatrixBack[i][6])?1:0,(fCTTMmatrixBack[i][7])?1:0,(fCTTMmatrixBack[i][8])?1:0, \ | |
714 | (fCTTMmatrixBack[i][9])?1:0,(fCTTMmatrixBack[i][10])?1:0,(fCTTMmatrixBack[i][11])?1:0, \ | |
715 | (fCTTMmatrixBack[i][12])?1:0,(fCTTMmatrixBack[i][13])?1:0,(fCTTMmatrixBack[i][14])?1:0, \ | |
716 | (fCTTMmatrixBack[i][15])?1:0,(fCTTMmatrixBack[i][16])?1:0,(fCTTMmatrixBack[i][17])?1:0, \ | |
717 | (fCTTMmatrixBack[i][18])?1:0,(fCTTMmatrixBack[i][19])?1:0,(fCTTMmatrixBack[i][20])?1:0, \ | |
718 | (fCTTMmatrixBack[i][21])?1:0,(fCTTMmatrixBack[i][22])?1:0,(fCTTMmatrixBack[i][23])?1:0); | |
719 | } | |
720 | } | |
721 | ||
722 | } | |
723 | */ | |
724 | //------------------------------------------------------------------------- | |
725 | ||
5cd96e39 | 726 | void AliTOFTrigger::GetMapMatrix(Bool_t map[][24]) const |
727 | { | |
728 | // | |
729 | // Returns CTTM map | |
730 | // | |
731 | ||
732 | for(Int_t i = 0; i<kNLTM;i++) | |
733 | for(Int_t j = 0; j<kNCTTMchannels;j++) | |
734 | map[i][j]=(i<36)?fCTTMmatrixFront[i][j]:fCTTMmatrixBack[i-36][j]; | |
735 | ||
736 | } | |
737 | //------------------------------------------------------------------------- | |
738 | ||
42e171ac | 739 | void AliTOFTrigger::GetMap(Bool_t **map) const |
ee51d470 | 740 | { |
741 | // | |
42e171ac | 742 | // Returns CTTM map |
ee51d470 | 743 | // |
744 | ||
745 | for(Int_t i = 0; i<kNLTM;i++) | |
746 | for(Int_t j = 0; j<kNCTTMchannels;j++) | |
5cd96e39 | 747 | map[i][j]=(i<36)?fCTTMmatrixFront[i][j]:fCTTMmatrixBack[i-36][j]; |
ee51d470 | 748 | |
749 | } | |
750 | ||
5cd96e39 | 751 | |
ee51d470 | 752 | //------------------------------------------------------------------------- |
42e171ac | 753 | void AliTOFTrigger::GetTRDmap(Bool_t **map) const |
ee51d470 | 754 | { |
755 | // | |
756 | // Retriev the bit map sent to the TRD detector | |
757 | // | |
5cd96e39 | 758 | |
759 | for(int i = 0; i<kNLTM;i++) | |
760 | for(int j = 0; j<kNLTMtoTRDchannels;j++){ | |
761 | map[i][j]=kFALSE; | |
762 | } | |
ee51d470 | 763 | |
5cd96e39 | 764 | for(int i = 0; i<kNLTM/2;i++) |
ee51d470 | 765 | for(int j = 0; j<AliTOFTrigger::kNCTTMchannels;j++){ |
5cd96e39 | 766 | UInt_t uTRDbit=j/3; |
767 | if(fCTTMmatrixFront[i][j]) map[i][uTRDbit]=kTRUE; | |
ee51d470 | 768 | } |
769 | for(int i = kNLTM/2; i<kNLTM;i++) | |
5cd96e39 | 770 | for(int j = 0; j<AliTOFTrigger::kNCTTMchannels;j++){ |
771 | UInt_t uTRDbit=j/3; | |
772 | if(fCTTMmatrixBack[i-kNLTM/2][j]) map[i][uTRDbit]=kTRUE; | |
773 | } | |
774 | ||
775 | } | |
776 | //------------------------------------------------------------------------- | |
777 | void AliTOFTrigger::GetTRDmapMatrix(Bool_t map[][8]) const | |
778 | { | |
779 | // | |
780 | // Retriev the bit map sent to the TRD detector | |
781 | // | |
782 | ||
783 | for(int i = 0; i<kNLTM;i++) | |
784 | for(int j = 0; j<kNLTMtoTRDchannels;j++){ | |
785 | map[i][j]=kFALSE; | |
786 | } | |
787 | ||
788 | for(int i = 0; i<kNLTM/2;i++) | |
ee51d470 | 789 | for(int j = 0; j<AliTOFTrigger::kNCTTMchannels;j++){ |
5cd96e39 | 790 | UInt_t uTRDbit=j/3; |
791 | if(fCTTMmatrixFront[i][j]) map[i][uTRDbit]=kTRUE; | |
792 | } | |
793 | for(int i = kNLTM/2; i<kNLTM;i++) | |
794 | for(int j = 0; j<AliTOFTrigger::kNCTTMchannels;j++){ | |
795 | UInt_t uTRDbit=j/3; | |
796 | if(fCTTMmatrixBack[i-kNLTM/2][j]) map[i][uTRDbit]=kTRUE; | |
ee51d470 | 797 | } |
5cd96e39 | 798 | |
ee51d470 | 799 | } |
800 | ||
801 | //------------------------------------------------------------------------- | |
802 | void AliTOFTrigger::SetBit(Int_t *detind) | |
803 | { | |
804 | // | |
42e171ac | 805 | // Sets CTTM map element corresponding to detector element 'detind' |
ee51d470 | 806 | // |
807 | ||
808 | Int_t index[2]; | |
809 | GetCTTMIndex(detind,index); | |
810 | if(index[0]<36) | |
811 | fCTTMmatrixFront[index[0]][index[1]]=kTRUE; | |
812 | else | |
5cd96e39 | 813 | fCTTMmatrixBack[index[0]-36][index[1]]=kTRUE; |
ee51d470 | 814 | |
815 | } | |
816 | ||
817 | //------------------------------------------------------------------------- | |
818 | void AliTOFTrigger::SetBit(Int_t nDDL, Int_t nTRM, Int_t iChain, | |
819 | Int_t iTDC, Int_t iCH) | |
820 | { | |
821 | // | |
42e171ac | 822 | // Sets CTTM map element corresponding to equipment ID |
823 | // labelled by number nDDL, nTRM, iChain, iTDC, iCH | |
ee51d470 | 824 | // |
825 | ||
5cd96e39 | 826 | if(nTRM==3 && iTDC>=12 && iTDC<=14 && nDDL%2==1){ // DDL number to LTM number mapping |
827 | // getchar(); | |
ee51d470 | 828 | Int_t iLTMindex=-1; |
829 | Int_t iChannelIndex=-1; | |
830 | switch(nDDL%AliTOFGeometry::NDDL()){ | |
831 | case 1: | |
832 | iLTMindex=1; | |
833 | break; | |
834 | case 3: | |
835 | iLTMindex=36; | |
836 | break; | |
837 | default: | |
838 | AliError("Call this function only if(nTRM==3 && iTDC>12 && iTDC<14 && nDDL%2==1) "); | |
839 | break; | |
840 | } | |
841 | iLTMindex+=2*(Int_t)(nDDL/AliTOFGeometry::NDDL()); | |
842 | if(iChain==0 && nDDL<36) | |
843 | iLTMindex--; | |
844 | if(iChain==0 && nDDL>=36) | |
845 | iLTMindex++; | |
846 | iChannelIndex=iCH+iTDC*AliTOFGeometry::NCh()-12*AliTOFGeometry::NCh(); | |
847 | Int_t index[2]={iLTMindex,iChannelIndex}; | |
5cd96e39 | 848 | if (index[0]<36){ |
ee51d470 | 849 | fCTTMmatrixFront[index[0]][index[1]]=kTRUE; |
5cd96e39 | 850 | fLTMmatrix[index[0]][index[1]*2]=kTRUE; |
851 | } | |
852 | else{ | |
853 | fCTTMmatrixBack[index[0]-36][index[1]]=kTRUE; | |
854 | fLTMmatrix[index[0]][index[1]*2]=kTRUE; | |
855 | } | |
856 | } | |
ee51d470 | 857 | |
858 | } | |
859 | //------------------------------------------------------------------------- | |
860 | ||
861 | void AliTOFTrigger::ResetBit(Int_t *detind) | |
862 | { | |
863 | // | |
42e171ac | 864 | // Sets CTTM map element corresponding to detector element 'detind' |
ee51d470 | 865 | // |
866 | ||
867 | Int_t index[2]; | |
868 | GetCTTMIndex(detind,index); | |
869 | if(index[0]<36) | |
870 | fCTTMmatrixFront[index[0]][index[1]]=kFALSE; | |
871 | else | |
5cd96e39 | 872 | fCTTMmatrixBack[index[0]-36][index[1]]=kFALSE; |
ee51d470 | 873 | |
874 | } | |
875 | ||
876 | //------------------------------------------------------------------------- | |
877 | void AliTOFTrigger::ResetBit(Int_t nDDL, Int_t nTRM, Int_t iChain, | |
878 | Int_t iTDC, Int_t iCH) | |
879 | { | |
880 | // | |
42e171ac | 881 | // Sets CTTM map element corresponding to equipment ID |
882 | // labelled by number nDDL, nTRM, iChain, iTDC, iCH | |
ee51d470 | 883 | // |
884 | ||
885 | if(nTRM==3 && iTDC>12 && iTDC<14 && nDDL%2==1){ // DDL number to LTM number mapping | |
886 | Int_t iLTMindex=-1; | |
887 | Int_t iChannelIndex=-1; | |
888 | switch(nDDL%AliTOFGeometry::NDDL()){ | |
889 | case 1: | |
890 | iLTMindex=1; | |
891 | break; | |
892 | case 3: | |
893 | iLTMindex=36; | |
894 | break; | |
895 | default: | |
896 | AliError("Call this function only if(nTRM==3 && iTDC>12 && iTDC<14 && nDDL%2==1) "); | |
897 | break; | |
898 | } | |
899 | iLTMindex+=2*(Int_t)(nDDL/AliTOFGeometry::NDDL()); | |
900 | if(iChain==0 && nDDL<36) | |
901 | iLTMindex--; | |
902 | if(iChain==0 && nDDL>=36) | |
903 | iLTMindex++; | |
904 | iChannelIndex=iCH+iTDC*AliTOFGeometry::NCh()-12*AliTOFGeometry::NCh(); | |
905 | Int_t index[2]={iLTMindex,iChannelIndex}; | |
5cd96e39 | 906 | if (index[0]<36){ |
ee51d470 | 907 | fCTTMmatrixFront[index[0]][index[1]]=kFALSE; |
5cd96e39 | 908 | } |
909 | else{ | |
910 | fCTTMmatrixBack[index[0]-36][index[1]]=kFALSE; | |
911 | } | |
ee51d470 | 912 | } |
913 | else | |
914 | AliError("Call this function only if(nTRM==3 && iTDC>12 && iTDC<14 && nDDL%2==1) "); | |
915 | ||
916 | } | |
917 | //------------------------------------------------------------------------- | |
918 | ||
919 | Bool_t AliTOFTrigger::GetBit(Int_t *detind) | |
920 | { | |
921 | // | |
42e171ac | 922 | // Returns CTTM map element corresponding to detector element 'detind' |
ee51d470 | 923 | // |
924 | ||
925 | Int_t index[2]; | |
926 | GetCTTMIndex(detind,index); | |
5cd96e39 | 927 | return (index[0]<36)?fCTTMmatrixFront[index[0]][index[1]]:fCTTMmatrixBack[index[0]-36][index[1]]; |
ee51d470 | 928 | |
929 | } | |
930 | ||
931 | //------------------------------------------------------------------------- | |
932 | Bool_t AliTOFTrigger::GetBit(Int_t nDDL, Int_t nTRM, Int_t iChain, | |
933 | Int_t iTDC, Int_t iCH) | |
934 | { | |
935 | // | |
42e171ac | 936 | // Returns CTTM map element corresponding to equipment ID |
937 | // labelled by number nDDL, nTRM, iChain, iTDC, iCH | |
ee51d470 | 938 | // |
939 | ||
940 | if ( !(nTRM==3 && iTDC>12 && iTDC<14 && nDDL%2==1) ) { | |
941 | AliWarning("Call this function only if(nTRM==3 && iTDC>12 && iTDC<14) "); | |
942 | return kFALSE; | |
943 | } | |
944 | //if (nTRM==3 && iTDC>12 && iTDC<14 && nDDL%2==1) { // DDL number to LTM number mapping | |
945 | ||
946 | UInt_t iLTMindex=0; | |
947 | UInt_t iChannelindex=0; | |
948 | switch(nDDL%AliTOFGeometry::NDDL()) { | |
949 | case 1: | |
950 | iLTMindex=1; | |
951 | break; | |
952 | case 3: | |
953 | iLTMindex=36; | |
954 | break; | |
955 | default: | |
956 | AliError("something wrong"); | |
957 | break; | |
958 | } | |
959 | iLTMindex+=2*(Int_t)(nDDL/AliTOFGeometry::NDDL()); | |
960 | ||
961 | if (iChain==1) return kFALSE; // AdC | |
962 | ||
963 | if (nDDL<36) | |
964 | iLTMindex--; | |
965 | if (nDDL>=36) | |
966 | iLTMindex++; | |
967 | iChannelindex=iCH+iTDC*AliTOFGeometry::NCh()-12*AliTOFGeometry::NCh(); | |
968 | Int_t index[2]={iLTMindex,iChannelindex}; | |
5cd96e39 | 969 | return (index[0]<36)?fCTTMmatrixFront[index[0]][index[1]]:fCTTMmatrixBack[index[0]-36][index[1]]; |
ee51d470 | 970 | |
971 | } | |
972 | ||
973 | //------------------------------------------------------------------------- | |
974 | ||
975 | void AliTOFTrigger::CreateCTTMMatrix() { | |
976 | // | |
977 | // Create CTTM bit map | |
978 | // | |
a6ec5bf6 | 979 | Int_t fromTriggertoDCS[72] = {0,1,4,5,8,9,12,13,16,17,20,21,24,25,28,29,32,33,36,37,40,41,44,45,48,49,52,53,56,57,60,61,64,65,68,69,3, |
980 | 2,7,6,11,10,15,14,19,18,23,22,27,26,31,30,35,34,39,38,43,42,47,46,51,50,55,54,59,58,63,62,67,66,71,70}; | |
981 | ||
982 | ||
c06f660b | 983 | fNMaxipadOnAll=0; |
984 | fNMaxipadOn=0; | |
985 | ||
986 | for(Int_t i = 0; i<kNLTM;i++){ | |
987 | UInt_t currentMask = fPowerMask[kNCTTMchannels]-1; | |
a6ec5bf6 | 988 | if(fTOFTrigMask) currentMask=fTOFTrigMask->GetTriggerMask(fromTriggertoDCS[i]); |
c06f660b | 989 | if(i<kNCTTM){ |
990 | for(Int_t j = 0; j<kNCTTMchannels;j++){ | |
991 | fCTTMmatrixFront[i][j]=fLTMmatrix[i][2*j]||fLTMmatrix[i][2*j+1]; | |
992 | if(fCTTMmatrixFront[i][j]) fNMaxipadOnAll++; | |
993 | if(!(currentMask & fPowerMask[j])) fCTTMmatrixFront[i][j]=0; | |
c11d3763 | 994 | if(fCTTMmatrixFront[i][j]){ |
995 | fNMaxipadOn++; | |
996 | fLTMarray[i] = kTRUE; | |
997 | } | |
c06f660b | 998 | } |
999 | } | |
1000 | else{ | |
1001 | for(Int_t j = 0; j<kNCTTMchannels;j++){ | |
1002 | fCTTMmatrixBack[i-kNCTTM][j]=fLTMmatrix[i][2*j]||fLTMmatrix[i][2*j+1];; | |
1003 | if(fCTTMmatrixBack[i-kNCTTM][j]) fNMaxipadOnAll++; | |
1004 | if(!(currentMask & fPowerMask[j])) fCTTMmatrixBack[i-kNCTTM][j]=0; | |
c11d3763 | 1005 | if(fCTTMmatrixBack[i-kNCTTM][j]){ |
1006 | fNMaxipadOn++; | |
1007 | fLTMarray[i-kNCTTM] = kTRUE; | |
1008 | } | |
c06f660b | 1009 | } |
1010 | } | |
ee51d470 | 1011 | } |
c11d3763 | 1012 | |
1013 | fNCrateOn = 0; | |
1014 | for(Int_t j=0; j < kNCTTM; j++) {if(fLTMarray[j]) fNCrateOn++;} | |
1015 | ||
ee51d470 | 1016 | } |
1017 | //----------------------------------------------------------------------------- | |
1018 | ||
1019 | void AliTOFTrigger::GetCTTMIndex(Int_t *detind, Int_t *indexCTTM) { | |
1020 | // | |
42e171ac | 1021 | // Returns CTTM index corresponding to the detector element detind |
ee51d470 | 1022 | // |
1023 | ||
1024 | GetLTMIndex(detind,indexCTTM); | |
1025 | indexCTTM[1]/=2; | |
1026 | ||
cd82ed2f | 1027 | } |
c06f660b | 1028 | //----------------------------------------------------------------------------- |
1029 | void AliTOFTrigger::LoadActiveMask(){ | |
1030 | // | |
1031 | // Load OCDB current mask | |
1032 | // | |
c11d3763 | 1033 | |
1034 | AliCDBManager *cdb = AliCDBManager::Instance(); | |
1035 | if(cdb->GetRun() < 0 || !(cdb->GetDefaultStorage())){ | |
1036 | if(!(cdb->GetDefaultStorage())){ | |
1037 | cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); | |
1038 | printf("AliTOFTrigger (WARNING): probably CDB first instance - Default Sorage set to \"local://$ALICE_ROOT/OCDB\"\n"); | |
1039 | } | |
1040 | if(cdb->GetRun() < 0){ | |
1041 | cdb->SetRun(0); | |
1042 | printf("AliTOFTrigger (WARNING): probably CDB first instance - number of run set to 0\n"); | |
1043 | } | |
1044 | } | |
de40f9c1 | 1045 | |
c11d3763 | 1046 | AliCDBEntry *cdbe = cdb->Get("TRIGGER/TOF/TriggerMask"); |
de40f9c1 | 1047 | if(!cdbe) return; |
c11d3763 | 1048 | fTOFTrigMask= (AliTOFTriggerMask *)cdbe->GetObject(); |
c06f660b | 1049 | |
c11d3763 | 1050 | // UInt_t maskArray[kNLTM]; |
1051 | // if(fTOFTrigMask == NULL) fTOFTrigMask = new AliTOFTriggerMask(); | |
1052 | // for (Int_t k = 0; k < kNLTM ; k++) maskArray[k] = fPowerMask[kNCTTMchannels]-1; | |
1053 | // //for (Int_t k = 0; k < kNLTM ; k+=2) maskArray[k] = 0; | |
1054 | ||
1055 | // fTOFTrigMask->SetTriggerMaskArray(maskArray); | |
c06f660b | 1056 | } |
1057 | ||
1058 | ||
1059 | //----------------------------------------------------------------------------- | |
1060 | AliTOFTrigger::~AliTOFTrigger() | |
1061 | { | |
1062 | // dtor | |
1063 | ||
c06f660b | 1064 | } |
1065 | ||
1066 | //----------------------------------------------------------------------------- | |
1067 | AliTOFTrigger& AliTOFTrigger::operator=(const AliTOFTrigger &/*source*/) | |
1068 | { | |
1069 | // ass. op. | |
1070 | return *this; | |
1071 | ||
1072 | } | |
c11d3763 | 1073 |