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>
38 #include "AliLoader.h"
40 #include "AliRunLoader.h"
42 #include "AliTriggerInput.h"
43 #include "AliRawReader.h"
45 #include "AliTOFRawStream.h"
46 #include "AliTOFrawData.h"
47 #include "AliTOFdigit.h"
48 #include "AliTOFGeometry.h"
49 #include "AliTOFTrigger.h"
50 #include "AliTOFTriggerMask.h"
52 #include "AliCDBManager.h"
53 #include "AliCDBEntry.h"
56 extern AliRun* gAlice;
58 AliTOFGeometry* AliTOFTrigger::fgTofGeo = NULL; // TOF geometry needed to get the minimial arrival time for each channel
60 //-------------------------------------------------------------------------
61 ClassImp(AliTOFTrigger)
63 //----------------------------------------------------------------------
64 AliTOFTrigger::AliTOFTrigger() :
67 fppMBTh(4),//4:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
70 fdeltaminpsi(150), //150
71 fdeltamaxpsi(170), //170
84 fTimeWidthTrigger(25.0)
88 for (Int_t i=0;i<kNCTTM;i++) fLTMarray[i] = kFALSE;
90 for (Int_t i=0;i<kNLTM;i++){
92 for (Int_t j=0;j<kNLTMchannels;j++){
93 fLTMmatrix[i][j]=kFALSE;
96 for (Int_t j=0;j<kNCTTMchannels;j++){
97 fCTTMmatrixFront[i][j]=kFALSE;
98 fCTTMmatrixBack[i][j]=kFALSE;
104 for(Int_t i=1;i <= kNCTTMchannels;i++){
105 fPowerMask[i] = fPowerMask[i-1]*2;
113 //----------------------------------------------------------------------
115 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) :
116 AliTriggerDetector(),
117 fHighMultTh(HighMultTh),
119 fMultiMuonTh(MultiMuonTh),
121 fdeltaminpsi(deltaminpsi),
122 fdeltamaxpsi(deltamaxpsi),
123 fdeltaminro(deltaminro),
124 fdeltamaxro(deltamaxro),
125 fstripWindow(stripWindow),
134 fStartTimeHit(startTimeWindow),
135 fTimeWidthTrigger(widthTimeWindow)
137 //ctor with thresholds for triggers
138 for (Int_t i=0;i<kNCTTM;i++) fLTMarray[i] = kFALSE;
139 for (Int_t i=0;i<kNLTM;i++){
140 for (Int_t j=0;j<kNLTMchannels;j++){
141 fLTMmatrix[i][j]=kFALSE;
144 for (Int_t j=0;j<kNCTTMchannels;j++){
145 fCTTMmatrixFront[i][j]=kFALSE;
146 fCTTMmatrixBack[i][j]=kFALSE;
152 for(Int_t i=1;i <= kNCTTMchannels;i++){
153 fPowerMask[i] = fPowerMask[i-1]*2;
161 #if 0 /*** COPY CONSTRUCTOR SUPPRESSED **/
162 //____________________________________________________________________________
164 AliTOFTrigger::AliTOFTrigger(const AliTOFTrigger & tr):
165 AliTriggerDetector(tr),
166 fHighMultTh(tr.fHighMultTh),
168 fMultiMuonTh(tr.fMultiMuonTh),
170 fdeltaminpsi(tr.fdeltaminpsi),
171 fdeltamaxpsi(tr.fdeltamaxpsi),
172 fdeltaminro(tr.fdeltaminro),
173 fdeltamaxro(tr.fdeltamaxro),
174 fstripWindow(tr.fstripWindow),
179 fNCrateOn(tr.fNCrateOn),
180 fNMaxipadOn(tr.fNMaxipadOn),
181 fNMaxipadOnAll(tr.fNMaxipadOnAll),
185 for (Int_t i=0;i<kNCTTM;i++) fLTMarray[i] = kFALSE;
186 for (Int_t i=0;i<kNLTM;i++){
187 for (Int_t j=0;j<kNLTMchannels;j++){
188 fLTMmatrix[i][j]=tr.fLTMmatrix[i][j];
191 for (Int_t j=0;j<kNCTTMchannels;j++){
192 fCTTMmatrixFront[i][j]=tr.fCTTMmatrixFront[i][j];
193 fCTTMmatrixBack[i][j]=tr.fCTTMmatrixBack[i][j];
199 for(Int_t i=1;i <= kNCTTMchannels;i++){
200 fPowerMask[i] = fPowerMask[i-1]*2;
204 fTOFTrigMask = new AliTOFTriggerMask();
205 fTOFTrigMask->SetTriggerMaskArray(tr.fTOFTrigMask->GetTriggerMaskArray());
208 SetName(tr.GetName());
209 //fInputs=&(tr.GetInputs());
213 #endif /*** COPY CONTRUCTOR SUPPRESSED ***/
215 //----------------------------------------------------------------------
217 void AliTOFTrigger::CreateInputs()
220 // Do not create inputs again!!
221 if( fInputs.GetEntriesFast() > 0 ) return;
225 fInputs.AddLast(new AliTriggerInput("TOF_Cosmic_MultiMuon_L0","TOF",0));
226 fInputs.AddLast(new AliTriggerInput("0OIN","TOF",0)); // was "TOF_pp_MB_L0"
227 fInputs.AddLast(new AliTriggerInput("0OM2","TOF",0)); // was "TOF_PbPb_MB2_L0"
228 fInputs.AddLast(new AliTriggerInput("0OM3","TOF",0)); // was "TOF_PbPb_MB3_L0"
229 fInputs.AddLast(new AliTriggerInput("0OUP","TOF",0)); // was "TOF_UltraPer_Coll_L0"
230 fInputs.AddLast(new AliTriggerInput("0OMU","TOF",0)); // new trigger (150 < DeltaPhi < 180) and 2 <= N_pad <= 6
232 fInputs.AddLast(new AliTriggerInput("0OHM","TOF",0)); // was "TOF_High_Mult_L0"
233 fInputs.AddLast(new AliTriggerInput("TOF_Jet_L1","TOF",0));
237 //----------------------------------------------------------------------
238 void AliTOFTrigger::Trigger() {
247 Int_t nchonFront = 0;
250 Int_t nSectOn = 0; // °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
251 Int_t DeSlots = -1;// °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
252 Int_t AntiDeSlots = -1;// °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
253 Int_t nchonFrontBack = 0;
254 Int_t nchonFront1 = 0;
255 Int_t nchonBack1 = 0;
256 Int_t nchonFrontBack1 = 0;
257 Int_t mindeltapsi = (Int_t)fdeltaminpsi/10;
258 Int_t maxdeltapsi = (Int_t)fdeltamaxpsi/10;
259 Int_t mindeltaro = (Int_t)fdeltaminro/10;
260 Int_t maxdeltaro = (Int_t)fdeltamaxro/10;
262 for (Int_t i=0;i<kNCTTM;i++){
263 for (Int_t j=0;j<kNCTTMchannels;j++){
264 if (fCTTMmatrixFront[i][j]) nchonFront++;
268 for (Int_t i=kNCTTM;i<(kNCTTM*2);i++){
269 for (Int_t j=0;j<kNCTTMchannels;j++){
270 if (fCTTMmatrixBack[i-kNCTTM][j]) nchonBack++;
274 nchonTot = nchonFront + nchonBack;
275 // fNMaxipadOn = nchonTot;
276 for(Int_t i=0;i<kNCTTM;i++) { if(fLTMarray[i]) nSectOn++; }
278 //pp Minimum Bias Trigger
279 if (nchonTot >= fppMBTh) {
282 //printf("0OIN - MB\n");
295 //High Multiplicity Trigger
296 if (nchonTot >= fHighMultTh) {
298 //printf("0OHM - High Mult\n");
307 Bool_t boolCTTMor = kFALSE;
309 for (Int_t i=0;i<(kNCTTM/2);i++){
310 Int_t iopp = i+kNCTTM/2;
311 for (Int_t j=0;j<kNCTTMchannels;j++){
312 if (fCTTMmatrixFront[i][j]){
313 Int_t minj = j-fstripWindow;
314 Int_t maxj = j+fstripWindow;
316 if (maxj>=kNCTTMchannels) maxj = kNCTTMchannels-1;
318 for (Int_t k = minj;k<=maxj;k++){
319 boolCTTMor |= fCTTMmatrixFront[iopp][k];
326 if (fCTTMmatrixBack[i][j]){
327 Int_t minj = j-fstripWindow;
328 Int_t maxj = j+fstripWindow;
330 if (maxj>=kNCTTMchannels) maxj =kNCTTMchannels-1;
332 for (Int_t k = minj;k<=maxj;k++){
333 boolCTTMor |= fCTTMmatrixBack[iopp][k];
342 nchonFrontBack = nchonFront+nchonBack;
349 for (Int_t i=0;i<(kNCTTM/2);i++){
350 Int_t i2max = (kNCTTM-1)-i+1;
351 Int_t i2min = (kNCTTM-1)-i-1;
352 if (i2max >=kNCTTM) i2max = kNCTTM-1;
353 if (i2min==i) i2min = kNCTTM-1-i;
354 for (Int_t j=0;j<kNCTTMchannels;j++){
355 Int_t j2min = j-fstripWindow;
356 Int_t j2max = j+fstripWindow;
357 if (j2min<0) j2min =0;
358 if (j2max>=kNCTTMchannels) j2max =kNCTTMchannels-1;
359 if (fCTTMmatrixFront[i][j]){
361 for (Int_t i2=i2min;i2<=i2max;i2++){
362 for (Int_t j2 = j2min;j2<=j2max;j2++){
363 boolCTTMor |= fCTTMmatrixFront[i2][j2];
370 if (fCTTMmatrixBack[i][j]){
372 for (Int_t i2=i2min;i2<=i2max;i2++){
373 for (Int_t j2 = j2min;j2<=j2max;j2++){
374 boolCTTMor |= fCTTMmatrixBack[i2][j2];
384 nchonFrontBack1 = nchonFront1+nchonBack1;
386 if (nchonFrontBack >= fMultiMuonTh || nchonFrontBack1 >= fMultiMuonTh) {
387 SetInput("TOF_Cosmic_MultiMuon_L0");
390 //Ultra-Peripheral collision Trigger
392 // °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
393 // DeSlots = (k+1)_Array Element - k_Array Element
394 // AntiDeSlots = kNCTTM - DeSlots
396 if((!fSel1))// && nchonFront < 4 && nchonBack < 4)
398 // printf("nHitMaxipad CLASSE: %i \n",fNMaxipadOn);
399 // printf("Total Number per event of Switched-On sectors : %i \n", nSectOn);
400 // printf("mindeltapsi %i \n", mindeltapsi);
401 //printf("maxdeltapsi %i \n", maxdeltapsi);
402 for(Int_t i = 0; i < kNCTTM; i++){
404 // printf(" i-sect On: %i\n",i);
405 for(Int_t j = i+1; j < kNCTTM; j++){
407 // printf(" j-sect On: %i\n",j);
409 AntiDeSlots = kNCTTM - DeSlots;
410 //printf("DeSlots = %i \n",DeSlots);
411 //printf("AntiDeSlots = %i \n",AntiDeSlots);
412 if(DeSlots >= mindeltapsi && DeSlots <= maxdeltapsi){
415 //printf("trigger On with DeSlot \n");
417 if(AntiDeSlots >= mindeltapsi && AntiDeSlots <= maxdeltapsi){
420 //printf("trigger On with AntiDeSlot \n");
424 if(DeSlots >= mindeltaro && DeSlots <= maxdeltaro){
427 //printf("trigger On with DeSlot \n");
429 if(AntiDeSlots >= mindeltaro && AntiDeSlots <= maxdeltaro){
432 //printf("trigger On with AntiDeSlot \n");
435 if(nchonTot >= 2 && nchonTot <= 6){
436 if(DeSlots >= 15 && DeSlots <= 18){
439 else if(AntiDeSlots >= 15 && AntiDeSlots <= 18){
450 //-----------------------------------------------------------------------------
451 void AliTOFTrigger::CreateLTMMatrix() {
454 CreateLTMMatrixFromDigits();
458 //-------------------------------------------------------------------------
460 void AliTOFTrigger::CreateLTMMatrixFromDigits() {
462 // Create LTM matrix by TOF digits
466 for (Int_t i=0;i<kNCTTM;i++) fLTMarray[i]= kFALSE;
467 for (Int_t i=0;i<kNLTM;i++){
468 for (Int_t j=0;j<kNLTMchannels;j++){
469 fLTMmatrix[i][j]=kFALSE;
472 for (Int_t i=0;i<kNCTTM;i++){
473 for (Int_t j=0;j<kNCTTMchannels;j++){
474 fCTTMmatrixFront[i][j]=kFALSE;
475 fCTTMmatrixBack[i][j]=kFALSE;
481 rl = AliRunLoader::Instance();
483 Int_t ncurrevent = rl->GetEventNumber();
484 rl->GetEvent(ncurrevent);
486 AliLoader * tofLoader = rl->GetLoader("TOFLoader");
488 tofLoader->LoadDigits("read");
489 TTree *treeD = tofLoader->TreeD();
491 AliFatal("AliTOFTrigger: Can not get TreeD");
495 TBranch *branch = treeD->GetBranch("TOF");
497 AliError("can't get the branch with the TOF digits !");
500 TClonesArray *tofDigits =new TClonesArray("AliTOFdigit", 1000);
501 branch->SetAddress(&tofDigits);
503 Int_t ndigits = tofDigits->GetEntriesFast();
504 Int_t detind[5]; //detector indexes: 0 -> sector
505 // 1 -> plate(modulo)
510 if(! fgTofGeo) fgTofGeo = new AliTOFGeometry();
513 for (Int_t i=0;i<ndigits;i++){
514 AliTOFdigit * digit = (AliTOFdigit*)tofDigits->UncheckedAt(i);
515 detind[0] = digit->GetSector();
516 detind[1] = digit->GetPlate();
517 detind[2] = digit->GetStrip();
518 detind[3] = digit->GetPadz();
519 detind[4] = digit->GetPadx();
521 Int_t indexLTM[2] = {-1,-1};
522 GetLTMIndex(detind,indexLTM);
524 //Float_t timedigit = digit->GetTdc()*AliTOFGeometry::TdcBinWidth()*1E-3; // decalibrated time digit in ns
525 Float_t timedigit = digit->GetTdcND()*AliTOFGeometry::TdcBinWidth()*1E-3; // time digit in ns
528 fgTofGeo->GetPosPar(detind, pos);
530 for (Int_t ic = 0; ic < 3; ic++) length += pos[ic] * pos[ic];
531 length = TMath::Sqrt(length);
532 timedigit -= length * 0.0333564095198152043; // subtract the minimal time in ns for the current channel
534 if(timedigit > fStartTimeHit - 0.5 && timedigit < fStartTimeHit + fTimeWidthTrigger - 0.5)
535 fLTMmatrix[indexLTM[0]][indexLTM[1]] = kTRUE;
537 // fLTMarray[indexLTM[0]%36] = kTRUE; //dimensione MAX array 36 = kNCTTM
541 tofLoader->UnloadDigits();
542 // rl->UnloadgAlice();
546 //-----------------------------------------------------------------------------
548 void AliTOFTrigger::CreateLTMMatrixFromRaw(AliRawReader *fRawReader) {
550 // Create LTM matrix by TOF raw data
554 for (Int_t i=0;i<kNLTM;i++){
555 for (Int_t j=0;j<kNLTMchannels;j++){
556 fLTMmatrix[i][j]=kFALSE;
559 for (Int_t i=0;i<kNCTTM;i++){
560 for (Int_t j=0;j<kNCTTMchannels;j++){
561 fCTTMmatrixFront[i][j]=kFALSE;
562 fCTTMmatrixBack[i][j]=kFALSE;
567 AliTOFRawStream * tofRawStream = new AliTOFRawStream();
571 //if(!GetLoader()->TreeS()) {MakeTree("S"); MakeBranch("S");}
574 tofRawStream->SetRawReader(fRawReader);
577 //if (fVerbose==2) ftxt.open("TOFsdigitsRead.txt",ios::app);
579 TClonesArray staticRawData("AliTOFrawData",10000);
580 staticRawData.Clear();
581 TClonesArray * clonesRawData = &staticRawData;
584 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
591 AliTOFrawData *tofRawDatum = 0;
592 for (indexDDL=0; indexDDL<AliDAQ::NumberOfDdls("TOF"); indexDDL++) {
595 tofRawStream->LoadRawDataBuffersV2(indexDDL);
597 clonesRawData = tofRawStream->GetRawData();
598 if (clonesRawData->GetEntriesFast()!=0) AliInfo(Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
599 for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
601 tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
603 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
604 if (tofRawDatum->GetTOF()==-1) continue;
606 SetBit(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
607 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel());
609 dummy = detectorIndex[3];
610 detectorIndex[3] = detectorIndex[4];//padz
611 detectorIndex[4] = dummy;//padx
613 digit[0] = tofRawDatum->GetTOF();
614 digit[1] = tofRawDatum->GetTOT();
616 dummy = detectorIndex[3];
617 detectorIndex[3] = detectorIndex[4];//padx
618 detectorIndex[4] = dummy;//padz
620 // Do not reconstruct anything in the holes
621 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
622 if (detectorIndex[1]==2) { // plate with holes
631 clonesRawData->Clear();
635 //if (fVerbose==2) ftxt.close();
637 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
645 //-----------------------------------------------------------------------------
646 void AliTOFTrigger::GetLTMIndex(const Int_t * const detind, Int_t *indexLTM) {
648 // getting LTMmatrix indexes for current digit
651 if (detind[1]==0 || detind[1]==1 || (detind[1]==2 && detind[2]<=7)) {
653 indexLTM[0] = detind[0]*2;
656 indexLTM[0] = detind[0]*2+1;
661 indexLTM[0] = detind[0]*2+36;
664 indexLTM[0] = (detind[0]*2+1)+36;
668 if (indexLTM[0]<36) {
670 indexLTM[1] = detind[2];
672 else if (detind[1] ==1){
673 indexLTM[1] = detind[2]+19;
675 else if (detind[1] ==2){
676 indexLTM[1] = detind[2]+19*2;
679 AliError("Smth Wrong!!!");
684 indexLTM[1] = detind[2]-8;
686 else if (detind[1] ==3){
687 indexLTM[1] = detind[2]+7;
689 else if (detind[1] ==4){
690 indexLTM[1] = detind[2]+26;
693 AliError("Smth Wrong!!!");
698 //-------------------------------------------------------------------------
700 // to be checked because of warning problems
701 void AliTOFTrigger::PrintMap()
707 for(Int_t i = 0; i<kNLTM;i++) {
709 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",
710 (fCTTMmatrixFront[i][0])?1:0,(fCTTMmatrixFront[i][1])?1:0,(fCTTMmatrixFront[i][2])?1:0, \
711 (fCTTMmatrixFront[i][3])?1:0,(fCTTMmatrixFront[i][4])?1:0,(fCTTMmatrixFront[i][5])?1:0, \
712 (fCTTMmatrixFront[i][6])?1:0,(fCTTMmatrixFront[i][7])?1:0,(fCTTMmatrixFront[i][8])?1:0, \
713 (fCTTMmatrixFront[i][9])?1:0,(fCTTMmatrixFront[i][10])?1:0,(fCTTMmatrixFront[i][11])?1:0, \
714 (fCTTMmatrixFront[i][12])?1:0,(fCTTMmatrixFront[i][13])?1:0,(fCTTMmatrixFront[i][14])?1:0, \
715 (fCTTMmatrixFront[i][15])?1:0,(fCTTMmatrixFront[i][16])?1:0,(fCTTMmatrixFront[i][17])?1:0, \
716 (fCTTMmatrixFront[i][18])?1:0,(fCTTMmatrixFront[i][19])?1:0,(fCTTMmatrixFront[i][20])?1:0, \
717 (fCTTMmatrixFront[i][21])?1:0,(fCTTMmatrixFront[i][22])?1:0,(fCTTMmatrixFront[i][23])?1:0);
719 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",
720 (fCTTMmatrixBack[i][0])?1:0,(fCTTMmatrixBack[i][1])?1:0,(fCTTMmatrixBack[i][2])?1:0, \
721 (fCTTMmatrixBack[i][3])?1:0,(fCTTMmatrixBack[i][4])?1:0,(fCTTMmatrixBack[i][5])?1:0, \
722 (fCTTMmatrixBack[i][6])?1:0,(fCTTMmatrixBack[i][7])?1:0,(fCTTMmatrixBack[i][8])?1:0, \
723 (fCTTMmatrixBack[i][9])?1:0,(fCTTMmatrixBack[i][10])?1:0,(fCTTMmatrixBack[i][11])?1:0, \
724 (fCTTMmatrixBack[i][12])?1:0,(fCTTMmatrixBack[i][13])?1:0,(fCTTMmatrixBack[i][14])?1:0, \
725 (fCTTMmatrixBack[i][15])?1:0,(fCTTMmatrixBack[i][16])?1:0,(fCTTMmatrixBack[i][17])?1:0, \
726 (fCTTMmatrixBack[i][18])?1:0,(fCTTMmatrixBack[i][19])?1:0,(fCTTMmatrixBack[i][20])?1:0, \
727 (fCTTMmatrixBack[i][21])?1:0,(fCTTMmatrixBack[i][22])?1:0,(fCTTMmatrixBack[i][23])?1:0);
733 //-------------------------------------------------------------------------
735 void AliTOFTrigger::GetMapMatrix(Bool_t map[][24]) const
741 for(Int_t i = 0; i<kNLTM;i++)
742 for(Int_t j = 0; j<kNCTTMchannels;j++)
743 map[i][j]=(i<36)?fCTTMmatrixFront[i][j]:fCTTMmatrixBack[i-36][j];
746 //-------------------------------------------------------------------------
748 void AliTOFTrigger::GetMap(Bool_t **map) const
754 for(Int_t i = 0; i<kNLTM;i++)
755 for(Int_t j = 0; j<kNCTTMchannels;j++)
756 map[i][j]=(i<36)?fCTTMmatrixFront[i][j]:fCTTMmatrixBack[i-36][j];
761 //-------------------------------------------------------------------------
762 void AliTOFTrigger::GetTRDmap(Bool_t **map) const
765 // Retriev the bit map sent to the TRD detector
768 for(int i = 0; i<kNLTM;i++)
769 for(int j = 0; j<kNLTMtoTRDchannels;j++){
773 for(int i = 0; i<kNLTM/2;i++)
774 for(int j = 0; j<AliTOFTrigger::kNCTTMchannels;j++){
776 if(fCTTMmatrixFront[i][j]) map[i][uTRDbit]=kTRUE;
778 for(int i = kNLTM/2; i<kNLTM;i++)
779 for(int j = 0; j<AliTOFTrigger::kNCTTMchannels;j++){
781 if(fCTTMmatrixBack[i-kNLTM/2][j]) map[i][uTRDbit]=kTRUE;
785 //-------------------------------------------------------------------------
786 void AliTOFTrigger::GetTRDmapMatrix(Bool_t map[][8]) const
789 // Retriev the bit map sent to the TRD detector
792 for(int i = 0; i<kNLTM;i++)
793 for(int j = 0; j<kNLTMtoTRDchannels;j++){
797 for(int i = 0; i<kNLTM/2;i++)
798 for(int j = 0; j<AliTOFTrigger::kNCTTMchannels;j++){
800 if(fCTTMmatrixFront[i][j]) map[i][uTRDbit]=kTRUE;
802 for(int i = kNLTM/2; i<kNLTM;i++)
803 for(int j = 0; j<AliTOFTrigger::kNCTTMchannels;j++){
805 if(fCTTMmatrixBack[i-kNLTM/2][j]) map[i][uTRDbit]=kTRUE;
810 //-------------------------------------------------------------------------
811 void AliTOFTrigger::SetBit(Int_t *detind)
814 // Sets CTTM map element corresponding to detector element 'detind'
818 GetCTTMIndex(detind,index);
820 fCTTMmatrixFront[index[0]][index[1]]=kTRUE;
822 fCTTMmatrixBack[index[0]-36][index[1]]=kTRUE;
826 //-------------------------------------------------------------------------
827 void AliTOFTrigger::SetBit(Int_t nDDL, Int_t nTRM, Int_t iChain,
828 Int_t iTDC, Int_t iCH)
831 // Sets CTTM map element corresponding to equipment ID
832 // labelled by number nDDL, nTRM, iChain, iTDC, iCH
835 if(nTRM==3 && iTDC>=12 && iTDC<=14 && nDDL%2==1){ // DDL number to LTM number mapping
838 Int_t iChannelIndex=-1;
839 switch(nDDL%AliTOFGeometry::NDDL()){
847 AliError("Call this function only if(nTRM==3 && iTDC>12 && iTDC<14 && nDDL%2==1) ");
850 iLTMindex+=2*(Int_t)(nDDL/AliTOFGeometry::NDDL());
851 if(iChain==0 && nDDL<36)
853 if(iChain==0 && nDDL>=36)
855 iChannelIndex=iCH+iTDC*AliTOFGeometry::NCh()-12*AliTOFGeometry::NCh();
856 Int_t index[2]={iLTMindex,iChannelIndex};
858 fCTTMmatrixFront[index[0]][index[1]]=kTRUE;
859 fLTMmatrix[index[0]][index[1]*2]=kTRUE;
862 fCTTMmatrixBack[index[0]-36][index[1]]=kTRUE;
863 fLTMmatrix[index[0]][index[1]*2]=kTRUE;
868 //-------------------------------------------------------------------------
870 void AliTOFTrigger::ResetBit(Int_t *detind)
873 // Sets CTTM map element corresponding to detector element 'detind'
877 GetCTTMIndex(detind,index);
879 fCTTMmatrixFront[index[0]][index[1]]=kFALSE;
881 fCTTMmatrixBack[index[0]-36][index[1]]=kFALSE;
885 //-------------------------------------------------------------------------
886 void AliTOFTrigger::ResetBit(Int_t nDDL, Int_t nTRM, Int_t iChain,
887 Int_t iTDC, Int_t iCH)
890 // Sets CTTM map element corresponding to equipment ID
891 // labelled by number nDDL, nTRM, iChain, iTDC, iCH
894 if(nTRM==3 && iTDC>12 && iTDC<14 && nDDL%2==1){ // DDL number to LTM number mapping
896 Int_t iChannelIndex=-1;
897 switch(nDDL%AliTOFGeometry::NDDL()){
905 AliError("Call this function only if(nTRM==3 && iTDC>12 && iTDC<14 && nDDL%2==1) ");
908 iLTMindex+=2*(Int_t)(nDDL/AliTOFGeometry::NDDL());
909 if(iChain==0 && nDDL<36)
911 if(iChain==0 && nDDL>=36)
913 iChannelIndex=iCH+iTDC*AliTOFGeometry::NCh()-12*AliTOFGeometry::NCh();
914 Int_t index[2]={iLTMindex,iChannelIndex};
916 fCTTMmatrixFront[index[0]][index[1]]=kFALSE;
919 fCTTMmatrixBack[index[0]-36][index[1]]=kFALSE;
923 AliError("Call this function only if(nTRM==3 && iTDC>12 && iTDC<14 && nDDL%2==1) ");
926 //-------------------------------------------------------------------------
928 Bool_t AliTOFTrigger::GetBit(Int_t *detind)
931 // Returns CTTM map element corresponding to detector element 'detind'
935 GetCTTMIndex(detind,index);
936 return (index[0]<36)?fCTTMmatrixFront[index[0]][index[1]]:fCTTMmatrixBack[index[0]-36][index[1]];
940 //-------------------------------------------------------------------------
941 Bool_t AliTOFTrigger::GetBit(Int_t nDDL, Int_t nTRM, Int_t iChain,
942 Int_t iTDC, Int_t iCH)
945 // Returns CTTM map element corresponding to equipment ID
946 // labelled by number nDDL, nTRM, iChain, iTDC, iCH
949 if ( !(nTRM==3 && iTDC>12 && iTDC<14 && nDDL%2==1) ) {
950 AliWarning("Call this function only if(nTRM==3 && iTDC>12 && iTDC<14) ");
953 //if (nTRM==3 && iTDC>12 && iTDC<14 && nDDL%2==1) { // DDL number to LTM number mapping
956 UInt_t iChannelindex=0;
957 switch(nDDL%AliTOFGeometry::NDDL()) {
965 AliError("something wrong");
968 iLTMindex+=2*(Int_t)(nDDL/AliTOFGeometry::NDDL());
970 if (iChain==1) return kFALSE; // AdC
976 iChannelindex=iCH+iTDC*AliTOFGeometry::NCh()-12*AliTOFGeometry::NCh();
977 Int_t index[2]={iLTMindex,iChannelindex};
978 return (index[0]<36)?fCTTMmatrixFront[index[0]][index[1]]:fCTTMmatrixBack[index[0]-36][index[1]];
982 //-------------------------------------------------------------------------
984 void AliTOFTrigger::CreateCTTMMatrix() {
986 // Create CTTM bit map
991 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,
992 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};
998 for(Int_t i = 0; i<kNLTM;i++){
999 UInt_t currentMask = fPowerMask[kNCTTMchannels]-1;
1000 if(fTOFTrigMask) currentMask=fTOFTrigMask->GetTriggerMask(fromTriggertoDCS[i]);
1002 for(Int_t j = 0; j<kNCTTMchannels;j++){
1003 fCTTMmatrixFront[i][j]=fLTMmatrix[i][2*j]||fLTMmatrix[i][2*j+1];
1004 if(fCTTMmatrixFront[i][j]) fNMaxipadOnAll++;
1005 if(!(currentMask & fPowerMask[j])) fCTTMmatrixFront[i][j]=0;
1006 if(fCTTMmatrixFront[i][j]){
1008 fLTMarray[i] = kTRUE;
1013 for(Int_t j = 0; j<kNCTTMchannels;j++){
1014 fCTTMmatrixBack[i-kNCTTM][j]=fLTMmatrix[i][2*j]||fLTMmatrix[i][2*j+1];;
1015 if(fCTTMmatrixBack[i-kNCTTM][j]) fNMaxipadOnAll++;
1016 if(!(currentMask & fPowerMask[j])) fCTTMmatrixBack[i-kNCTTM][j]=0;
1017 if(fCTTMmatrixBack[i-kNCTTM][j]){
1019 fLTMarray[i-kNCTTM] = kTRUE;
1026 for(Int_t j=0; j < kNCTTM; j++) {if(fLTMarray[j]) fNCrateOn++;}
1029 //-----------------------------------------------------------------------------
1031 void AliTOFTrigger::GetCTTMIndex(Int_t *detind, Int_t *indexCTTM) {
1033 // Returns CTTM index corresponding to the detector element detind
1036 GetLTMIndex(detind,indexCTTM);
1040 //-----------------------------------------------------------------------------
1041 void AliTOFTrigger::LoadActiveMask(){
1043 // Load OCDB current mask
1046 AliCDBManager *cdb = AliCDBManager::Instance();
1047 if(cdb->GetRun() < 0 || !(cdb->GetDefaultStorage())){
1048 if(!(cdb->GetDefaultStorage())){
1049 cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
1050 printf("AliTOFTrigger (WARNING): probably CDB first instance - Default Sorage set to \"local://$ALICE_ROOT/OCDB\"\n");
1052 if(cdb->GetRun() < 0){
1054 printf("AliTOFTrigger (WARNING): probably CDB first instance - number of run set to 0\n");
1058 AliCDBEntry *cdbe = cdb->Get("TRIGGER/TOF/TriggerMask");
1060 fTOFTrigMask= (AliTOFTriggerMask *)cdbe->GetObject();
1062 // UInt_t maskArray[kNLTM];
1063 // if(fTOFTrigMask == NULL) fTOFTrigMask = new AliTOFTriggerMask();
1064 // for (Int_t k = 0; k < kNLTM ; k++) maskArray[k] = fPowerMask[kNCTTMchannels]-1;
1065 // //for (Int_t k = 0; k < kNLTM ; k+=2) maskArray[k] = 0;
1067 // fTOFTrigMask->SetTriggerMaskArray(maskArray);
1071 //-----------------------------------------------------------------------------
1072 AliTOFTrigger::~AliTOFTrigger()
1078 //-----------------------------------------------------------------------------
1079 AliTOFTrigger& AliTOFTrigger::operator=(const AliTOFTrigger &/*source*/)