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