]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALTrigger.cxx
Trigger method FillTRU (for PHOS it is in AliPHOSTrigger) modified and
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALTrigger.cxx
CommitLineData
f0377b23 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15/* $Id$ */
16
17
18//_________________________________________________________________________
19//
20// Class for trigger analysis.
21// Digits are grouped in TRU's (384 cells? ordered fNTRUPhi x fNTRUEta).
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.
25// Last 2 modules are half size but they are treated as fullsize, then their
26// TRU should be smaller. When this is fixed, class will be updated.
27// Usage:
28//
29// //Inside the event loop
30// AliEMCALTrigger *tr = new AliEMCALTrigger();//Init Trigger
31// tr->SetL0MBPbPbThreshold(500);
32// tr->SetL0MBppThreshold(100);
33// tr->SetL1JetLowPtThreshold(1000);
34// tr->SetL1JetMediumPtThreshold(10000);
35// tr->SetL1JetHighPtThreshold(20000);
36// tr->Trigger(); //Execute Trigger
37// tr->Print(""); //Print results
38//
39//*-- Author: Gustavo Conesa & Yves Schutz (IFIC, CERN)
40//////////////////////////////////////////////////////////////////////////////
41
42
43// --- ROOT system ---
44#include "TMatrixD.h"
45
46// --- ALIROOT system ---
47
48#include "AliRun.h"
49#include "AliRunLoader.h"
50#include "AliTriggerInput.h"
51#include "AliEMCAL.h"
52#include "AliEMCALLoader.h"
53#include "AliEMCALDigit.h"
54#include "AliEMCALTrigger.h"
55#include "AliEMCALGeometry.h"
56
57ClassImp(AliEMCALTrigger)
58
59//______________________________________________________________________
60AliEMCALTrigger::AliEMCALTrigger()
61 : AliTriggerDetector(),
62 fL0MBPbPbThreshold(500), fL0MBppThreshold(50),fL1JetLowPtThreshold(1000),
63 fL1JetMediumPtThreshold(10000), fL1JetHighPtThreshold(20000)
64{
65 //ctor
66
67 SetName("EMCAL");
68 CreateInputs();
69
70 //Print("all") ;
71}
72
73
74
75//____________________________________________________________________________
76AliEMCALTrigger::AliEMCALTrigger(const AliEMCALTrigger & trig)
77 : AliTriggerDetector(trig)
78{
79
80 // cpy ctor
81
82 fL0MBPbPbThreshold = trig.fL0MBPbPbThreshold ;
83 fL0MBppThreshold = trig.fL0MBppThreshold ;
84 fL1JetLowPtThreshold = trig.fL1JetLowPtThreshold ;
85 fL1JetMediumPtThreshold = trig.fL1JetMediumPtThreshold ;
86 fL1JetHighPtThreshold = trig.fL1JetHighPtThreshold ;
87
88}
89
90//----------------------------------------------------------------------
91void AliEMCALTrigger::CreateInputs()
92{
93 // inputs
94
95 // Do not create inputs again!!
96 if( fInputs.GetEntriesFast() > 0 ) return;
97
98 fInputs.AddLast( new AliTriggerInput( "EMCAL_MB_PbPb_L0", "EMCAL PbPb Minimum Bias L0", 0x01 ) );
99 fInputs.AddLast( new AliTriggerInput( "EMCAL_MB_pp_L0", "EMCAL pp Minimum Bias L0", 0x02 ) );
100 fInputs.AddLast( new AliTriggerInput( "EMCAL_PbPb_JetHPt_L1", "EMCAL PbPb Jet High Pt L1", 0x04 ) );
101 fInputs.AddLast( new AliTriggerInput( "EMCAL_PbPb_JetMPt_L1", "EMCAL PbPb Jet Medium Pt L1", 0x08 ) );
102 fInputs.AddLast( new AliTriggerInput( "EMCAL_PbPb_JetLPt_L1", "EMCAL PbPb Jet Low Pt L1", 0x016 ) );
103
104}
105
106//____________________________________________________________________________
107void AliEMCALTrigger::MakeSlidingCell(const TClonesArray * trus ,
108 const Int_t isupermod,
109 const Int_t nTRU,
110 const Int_t nCellsPhi,
111 const Int_t nCellsEta,
112 Float_t *ampmax){
113
114 //Sums energy of all possible 4x4 cells per each TRU. Fast signal
115 //in the experiment is given by 2x2 cells, for this reason we loop
116 //inside the TRU cells by 2.
117
118 Float_t amp = 0 ;
119
120 for(Int_t i = 0 ; i < nTRU ; i++)
121 ampmax[i] = 0 ;
122
123 //Loop over all TRUS in the seleted supermodule
124 for(Int_t itru = 0 + (isupermod - 1) * nTRU ; itru < isupermod*nTRU ; itru++)
125 {
126 TMatrixD * tru = dynamic_cast<TMatrixD *>(trus->At(itru)) ;
127
128 //Sliding 2x2 cell
129 for(Int_t irow = 0 ; irow < nCellsPhi; irow += 2){
130 for(Int_t icol = 0 ; icol < nCellsEta ; icol += 2){
131 amp = 0;
132 if( (irow+3) < nCellsPhi && (icol+3) < nCellsEta){//Avoid exit the TRU
133 for(Int_t i = irow; i < irow + 4 ; i++){
134 for(Int_t j = icol; j < icol + 4 ; j++){
135 amp += (*tru)(i,j) ;
136 }
137 }
138 }
139 if(amp > ampmax[itru-(isupermod-1)*nTRU])
140 ampmax[itru-(isupermod-1)*nTRU] = amp ;
141
142 }
143 }
144 }
145}
146
147//____________________________________________________________________________
148void AliEMCALTrigger::Trigger()
149{
150
151 //Main Method to select triggers.
152 //Loader
153 AliRunLoader *rl = AliRunLoader::GetRunLoader();
154 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>
155 (rl->GetDetectorLoader("EMCAL"));
156
157 //Load EMCAL Geometry
158 rl->LoadgAlice();
159 AliRun * gAlice = rl->GetAliRun();
160 AliEMCAL * emcal = (AliEMCAL*)gAlice->GetDetector("EMCAL");
161 AliEMCALGeometry * geom = emcal->GetGeometry();
162 //AliEMCALGeometry * geom = AliEMCALGeometry::GetInstance();
163
164 if (geom==0)
165 AliFatal("Did not get geometry from EMCALLoader");
166
167 //Define some useful parameters
168
169 Int_t nSuperModules = geom->GetNumberOfSuperModules() ; //12 SM in EMCAL
170 Int_t nTRU = geom->GetNTRU();//3 TRU per super module
171 Int_t nCellsPhi = geom->GetNPhi()*2/geom->GetNTRUPhi() ;
172 // 12(tow)*2(cell)/1 TRU, cells in Phi in one TRU
173 Int_t nCellsEta = geom->GetNEta()*2/geom->GetNTRUEta() ;
174 // 24(mod)*2(tower)/3 TRU, cells in Eta in one TRU
175
176 //Info("Trigger","nSuperModules %d, nCellsPhi %d, nCellsEta %d",
177 // nSuperModules, nCellsPhi,nCellsEta);
178
179 //Take the digits list and declare digits pointers
180 TClonesArray * digits = emcalLoader->Digits(); //gime->Digits() ;
181
182 TClonesArray * trus = geom->FillTRU(digits) ;
183
184 //Do Cell Sliding and select Trigger
185 Float_t max [10] ;
186 for(Int_t iSM = 1 ; iSM <= nSuperModules ; iSM++) {
187
188 MakeSlidingCell(trus, iSM, nTRU, nCellsPhi, nCellsEta, max);
189
190 //cout<<"Max Amplitude in SuperMod "<<iSM<<" TRU1 "<<max[0]
191 //<<" TRU2 "<<max[1]<<" TRU3 "<<max[2]<<endl;
192 SetTriggers(max, nTRU) ;
193 }
194
195}
196
197//____________________________________________________________________________
198void AliEMCALTrigger::Print(const Option_t * opt) const
199{
200
201 //Prints main parameters
202
203 if(! opt)
204 return;
205 AliTriggerInput* in = 0x0 ;
206
207
208 AliInfo("EMCAL trigger information:") ;
209 printf( " Threshold for pp MB LO %d\n", fL0MBppThreshold) ;
210 in = (AliTriggerInput*)fInputs.FindObject( "EMCAL_MB_pp_L0" );
211 if(in->GetValue())
212 printf( " *** EMCAL MB pp LO is set ***\n") ;
213
214 printf( " Threshold for PbPb MB LO %d\n", fL0MBPbPbThreshold) ;
215 in = (AliTriggerInput*)fInputs.FindObject( "EMCAL_MB_PbPb_L0" );
216 if(in->GetValue())
217 printf( " *** EMCAL MB PbPb LO is set ***\n") ;
218
219 printf( " Jet Low Pt Threshold for PbPb L1 %d\n", fL1JetLowPtThreshold) ;
220 in = (AliTriggerInput*)fInputs.FindObject( "EMCAL_PbPb_JetLPt_L1" );
221 if(in->GetValue())
222 printf( " *** EMCAL Jet Low Pt for PbPb L1 is set ***\n") ;
223
224 printf( " Jet Medium Pt Threshold for L1 %d\n", fL1JetMediumPtThreshold) ;
225 in = (AliTriggerInput*) fInputs.FindObject( "EMCAL_PbPb_JetMPt_L1" );
226 if(in->GetValue())
227 printf( " *** EMCAL Jet Medium Pt for PbPb L1 is set ***\n") ;
228
229 printf( " Jet High Pt Threshold for L1 %d\n", fL1JetHighPtThreshold) ;
230 in = (AliTriggerInput*) fInputs.FindObject( "EMCAL_PbPb_JetHPt_L1" );
231 if(in->GetValue())
232 printf( " *** EMCAL Jet High Pt for PbPb L1 is set ***\n") ;
233
234}
235
236//____________________________________________________________________________
237void AliEMCALTrigger::SetTriggers(const Float_t * amp, const Int_t nTRU)
238{
239
240 //Checks the maximum amplitude per each TRU and compares with the
241 //different triggers thresholds
242
243 Float_t max = 0;
244 for(Int_t i = 0 ; i < nTRU ; i++){
245 if(max < amp[i] )
246 max = amp[i] ;
247 }
248
249 if(max >= fL0MBppThreshold)
250 SetInput("EMCAL_MB_pp_L0");
251 if(max >= fL0MBPbPbThreshold)
252 SetInput("EMCAL_MB_PbPb_L0");
253 if(max >= fL1JetLowPtThreshold)
254 SetInput("EMCAL_PbPb_JetLPt_L1");
255 if(max >= fL1JetMediumPtThreshold)
256 SetInput("EMCAL_PbPb_JetMPt_L1");
257 if(max >= fL1JetHighPtThreshold)
258 SetInput("EMCAL_PbPb_JetHPt_L1");
259
260}