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 for trigger analysis.
21 // Digits are grouped in TRU's (16x28 crystals ordered fNTRUPhi x fNTRUZ).
22 // The algorithm searches all possible 4x4 cell combinations per each TRU,
23 // adding the digits amplitude and finding the maximum. Maximums are compared
24 // to triggers threshold and they are set. Thresholds need to be fixed.
27 // //Inside the event loop
28 // AliEMCALTrigger *tr = new AliEMCALTrigger();//Init Trigger
29 // tr->SetL0MBPbPbThreshold(500);
30 // tr->SetL0MBppThreshold(100);
31 // tr->SetL1JetLowPtThreshold(1000);
32 // tr->SetL1JetMediumPtThreshold(10000);
33 // tr->SetL1JetHighPtThreshold(20000);
34 // tr->Trigger(); //Execute Trigger
35 // tr->Print(""); //Print result, with "deb" option all data members
38 //*-- Author: Gustavo Conesa & Yves Schutz (IFIC, CERN)
39 //////////////////////////////////////////////////////////////////////////////
42 // --- ROOT system ---
45 // --- ALIROOT system ---
46 #include "AliPHOSTrigger.h"
47 #include "AliPHOSGeometry.h"
48 #include "AliPHOSGetter.h"
49 #include "AliTriggerInput.h"
52 ClassImp(AliPHOSTrigger)
54 //______________________________________________________________________
55 AliPHOSTrigger::AliPHOSTrigger()
56 : AliTriggerDetector(), fNTRU(8), fNTRUZ(2), fNTRUPhi(4),
57 fL0MBPbPbThreshold(500), fL0MBppThreshold(50),
58 fL1JetLowPtThreshold(1200), fL1JetHighPtThreshold(30000)
70 //____________________________________________________________________________
71 AliPHOSTrigger::AliPHOSTrigger(const AliPHOSTrigger & trig)
72 : AliTriggerDetector(trig)
77 fNTRUZ = trig.fNTRUZ ;
78 fNTRUPhi = trig.fNTRUPhi ;
79 fL0MBPbPbThreshold = trig.fL0MBPbPbThreshold ;
80 fL0MBppThreshold = trig.fL0MBppThreshold ;
81 fL1JetLowPtThreshold = trig.fL1JetLowPtThreshold ;
82 fL1JetHighPtThreshold = trig.fL1JetHighPtThreshold ;
86 //----------------------------------------------------------------------
87 void AliPHOSTrigger::CreateInputs()
91 // Do not create inputs again!!
92 if( fInputs.GetEntriesFast() > 0 ) return;
94 fInputs.AddLast( new AliTriggerInput( "PHOS_MB_PbPb_L0", "PHOS PbPb Minimum Bias L0", 0x01 ) );
95 fInputs.AddLast( new AliTriggerInput( "PHOS_MB_pp_L0", "PHOS pp Minimum Bias L0", 0x02 ) );
96 fInputs.AddLast( new AliTriggerInput( "PHOS_PbPb_JetHPt_L1", "PHOS PbPb Jet High Pt L1", 0x04 ) );
97 fInputs.AddLast( new AliTriggerInput( "PHOS_PbPb_JetLPt_L1", "PHOS PbPb Jet Low Pt L1", 0x08 ) );
101 //____________________________________________________________________________
102 TClonesArray * AliPHOSTrigger::FillTRU(const TClonesArray * digits,
103 const AliPHOSGeometry * geom,
104 const Int_t nModules,
105 const Int_t nCrystalsPhi,
106 const Int_t nCrystalsZ) const {
108 //Orders digits ampitudes list in fNTRU TRUs (28x16 crystals) per module.
109 //Each TRU is a TMatrixD, and they are kept in TClonesArrays. The number of
110 //TRU in phi is fNTRUPhi, and the number of TRU in eta is fNTRUZ.
114 if(fNTRUZ*fNTRUPhi != fNTRU)
115 Error("FillTRU"," Wrong number of TRUS per Z or Phi");
117 //Initilize variables
118 //List of TRU matrices initialized to 0.
120 TClonesArray * matrix = new TClonesArray("TMatrixD",1000);
121 for(Int_t k = 0; k < fNTRU*nModules ; k++){
122 TMatrixD * trus = new TMatrixD(nCrystalsPhi,nCrystalsZ) ;
123 for(Int_t i = 0; i < nCrystalsPhi; i++)
124 for(Int_t j = 0; j < nCrystalsZ; j++)
126 new((*matrix)[k]) TMatrixD(*trus) ;
135 //Digits loop to fill TRU matrices with amplitudes.
137 for(Int_t idig = 0 ; idig < digits->GetEntriesFast() ; idig++){
139 dig = static_cast<AliPHOSDigit *>(digits->At(idig)) ;
140 amp = dig->GetAmp() ; //Energy of the digit (arbitrary units)
141 geom->AbsToRelNumbering(dig->GetId(), relid) ;
142 //Transform digit number into 4 numbers
144 //relid[1] = EMC (0) or CPV (-1)
145 //relid[2] = row <= 64 (fNPhi)
146 //relid[3] = column <= 56 (fNZ)
148 if(relid[1] == 0){//Not CPV, Only EMC digits
150 //Check to which TRU in the supermodule belongs the cell.
151 //Supermodules are divided in a TRU matrix of dimension
153 //Each TRU is a cell matrix of dimension (nCrystalsPhi,nCrystalsZ)
155 //First calculate the row and column in the supermodule
156 //of the TRU to which the cell belongs.
158 Int_t col = (relid[3]-1)/nCrystalsZ+1;
159 Int_t row = (relid[2]-1)/nCrystalsPhi+1;
160 Int_t itru = col*row + (relid[0]-1)*fNTRU - 1;
162 //Fill TRU matrix with cell values
164 TMatrixD * trus = dynamic_cast<TMatrixD *>(matrix->At(itru)) ;
166 //Calculate row and column of the cell inside the TRU with number itru
168 Int_t nrow = (relid[2]-1) - (row-1) * nCrystalsPhi;
169 Int_t ncol = (relid[3]-1) - (col-1) * nCrystalsZ;
171 (*trus)(nrow,ncol) = amp ;
177 //____________________________________________________________________________
178 void AliPHOSTrigger::MakeSlidingCell(const TClonesArray * trus,
180 const Int_t nCrystalsPhi,
181 const Int_t nCrystalsZ,
184 //Sums energy of all possible 4x4 crystals per each TRU. Fast signal
185 //in the experiment is given by 2x2 crystals, for this reason we loop
186 //inside the TRU crystals by 2.
190 for(Int_t i = 0 ; i < fNTRU ; i++)
193 //Loop over all TRUS in a module
194 for(Int_t itru = 0 + (mod - 1) * fNTRU ; itru < mod*fNTRU ; itru++){
195 TMatrixD * tru = dynamic_cast<TMatrixD *>(trus->At(itru)) ;
197 //ampmax[itru-(mod-1)*8]=0.0;
198 for(Int_t irow = 0 ; irow < nCrystalsPhi; irow += 2){
199 for(Int_t icol = 0 ; icol < nCrystalsZ ; icol += 2){
201 if( (irow+3) < nCrystalsPhi && (icol+3) < nCrystalsZ){//Avoid exit the TRU
202 for(Int_t i = irow; i < irow + 4 ; i++){
203 for(Int_t j = icol; j < icol + 4 ; j++){
208 if(amp > ampmax[itru-(mod-1)*fNTRU])
209 ampmax[itru-(mod-1)*fNTRU] = amp ;
215 //____________________________________________________________________________
216 void AliPHOSTrigger::Trigger()
219 //Main Method to select triggers.
221 AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
224 const AliPHOSGeometry * geom = AliPHOSGetter::Instance()->PHOSGeometry() ;
226 //Define some useful parameters
227 Int_t nModules = geom->GetNModules();
228 Int_t nCrystalsPhi = geom->GetNPhi()/fNTRUPhi ;// 64/4=16
229 Int_t nCrystalsZ = geom->GetNZ()/fNTRUZ ;// 56/2=28
231 //Take the digits list and declare digits pointers
232 TClonesArray * digits = gime->Digits() ;
235 TClonesArray * trus = FillTRU(digits,geom, nModules, nCrystalsPhi,
238 //Do Cell Sliding and select Trigger
240 for(Int_t imod = 1 ; imod <= nModules ; imod++) {
241 MakeSlidingCell(trus, imod, nCrystalsPhi, nCrystalsZ, max);
242 // cout<<" Max Amplitude: mod " << imod <<" TRU0 " << max[0]
243 // <<" TRU1 " << max[1] <<" TRU2 " << max[2] <<" TRU3 " << max[3]
244 // <<" TRU4 " << max[4] <<" TRU5 " << max[5] <<" TRU6 " << max[6]
245 // <<" TRU7 " << max[7] <<endl;
252 //____________________________________________________________________________
253 void AliPHOSTrigger::Print(const Option_t * opt) const
256 //Prints main parameters
260 AliTriggerInput* in = 0x0 ;
262 AliInfo("PHOS trigger information:") ;
263 printf( " Threshold for pp MB LO %d\n", fL0MBppThreshold) ;
264 in = (AliTriggerInput*)fInputs.FindObject( "PHOS_MB_pp_L0" );
266 printf( " *** PHOS MB pp LO is set ***\n") ;
268 printf( " Threshold for PbPb MB LO %d\n", fL0MBPbPbThreshold) ;
269 in = (AliTriggerInput*)fInputs.FindObject( "PHOS_MB_PbPb_L0" );
271 printf( " *** PHOS MB PbPb LO is set ***\n") ;
273 printf( " Jet Low Pt Threshold for PbPb L1 %d\n", fL1JetLowPtThreshold) ;
274 in = (AliTriggerInput*)fInputs.FindObject( "PHOS_PbPb_JetLPt_L1" );
276 printf( " *** PHOS Jet Low Pt for PbPb L1 is set ***\n") ;
278 printf( " Jet High Pt Threshold for L1 %d\n", fL1JetHighPtThreshold) ;
279 in = (AliTriggerInput*) fInputs.FindObject( "PHOS_PbPb_JetHPt_L1" );
281 printf( " *** PHOS Jet High Pt for PbPb L1 is set ***\n") ;
283 if(strstr(opt,"all")){
284 printf( " Number of TRUs %d\n", fNTRU) ;
285 printf( " Number of crystals in Z in TRUs %d\n",
287 printf( " Number of crystals in Phi in TRUs %d\n",
292 //____________________________________________________________________________
293 void AliPHOSTrigger::SetTriggers(const Float_t * amp)
296 //Checks the maximum amplitude per each TRU and compares with the
297 //different triggers thresholds
300 for(Int_t i = 0 ; i < 8 ; i++){
305 if(max >= fL0MBppThreshold)
306 SetInput("PHOS_MB_pp_L0");
307 if(max >= fL0MBPbPbThreshold)
308 SetInput("PHOS_MB_PbPb_L0");
309 if(max >= fL1JetLowPtThreshold)
310 SetInput("PHOS_PbPb_JetLPt_L1");
311 if(max >= fL1JetHighPtThreshold)
312 SetInput("PHOS_PbPb_JetHPt_L1");