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). The algorithm searches all
22 // possible 4x4 crystal combinations and per each TRU, adding the digits
23 // amplitude and finding the maximum. Maximums are compared to triggers
24 // threshold and they are set.
26 //*-- Author: Gustavo Conesa & Yves Schutz (IFIC, CERN)
27 //////////////////////////////////////////////////////////////////////////////
30 // --- ROOT system ---
33 // --- ALIROOT system ---
34 #include "AliPHOSTrigger.h"
35 #include "AliPHOSGeometry.h"
36 #include "AliPHOSGetter.h"
37 #include "AliTriggerInput.h"
40 ClassImp(AliPHOSTrigger)
42 //______________________________________________________________________
43 AliPHOSTrigger::AliPHOSTrigger()
44 : AliTriggerDetector(), fNTRU(8), fNTRUZ(2), fNTRUPhi(4), fL0Threshold(50),
45 fL1LowThreshold(1200), fL1MediumThreshold(12000), fL1HighThreshold(30000)
57 //____________________________________________________________________________
58 AliPHOSTrigger::AliPHOSTrigger(const AliPHOSTrigger & trig)
59 : AliTriggerDetector(trig)
64 fNTRUZ = trig.fNTRUZ ;
65 fNTRUPhi = trig.fNTRUPhi ;
66 fL0Threshold = trig.fL0Threshold ;
67 fL1LowThreshold = trig.fL1LowThreshold ;
68 fL1MediumThreshold = trig.fL1MediumThreshold ;
69 fL1HighThreshold = trig.fL1HighThreshold ;
73 //----------------------------------------------------------------------
74 void AliPHOSTrigger::CreateInputs()
78 // Do not create inputs again!!
79 if( fInputs.GetEntriesFast() > 0 ) return;
81 fInputs.AddLast( new AliTriggerInput( "PHOS_MB_L0", "PHOS Minimum Bias L0", 0x01 ) );
83 fInputs.AddLast( new AliTriggerInput( "PHOS_HPt_L1", "PHOS High Pt L1", 0x02 ) );
84 fInputs.AddLast( new AliTriggerInput( "PHOS_MPt_L1", "PHOS Medium Pt L1", 0x04 ) );
85 fInputs.AddLast( new AliTriggerInput( "PHOS_LPt_L1", "PHOS Low Pt L1", 0x08 ) );
89 //____________________________________________________________________________
90 TClonesArray * AliPHOSTrigger::FillTRU(const TClonesArray * digits,
91 const AliPHOSGeometry * geom,
93 const Int_t nCrystalsPhi,
94 const Int_t nCrystalsZ) const {
96 //Orders digits ampitudes list in 8 TRUs (16x28 crystals) per module.
97 //Each TRU is a TMatrixD, and they are kept in TClonesArrays.
101 //const AliPHOSGeometry * geom = AliPHOSGetter::Instance()->PHOSGeometry() ;
103 TClonesArray * matrix = new TClonesArray("TMatrixD",1000);
104 for(Int_t k = 0; k < fNTRU*nModules ; k++){
105 TMatrixD * trus = new TMatrixD(nCrystalsPhi,nCrystalsZ) ;
106 for(Int_t i = 0; i < nCrystalsPhi; i++)
107 for(Int_t j = 0; j < nCrystalsZ; j++)
109 new((*matrix)[k]) TMatrixD(*trus) ;
118 for(Int_t idig = 0 ; idig < digits->GetEntriesFast() ; idig++){
120 dig = static_cast<AliPHOSDigit *>(digits->At(idig)) ;
121 amp = dig->GetAmp() ; //Energy of the digit (arbitrary units)
122 geom->AbsToRelNumbering(dig->GetId(), relid) ;//Transform digit number into 4 numbers
124 //relid[1] = EMC (0) or CPV (-1)
125 //relid[2] = row <= 64 (fNPhi)
126 //relid[3] = column <= 56 (fNZ)
133 //Check which TRU in the module. It is divided in a (4,2) matrix.
134 //Fill the TRU matrix (16,28)
137 for(i = 1; i < fNTRUZ ; i++)
138 if(relid[3] > nCrystalsZ*i && relid[3] <= nCrystalsZ*(i+1))
141 for(i = 1; i < fNTRUPhi ; i++)
142 if(relid[2] > nCrystalsPhi*i && relid[2] <= nCrystalsPhi*(i+1))
145 ntru = col*row + (relid[0]-1)*fNTRU - 1;
146 TMatrixD * trus = dynamic_cast<TMatrixD *>(matrix->At(ntru)) ;
148 Int_t nrow = (relid[2]-1) - (row-1) * nCrystalsPhi;
149 Int_t ncol = (relid[3]-1) - (col-1) * nCrystalsZ;
151 (*trus)(nrow,ncol) = amp ;
157 //____________________________________________________________________________
158 void AliPHOSTrigger::MakeSlidingCell(const TClonesArray * trus,
160 const Int_t nCrystalsPhi,
161 const Int_t nCrystalsZ,
164 //Sums energy of all possible 4x4 crystals per each TRU. Fast signal
165 //in the experiment is given by 2x2 crystals, for this reason we loop
166 //inside the TRU crystals by 2.
170 for(Int_t i = 0 ; i < fNTRU ; i++)
173 //Loop over all TRUS in a module
174 for(Int_t itru = 0 + (mod - 1) * fNTRU ; itru < mod*fNTRU ; itru++){
175 TMatrixD * tru = dynamic_cast<TMatrixD *>(trus->At(itru)) ;
177 //ampmax[itru-(mod-1)*8]=0.0;
178 for(Int_t irow = 0 ; irow < nCrystalsPhi; irow += 2){
179 for(Int_t icol = 0 ; icol < nCrystalsZ ; icol += 2){
181 if( (irow+3) < nCrystalsPhi && (icol+3) < nCrystalsZ){//Avoid exit the TRU
182 for(Int_t i = irow; i < irow + 4 ; i++){
183 for(Int_t j = icol; j < icol + 4 ; j++){
188 if(amp > ampmax[itru-(mod-1)*fNTRU])
189 ampmax[itru-(mod-1)*fNTRU] = amp ;
195 //____________________________________________________________________________
196 void AliPHOSTrigger::Trigger()
199 //Main Method to select triggers.
201 AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
203 //Define some useful parameters
204 const AliPHOSGeometry * geom = AliPHOSGetter::Instance()->PHOSGeometry() ;
205 Int_t nModules = geom->GetNModules();
206 Int_t nCrystalsPhi = geom->GetNPhi()/fNTRUPhi ;// 64/4=16
207 Int_t nCrystalsZ = geom->GetNZ()/fNTRUZ ;// 56/2=28
209 //Take the digits list and declare digits pointers
210 TClonesArray * digits = gime->Digits() ;
213 TClonesArray * trus = FillTRU(digits,geom, nModules, nCrystalsPhi,
216 //Do Cell Sliding and select Trigger
218 for(Int_t imod = 1 ; imod <= nModules ; imod++) {
219 MakeSlidingCell(trus, imod, nCrystalsPhi, nCrystalsZ, max);
220 // cout<<" Max Amplitude: mod " << imod <<" TRU0 " << max[0]
221 // <<" TRU1 " << max[1] <<" TRU2 " << max[2] <<" TRU3 " << max[3]
222 // <<" TRU4 " << max[4] <<" TRU5 " << max[5] <<" TRU6 " << max[6]
223 // <<" TRU7 " << max[7] <<endl;
230 //____________________________________________________________________________
231 void AliPHOSTrigger::Print(const Option_t * opt) const
234 //Prints main parameters
238 AliTriggerInput* in = 0x0 ;
240 AliInfo("PHOS trigger information:") ;
241 printf( " Threshold for LO %d\n", fL0Threshold) ;
242 in = (AliTriggerInput*)fInputs.FindObject( "PHOS_MB_L0" );
244 printf( " PHOS MB LO is set\n") ;
246 printf( " Low Threshold for L1 %d\n", fL1LowThreshold) ;
247 in = (AliTriggerInput*)fInputs.FindObject( "PHOS_LPt_L1" );
249 printf( " PHOS Low Pt L1 is set\n") ;
251 printf( " Medium Threshold for L1 %d\n", fL1MediumThreshold) ;
252 in = (AliTriggerInput*) fInputs.FindObject( "PHOS_MPt_L1" );
254 printf( " PHOS Medium Pt L1 is set\n") ;
256 printf( " High Threshold for L1 %d\n", fL1HighThreshold) ;
257 in = (AliTriggerInput*) fInputs.FindObject( "PHOS_HPt_L1" );
259 printf( " PHOS High Pt L1 is set\n") ;
261 if(strstr(opt,"all")){
262 printf( " Number of TRUs %d\n", fNTRU) ;
263 printf( " Number of crystals in Z in TRUs %d\n",
265 printf( " Number of crystals in Phi in TRUs %d\n",
270 //____________________________________________________________________________
271 void AliPHOSTrigger::SetTriggers(const Float_t * amp)
274 //Checks the maximum amplitude per each TRU and compares with the
275 //different triggers thresholds
278 for(Int_t i = 0 ; i < 8 ; i++){
283 if(max >= fL0Threshold){
284 SetInput("PHOS_MB_L0");
285 if(max >= fL1LowThreshold){
286 SetInput("PHOS_LPt_L1");
287 if(max >= fL1MediumThreshold){
288 SetInput("PHOS_MPt_L1");
289 if(max >= fL1HighThreshold){
290 SetInput("PHOS_HPt_L1");