1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 /////////////////////////////////////////////////////////////////////
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)
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
32 /////////////////////////////////////////////////////////////////////
34 #include <TClonesArray.h>
37 #include "AliLoader.h"
39 #include "AliRunLoader.h"
41 #include "AliTriggerInput.h"
42 #include "AliRawReader.h"
44 #include "AliTOFRawStream.h"
45 #include "AliTOFrawData.h"
46 #include "AliTOFdigit.h"
47 #include "AliTOFGeometry.h"
48 #include "AliTOFTrigger.h"
49 #include "AliTOFTriggerMask.h"
51 #include "AliCDBManager.h"
52 #include "AliCDBEntry.h"
55 extern AliRun* gAlice;
57 //-------------------------------------------------------------------------
58 ClassImp(AliTOFTrigger)
60 //----------------------------------------------------------------------
61 AliTOFTrigger::AliTOFTrigger() :
64 fppMBTh(4),//4:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
67 fdeltaminpsi(150), //150
68 fdeltamaxpsi(170), //170
82 for (Int_t i=0;i<kNCTTM;i++) fLTMarray[i] = kFALSE;
84 for (Int_t i=0;i<kNLTM;i++){
86 for (Int_t j=0;j<kNLTMchannels;j++){
87 fLTMmatrix[i][j]=kFALSE;
90 for (Int_t j=0;j<kNCTTMchannels;j++){
91 fCTTMmatrixFront[i][j]=kFALSE;
92 fCTTMmatrixBack[i][j]=kFALSE;
98 for(Int_t i=1;i <= kNCTTMchannels;i++){
99 fPowerMask[i] = fPowerMask[i-1]*2;
107 //----------------------------------------------------------------------
109 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) :
110 AliTriggerDetector(),
111 fHighMultTh(HighMultTh),
113 fMultiMuonTh(MultiMuonTh),
115 fdeltaminpsi(deltaminpsi),
116 fdeltamaxpsi(deltamaxpsi),
117 fdeltaminro(deltaminro),
118 fdeltamaxro(deltamaxro),
119 fstripWindow(stripWindow),
129 //ctor with thresholds for triggers
130 for (Int_t i=0;i<kNCTTM;i++) fLTMarray[i] = kFALSE;
131 for (Int_t i=0;i<kNLTM;i++){
132 for (Int_t j=0;j<kNLTMchannels;j++){
133 fLTMmatrix[i][j]=kFALSE;
136 for (Int_t j=0;j<kNCTTMchannels;j++){
137 fCTTMmatrixFront[i][j]=kFALSE;
138 fCTTMmatrixBack[i][j]=kFALSE;
144 for(Int_t i=1;i <= kNCTTMchannels;i++){
145 fPowerMask[i] = fPowerMask[i-1]*2;
153 #if 0 /*** COPY CONSTRUCTOR SUPPRESSED **/
154 //____________________________________________________________________________
156 AliTOFTrigger::AliTOFTrigger(const AliTOFTrigger & tr):
157 AliTriggerDetector(tr),
158 fHighMultTh(tr.fHighMultTh),
160 fMultiMuonTh(tr.fMultiMuonTh),
162 fdeltaminpsi(tr.fdeltaminpsi),
163 fdeltamaxpsi(tr.fdeltamaxpsi),
164 fdeltaminro(tr.fdeltaminro),
165 fdeltamaxro(tr.fdeltamaxro),
166 fstripWindow(tr.fstripWindow),
171 fNCrateOn(tr.fNCrateOn),
172 fNMaxipadOn(tr.fNMaxipadOn),
173 fNMaxipadOnAll(tr.fNMaxipadOnAll),
177 for (Int_t i=0;i<kNCTTM;i++) fLTMarray[i] = kFALSE;
178 for (Int_t i=0;i<kNLTM;i++){
179 for (Int_t j=0;j<kNLTMchannels;j++){
180 fLTMmatrix[i][j]=tr.fLTMmatrix[i][j];
183 for (Int_t j=0;j<kNCTTMchannels;j++){
184 fCTTMmatrixFront[i][j]=tr.fCTTMmatrixFront[i][j];
185 fCTTMmatrixBack[i][j]=tr.fCTTMmatrixBack[i][j];
191 for(Int_t i=1;i <= kNCTTMchannels;i++){
192 fPowerMask[i] = fPowerMask[i-1]*2;
196 fTOFTrigMask = new AliTOFTriggerMask();
197 fTOFTrigMask->SetTriggerMaskArray(tr.fTOFTrigMask->GetTriggerMaskArray());
200 SetName(tr.GetName());
201 //fInputs=&(tr.GetInputs());
205 #endif /*** COPY CONTRUCTOR SUPPRESSED ***/
207 //----------------------------------------------------------------------
209 void AliTOFTrigger::CreateInputs()
212 // Do not create inputs again!!
213 if( fInputs.GetEntriesFast() > 0 ) return;
217 fInputs.AddLast(new AliTriggerInput("TOF_Cosmic_MultiMuon_L0","TOF",0));
218 fInputs.AddLast(new AliTriggerInput("0OIN","TOF",0)); // was "TOF_pp_MB_L0"
219 fInputs.AddLast(new AliTriggerInput("0OM2","TOF",0)); // was "TOF_PbPb_MB2_L0"
220 fInputs.AddLast(new AliTriggerInput("0OM3","TOF",0)); // was "TOF_PbPb_MB3_L0"
221 fInputs.AddLast(new AliTriggerInput("0OUP","TOF",0)); // was "TOF_UltraPer_Coll_L0"
223 fInputs.AddLast(new AliTriggerInput("0OHM","TOF",0)); // was "TOF_High_Mult_L0"
224 fInputs.AddLast(new AliTriggerInput("TOF_Jet_L1","TOF",0));
228 //----------------------------------------------------------------------
229 void AliTOFTrigger::Trigger() {
237 Int_t nchonFront = 0;
240 Int_t nSectOn = 0; // °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
241 Int_t DeSlots = -1;// °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
242 Int_t AntiDeSlots = -1;// °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
243 Int_t nchonFrontBack = 0;
244 Int_t nchonFront1 = 0;
245 Int_t nchonBack1 = 0;
246 Int_t nchonFrontBack1 = 0;
247 Int_t mindeltapsi = (Int_t)fdeltaminpsi/10;
248 Int_t maxdeltapsi = (Int_t)fdeltamaxpsi/10;
249 Int_t mindeltaro = (Int_t)fdeltaminro/10;
250 Int_t maxdeltaro = (Int_t)fdeltamaxro/10;
252 for (Int_t i=0;i<kNCTTM;i++){
253 for (Int_t j=0;j<kNCTTMchannels;j++){
254 if (fCTTMmatrixFront[i][j]) nchonFront++;
258 for (Int_t i=kNCTTM;i<(kNCTTM*2);i++){
259 for (Int_t j=0;j<kNCTTMchannels;j++){
260 if (fCTTMmatrixBack[i-kNCTTM][j]) nchonBack++;
264 nchonTot = nchonFront + nchonBack;
265 // fNMaxipadOn = nchonTot;
266 for(Int_t i=0;i<kNCTTM;i++) { if(fLTMarray[i]) nSectOn++; }
268 //pp Minimum Bias Trigger
269 if (nchonTot >= fppMBTh) {
272 //printf("0OIN - MB\n");
285 //High Multiplicity Trigger
286 if (nchonTot >= fHighMultTh) {
288 //printf("0OHM - High Mult\n");
297 Bool_t boolCTTMor = kFALSE;
299 for (Int_t i=0;i<(kNCTTM/2);i++){
300 Int_t iopp = i+kNCTTM/2;
301 for (Int_t j=0;j<kNCTTMchannels;j++){
302 if (fCTTMmatrixFront[i][j]){
303 Int_t minj = j-fstripWindow;
304 Int_t maxj = j+fstripWindow;
306 if (maxj>=kNCTTMchannels) maxj = kNCTTMchannels-1;
308 for (Int_t k = minj;k<=maxj;k++){
309 boolCTTMor |= fCTTMmatrixFront[iopp][k];
316 if (fCTTMmatrixBack[i][j]){
317 Int_t minj = j-fstripWindow;
318 Int_t maxj = j+fstripWindow;
320 if (maxj>=kNCTTMchannels) maxj =kNCTTMchannels-1;
322 for (Int_t k = minj;k<=maxj;k++){
323 boolCTTMor |= fCTTMmatrixBack[iopp][k];
332 nchonFrontBack = nchonFront+nchonBack;
339 for (Int_t i=0;i<(kNCTTM/2);i++){
340 Int_t i2max = (kNCTTM-1)-i+1;
341 Int_t i2min = (kNCTTM-1)-i-1;
342 if (i2max >=kNCTTM) i2max = kNCTTM-1;
343 if (i2min==i) i2min = kNCTTM-1-i;
344 for (Int_t j=0;j<kNCTTMchannels;j++){
345 Int_t j2min = j-fstripWindow;
346 Int_t j2max = j+fstripWindow;
347 if (j2min<0) j2min =0;
348 if (j2max>=kNCTTMchannels) j2max =kNCTTMchannels-1;
349 if (fCTTMmatrixFront[i][j]){
351 for (Int_t i2=i2min;i2<=i2max;i2++){
352 for (Int_t j2 = j2min;j2<=j2max;j2++){
353 boolCTTMor |= fCTTMmatrixFront[i2][j2];
360 if (fCTTMmatrixBack[i][j]){
362 for (Int_t i2=i2min;i2<=i2max;i2++){
363 for (Int_t j2 = j2min;j2<=j2max;j2++){
364 boolCTTMor |= fCTTMmatrixBack[i2][j2];
374 nchonFrontBack1 = nchonFront1+nchonBack1;
376 if (nchonFrontBack >= fMultiMuonTh || nchonFrontBack1 >= fMultiMuonTh) {
377 SetInput("TOF_Cosmic_MultiMuon_L0");
380 //Ultra-Peripheral collision Trigger
382 // °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
383 // DeSlots = (k+1)_Array Element - k_Array Element
384 // AntiDeSlots = kNCTTM - DeSlots
386 if((!fSel1))// && nchonFront < 4 && nchonBack < 4)
388 // printf("nHitMaxipad CLASSE: %i \n",fNMaxipadOn);
389 // printf("Total Number per event of Switched-On sectors : %i \n", nSectOn);
390 // printf("mindeltapsi %i \n", mindeltapsi);
391 //printf("maxdeltapsi %i \n", maxdeltapsi);
392 for(Int_t i = 0; i < kNCTTM; i++){
394 // printf(" i-sect On: %i\n",i);
395 for(Int_t j = i+1; j < kNCTTM; j++){
397 // printf(" j-sect On: %i\n",j);
399 AntiDeSlots = kNCTTM - DeSlots;
400 //printf("DeSlots = %i \n",DeSlots);
401 //printf("AntiDeSlots = %i \n",AntiDeSlots);
402 if(DeSlots >= mindeltapsi && DeSlots <= maxdeltapsi){
405 //printf("trigger On with DeSlot \n");
407 if(AntiDeSlots >= mindeltapsi && AntiDeSlots <= maxdeltapsi){
410 //printf("trigger On with AntiDeSlot \n");
414 if(DeSlots >= mindeltaro && DeSlots <= maxdeltaro){
417 //printf("trigger On with DeSlot \n");
419 if(AntiDeSlots >= mindeltaro && AntiDeSlots <= maxdeltaro){
422 //printf("trigger On with AntiDeSlot \n");
433 //-----------------------------------------------------------------------------
434 void AliTOFTrigger::CreateLTMMatrix() {
437 CreateLTMMatrixFromDigits();
440 //-------------------------------------------------------------------------
442 void AliTOFTrigger::CreateLTMMatrixFromDigits() {
444 // Create LTM matrix by TOF digits
448 for (Int_t i=0;i<kNCTTM;i++) fLTMarray[i]= kFALSE;
449 for (Int_t i=0;i<kNLTM;i++){
450 for (Int_t j=0;j<kNLTMchannels;j++){
451 fLTMmatrix[i][j]=kFALSE;
454 for (Int_t i=0;i<kNCTTM;i++){
455 for (Int_t j=0;j<kNCTTMchannels;j++){
456 fCTTMmatrixFront[i][j]=kFALSE;
457 fCTTMmatrixBack[i][j]=kFALSE;
463 rl = AliRunLoader::Instance();
465 Int_t ncurrevent = rl->GetEventNumber();
466 rl->GetEvent(ncurrevent);
468 AliLoader * tofLoader = rl->GetLoader("TOFLoader");
470 tofLoader->LoadDigits("read");
471 TTree *treeD = tofLoader->TreeD();
473 AliFatal("AliTOFTrigger: Can not get TreeD");
477 TBranch *branch = treeD->GetBranch("TOF");
479 AliError("can't get the branch with the TOF digits !");
482 TClonesArray *tofDigits =new TClonesArray("AliTOFdigit", 1000);
483 branch->SetAddress(&tofDigits);
485 Int_t ndigits = tofDigits->GetEntriesFast();
486 Int_t detind[5]; //detector indexes: 0 -> sector
487 // 1 -> plate(modulo)
492 for (Int_t i=0;i<ndigits;i++){
493 AliTOFdigit * digit = (AliTOFdigit*)tofDigits->UncheckedAt(i);
494 detind[0] = digit->GetSector();
495 detind[1] = digit->GetPlate();
496 detind[2] = digit->GetStrip();
497 detind[3] = digit->GetPadz();
498 detind[4] = digit->GetPadx();
500 Int_t indexLTM[2] = {-1,-1};
501 GetLTMIndex(detind,indexLTM);
503 fLTMmatrix[indexLTM[0]][indexLTM[1]] = kTRUE;
504 // fLTMarray[indexLTM[0]%36] = kTRUE; //dimensione MAX array 36 = kNCTTM
508 tofLoader->UnloadDigits();
509 // rl->UnloadgAlice();
514 //-----------------------------------------------------------------------------
516 void AliTOFTrigger::CreateLTMMatrixFromRaw(AliRawReader *fRawReader) {
518 // Create LTM matrix by TOF raw data
522 for (Int_t i=0;i<kNLTM;i++){
523 for (Int_t j=0;j<kNLTMchannels;j++){
524 fLTMmatrix[i][j]=kFALSE;
527 for (Int_t i=0;i<kNCTTM;i++){
528 for (Int_t j=0;j<kNCTTMchannels;j++){
529 fCTTMmatrixFront[i][j]=kFALSE;
530 fCTTMmatrixBack[i][j]=kFALSE;
535 AliTOFRawStream * tofRawStream = new AliTOFRawStream();
539 //if(!GetLoader()->TreeS()) {MakeTree("S"); MakeBranch("S");}
542 tofRawStream->SetRawReader(fRawReader);
545 //if (fVerbose==2) ftxt.open("TOFsdigitsRead.txt",ios::app);
547 TClonesArray staticRawData("AliTOFrawData",10000);
548 staticRawData.Clear();
549 TClonesArray * clonesRawData = &staticRawData;
552 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
559 AliTOFrawData *tofRawDatum = 0;
560 for (indexDDL=0; indexDDL<AliDAQ::NumberOfDdls("TOF"); indexDDL++) {
563 tofRawStream->LoadRawDataBuffersV2(indexDDL);
565 clonesRawData = tofRawStream->GetRawData();
566 if (clonesRawData->GetEntriesFast()!=0) AliInfo(Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
567 for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
569 tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
571 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
572 if (tofRawDatum->GetTOF()==-1) continue;
574 SetBit(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
575 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel());
577 dummy = detectorIndex[3];
578 detectorIndex[3] = detectorIndex[4];//padz
579 detectorIndex[4] = dummy;//padx
581 digit[0] = tofRawDatum->GetTOF();
582 digit[1] = tofRawDatum->GetTOT();
584 dummy = detectorIndex[3];
585 detectorIndex[3] = detectorIndex[4];//padx
586 detectorIndex[4] = dummy;//padz
588 // Do not reconstruct anything in the holes
589 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
590 if (detectorIndex[1]==2) { // plate with holes
599 clonesRawData->Clear();
603 //if (fVerbose==2) ftxt.close();
605 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
613 //-----------------------------------------------------------------------------
614 void AliTOFTrigger::GetLTMIndex(const Int_t * const detind, Int_t *indexLTM) {
616 // getting LTMmatrix indexes for current digit
619 if (detind[1]==0 || detind[1]==1 || (detind[1]==2 && detind[2]<=7)) {
621 indexLTM[0] = detind[0]*2;
624 indexLTM[0] = detind[0]*2+1;
629 indexLTM[0] = detind[0]*2+36;
632 indexLTM[0] = (detind[0]*2+1)+36;
636 if (indexLTM[0]<36) {
638 indexLTM[1] = detind[2];
640 else if (detind[1] ==1){
641 indexLTM[1] = detind[2]+19;
643 else if (detind[1] ==2){
644 indexLTM[1] = detind[2]+19*2;
647 AliError("Smth Wrong!!!");
652 indexLTM[1] = detind[2]-8;
654 else if (detind[1] ==3){
655 indexLTM[1] = detind[2]+7;
657 else if (detind[1] ==4){
658 indexLTM[1] = detind[2]+26;
661 AliError("Smth Wrong!!!");
666 //-------------------------------------------------------------------------
668 // to be checked because of warning problems
669 void AliTOFTrigger::PrintMap()
675 for(Int_t i = 0; i<kNLTM;i++) {
677 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",
678 (fCTTMmatrixFront[i][0])?1:0,(fCTTMmatrixFront[i][1])?1:0,(fCTTMmatrixFront[i][2])?1:0, \
679 (fCTTMmatrixFront[i][3])?1:0,(fCTTMmatrixFront[i][4])?1:0,(fCTTMmatrixFront[i][5])?1:0, \
680 (fCTTMmatrixFront[i][6])?1:0,(fCTTMmatrixFront[i][7])?1:0,(fCTTMmatrixFront[i][8])?1:0, \
681 (fCTTMmatrixFront[i][9])?1:0,(fCTTMmatrixFront[i][10])?1:0,(fCTTMmatrixFront[i][11])?1:0, \
682 (fCTTMmatrixFront[i][12])?1:0,(fCTTMmatrixFront[i][13])?1:0,(fCTTMmatrixFront[i][14])?1:0, \
683 (fCTTMmatrixFront[i][15])?1:0,(fCTTMmatrixFront[i][16])?1:0,(fCTTMmatrixFront[i][17])?1:0, \
684 (fCTTMmatrixFront[i][18])?1:0,(fCTTMmatrixFront[i][19])?1:0,(fCTTMmatrixFront[i][20])?1:0, \
685 (fCTTMmatrixFront[i][21])?1:0,(fCTTMmatrixFront[i][22])?1:0,(fCTTMmatrixFront[i][23])?1:0);
687 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",
688 (fCTTMmatrixBack[i][0])?1:0,(fCTTMmatrixBack[i][1])?1:0,(fCTTMmatrixBack[i][2])?1:0, \
689 (fCTTMmatrixBack[i][3])?1:0,(fCTTMmatrixBack[i][4])?1:0,(fCTTMmatrixBack[i][5])?1:0, \
690 (fCTTMmatrixBack[i][6])?1:0,(fCTTMmatrixBack[i][7])?1:0,(fCTTMmatrixBack[i][8])?1:0, \
691 (fCTTMmatrixBack[i][9])?1:0,(fCTTMmatrixBack[i][10])?1:0,(fCTTMmatrixBack[i][11])?1:0, \
692 (fCTTMmatrixBack[i][12])?1:0,(fCTTMmatrixBack[i][13])?1:0,(fCTTMmatrixBack[i][14])?1:0, \
693 (fCTTMmatrixBack[i][15])?1:0,(fCTTMmatrixBack[i][16])?1:0,(fCTTMmatrixBack[i][17])?1:0, \
694 (fCTTMmatrixBack[i][18])?1:0,(fCTTMmatrixBack[i][19])?1:0,(fCTTMmatrixBack[i][20])?1:0, \
695 (fCTTMmatrixBack[i][21])?1:0,(fCTTMmatrixBack[i][22])?1:0,(fCTTMmatrixBack[i][23])?1:0);
701 //-------------------------------------------------------------------------
703 void AliTOFTrigger::GetMapMatrix(Bool_t map[][24]) const
709 for(Int_t i = 0; i<kNLTM;i++)
710 for(Int_t j = 0; j<kNCTTMchannels;j++)
711 map[i][j]=(i<36)?fCTTMmatrixFront[i][j]:fCTTMmatrixBack[i-36][j];
714 //-------------------------------------------------------------------------
716 void AliTOFTrigger::GetMap(Bool_t **map) const
722 for(Int_t i = 0; i<kNLTM;i++)
723 for(Int_t j = 0; j<kNCTTMchannels;j++)
724 map[i][j]=(i<36)?fCTTMmatrixFront[i][j]:fCTTMmatrixBack[i-36][j];
729 //-------------------------------------------------------------------------
730 void AliTOFTrigger::GetTRDmap(Bool_t **map) const
733 // Retriev the bit map sent to the TRD detector
736 for(int i = 0; i<kNLTM;i++)
737 for(int j = 0; j<kNLTMtoTRDchannels;j++){
741 for(int i = 0; i<kNLTM/2;i++)
742 for(int j = 0; j<AliTOFTrigger::kNCTTMchannels;j++){
744 if(fCTTMmatrixFront[i][j]) map[i][uTRDbit]=kTRUE;
746 for(int i = kNLTM/2; i<kNLTM;i++)
747 for(int j = 0; j<AliTOFTrigger::kNCTTMchannels;j++){
749 if(fCTTMmatrixBack[i-kNLTM/2][j]) map[i][uTRDbit]=kTRUE;
753 //-------------------------------------------------------------------------
754 void AliTOFTrigger::GetTRDmapMatrix(Bool_t map[][8]) const
757 // Retriev the bit map sent to the TRD detector
760 for(int i = 0; i<kNLTM;i++)
761 for(int j = 0; j<kNLTMtoTRDchannels;j++){
765 for(int i = 0; i<kNLTM/2;i++)
766 for(int j = 0; j<AliTOFTrigger::kNCTTMchannels;j++){
768 if(fCTTMmatrixFront[i][j]) map[i][uTRDbit]=kTRUE;
770 for(int i = kNLTM/2; i<kNLTM;i++)
771 for(int j = 0; j<AliTOFTrigger::kNCTTMchannels;j++){
773 if(fCTTMmatrixBack[i-kNLTM/2][j]) map[i][uTRDbit]=kTRUE;
778 //-------------------------------------------------------------------------
779 void AliTOFTrigger::SetBit(Int_t *detind)
782 // Sets CTTM map element corresponding to detector element 'detind'
786 GetCTTMIndex(detind,index);
788 fCTTMmatrixFront[index[0]][index[1]]=kTRUE;
790 fCTTMmatrixBack[index[0]-36][index[1]]=kTRUE;
794 //-------------------------------------------------------------------------
795 void AliTOFTrigger::SetBit(Int_t nDDL, Int_t nTRM, Int_t iChain,
796 Int_t iTDC, Int_t iCH)
799 // Sets CTTM map element corresponding to equipment ID
800 // labelled by number nDDL, nTRM, iChain, iTDC, iCH
803 if(nTRM==3 && iTDC>=12 && iTDC<=14 && nDDL%2==1){ // DDL number to LTM number mapping
806 Int_t iChannelIndex=-1;
807 switch(nDDL%AliTOFGeometry::NDDL()){
815 AliError("Call this function only if(nTRM==3 && iTDC>12 && iTDC<14 && nDDL%2==1) ");
818 iLTMindex+=2*(Int_t)(nDDL/AliTOFGeometry::NDDL());
819 if(iChain==0 && nDDL<36)
821 if(iChain==0 && nDDL>=36)
823 iChannelIndex=iCH+iTDC*AliTOFGeometry::NCh()-12*AliTOFGeometry::NCh();
824 Int_t index[2]={iLTMindex,iChannelIndex};
826 fCTTMmatrixFront[index[0]][index[1]]=kTRUE;
827 fLTMmatrix[index[0]][index[1]*2]=kTRUE;
830 fCTTMmatrixBack[index[0]-36][index[1]]=kTRUE;
831 fLTMmatrix[index[0]][index[1]*2]=kTRUE;
836 //-------------------------------------------------------------------------
838 void AliTOFTrigger::ResetBit(Int_t *detind)
841 // Sets CTTM map element corresponding to detector element 'detind'
845 GetCTTMIndex(detind,index);
847 fCTTMmatrixFront[index[0]][index[1]]=kFALSE;
849 fCTTMmatrixBack[index[0]-36][index[1]]=kFALSE;
853 //-------------------------------------------------------------------------
854 void AliTOFTrigger::ResetBit(Int_t nDDL, Int_t nTRM, Int_t iChain,
855 Int_t iTDC, Int_t iCH)
858 // Sets CTTM map element corresponding to equipment ID
859 // labelled by number nDDL, nTRM, iChain, iTDC, iCH
862 if(nTRM==3 && iTDC>12 && iTDC<14 && nDDL%2==1){ // DDL number to LTM number mapping
864 Int_t iChannelIndex=-1;
865 switch(nDDL%AliTOFGeometry::NDDL()){
873 AliError("Call this function only if(nTRM==3 && iTDC>12 && iTDC<14 && nDDL%2==1) ");
876 iLTMindex+=2*(Int_t)(nDDL/AliTOFGeometry::NDDL());
877 if(iChain==0 && nDDL<36)
879 if(iChain==0 && nDDL>=36)
881 iChannelIndex=iCH+iTDC*AliTOFGeometry::NCh()-12*AliTOFGeometry::NCh();
882 Int_t index[2]={iLTMindex,iChannelIndex};
884 fCTTMmatrixFront[index[0]][index[1]]=kFALSE;
887 fCTTMmatrixBack[index[0]-36][index[1]]=kFALSE;
891 AliError("Call this function only if(nTRM==3 && iTDC>12 && iTDC<14 && nDDL%2==1) ");
894 //-------------------------------------------------------------------------
896 Bool_t AliTOFTrigger::GetBit(Int_t *detind)
899 // Returns CTTM map element corresponding to detector element 'detind'
903 GetCTTMIndex(detind,index);
904 return (index[0]<36)?fCTTMmatrixFront[index[0]][index[1]]:fCTTMmatrixBack[index[0]-36][index[1]];
908 //-------------------------------------------------------------------------
909 Bool_t AliTOFTrigger::GetBit(Int_t nDDL, Int_t nTRM, Int_t iChain,
910 Int_t iTDC, Int_t iCH)
913 // Returns CTTM map element corresponding to equipment ID
914 // labelled by number nDDL, nTRM, iChain, iTDC, iCH
917 if ( !(nTRM==3 && iTDC>12 && iTDC<14 && nDDL%2==1) ) {
918 AliWarning("Call this function only if(nTRM==3 && iTDC>12 && iTDC<14) ");
921 //if (nTRM==3 && iTDC>12 && iTDC<14 && nDDL%2==1) { // DDL number to LTM number mapping
924 UInt_t iChannelindex=0;
925 switch(nDDL%AliTOFGeometry::NDDL()) {
933 AliError("something wrong");
936 iLTMindex+=2*(Int_t)(nDDL/AliTOFGeometry::NDDL());
938 if (iChain==1) return kFALSE; // AdC
944 iChannelindex=iCH+iTDC*AliTOFGeometry::NCh()-12*AliTOFGeometry::NCh();
945 Int_t index[2]={iLTMindex,iChannelindex};
946 return (index[0]<36)?fCTTMmatrixFront[index[0]][index[1]]:fCTTMmatrixBack[index[0]-36][index[1]];
950 //-------------------------------------------------------------------------
952 void AliTOFTrigger::CreateCTTMMatrix() {
954 // Create CTTM bit map
956 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,
957 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};
963 for(Int_t i = 0; i<kNLTM;i++){
964 UInt_t currentMask = fPowerMask[kNCTTMchannels]-1;
965 if(fTOFTrigMask) currentMask=fTOFTrigMask->GetTriggerMask(fromTriggertoDCS[i]);
967 for(Int_t j = 0; j<kNCTTMchannels;j++){
968 fCTTMmatrixFront[i][j]=fLTMmatrix[i][2*j]||fLTMmatrix[i][2*j+1];
969 if(fCTTMmatrixFront[i][j]) fNMaxipadOnAll++;
970 if(!(currentMask & fPowerMask[j])) fCTTMmatrixFront[i][j]=0;
971 if(fCTTMmatrixFront[i][j]){
973 fLTMarray[i] = kTRUE;
978 for(Int_t j = 0; j<kNCTTMchannels;j++){
979 fCTTMmatrixBack[i-kNCTTM][j]=fLTMmatrix[i][2*j]||fLTMmatrix[i][2*j+1];;
980 if(fCTTMmatrixBack[i-kNCTTM][j]) fNMaxipadOnAll++;
981 if(!(currentMask & fPowerMask[j])) fCTTMmatrixBack[i-kNCTTM][j]=0;
982 if(fCTTMmatrixBack[i-kNCTTM][j]){
984 fLTMarray[i-kNCTTM] = kTRUE;
991 for(Int_t j=0; j < kNCTTM; j++) {if(fLTMarray[j]) fNCrateOn++;}
994 //-----------------------------------------------------------------------------
996 void AliTOFTrigger::GetCTTMIndex(Int_t *detind, Int_t *indexCTTM) {
998 // Returns CTTM index corresponding to the detector element detind
1001 GetLTMIndex(detind,indexCTTM);
1005 //-----------------------------------------------------------------------------
1006 void AliTOFTrigger::LoadActiveMask(){
1008 // Load OCDB current mask
1011 AliCDBManager *cdb = AliCDBManager::Instance();
1012 if(cdb->GetRun() < 0 || !(cdb->GetDefaultStorage())){
1013 if(!(cdb->GetDefaultStorage())){
1014 cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
1015 printf("AliTOFTrigger (WARNING): probably CDB first instance - Default Sorage set to \"local://$ALICE_ROOT/OCDB\"\n");
1017 if(cdb->GetRun() < 0){
1019 printf("AliTOFTrigger (WARNING): probably CDB first instance - number of run set to 0\n");
1023 AliCDBEntry *cdbe = cdb->Get("TRIGGER/TOF/TriggerMask");
1025 fTOFTrigMask= (AliTOFTriggerMask *)cdbe->GetObject();
1027 // UInt_t maskArray[kNLTM];
1028 // if(fTOFTrigMask == NULL) fTOFTrigMask = new AliTOFTriggerMask();
1029 // for (Int_t k = 0; k < kNLTM ; k++) maskArray[k] = fPowerMask[kNCTTMchannels]-1;
1030 // //for (Int_t k = 0; k < kNLTM ; k+=2) maskArray[k] = 0;
1032 // fTOFTrigMask->SetTriggerMaskArray(maskArray);
1036 //-----------------------------------------------------------------------------
1037 AliTOFTrigger::~AliTOFTrigger()
1043 //-----------------------------------------------------------------------------
1044 AliTOFTrigger& AliTOFTrigger::operator=(const AliTOFTrigger &/*source*/)