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>
36 #include "AliLoader.h"
38 #include "AliRunLoader.h"
40 #include "AliTriggerInput.h"
41 #include "AliRawReader.h"
43 #include "AliTOFRawStream.h"
44 #include "AliTOFrawData.h"
45 #include "AliTOFdigit.h"
46 #include "AliTOFGeometry.h"
47 #include "AliTOFTrigger.h"
48 #include "AliTOFTriggerMask.h"
50 #include "AliCDBManager.h"
51 #include "AliCDBEntry.h"
54 extern AliRun* gAlice;
56 //-------------------------------------------------------------------------
57 ClassImp(AliTOFTrigger)
59 //----------------------------------------------------------------------
60 AliTOFTrigger::AliTOFTrigger() :
63 fppMBTh(4),//4:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
66 fdeltaminpsi(150), //150
67 fdeltamaxpsi(170), //170
81 for (Int_t i=0;i<kNCTTM;i++) fLTMarray[i] = kFALSE;
83 for (Int_t i=0;i<kNLTM;i++){
85 for (Int_t j=0;j<kNLTMchannels;j++){
86 fLTMmatrix[i][j]=kFALSE;
89 for (Int_t j=0;j<kNCTTMchannels;j++){
90 fCTTMmatrixFront[i][j]=kFALSE;
91 fCTTMmatrixBack[i][j]=kFALSE;
97 for(Int_t i=1;i <= kNCTTMchannels;i++){
98 fPowerMask[i] = fPowerMask[i-1]*2;
106 //----------------------------------------------------------------------
108 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) :
109 AliTriggerDetector(),
110 fHighMultTh(HighMultTh),
112 fMultiMuonTh(MultiMuonTh),
114 fdeltaminpsi(deltaminpsi),
115 fdeltamaxpsi(deltamaxpsi),
116 fdeltaminro(deltaminro),
117 fdeltamaxro(deltamaxro),
118 fstripWindow(stripWindow),
128 //ctor with thresholds for triggers
129 for (Int_t i=0;i<kNCTTM;i++) fLTMarray[i] = kFALSE;
130 for (Int_t i=0;i<kNLTM;i++){
131 for (Int_t j=0;j<kNLTMchannels;j++){
132 fLTMmatrix[i][j]=kFALSE;
135 for (Int_t j=0;j<kNCTTMchannels;j++){
136 fCTTMmatrixFront[i][j]=kFALSE;
137 fCTTMmatrixBack[i][j]=kFALSE;
143 for(Int_t i=1;i <= kNCTTMchannels;i++){
144 fPowerMask[i] = fPowerMask[i-1]*2;
152 #if 0 /*** COPY CONSTRUCTOR SUPPRESSED **/
153 //____________________________________________________________________________
155 AliTOFTrigger::AliTOFTrigger(const AliTOFTrigger & tr):
156 AliTriggerDetector(tr),
157 fHighMultTh(tr.fHighMultTh),
159 fMultiMuonTh(tr.fMultiMuonTh),
161 fdeltaminpsi(tr.fdeltaminpsi),
162 fdeltamaxpsi(tr.fdeltamaxpsi),
163 fdeltaminro(tr.fdeltaminro),
164 fdeltamaxro(tr.fdeltamaxro),
165 fstripWindow(tr.fstripWindow),
170 fNCrateOn(tr.fNCrateOn),
171 fNMaxipadOn(tr.fNMaxipadOn),
172 fNMaxipadOnAll(tr.fNMaxipadOnAll),
176 for (Int_t i=0;i<kNCTTM;i++) fLTMarray[i] = kFALSE;
177 for (Int_t i=0;i<kNLTM;i++){
178 for (Int_t j=0;j<kNLTMchannels;j++){
179 fLTMmatrix[i][j]=tr.fLTMmatrix[i][j];
182 for (Int_t j=0;j<kNCTTMchannels;j++){
183 fCTTMmatrixFront[i][j]=tr.fCTTMmatrixFront[i][j];
184 fCTTMmatrixBack[i][j]=tr.fCTTMmatrixBack[i][j];
190 for(Int_t i=1;i <= kNCTTMchannels;i++){
191 fPowerMask[i] = fPowerMask[i-1]*2;
195 fTOFTrigMask = new AliTOFTriggerMask();
196 fTOFTrigMask->SetTriggerMaskArray(tr.fTOFTrigMask->GetTriggerMaskArray());
199 SetName(tr.GetName());
200 //fInputs=&(tr.GetInputs());
204 #endif /*** COPY CONTRUCTOR SUPPRESSED ***/
206 //----------------------------------------------------------------------
208 void AliTOFTrigger::CreateInputs()
211 // Do not create inputs again!!
212 if( fInputs.GetEntriesFast() > 0 ) return;
216 fInputs.AddLast(new AliTriggerInput("TOF_Cosmic_MultiMuon_L0","TOF",0));
217 fInputs.AddLast(new AliTriggerInput("0OIN","TOF",0)); // was "TOF_pp_MB_L0"
218 fInputs.AddLast(new AliTriggerInput("0OM2","TOF",0)); // was "TOF_PbPb_MB2_L0"
219 fInputs.AddLast(new AliTriggerInput("0OM3","TOF",0)); // was "TOF_PbPb_MB3_L0"
220 fInputs.AddLast(new AliTriggerInput("0OUP","TOF",0)); // was "TOF_UltraPer_Coll_L0"
222 fInputs.AddLast(new AliTriggerInput("0OHM","TOF",0)); // was "TOF_High_Mult_L0"
223 fInputs.AddLast(new AliTriggerInput("TOF_Jet_L1","TOF",0));
227 //----------------------------------------------------------------------
228 void AliTOFTrigger::Trigger() {
236 Int_t nchonFront = 0;
239 Int_t nSectOn = 0; // °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
240 Int_t DeSlots = -1;// °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
241 Int_t AntiDeSlots = -1;// °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
242 Int_t nchonFrontBack = 0;
243 Int_t nchonFront1 = 0;
244 Int_t nchonBack1 = 0;
245 Int_t nchonFrontBack1 = 0;
246 Int_t mindeltapsi = (Int_t)fdeltaminpsi/10;
247 Int_t maxdeltapsi = (Int_t)fdeltamaxpsi/10;
248 Int_t mindeltaro = (Int_t)fdeltaminro/10;
249 Int_t maxdeltaro = (Int_t)fdeltamaxro/10;
251 for (Int_t i=0;i<kNCTTM;i++){
252 for (Int_t j=0;j<kNCTTMchannels;j++){
253 if (fCTTMmatrixFront[i][j]) nchonFront++;
257 for (Int_t i=kNCTTM;i<(kNCTTM*2);i++){
258 for (Int_t j=0;j<kNCTTMchannels;j++){
259 if (fCTTMmatrixBack[i-kNCTTM][j]) nchonBack++;
263 nchonTot = nchonFront + nchonBack;
264 // fNMaxipadOn = nchonTot;
265 for(Int_t i=0;i<kNCTTM;i++) { if(fLTMarray[i]) nSectOn++; }
267 //pp Minimum Bias Trigger
268 if (nchonTot >= fppMBTh) {
271 //printf("0OIN - MB\n");
284 //High Multiplicity Trigger
285 if (nchonTot >= fHighMultTh) {
287 //printf("0OHM - High Mult\n");
296 Bool_t boolCTTMor = kFALSE;
298 for (Int_t i=0;i<(kNCTTM/2);i++){
299 Int_t iopp = i+kNCTTM/2;
300 for (Int_t j=0;j<kNCTTMchannels;j++){
301 if (fCTTMmatrixFront[i][j]){
302 Int_t minj = j-fstripWindow;
303 Int_t maxj = j+fstripWindow;
305 if (maxj>=kNCTTMchannels) maxj = kNCTTMchannels-1;
307 for (Int_t k = minj;k<=maxj;k++){
308 boolCTTMor |= fCTTMmatrixFront[iopp][k];
315 if (fCTTMmatrixBack[i][j]){
316 Int_t minj = j-fstripWindow;
317 Int_t maxj = j+fstripWindow;
319 if (maxj>=kNCTTMchannels) maxj =kNCTTMchannels-1;
321 for (Int_t k = minj;k<=maxj;k++){
322 boolCTTMor |= fCTTMmatrixBack[iopp][k];
331 nchonFrontBack = nchonFront+nchonBack;
338 for (Int_t i=0;i<(kNCTTM/2);i++){
339 Int_t i2max = (kNCTTM-1)-i+1;
340 Int_t i2min = (kNCTTM-1)-i-1;
341 if (i2max >=kNCTTM) i2max = kNCTTM-1;
342 if (i2min==i) i2min = kNCTTM-1-i;
343 for (Int_t j=0;j<kNCTTMchannels;j++){
344 Int_t j2min = j-fstripWindow;
345 Int_t j2max = j+fstripWindow;
346 if (j2min<0) j2min =0;
347 if (j2max>=kNCTTMchannels) j2max =kNCTTMchannels-1;
348 if (fCTTMmatrixFront[i][j]){
350 for (Int_t i2=i2min;i2<=i2max;i2++){
351 for (Int_t j2 = j2min;j2<=j2max;j2++){
352 boolCTTMor |= fCTTMmatrixFront[i2][j2];
359 if (fCTTMmatrixBack[i][j]){
361 for (Int_t i2=i2min;i2<=i2max;i2++){
362 for (Int_t j2 = j2min;j2<=j2max;j2++){
363 boolCTTMor |= fCTTMmatrixBack[i2][j2];
373 nchonFrontBack1 = nchonFront1+nchonBack1;
375 if (nchonFrontBack >= fMultiMuonTh || nchonFrontBack1 >= fMultiMuonTh) {
376 SetInput("TOF_Cosmic_MultiMuon_L0");
379 //Ultra-Peripheral collision Trigger
381 // °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
382 // DeSlots = (k+1)_Array Element - k_Array Element
383 // AntiDeSlots = kNCTTM - DeSlots
385 if((!fSel1))// && nchonFront < 4 && nchonBack < 4)
387 // printf("nHitMaxipad CLASSE: %i \n",fNMaxipadOn);
388 // printf("Total Number per event of Switched-On sectors : %i \n", nSectOn);
389 // printf("mindeltapsi %i \n", mindeltapsi);
390 //printf("maxdeltapsi %i \n", maxdeltapsi);
391 for(Int_t i = 0; i < kNCTTM; i++){
393 // printf(" i-sect On: %i\n",i);
394 for(Int_t j = i+1; j < kNCTTM; j++){
396 // printf(" j-sect On: %i\n",j);
398 AntiDeSlots = kNCTTM - DeSlots;
399 //printf("DeSlots = %i \n",DeSlots);
400 //printf("AntiDeSlots = %i \n",AntiDeSlots);
401 if(DeSlots >= mindeltapsi && DeSlots <= maxdeltapsi){
404 //printf("trigger On with DeSlot \n");
406 if(AntiDeSlots >= mindeltapsi && AntiDeSlots <= maxdeltapsi){
409 //printf("trigger On with AntiDeSlot \n");
413 if(DeSlots >= mindeltaro && DeSlots <= maxdeltaro){
416 //printf("trigger On with DeSlot \n");
418 if(AntiDeSlots >= mindeltaro && AntiDeSlots <= maxdeltaro){
421 //printf("trigger On with AntiDeSlot \n");
432 //-----------------------------------------------------------------------------
433 void AliTOFTrigger::CreateLTMMatrix() {
436 CreateLTMMatrixFromDigits();
439 //-------------------------------------------------------------------------
441 void AliTOFTrigger::CreateLTMMatrixFromDigits() {
443 // Create LTM matrix by TOF digits
447 for (Int_t i=0;i<kNCTTM;i++) fLTMarray[i]= kFALSE;
448 for (Int_t i=0;i<kNLTM;i++){
449 for (Int_t j=0;j<kNLTMchannels;j++){
450 fLTMmatrix[i][j]=kFALSE;
453 for (Int_t i=0;i<kNCTTM;i++){
454 for (Int_t j=0;j<kNCTTMchannels;j++){
455 fCTTMmatrixFront[i][j]=kFALSE;
456 fCTTMmatrixBack[i][j]=kFALSE;
462 rl = AliRunLoader::Instance();
464 Int_t ncurrevent = rl->GetEventNumber();
465 rl->GetEvent(ncurrevent);
467 AliLoader * tofLoader = rl->GetLoader("TOFLoader");
469 tofLoader->LoadDigits("read");
470 TTree *treeD = tofLoader->TreeD();
472 AliFatal("AliTOFTrigger: Can not get TreeD");
476 TBranch *branch = treeD->GetBranch("TOF");
478 AliError("can't get the branch with the TOF digits !");
481 TClonesArray *tofDigits =new TClonesArray("AliTOFdigit", 1000);
482 branch->SetAddress(&tofDigits);
484 Int_t ndigits = tofDigits->GetEntriesFast();
485 Int_t detind[5]; //detector indexes: 0 -> sector
486 // 1 -> plate(modulo)
491 for (Int_t i=0;i<ndigits;i++){
492 AliTOFdigit * digit = (AliTOFdigit*)tofDigits->UncheckedAt(i);
493 detind[0] = digit->GetSector();
494 detind[1] = digit->GetPlate();
495 detind[2] = digit->GetStrip();
496 detind[3] = digit->GetPadz();
497 detind[4] = digit->GetPadx();
499 Int_t indexLTM[2] = {-1,-1};
500 GetLTMIndex(detind,indexLTM);
502 fLTMmatrix[indexLTM[0]][indexLTM[1]] = kTRUE;
503 // fLTMarray[indexLTM[0]%36] = kTRUE; //dimensione MAX array 36 = kNCTTM
507 tofLoader->UnloadDigits();
508 // rl->UnloadgAlice();
513 //-----------------------------------------------------------------------------
515 void AliTOFTrigger::CreateLTMMatrixFromRaw(AliRawReader *fRawReader) {
517 // Create LTM matrix by TOF raw data
521 for (Int_t i=0;i<kNLTM;i++){
522 for (Int_t j=0;j<kNLTMchannels;j++){
523 fLTMmatrix[i][j]=kFALSE;
526 for (Int_t i=0;i<kNCTTM;i++){
527 for (Int_t j=0;j<kNCTTMchannels;j++){
528 fCTTMmatrixFront[i][j]=kFALSE;
529 fCTTMmatrixBack[i][j]=kFALSE;
534 AliTOFRawStream * tofRawStream = new AliTOFRawStream();
538 //if(!GetLoader()->TreeS()) {MakeTree("S"); MakeBranch("S");}
541 tofRawStream->SetRawReader(fRawReader);
544 //if (fVerbose==2) ftxt.open("TOFsdigitsRead.txt",ios::app);
546 TClonesArray staticRawData("AliTOFrawData",10000);
547 staticRawData.Clear();
548 TClonesArray * clonesRawData = &staticRawData;
551 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
558 AliTOFrawData *tofRawDatum = 0;
559 for (indexDDL=0; indexDDL<AliDAQ::NumberOfDdls("TOF"); indexDDL++) {
562 tofRawStream->LoadRawDataBuffersV2(indexDDL);
564 clonesRawData = tofRawStream->GetRawData();
565 if (clonesRawData->GetEntriesFast()!=0) AliInfo(Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
566 for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
568 tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
570 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
571 if (tofRawDatum->GetTOF()==-1) continue;
573 SetBit(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
574 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel());
576 dummy = detectorIndex[3];
577 detectorIndex[3] = detectorIndex[4];//padz
578 detectorIndex[4] = dummy;//padx
580 digit[0] = tofRawDatum->GetTOF();
581 digit[1] = tofRawDatum->GetTOT();
583 dummy = detectorIndex[3];
584 detectorIndex[3] = detectorIndex[4];//padx
585 detectorIndex[4] = dummy;//padz
587 // Do not reconstruct anything in the holes
588 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
589 if (detectorIndex[1]==2) { // plate with holes
598 clonesRawData->Clear();
602 //if (fVerbose==2) ftxt.close();
604 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
612 //-----------------------------------------------------------------------------
613 void AliTOFTrigger::GetLTMIndex(const Int_t * const detind, Int_t *indexLTM) {
615 // getting LTMmatrix indexes for current digit
618 if (detind[1]==0 || detind[1]==1 || (detind[1]==2 && detind[2]<=7)) {
620 indexLTM[0] = detind[0]*2;
623 indexLTM[0] = detind[0]*2+1;
628 indexLTM[0] = detind[0]*2+36;
631 indexLTM[0] = (detind[0]*2+1)+36;
635 if (indexLTM[0]<36) {
637 indexLTM[1] = detind[2];
639 else if (detind[1] ==1){
640 indexLTM[1] = detind[2]+19;
642 else if (detind[1] ==2){
643 indexLTM[1] = detind[2]+19*2;
646 AliError("Smth Wrong!!!");
651 indexLTM[1] = detind[2]-8;
653 else if (detind[1] ==3){
654 indexLTM[1] = detind[2]+7;
656 else if (detind[1] ==4){
657 indexLTM[1] = detind[2]+26;
660 AliError("Smth Wrong!!!");
665 //-------------------------------------------------------------------------
667 // to be checked because of warning problems
668 void AliTOFTrigger::PrintMap()
674 for(Int_t i = 0; i<kNLTM;i++) {
676 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",
677 (fCTTMmatrixFront[i][0])?1:0,(fCTTMmatrixFront[i][1])?1:0,(fCTTMmatrixFront[i][2])?1:0, \
678 (fCTTMmatrixFront[i][3])?1:0,(fCTTMmatrixFront[i][4])?1:0,(fCTTMmatrixFront[i][5])?1:0, \
679 (fCTTMmatrixFront[i][6])?1:0,(fCTTMmatrixFront[i][7])?1:0,(fCTTMmatrixFront[i][8])?1:0, \
680 (fCTTMmatrixFront[i][9])?1:0,(fCTTMmatrixFront[i][10])?1:0,(fCTTMmatrixFront[i][11])?1:0, \
681 (fCTTMmatrixFront[i][12])?1:0,(fCTTMmatrixFront[i][13])?1:0,(fCTTMmatrixFront[i][14])?1:0, \
682 (fCTTMmatrixFront[i][15])?1:0,(fCTTMmatrixFront[i][16])?1:0,(fCTTMmatrixFront[i][17])?1:0, \
683 (fCTTMmatrixFront[i][18])?1:0,(fCTTMmatrixFront[i][19])?1:0,(fCTTMmatrixFront[i][20])?1:0, \
684 (fCTTMmatrixFront[i][21])?1:0,(fCTTMmatrixFront[i][22])?1:0,(fCTTMmatrixFront[i][23])?1:0);
686 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",
687 (fCTTMmatrixBack[i][0])?1:0,(fCTTMmatrixBack[i][1])?1:0,(fCTTMmatrixBack[i][2])?1:0, \
688 (fCTTMmatrixBack[i][3])?1:0,(fCTTMmatrixBack[i][4])?1:0,(fCTTMmatrixBack[i][5])?1:0, \
689 (fCTTMmatrixBack[i][6])?1:0,(fCTTMmatrixBack[i][7])?1:0,(fCTTMmatrixBack[i][8])?1:0, \
690 (fCTTMmatrixBack[i][9])?1:0,(fCTTMmatrixBack[i][10])?1:0,(fCTTMmatrixBack[i][11])?1:0, \
691 (fCTTMmatrixBack[i][12])?1:0,(fCTTMmatrixBack[i][13])?1:0,(fCTTMmatrixBack[i][14])?1:0, \
692 (fCTTMmatrixBack[i][15])?1:0,(fCTTMmatrixBack[i][16])?1:0,(fCTTMmatrixBack[i][17])?1:0, \
693 (fCTTMmatrixBack[i][18])?1:0,(fCTTMmatrixBack[i][19])?1:0,(fCTTMmatrixBack[i][20])?1:0, \
694 (fCTTMmatrixBack[i][21])?1:0,(fCTTMmatrixBack[i][22])?1:0,(fCTTMmatrixBack[i][23])?1:0);
700 //-------------------------------------------------------------------------
702 void AliTOFTrigger::GetMapMatrix(Bool_t map[][24]) const
708 for(Int_t i = 0; i<kNLTM;i++)
709 for(Int_t j = 0; j<kNCTTMchannels;j++)
710 map[i][j]=(i<36)?fCTTMmatrixFront[i][j]:fCTTMmatrixBack[i-36][j];
713 //-------------------------------------------------------------------------
715 void AliTOFTrigger::GetMap(Bool_t **map) const
721 for(Int_t i = 0; i<kNLTM;i++)
722 for(Int_t j = 0; j<kNCTTMchannels;j++)
723 map[i][j]=(i<36)?fCTTMmatrixFront[i][j]:fCTTMmatrixBack[i-36][j];
728 //-------------------------------------------------------------------------
729 void AliTOFTrigger::GetTRDmap(Bool_t **map) const
732 // Retriev the bit map sent to the TRD detector
735 for(int i = 0; i<kNLTM;i++)
736 for(int j = 0; j<kNLTMtoTRDchannels;j++){
740 for(int i = 0; i<kNLTM/2;i++)
741 for(int j = 0; j<AliTOFTrigger::kNCTTMchannels;j++){
743 if(fCTTMmatrixFront[i][j]) map[i][uTRDbit]=kTRUE;
745 for(int i = kNLTM/2; i<kNLTM;i++)
746 for(int j = 0; j<AliTOFTrigger::kNCTTMchannels;j++){
748 if(fCTTMmatrixBack[i-kNLTM/2][j]) map[i][uTRDbit]=kTRUE;
752 //-------------------------------------------------------------------------
753 void AliTOFTrigger::GetTRDmapMatrix(Bool_t map[][8]) const
756 // Retriev the bit map sent to the TRD detector
759 for(int i = 0; i<kNLTM;i++)
760 for(int j = 0; j<kNLTMtoTRDchannels;j++){
764 for(int i = 0; i<kNLTM/2;i++)
765 for(int j = 0; j<AliTOFTrigger::kNCTTMchannels;j++){
767 if(fCTTMmatrixFront[i][j]) map[i][uTRDbit]=kTRUE;
769 for(int i = kNLTM/2; i<kNLTM;i++)
770 for(int j = 0; j<AliTOFTrigger::kNCTTMchannels;j++){
772 if(fCTTMmatrixBack[i-kNLTM/2][j]) map[i][uTRDbit]=kTRUE;
777 //-------------------------------------------------------------------------
778 void AliTOFTrigger::SetBit(Int_t *detind)
781 // Sets CTTM map element corresponding to detector element 'detind'
785 GetCTTMIndex(detind,index);
787 fCTTMmatrixFront[index[0]][index[1]]=kTRUE;
789 fCTTMmatrixBack[index[0]-36][index[1]]=kTRUE;
793 //-------------------------------------------------------------------------
794 void AliTOFTrigger::SetBit(Int_t nDDL, Int_t nTRM, Int_t iChain,
795 Int_t iTDC, Int_t iCH)
798 // Sets CTTM map element corresponding to equipment ID
799 // labelled by number nDDL, nTRM, iChain, iTDC, iCH
802 if(nTRM==3 && iTDC>=12 && iTDC<=14 && nDDL%2==1){ // DDL number to LTM number mapping
805 Int_t iChannelIndex=-1;
806 switch(nDDL%AliTOFGeometry::NDDL()){
814 AliError("Call this function only if(nTRM==3 && iTDC>12 && iTDC<14 && nDDL%2==1) ");
817 iLTMindex+=2*(Int_t)(nDDL/AliTOFGeometry::NDDL());
818 if(iChain==0 && nDDL<36)
820 if(iChain==0 && nDDL>=36)
822 iChannelIndex=iCH+iTDC*AliTOFGeometry::NCh()-12*AliTOFGeometry::NCh();
823 Int_t index[2]={iLTMindex,iChannelIndex};
825 fCTTMmatrixFront[index[0]][index[1]]=kTRUE;
826 fLTMmatrix[index[0]][index[1]*2]=kTRUE;
829 fCTTMmatrixBack[index[0]-36][index[1]]=kTRUE;
830 fLTMmatrix[index[0]][index[1]*2]=kTRUE;
835 //-------------------------------------------------------------------------
837 void AliTOFTrigger::ResetBit(Int_t *detind)
840 // Sets CTTM map element corresponding to detector element 'detind'
844 GetCTTMIndex(detind,index);
846 fCTTMmatrixFront[index[0]][index[1]]=kFALSE;
848 fCTTMmatrixBack[index[0]-36][index[1]]=kFALSE;
852 //-------------------------------------------------------------------------
853 void AliTOFTrigger::ResetBit(Int_t nDDL, Int_t nTRM, Int_t iChain,
854 Int_t iTDC, Int_t iCH)
857 // Sets CTTM map element corresponding to equipment ID
858 // labelled by number nDDL, nTRM, iChain, iTDC, iCH
861 if(nTRM==3 && iTDC>12 && iTDC<14 && nDDL%2==1){ // DDL number to LTM number mapping
863 Int_t iChannelIndex=-1;
864 switch(nDDL%AliTOFGeometry::NDDL()){
872 AliError("Call this function only if(nTRM==3 && iTDC>12 && iTDC<14 && nDDL%2==1) ");
875 iLTMindex+=2*(Int_t)(nDDL/AliTOFGeometry::NDDL());
876 if(iChain==0 && nDDL<36)
878 if(iChain==0 && nDDL>=36)
880 iChannelIndex=iCH+iTDC*AliTOFGeometry::NCh()-12*AliTOFGeometry::NCh();
881 Int_t index[2]={iLTMindex,iChannelIndex};
883 fCTTMmatrixFront[index[0]][index[1]]=kFALSE;
886 fCTTMmatrixBack[index[0]-36][index[1]]=kFALSE;
890 AliError("Call this function only if(nTRM==3 && iTDC>12 && iTDC<14 && nDDL%2==1) ");
893 //-------------------------------------------------------------------------
895 Bool_t AliTOFTrigger::GetBit(Int_t *detind)
898 // Returns CTTM map element corresponding to detector element 'detind'
902 GetCTTMIndex(detind,index);
903 return (index[0]<36)?fCTTMmatrixFront[index[0]][index[1]]:fCTTMmatrixBack[index[0]-36][index[1]];
907 //-------------------------------------------------------------------------
908 Bool_t AliTOFTrigger::GetBit(Int_t nDDL, Int_t nTRM, Int_t iChain,
909 Int_t iTDC, Int_t iCH)
912 // Returns CTTM map element corresponding to equipment ID
913 // labelled by number nDDL, nTRM, iChain, iTDC, iCH
916 if ( !(nTRM==3 && iTDC>12 && iTDC<14 && nDDL%2==1) ) {
917 AliWarning("Call this function only if(nTRM==3 && iTDC>12 && iTDC<14) ");
920 //if (nTRM==3 && iTDC>12 && iTDC<14 && nDDL%2==1) { // DDL number to LTM number mapping
923 UInt_t iChannelindex=0;
924 switch(nDDL%AliTOFGeometry::NDDL()) {
932 AliError("something wrong");
935 iLTMindex+=2*(Int_t)(nDDL/AliTOFGeometry::NDDL());
937 if (iChain==1) return kFALSE; // AdC
943 iChannelindex=iCH+iTDC*AliTOFGeometry::NCh()-12*AliTOFGeometry::NCh();
944 Int_t index[2]={iLTMindex,iChannelindex};
945 return (index[0]<36)?fCTTMmatrixFront[index[0]][index[1]]:fCTTMmatrixBack[index[0]-36][index[1]];
949 //-------------------------------------------------------------------------
951 void AliTOFTrigger::CreateCTTMMatrix() {
953 // Create CTTM bit map
955 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,
956 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};
962 for(Int_t i = 0; i<kNLTM;i++){
963 UInt_t currentMask = fPowerMask[kNCTTMchannels]-1;
964 if(fTOFTrigMask) currentMask=fTOFTrigMask->GetTriggerMask(fromTriggertoDCS[i]);
966 for(Int_t j = 0; j<kNCTTMchannels;j++){
967 fCTTMmatrixFront[i][j]=fLTMmatrix[i][2*j]||fLTMmatrix[i][2*j+1];
968 if(fCTTMmatrixFront[i][j]) fNMaxipadOnAll++;
969 if(!(currentMask & fPowerMask[j])) fCTTMmatrixFront[i][j]=0;
970 if(fCTTMmatrixFront[i][j]){
972 fLTMarray[i] = kTRUE;
977 for(Int_t j = 0; j<kNCTTMchannels;j++){
978 fCTTMmatrixBack[i-kNCTTM][j]=fLTMmatrix[i][2*j]||fLTMmatrix[i][2*j+1];;
979 if(fCTTMmatrixBack[i-kNCTTM][j]) fNMaxipadOnAll++;
980 if(!(currentMask & fPowerMask[j])) fCTTMmatrixBack[i-kNCTTM][j]=0;
981 if(fCTTMmatrixBack[i-kNCTTM][j]){
983 fLTMarray[i-kNCTTM] = kTRUE;
990 for(Int_t j=0; j < kNCTTM; j++) {if(fLTMarray[j]) fNCrateOn++;}
993 //-----------------------------------------------------------------------------
995 void AliTOFTrigger::GetCTTMIndex(Int_t *detind, Int_t *indexCTTM) {
997 // Returns CTTM index corresponding to the detector element detind
1000 GetLTMIndex(detind,indexCTTM);
1004 //-----------------------------------------------------------------------------
1005 void AliTOFTrigger::LoadActiveMask(){
1007 // Load OCDB current mask
1010 AliCDBManager *cdb = AliCDBManager::Instance();
1011 if(cdb->GetRun() < 0 || !(cdb->GetDefaultStorage())){
1012 if(!(cdb->GetDefaultStorage())){
1013 cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
1014 printf("AliTOFTrigger (WARNING): probably CDB first instance - Default Sorage set to \"local://$ALICE_ROOT/OCDB\"\n");
1016 if(cdb->GetRun() < 0){
1018 printf("AliTOFTrigger (WARNING): probably CDB first instance - number of run set to 0\n");
1022 AliCDBEntry *cdbe = cdb->Get("TRIGGER/TOF/TriggerMask");
1024 fTOFTrigMask= (AliTOFTriggerMask *)cdbe->GetObject();
1026 // UInt_t maskArray[kNLTM];
1027 // if(fTOFTrigMask == NULL) fTOFTrigMask = new AliTOFTriggerMask();
1028 // for (Int_t k = 0; k < kNLTM ; k++) maskArray[k] = fPowerMask[kNCTTMchannels]-1;
1029 // //for (Int_t k = 0; k < kNLTM ; k+=2) maskArray[k] = 0;
1031 // fTOFTrigMask->SetTriggerMaskArray(maskArray);
1035 //-----------------------------------------------------------------------------
1036 AliTOFTrigger::~AliTOFTrigger()
1042 //-----------------------------------------------------------------------------
1043 AliTOFTrigger& AliTOFTrigger::operator=(const AliTOFTrigger &/*source*/)