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<kNLTM;i++){
82 fLTMarray[i] = kFALSE; //*******************************************************************************************************
83 for (Int_t j=0;j<kNLTMchannels;j++){
84 fLTMmatrix[i][j]=kFALSE;
87 for (Int_t j=0;j<kNCTTMchannels;j++){
88 fCTTMmatrixFront[i][j]=kFALSE;
89 fCTTMmatrixBack[i][j]=kFALSE;
95 for(Int_t i=1;i <= kNCTTMchannels;i++){
96 fPowerMask[i] = fPowerMask[i-1]*2;
104 //----------------------------------------------------------------------
106 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) :
107 AliTriggerDetector(),
108 fHighMultTh(HighMultTh),
110 fMultiMuonTh(MultiMuonTh),
112 fdeltaminpsi(deltaminpsi),
113 fdeltamaxpsi(deltamaxpsi),
114 fdeltaminro(deltaminro),
115 fdeltamaxro(deltamaxro),
116 fstripWindow(stripWindow),
126 //ctor with thresholds for triggers
127 for (Int_t i=0;i<kNLTM;i++){
128 fLTMarray[i] = kFALSE; //*******************************************************************************************************
129 for (Int_t j=0;j<kNLTMchannels;j++){
130 fLTMmatrix[i][j]=kFALSE;
133 for (Int_t j=0;j<kNCTTMchannels;j++){
134 fCTTMmatrixFront[i][j]=kFALSE;
135 fCTTMmatrixBack[i][j]=kFALSE;
141 for(Int_t i=1;i <= kNCTTMchannels;i++){
142 fPowerMask[i] = fPowerMask[i-1]*2;
150 #if 0 /*** COPY CONSTRUCTOR SUPPRESSED **/
151 //____________________________________________________________________________
153 AliTOFTrigger::AliTOFTrigger(const AliTOFTrigger & tr):
154 AliTriggerDetector(tr),
155 fHighMultTh(tr.fHighMultTh),
157 fMultiMuonTh(tr.fMultiMuonTh),
159 fdeltaminpsi(tr.fdeltaminpsi),
160 fdeltamaxpsi(tr.fdeltamaxpsi),
161 fdeltaminro(tr.fdeltaminro),
162 fdeltamaxro(tr.fdeltamaxro),
163 fstripWindow(tr.fstripWindow),
168 fNCrateOn(tr.fNCrateOn),
169 fNMaxipadOn(tr.fNMaxipadOn),
170 fNMaxipadOnAll(tr.fNMaxipadOnAll),
174 for (Int_t i=0;i<kNLTM;i++){
175 fLTMarray[i] = tr.fLTMarray[i];
176 for (Int_t j=0;j<kNLTMchannels;j++){
177 fLTMmatrix[i][j]=tr.fLTMmatrix[i][j];
180 for (Int_t j=0;j<kNCTTMchannels;j++){
181 fCTTMmatrixFront[i][j]=tr.fCTTMmatrixFront[i][j];
182 fCTTMmatrixBack[i][j]=tr.fCTTMmatrixBack[i][j];
188 for(Int_t i=1;i <= kNCTTMchannels;i++){
189 fPowerMask[i] = fPowerMask[i-1]*2;
193 fTOFTrigMask = new AliTOFTriggerMask();
194 fTOFTrigMask->SetTriggerMaskArray(tr.fTOFTrigMask->GetTriggerMaskArray());
197 SetName(tr.GetName());
198 //fInputs=&(tr.GetInputs());
202 #endif /*** COPY CONTRUCTOR SUPPRESSED ***/
204 //----------------------------------------------------------------------
206 void AliTOFTrigger::CreateInputs()
209 // Do not create inputs again!!
210 if( fInputs.GetEntriesFast() > 0 ) return;
214 fInputs.AddLast(new AliTriggerInput("TOF_Cosmic_MultiMuon_L0","TOF",0));
215 fInputs.AddLast(new AliTriggerInput("0OIN","TOF",0)); // was "TOF_pp_MB_L0"
216 fInputs.AddLast(new AliTriggerInput("0OM2","TOF",0)); // was "TOF_PbPb_MB2_L0"
217 fInputs.AddLast(new AliTriggerInput("0OM3","TOF",0)); // was "TOF_PbPb_MB3_L0"
218 fInputs.AddLast(new AliTriggerInput("0OUP","TOF",0)); // was "TOF_UltraPer_Coll_L0"
220 fInputs.AddLast(new AliTriggerInput("0OHM","TOF",0)); // was "TOF_High_Mult_L0"
221 fInputs.AddLast(new AliTriggerInput("TOF_Jet_L1","TOF",0));
225 //----------------------------------------------------------------------
226 void AliTOFTrigger::Trigger() {
234 Int_t nchonFront = 0;
237 Int_t nSectOn = 0; // °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
238 Int_t DeSlots = -1;// °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
239 Int_t AntiDeSlots = -1;// °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
240 Int_t nchonFrontBack = 0;
241 Int_t nchonFront1 = 0;
242 Int_t nchonBack1 = 0;
243 Int_t nchonFrontBack1 = 0;
244 Int_t mindeltapsi = (Int_t)fdeltaminpsi/10;
245 Int_t maxdeltapsi = (Int_t)fdeltamaxpsi/10;
246 Int_t mindeltaro = (Int_t)fdeltaminro/10;
247 Int_t maxdeltaro = (Int_t)fdeltamaxro/10;
249 for (Int_t i=0;i<kNCTTM;i++){
250 for (Int_t j=0;j<kNCTTMchannels;j++){
251 if (fCTTMmatrixFront[i][j]) nchonFront++;
255 for (Int_t i=kNCTTM;i<(kNCTTM*2);i++){
256 for (Int_t j=0;j<kNCTTMchannels;j++){
257 if (fCTTMmatrixBack[i-kNCTTM][j]) nchonBack++;
261 nchonTot = nchonFront + nchonBack;
262 // fNMaxipadOn = nchonTot;
263 for(Int_t i=0;i<kNCTTM;i++) { if(fLTMarray[i]) nSectOn++; }
265 //pp Minimum Bias Trigger
266 if (nchonTot >= fppMBTh) {
269 //printf("0OIN - MB\n");
282 //High Multiplicity Trigger
283 if (nchonTot >= fHighMultTh) {
285 //printf("0OHM - High Mult\n");
294 Bool_t boolCTTMor = kFALSE;
296 for (Int_t i=0;i<(kNCTTM/2);i++){
297 Int_t iopp = i+kNCTTM/2;
298 for (Int_t j=0;j<kNCTTMchannels;j++){
299 if (fCTTMmatrixFront[i][j]){
300 Int_t minj = j-fstripWindow;
301 Int_t maxj = j+fstripWindow;
303 if (maxj>=kNCTTMchannels) maxj = kNCTTMchannels-1;
305 for (Int_t k = minj;k<=maxj;k++){
306 boolCTTMor |= fCTTMmatrixFront[iopp][k];
313 if (fCTTMmatrixBack[i][j]){
314 Int_t minj = j-fstripWindow;
315 Int_t maxj = j+fstripWindow;
317 if (maxj>=kNCTTMchannels) maxj =kNCTTMchannels-1;
319 for (Int_t k = minj;k<=maxj;k++){
320 boolCTTMor |= fCTTMmatrixBack[iopp][k];
329 nchonFrontBack = nchonFront+nchonBack;
336 for (Int_t i=0;i<(kNCTTM/2);i++){
337 Int_t i2max = (kNCTTM-1)-i+1;
338 Int_t i2min = (kNCTTM-1)-i-1;
339 if (i2max >=kNCTTM) i2max = kNCTTM-1;
340 if (i2min==i) i2min = kNCTTM-1-i;
341 for (Int_t j=0;j<kNCTTMchannels;j++){
342 Int_t j2min = j-fstripWindow;
343 Int_t j2max = j+fstripWindow;
344 if (j2min<0) j2min =0;
345 if (j2max>=kNCTTMchannels) j2max =kNCTTMchannels-1;
346 if (fCTTMmatrixFront[i][j]){
348 for (Int_t i2=i2min;i2<=i2max;i2++){
349 for (Int_t j2 = j2min;j2<=j2max;j2++){
350 boolCTTMor |= fCTTMmatrixFront[i2][j2];
357 if (fCTTMmatrixBack[i][j]){
359 for (Int_t i2=i2min;i2<=i2max;i2++){
360 for (Int_t j2 = j2min;j2<=j2max;j2++){
361 boolCTTMor |= fCTTMmatrixBack[i2][j2];
371 nchonFrontBack1 = nchonFront1+nchonBack1;
373 if (nchonFrontBack >= fMultiMuonTh || nchonFrontBack1 >= fMultiMuonTh) {
374 SetInput("TOF_Cosmic_MultiMuon_L0");
377 //Ultra-Peripheral collision Trigger
379 // °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
380 // DeSlots = (k+1)_Array Element - k_Array Element
381 // AntiDeSlots = kNCTTM - DeSlots
383 if((!fSel1))// && nchonFront < 4 && nchonBack < 4)
385 // printf("nHitMaxipad CLASSE: %i \n",fNMaxipadOn);
386 // printf("Total Number per event of Switched-On sectors : %i \n", nSectOn);
387 // printf("mindeltapsi %i \n", mindeltapsi);
388 //printf("maxdeltapsi %i \n", maxdeltapsi);
389 for(Int_t i = 0; i < kNCTTM; i++){
391 // printf(" i-sect On: %i\n",i);
392 for(Int_t j = i+1; j < kNCTTM; j++){
394 // printf(" j-sect On: %i\n",j);
396 AntiDeSlots = kNCTTM - DeSlots;
397 //printf("DeSlots = %i \n",DeSlots);
398 //printf("AntiDeSlots = %i \n",AntiDeSlots);
399 if(DeSlots >= mindeltapsi && DeSlots <= maxdeltapsi){
402 //printf("trigger On with DeSlot \n");
404 if(AntiDeSlots >= mindeltapsi && AntiDeSlots <= maxdeltapsi){
407 //printf("trigger On with AntiDeSlot \n");
411 if(DeSlots >= mindeltaro && DeSlots <= maxdeltaro){
414 //printf("trigger On with DeSlot \n");
416 if(AntiDeSlots >= mindeltaro && AntiDeSlots <= maxdeltaro){
419 //printf("trigger On with AntiDeSlot \n");
430 //-----------------------------------------------------------------------------
431 void AliTOFTrigger::CreateLTMMatrix() {
434 CreateLTMMatrixFromDigits();
437 //-------------------------------------------------------------------------
439 void AliTOFTrigger::CreateLTMMatrixFromDigits() {
441 // Create LTM matrix by TOF digits
445 for (Int_t i=0;i<kNLTM;i++){
446 fLTMarray[i]= kFALSE;
447 for (Int_t j=0;j<kNLTMchannels;j++){
448 fLTMmatrix[i][j]=kFALSE;
451 for (Int_t i=0;i<kNCTTM;i++){
452 for (Int_t j=0;j<kNCTTMchannels;j++){
453 fCTTMmatrixFront[i][j]=kFALSE;
454 fCTTMmatrixBack[i][j]=kFALSE;
460 rl = AliRunLoader::Instance();
462 Int_t ncurrevent = rl->GetEventNumber();
463 rl->GetEvent(ncurrevent);
465 AliLoader * tofLoader = rl->GetLoader("TOFLoader");
467 tofLoader->LoadDigits("read");
468 TTree *treeD = tofLoader->TreeD();
471 AliFatal("AliTOFTrigger: Can not get TreeD");
474 TBranch *branch = treeD->GetBranch("TOF");
476 AliError("can't get the branch with the TOF digits !");
479 TClonesArray *tofDigits =new TClonesArray("AliTOFdigit", 1000);
480 branch->SetAddress(&tofDigits);
482 Int_t ndigits = tofDigits->GetEntriesFast();
483 Int_t detind[5]; //detector indexes: 0 -> sector
484 // 1 -> plate(modulo)
489 for (Int_t i=0;i<ndigits;i++){
490 AliTOFdigit * digit = (AliTOFdigit*)tofDigits->UncheckedAt(i);
491 detind[0] = digit->GetSector();
492 detind[1] = digit->GetPlate();
493 detind[2] = digit->GetStrip();
494 detind[3] = digit->GetPadz();
495 detind[4] = digit->GetPadx();
497 Int_t indexLTM[2] = {-1,-1};
498 GetLTMIndex(detind,indexLTM);
500 fLTMmatrix[indexLTM[0]][indexLTM[1]] = kTRUE;
501 // fLTMarray[indexLTM[0]%36] = kTRUE; //dimensione MAX array 36 = kNCTTM
505 tofLoader->UnloadDigits();
506 // rl->UnloadgAlice();
511 //-----------------------------------------------------------------------------
513 void AliTOFTrigger::CreateLTMMatrixFromRaw(AliRawReader *fRawReader) {
515 // Create LTM matrix by TOF raw data
519 for (Int_t i=0;i<kNLTM;i++){
520 for (Int_t j=0;j<kNLTMchannels;j++){
521 fLTMmatrix[i][j]=kFALSE;
524 for (Int_t i=0;i<kNCTTM;i++){
525 for (Int_t j=0;j<kNCTTMchannels;j++){
526 fCTTMmatrixFront[i][j]=kFALSE;
527 fCTTMmatrixBack[i][j]=kFALSE;
532 AliTOFRawStream * tofRawStream = new AliTOFRawStream();
536 //if(!GetLoader()->TreeS()) {MakeTree("S"); MakeBranch("S");}
539 tofRawStream->SetRawReader(fRawReader);
542 //if (fVerbose==2) ftxt.open("TOFsdigitsRead.txt",ios::app);
544 TClonesArray staticRawData("AliTOFrawData",10000);
545 staticRawData.Clear();
546 TClonesArray * clonesRawData = &staticRawData;
549 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
556 AliTOFrawData *tofRawDatum = 0;
557 for (indexDDL=0; indexDDL<AliDAQ::NumberOfDdls("TOF"); indexDDL++) {
560 tofRawStream->LoadRawDataBuffersV2(indexDDL);
562 clonesRawData = tofRawStream->GetRawData();
563 if (clonesRawData->GetEntriesFast()!=0) AliInfo(Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
564 for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
566 tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
568 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
569 if (tofRawDatum->GetTOF()==-1) continue;
571 SetBit(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
572 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel());
574 dummy = detectorIndex[3];
575 detectorIndex[3] = detectorIndex[4];//padz
576 detectorIndex[4] = dummy;//padx
578 digit[0] = tofRawDatum->GetTOF();
579 digit[1] = tofRawDatum->GetTOT();
581 dummy = detectorIndex[3];
582 detectorIndex[3] = detectorIndex[4];//padx
583 detectorIndex[4] = dummy;//padz
585 // Do not reconstruct anything in the holes
586 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
587 if (detectorIndex[1]==2) { // plate with holes
596 clonesRawData->Clear();
600 //if (fVerbose==2) ftxt.close();
602 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
610 //-----------------------------------------------------------------------------
611 void AliTOFTrigger::GetLTMIndex(const Int_t * const detind, Int_t *indexLTM) {
613 // getting LTMmatrix indexes for current digit
616 if (detind[1]==0 || detind[1]==1 || (detind[1]==2 && detind[2]<=7)) {
618 indexLTM[0] = detind[0]*2;
621 indexLTM[0] = detind[0]*2+1;
626 indexLTM[0] = detind[0]*2+36;
629 indexLTM[0] = (detind[0]*2+1)+36;
633 if (indexLTM[0]<36) {
635 indexLTM[1] = detind[2];
637 else if (detind[1] ==1){
638 indexLTM[1] = detind[2]+19;
640 else if (detind[1] ==2){
641 indexLTM[1] = detind[2]+19*2;
644 AliError("Smth Wrong!!!");
649 indexLTM[1] = detind[2]-8;
651 else if (detind[1] ==3){
652 indexLTM[1] = detind[2]+7;
654 else if (detind[1] ==4){
655 indexLTM[1] = detind[2]+26;
658 AliError("Smth Wrong!!!");
663 //-------------------------------------------------------------------------
665 // to be checked because of warning problems
666 void AliTOFTrigger::PrintMap()
672 for(Int_t i = 0; i<kNLTM;i++) {
674 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",
675 (fCTTMmatrixFront[i][0])?1:0,(fCTTMmatrixFront[i][1])?1:0,(fCTTMmatrixFront[i][2])?1:0, \
676 (fCTTMmatrixFront[i][3])?1:0,(fCTTMmatrixFront[i][4])?1:0,(fCTTMmatrixFront[i][5])?1:0, \
677 (fCTTMmatrixFront[i][6])?1:0,(fCTTMmatrixFront[i][7])?1:0,(fCTTMmatrixFront[i][8])?1:0, \
678 (fCTTMmatrixFront[i][9])?1:0,(fCTTMmatrixFront[i][10])?1:0,(fCTTMmatrixFront[i][11])?1:0, \
679 (fCTTMmatrixFront[i][12])?1:0,(fCTTMmatrixFront[i][13])?1:0,(fCTTMmatrixFront[i][14])?1:0, \
680 (fCTTMmatrixFront[i][15])?1:0,(fCTTMmatrixFront[i][16])?1:0,(fCTTMmatrixFront[i][17])?1:0, \
681 (fCTTMmatrixFront[i][18])?1:0,(fCTTMmatrixFront[i][19])?1:0,(fCTTMmatrixFront[i][20])?1:0, \
682 (fCTTMmatrixFront[i][21])?1:0,(fCTTMmatrixFront[i][22])?1:0,(fCTTMmatrixFront[i][23])?1:0);
684 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",
685 (fCTTMmatrixBack[i][0])?1:0,(fCTTMmatrixBack[i][1])?1:0,(fCTTMmatrixBack[i][2])?1:0, \
686 (fCTTMmatrixBack[i][3])?1:0,(fCTTMmatrixBack[i][4])?1:0,(fCTTMmatrixBack[i][5])?1:0, \
687 (fCTTMmatrixBack[i][6])?1:0,(fCTTMmatrixBack[i][7])?1:0,(fCTTMmatrixBack[i][8])?1:0, \
688 (fCTTMmatrixBack[i][9])?1:0,(fCTTMmatrixBack[i][10])?1:0,(fCTTMmatrixBack[i][11])?1:0, \
689 (fCTTMmatrixBack[i][12])?1:0,(fCTTMmatrixBack[i][13])?1:0,(fCTTMmatrixBack[i][14])?1:0, \
690 (fCTTMmatrixBack[i][15])?1:0,(fCTTMmatrixBack[i][16])?1:0,(fCTTMmatrixBack[i][17])?1:0, \
691 (fCTTMmatrixBack[i][18])?1:0,(fCTTMmatrixBack[i][19])?1:0,(fCTTMmatrixBack[i][20])?1:0, \
692 (fCTTMmatrixBack[i][21])?1:0,(fCTTMmatrixBack[i][22])?1:0,(fCTTMmatrixBack[i][23])?1:0);
698 //-------------------------------------------------------------------------
700 void AliTOFTrigger::GetMapMatrix(Bool_t map[][24]) const
706 for(Int_t i = 0; i<kNLTM;i++)
707 for(Int_t j = 0; j<kNCTTMchannels;j++)
708 map[i][j]=(i<36)?fCTTMmatrixFront[i][j]:fCTTMmatrixBack[i-36][j];
711 //-------------------------------------------------------------------------
713 void AliTOFTrigger::GetMap(Bool_t **map) const
719 for(Int_t i = 0; i<kNLTM;i++)
720 for(Int_t j = 0; j<kNCTTMchannels;j++)
721 map[i][j]=(i<36)?fCTTMmatrixFront[i][j]:fCTTMmatrixBack[i-36][j];
726 //-------------------------------------------------------------------------
727 void AliTOFTrigger::GetTRDmap(Bool_t **map) const
730 // Retriev the bit map sent to the TRD detector
733 for(int i = 0; i<kNLTM;i++)
734 for(int j = 0; j<kNLTMtoTRDchannels;j++){
738 for(int i = 0; i<kNLTM/2;i++)
739 for(int j = 0; j<AliTOFTrigger::kNCTTMchannels;j++){
741 if(fCTTMmatrixFront[i][j]) map[i][uTRDbit]=kTRUE;
743 for(int i = kNLTM/2; i<kNLTM;i++)
744 for(int j = 0; j<AliTOFTrigger::kNCTTMchannels;j++){
746 if(fCTTMmatrixBack[i-kNLTM/2][j]) map[i][uTRDbit]=kTRUE;
750 //-------------------------------------------------------------------------
751 void AliTOFTrigger::GetTRDmapMatrix(Bool_t map[][8]) const
754 // Retriev the bit map sent to the TRD detector
757 for(int i = 0; i<kNLTM;i++)
758 for(int j = 0; j<kNLTMtoTRDchannels;j++){
762 for(int i = 0; i<kNLTM/2;i++)
763 for(int j = 0; j<AliTOFTrigger::kNCTTMchannels;j++){
765 if(fCTTMmatrixFront[i][j]) map[i][uTRDbit]=kTRUE;
767 for(int i = kNLTM/2; i<kNLTM;i++)
768 for(int j = 0; j<AliTOFTrigger::kNCTTMchannels;j++){
770 if(fCTTMmatrixBack[i-kNLTM/2][j]) map[i][uTRDbit]=kTRUE;
775 //-------------------------------------------------------------------------
776 void AliTOFTrigger::SetBit(Int_t *detind)
779 // Sets CTTM map element corresponding to detector element 'detind'
783 GetCTTMIndex(detind,index);
785 fCTTMmatrixFront[index[0]][index[1]]=kTRUE;
787 fCTTMmatrixBack[index[0]-36][index[1]]=kTRUE;
791 //-------------------------------------------------------------------------
792 void AliTOFTrigger::SetBit(Int_t nDDL, Int_t nTRM, Int_t iChain,
793 Int_t iTDC, Int_t iCH)
796 // Sets CTTM map element corresponding to equipment ID
797 // labelled by number nDDL, nTRM, iChain, iTDC, iCH
800 if(nTRM==3 && iTDC>=12 && iTDC<=14 && nDDL%2==1){ // DDL number to LTM number mapping
803 Int_t iChannelIndex=-1;
804 switch(nDDL%AliTOFGeometry::NDDL()){
812 AliError("Call this function only if(nTRM==3 && iTDC>12 && iTDC<14 && nDDL%2==1) ");
815 iLTMindex+=2*(Int_t)(nDDL/AliTOFGeometry::NDDL());
816 if(iChain==0 && nDDL<36)
818 if(iChain==0 && nDDL>=36)
820 iChannelIndex=iCH+iTDC*AliTOFGeometry::NCh()-12*AliTOFGeometry::NCh();
821 Int_t index[2]={iLTMindex,iChannelIndex};
823 fCTTMmatrixFront[index[0]][index[1]]=kTRUE;
824 fLTMmatrix[index[0]][index[1]*2]=kTRUE;
827 fCTTMmatrixBack[index[0]-36][index[1]]=kTRUE;
828 fLTMmatrix[index[0]][index[1]*2]=kTRUE;
833 //-------------------------------------------------------------------------
835 void AliTOFTrigger::ResetBit(Int_t *detind)
838 // Sets CTTM map element corresponding to detector element 'detind'
842 GetCTTMIndex(detind,index);
844 fCTTMmatrixFront[index[0]][index[1]]=kFALSE;
846 fCTTMmatrixBack[index[0]-36][index[1]]=kFALSE;
850 //-------------------------------------------------------------------------
851 void AliTOFTrigger::ResetBit(Int_t nDDL, Int_t nTRM, Int_t iChain,
852 Int_t iTDC, Int_t iCH)
855 // Sets CTTM map element corresponding to equipment ID
856 // labelled by number nDDL, nTRM, iChain, iTDC, iCH
859 if(nTRM==3 && iTDC>12 && iTDC<14 && nDDL%2==1){ // DDL number to LTM number mapping
861 Int_t iChannelIndex=-1;
862 switch(nDDL%AliTOFGeometry::NDDL()){
870 AliError("Call this function only if(nTRM==3 && iTDC>12 && iTDC<14 && nDDL%2==1) ");
873 iLTMindex+=2*(Int_t)(nDDL/AliTOFGeometry::NDDL());
874 if(iChain==0 && nDDL<36)
876 if(iChain==0 && nDDL>=36)
878 iChannelIndex=iCH+iTDC*AliTOFGeometry::NCh()-12*AliTOFGeometry::NCh();
879 Int_t index[2]={iLTMindex,iChannelIndex};
881 fCTTMmatrixFront[index[0]][index[1]]=kFALSE;
884 fCTTMmatrixBack[index[0]-36][index[1]]=kFALSE;
888 AliError("Call this function only if(nTRM==3 && iTDC>12 && iTDC<14 && nDDL%2==1) ");
891 //-------------------------------------------------------------------------
893 Bool_t AliTOFTrigger::GetBit(Int_t *detind)
896 // Returns CTTM map element corresponding to detector element 'detind'
900 GetCTTMIndex(detind,index);
901 return (index[0]<36)?fCTTMmatrixFront[index[0]][index[1]]:fCTTMmatrixBack[index[0]-36][index[1]];
905 //-------------------------------------------------------------------------
906 Bool_t AliTOFTrigger::GetBit(Int_t nDDL, Int_t nTRM, Int_t iChain,
907 Int_t iTDC, Int_t iCH)
910 // Returns CTTM map element corresponding to equipment ID
911 // labelled by number nDDL, nTRM, iChain, iTDC, iCH
914 if ( !(nTRM==3 && iTDC>12 && iTDC<14 && nDDL%2==1) ) {
915 AliWarning("Call this function only if(nTRM==3 && iTDC>12 && iTDC<14) ");
918 //if (nTRM==3 && iTDC>12 && iTDC<14 && nDDL%2==1) { // DDL number to LTM number mapping
921 UInt_t iChannelindex=0;
922 switch(nDDL%AliTOFGeometry::NDDL()) {
930 AliError("something wrong");
933 iLTMindex+=2*(Int_t)(nDDL/AliTOFGeometry::NDDL());
935 if (iChain==1) return kFALSE; // AdC
941 iChannelindex=iCH+iTDC*AliTOFGeometry::NCh()-12*AliTOFGeometry::NCh();
942 Int_t index[2]={iLTMindex,iChannelindex};
943 return (index[0]<36)?fCTTMmatrixFront[index[0]][index[1]]:fCTTMmatrixBack[index[0]-36][index[1]];
947 //-------------------------------------------------------------------------
949 void AliTOFTrigger::CreateCTTMMatrix() {
951 // Create CTTM bit map
953 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,
954 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};
960 for(Int_t i = 0; i<kNLTM;i++){
961 UInt_t currentMask = fPowerMask[kNCTTMchannels]-1;
962 if(fTOFTrigMask) currentMask=fTOFTrigMask->GetTriggerMask(fromTriggertoDCS[i]);
964 for(Int_t j = 0; j<kNCTTMchannels;j++){
965 fCTTMmatrixFront[i][j]=fLTMmatrix[i][2*j]||fLTMmatrix[i][2*j+1];
966 if(fCTTMmatrixFront[i][j]) fNMaxipadOnAll++;
967 if(!(currentMask & fPowerMask[j])) fCTTMmatrixFront[i][j]=0;
968 if(fCTTMmatrixFront[i][j]){
970 fLTMarray[i] = kTRUE;
975 for(Int_t j = 0; j<kNCTTMchannels;j++){
976 fCTTMmatrixBack[i-kNCTTM][j]=fLTMmatrix[i][2*j]||fLTMmatrix[i][2*j+1];;
977 if(fCTTMmatrixBack[i-kNCTTM][j]) fNMaxipadOnAll++;
978 if(!(currentMask & fPowerMask[j])) fCTTMmatrixBack[i-kNCTTM][j]=0;
979 if(fCTTMmatrixBack[i-kNCTTM][j]){
981 fLTMarray[i-kNCTTM] = kTRUE;
988 for(Int_t j=0; j < kNCTTM; j++) {if(fLTMarray[j]) fNCrateOn++;}
991 //-----------------------------------------------------------------------------
993 void AliTOFTrigger::GetCTTMIndex(Int_t *detind, Int_t *indexCTTM) {
995 // Returns CTTM index corresponding to the detector element detind
998 GetLTMIndex(detind,indexCTTM);
1002 //-----------------------------------------------------------------------------
1003 void AliTOFTrigger::LoadActiveMask(){
1005 // Load OCDB current mask
1008 AliCDBManager *cdb = AliCDBManager::Instance();
1009 if(cdb->GetRun() < 0 || !(cdb->GetDefaultStorage())){
1010 if(!(cdb->GetDefaultStorage())){
1011 cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
1012 printf("AliTOFTrigger (WARNING): probably CDB first instance - Default Sorage set to \"local://$ALICE_ROOT/OCDB\"\n");
1014 if(cdb->GetRun() < 0){
1016 printf("AliTOFTrigger (WARNING): probably CDB first instance - number of run set to 0\n");
1020 AliCDBEntry *cdbe = cdb->Get("TRIGGER/TOF/TriggerMask");
1022 fTOFTrigMask= (AliTOFTriggerMask *)cdbe->GetObject();
1024 // UInt_t maskArray[kNLTM];
1025 // if(fTOFTrigMask == NULL) fTOFTrigMask = new AliTOFTriggerMask();
1026 // for (Int_t k = 0; k < kNLTM ; k++) maskArray[k] = fPowerMask[kNCTTMchannels]-1;
1027 // //for (Int_t k = 0; k < kNLTM ; k+=2) maskArray[k] = 0;
1029 // fTOFTrigMask->SetTriggerMaskArray(maskArray);
1033 //-----------------------------------------------------------------------------
1034 AliTOFTrigger::~AliTOFTrigger()
1040 //-----------------------------------------------------------------------------
1041 AliTOFTrigger& AliTOFTrigger::operator=(const AliTOFTrigger &/*source*/)