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