1 // $Id: AliEmcalTriggerMaker.cxx 64593 2013-10-18 10:23:58Z loizides $
3 // Class to make array of trigger patch objects in AOD/ESD events.
6 #include <TClonesArray.h>
9 #include "AliAODCaloTrigger.h"
10 #include "AliEMCALGeometry.h"
11 //#include "AliEMCALTriggerTypes.h"
12 #include "AliEmcalTriggerPatchInfo.h"
13 #include "AliEmcalTriggerSetupInfo.h"
15 #include "AliVCaloCells.h"
16 #include "AliVCaloTrigger.h"
17 #include "AliVVZERO.h"
18 #include "AliEmcalTriggerMaker.h"
20 #include "THistManager.h"
23 ClassImp(AliEmcalTriggerMaker)
27 //________________________________________________________________________
28 AliEmcalTriggerMaker::AliEmcalTriggerMaker() :
29 AliAnalysisTaskEmcal("AliEmcalTriggerMaker",kFALSE),
30 fCaloTriggersOutName("EmcalTriggers"),
31 fCaloTriggerSetupOutName("EmcalTriggersSetup"),
32 fV0InName("AliAODVZERO"),
33 fUseTriggerBitConfig(kNewConfig),
34 fTriggerBitConfig(NULL),
36 fCaloTriggerSetupOut(0),
37 fSimpleOfflineTriggers(0),
44 fRunTriggerType[kTMEMCalJet] = kTRUE;
45 fRunTriggerType[kTMEMCalGamma] = kTRUE;
46 fRunTriggerType[kTMEMCalLevel0] = kTRUE;
47 memset(fThresholdConstants, 0, sizeof(Int_t) * 12);
48 memset(fPatchADCSimple, 0, sizeof(Int_t) * kPatchCols * kPatchRows);
49 memset(fPatchADC, 0, sizeof(Int_t) * kPatchCols * kPatchRows);
52 //________________________________________________________________________
53 AliEmcalTriggerMaker::AliEmcalTriggerMaker(const char *name, Bool_t doQA) :
54 AliAnalysisTaskEmcal(name,doQA),
55 fCaloTriggersOutName("EmcalTriggers"),
56 fCaloTriggerSetupOutName("EmcalTriggersSetup"),
57 fV0InName("AliAODVZERO"),
58 fUseTriggerBitConfig(kNewConfig),
59 fTriggerBitConfig(NULL),
61 fCaloTriggerSetupOut(0),
62 fSimpleOfflineTriggers(0),
69 fRunTriggerType[kTMEMCalJet] = kTRUE;
70 fRunTriggerType[kTMEMCalGamma] = kTRUE;
71 fRunTriggerType[kTMEMCalLevel0] = kTRUE;
72 memset(fThresholdConstants, 0, sizeof(Int_t) * 12);
73 memset(fPatchADCSimple, 0, sizeof(Int_t) * kPatchCols * kPatchRows);
74 memset(fPatchADC, 0, sizeof(Int_t) * kPatchCols * kPatchRows);
77 //________________________________________________________________________
78 AliEmcalTriggerMaker::~AliEmcalTriggerMaker()
81 if(fTriggerBitConfig) delete fTriggerBitConfig;
84 //________________________________________________________________________
85 void AliEmcalTriggerMaker::ExecOnce()
89 AliAnalysisTaskEmcal::ExecOnce();
94 if(!fTriggerBitConfig){
95 switch(fUseTriggerBitConfig){
97 fTriggerBitConfig = new AliEmcalTriggerBitConfigNew();
100 fTriggerBitConfig = new AliEmcalTriggerBitConfigOld();
105 if (!fCaloTriggersOutName.IsNull()) {
106 fCaloTriggersOut = new TClonesArray("AliEmcalTriggerPatchInfo");
107 fCaloTriggersOut->SetName(fCaloTriggersOutName);
109 if (!(InputEvent()->FindListObject(fCaloTriggersOutName))) {
110 InputEvent()->AddObject(fCaloTriggersOut);
113 fInitialized = kFALSE;
114 AliFatal(Form("%s: Container with same name %s already present. Aborting", GetName(), fCaloTriggersOutName.Data()));
119 if (!fCaloTriggerSetupOutName.IsNull()) {
120 fCaloTriggerSetupOut = new AliEmcalTriggerSetupInfo();
121 fCaloTriggerSetupOut->SetName(fCaloTriggerSetupOutName);
123 if (!(InputEvent()->FindListObject(fCaloTriggerSetupOutName))) {
124 InputEvent()->AddObject(fCaloTriggerSetupOut);
127 fInitialized = kFALSE;
128 AliFatal(Form("%s: Container with same name %s already present. Aborting", GetName(), fCaloTriggerSetupOutName.Data()));
133 if ( ! fV0InName.IsNull()) {
134 fV0 = (AliVVZERO*)InputEvent()->FindListObject(fV0InName);
137 // container for simple offline trigger processing
138 fSimpleOfflineTriggers = new AliAODCaloTrigger();
139 fSimpleOfflineTriggers->Allocate(0);
142 //________________________________________________________________________
143 void AliEmcalTriggerMaker::UserCreateOutputObjects()
145 // Do basic QA monitoring (if requested)
146 AliAnalysisTaskEmcal::UserCreateOutputObjects();
148 if(fDoQA && fOutput){
149 fQAHistos = new THistManager("TriggerQA");
151 TString trtypenames[3] = {"EJE", "EGA", "EL0"};
152 for(int itype = 0; itype < 3; itype++){
153 fQAHistos->CreateTH2(Form("RCPos%s", trtypenames[itype].Data()), Form("Lower edge position of %s patches (col-row)", trtypenames[itype].Data()), 48, -0.5, 47.5, 64, -0.5, 63.5);
154 fQAHistos->CreateTH2(Form("EPCentPos%s", trtypenames[itype].Data()), Form("Center position of the %s trigger patches", trtypenames[itype].Data()), 20, -0.8, 0.8, 100., 1., 4.);
155 fQAHistos->CreateTH2(Form("PatchADCvsE%s", trtypenames[itype].Data()), Form("Patch ADC value for trigger type %s", trtypenames[itype].Data()), 200, 0., 200, 200, 0., 200);
157 fQAHistos->CreateTH1("triggerBitsAll", "Trigger bits for all incoming patches", 64, -0.5, 63.5);
158 fQAHistos->CreateTH1("triggerBitsSel", "Trigger bits for reconstructed patches", 64, -0.5, 63.5);
159 fOutput->Add(fQAHistos->GetListOfHistograms());
160 PostData(1, fOutput);
164 //________________________________________________________________________
165 Bool_t AliEmcalTriggerMaker::Run()
167 // Create and fill the patch array.
169 AliEmcalTriggerPatchInfo *trigger, *triggerMainJet, *triggerMainGamma, *triggerMainLevel0;
170 AliEmcalTriggerPatchInfo *triggerMainJetSimple, *triggerMainGammaSimple;
172 // delete patch array, clear setup object
173 fCaloTriggersOut->Delete();
174 fCaloTriggerSetupOut->Clean();
176 if (!fCaloTriggers) {
177 AliError(Form("Calo triggers container %s not available.", fCaloTriggersName.Data()));
181 AliError(Form("Calo cells container %s not available.", fCaloCellsName.Data()));
185 AliError(Form("V0 container %s not available.", fV0InName.Data()));
189 // do not process, if sooner than 11h period
191 if( InputEvent()->GetRunNumber() < 167693 )
194 // // do not process any MC, since no MC was generated with correct
195 // // EMCal trigger L1 jet trigger simulation, yet
196 // // productions will be enabled, once some correct once are produced
197 // if( MCEvent() != 0 )
200 // must reset before usage, or the class will fail
201 fCaloTriggers->Reset();
203 // first run over the patch array to compose a map of 2x2 patch energies
204 // which is then needed to construct the full patch ADC energy
205 // class is not empty
206 if (fCaloTriggers->GetEntries() > 0) {
208 memset(fPatchADC, 0, sizeof(Int_t) * kPatchCols * kPatchRows);
210 // go throuth the trigger channels
211 while (fCaloTriggers->Next()) {
212 // get position in global 2x2 tower coordinates
213 // A0 left bottom (0,0)
214 Int_t globCol=-1, globRow=-1;
215 fCaloTriggers->GetPosition(globCol, globRow);
216 // for some strange reason some ADC amps are initialized in reconstruction
217 // as -1, neglect those
219 fCaloTriggers->GetL1TimeSum(adcAmp);
221 fPatchADC[globCol][globRow] = adcAmp;
225 // fill the array for offline trigger processing
226 // using calibrated cell energies
227 memset(fPatchADCSimple, 0, sizeof(Int_t) * kPatchRows * kPatchCols);
229 // fill the patch ADCs from cells
230 Int_t nCell = fCaloCells->GetNumberOfCells();
231 for(Int_t iCell = 0; iCell < nCell; ++iCell) {
232 // get the cell info, based in index in array
233 Short_t cellId = fCaloCells->GetCellNumber(iCell);
234 Double_t amp = fCaloCells->GetAmplitude(iCell);
237 fGeom->GetFastORIndexFromCellIndex(cellId, absId);
238 Int_t globCol=-1, globRow=-1;
239 fGeom->GetPositionInEMCALFromAbsFastORIndex(absId, globCol, globRow);
241 fPatchADCSimple[globCol][globRow] += amp/kEMCL1ADCtoGeV;
244 // dig out common data (thresholds)
245 // 0 - jet high, 1 - gamma high, 2 - jet low, 3 - gamma low
246 fCaloTriggerSetupOut->SetThresholds(fCaloTriggers->GetL1Threshold(0),
247 fCaloTriggers->GetL1Threshold(1),
248 fCaloTriggers->GetL1Threshold(2),
249 fCaloTriggers->GetL1Threshold(3));
251 // get the V0 value and compute and set the offline thresholds
252 // get V0, compute thresholds and save them as global parameters
254 v0[0] = fV0->GetTriggerChargeA();
255 v0[1] = fV0->GetTriggerChargeC();
256 ULong64_t v0S = v0[0] + v0[1];
257 fSimpleOfflineTriggers->SetL1V0(v0);
259 for (Int_t i = 0; i < 4; ++i) {
260 // A*V0^2/2^32+B*V0/2^16+C
261 ULong64_t thresh = ( ((ULong64_t)fThresholdConstants[i][0]) * v0S * v0S ) >> 32;
262 thresh += ( ((ULong64_t)fThresholdConstants[i][1]) * v0S ) >> 16;
263 thresh += ((ULong64_t)fThresholdConstants[i][2]);
264 fSimpleOfflineTriggers->SetL1Threshold(i,thresh);
267 // save the thresholds in output object
268 fCaloTriggerSetupOut->SetThresholdsSimple(fSimpleOfflineTriggers->GetL1Threshold(0),
269 fSimpleOfflineTriggers->GetL1Threshold(1),
270 fSimpleOfflineTriggers->GetL1Threshold(2),
271 fSimpleOfflineTriggers->GetL1Threshold(3));
274 RunSimpleOfflineTrigger();
277 fCaloTriggers->Reset();
278 fSimpleOfflineTriggers->Reset();
280 // class is not empty
281 if (fCaloTriggers->GetEntries() > 0 || fSimpleOfflineTriggers->GetEntries() > 0) {
283 triggerMainGamma = 0;
285 triggerMainGammaSimple = 0;
286 triggerMainJetSimple = 0;
287 triggerMainLevel0 = 0;
289 // go throuth the trigger channels, real first, then offline
290 Bool_t isOfflineSimple=0;
291 while (NextTrigger(isOfflineSimple)) {
293 if(fRunTriggerType[kTMEMCalJet]){
294 trigger = ProcessPatch(kTMEMCalJet, isOfflineSimple);
295 // save main jet triggers in event
297 // check if more energetic than others for main patch marking
298 if (!isOfflineSimple) {
299 if (triggerMainJet == 0 || (triggerMainJet->GetPatchE() < trigger->GetPatchE()))
300 triggerMainJet = trigger;
302 if (triggerMainJetSimple == 0 || (triggerMainJetSimple->GetPatchE() < trigger->GetPatchE()))
303 triggerMainJetSimple = trigger;
309 if(fRunTriggerType[kTMEMCalGamma]){
310 trigger = ProcessPatch(kTMEMCalGamma, isOfflineSimple);
311 // save main gamma triggers in event
313 // check if more energetic than others for main patch marking
314 if (!isOfflineSimple) {
315 if (triggerMainGamma == 0 || (triggerMainGamma->GetPatchE() < trigger->GetPatchE()))
316 triggerMainGamma = trigger;
318 if (triggerMainGammaSimple == 0 || (triggerMainGammaSimple->GetPatchE() < trigger->GetPatchE()))
319 triggerMainGammaSimple = trigger;
325 if(fRunTriggerType[kTMEMCalLevel0]){
326 trigger = ProcessPatch(kTMEMCalLevel0, isOfflineSimple);
327 // save main level0 trigger in the event
329 if (!triggerMainLevel0 || (triggerMainLevel0->GetPatchE() < trigger->GetPatchE()))
330 triggerMainLevel0 = trigger;
335 // mark the most energetic patch as main
336 // for real and also simple offline
337 if (triggerMainJet != 0) {
338 Int_t tBits = triggerMainJet->GetTriggerBits();
340 tBits = tBits | ( 1 << 24 );
341 triggerMainJet->SetTriggerBits( tBits );
343 if (triggerMainJetSimple != 0) {
344 Int_t tBits = triggerMainJetSimple->GetTriggerBits();
346 tBits = tBits | ( 1 << 24 );
347 triggerMainJetSimple->SetTriggerBits(tBits);
349 if (triggerMainGamma != 0) {
350 Int_t tBits = triggerMainGamma->GetTriggerBits();
352 tBits = tBits | ( 1 << 24 );
353 triggerMainGamma->SetTriggerBits( tBits );
355 if (triggerMainGammaSimple != 0) {
356 Int_t tBits = triggerMainGammaSimple->GetTriggerBits();
358 tBits = tBits | ( 1 << 24 );
359 triggerMainGammaSimple->SetTriggerBits( tBits );
361 if(triggerMainLevel0){
362 Int_t tBits = triggerMainLevel0->GetTriggerBits();
365 triggerMainLevel0->SetTriggerBits(tBits);
367 } // there are some triggers
372 //________________________________________________________________________
373 AliEmcalTriggerPatchInfo* AliEmcalTriggerMaker::ProcessPatch(TriggerMakerTriggerType_t type, Bool_t isOfflineSimple)
375 // Process and fill trigger patch.
376 // check if jet trigger low or high
378 if (!isOfflineSimple)
379 fCaloTriggers->GetTriggerBits(tBits);
381 fSimpleOfflineTriggers->GetTriggerBits(tBits);
384 for(unsigned int ibit = 0; ibit < sizeof(tBits)*8; ibit++) {
385 if(tBits & (1 << ibit)){
386 fQAHistos->FillTH1("triggerBitsAll", ibit);
391 if ((type == kTMEMCalJet && !IsEJE( tBits )) ||
392 (type == kTMEMCalGamma && !IsEGA( tBits )) ||
393 (type == kTMEMCalLevel0 && !(CheckForL0(*fCaloTriggers))))
396 TString trtypenames[3] = {"EJE", "EGA", "EL0"}; // For QA
398 // save primary vertex in vector
400 vertex.SetXYZ(fVertex[0], fVertex[1], fVertex[2]);
402 // get position in global 2x2 tower coordinates
403 // A0 left bottom (0,0)
404 Int_t globCol=-1, globRow=-1;
405 if (!isOfflineSimple)
406 fCaloTriggers->GetPosition(globCol,globRow);
408 fSimpleOfflineTriggers->GetPosition(globCol, globRow);
410 // In case of level0 reject triggers with an odd row-col combination
411 // if(type == kTMEMCalLevel0 && (globRow % 2 != 0 || globCol % 2 != 0)) return 0;
413 // get the absolute trigger ID
415 fGeom->GetAbsFastORIndexFromPositionInEMCAL(globCol, globRow, absId);
416 // convert to the 4 absId of the cells composing the trigger channel
417 Int_t cellAbsId[4]={-1,-1,-1,-1};
418 fGeom->GetCellIndexFromFastORIndex(absId, cellAbsId);
420 // get low left edge (eta max, phi min)
422 fGeom->GetGlobal(cellAbsId[0], edge1);
424 // sum the available energy in the 32/32 window of cells
425 // step over trigger channels and get all the corresponding cells
431 int nfastor = (type == kTMEMCalJet) ? 16 : 2; // 32x32 cell window for L1 Jet trigger, 4x4 for L1 Gamma or L0 trigger
432 for (Int_t i = 0; i < nfastor; ++i) {
433 for (Int_t j = 0; j < nfastor; ++j) {
434 // get the 4 cells composing the trigger channel
435 fGeom->GetAbsFastORIndexFromPositionInEMCAL(globCol+i, globRow+j, absId);
436 fGeom->GetCellIndexFromFastORIndex(absId, cellAbsId);
437 // add amplitudes and find patch edges
438 for (Int_t k = 0; k < 4; ++k) {
439 Double_t ca = fCaloCells->GetCellAmplitude(cellAbsId[k]);
440 //fGeom->GetGlobal(cellAbsId[k], cellCoor);
442 cmiCol += ca*(Double_t)i;
443 cmiRow += ca*(Double_t)j;
445 // add the STU ADCs in the patch (in case of L1) or the TRU Amplitude (in case of L0)
446 if (!isOfflineSimple )
447 if(type == kTMEMCalLevel0){
448 adcAmp += fPatchADC[globCol+i][globRow+j] * 4; // precision loss in case of global integer field
450 adcAmp += fPatchADC[globCol+i][globRow+j];
452 adcAmp += fPatchADCSimple[globCol+i][globRow+j];
457 AliDebug(2,"EMCal trigger patch with 0 energy.");
461 // get the CM and patch index
464 Int_t cmCol = globCol + (Int_t)cmiCol;
465 Int_t cmRow = globRow + (Int_t)cmiRow;
467 // get the patch and corresponding cells
468 fGeom->GetAbsFastORIndexFromPositionInEMCAL( cmCol, cmRow, absId );
469 fGeom->GetCellIndexFromFastORIndex( absId, cellAbsId );
471 // find which out of the 4 cells is closest to CM and get it's position
472 Int_t cmiCellCol = TMath::Nint(cmiCol * 2.);
473 Int_t cmiCellRow = TMath::Nint(cmiRow * 2.);
475 fGeom->GetGlobal(cellAbsId[(cmiCellRow%2)*2 + cmiCellCol%2], centerMass);
477 // get up right edge (eta min, phi max)
478 // get the absolute trigger ID
494 fGeom->GetAbsFastORIndexFromPositionInEMCAL(globCol+posOffset, globRow+posOffset, absId);
495 fGeom->GetCellIndexFromFastORIndex(absId, cellAbsId);
497 fGeom->GetGlobal(cellAbsId[3], edge2);
499 // get the geometrical center as an average of two diagonally
500 // adjacent patches in the center
501 // picking two diagonally closest cells from the patches
516 fGeom->GetAbsFastORIndexFromPositionInEMCAL(globCol+posOffset, globRow+posOffset, absId);
517 fGeom->GetCellIndexFromFastORIndex(absId, cellAbsId);
519 fGeom->GetGlobal(cellAbsId[3], center1);
532 fGeom->GetAbsFastORIndexFromPositionInEMCAL(globCol+posOffset, globRow+posOffset, absId);
533 fGeom->GetCellIndexFromFastORIndex(absId, cellAbsId);
535 fGeom->GetGlobal(cellAbsId[0], center2);
537 TVector3 centerGeo(center1);
538 centerGeo += center2;
541 // relate all to primary vertex
543 centerMass -= vertex;
547 Int_t isMC = MCEvent() ? 1 : 0;
548 Int_t offSet = (1 - isMC) * fTriggerBitConfig->GetTriggerTypesEnd();
550 // fix tbits .. remove the unwanted type triggers
551 // for Jet and Gamma triggers we remove also the level 0 bit since it will be stored in the level 0 patch
552 // for level 0 we remove all gamma and jet trigger bits
555 tBits = tBits & ~( 1 << (fTriggerBitConfig->GetTriggerTypesEnd() + fTriggerBitConfig->GetGammaLowBit()) | 1 << (fTriggerBitConfig->GetTriggerTypesEnd() + fTriggerBitConfig->GetGammaHighBit()) |
556 1 << (fTriggerBitConfig->GetGammaLowBit()) | 1 << (fTriggerBitConfig->GetGammaHighBit()) |
557 1 << (fTriggerBitConfig->GetTriggerTypesEnd() + fTriggerBitConfig->GetLevel0Bit()) | 1 << (fTriggerBitConfig->GetLevel0Bit()));
560 tBits = tBits & ~( 1 << (fTriggerBitConfig->GetTriggerTypesEnd() + fTriggerBitConfig->GetJetLowBit()) | 1 << (fTriggerBitConfig->GetTriggerTypesEnd() + fTriggerBitConfig->GetJetHighBit()) |
561 1 << (fTriggerBitConfig->GetJetLowBit()) | 1 << (fTriggerBitConfig->GetJetHighBit()) |
562 1 << (fTriggerBitConfig->GetTriggerTypesEnd() + fTriggerBitConfig->GetLevel0Bit()) | 1 << (fTriggerBitConfig->GetLevel0Bit()));
565 // Explicitly set the level 0 bit to overcome the masking out
566 tBits |= 1 << (offSet + fTriggerBitConfig->GetLevel0Bit());
567 tBits = tBits & ~( 1 << (fTriggerBitConfig->GetTriggerTypesEnd() + fTriggerBitConfig->GetJetLowBit()) | 1 << (fTriggerBitConfig->GetTriggerTypesEnd() + fTriggerBitConfig->GetJetHighBit()) |
568 1 << (fTriggerBitConfig->GetJetLowBit()) | 1 << (fTriggerBitConfig->GetJetHighBit()) | 1 << (fTriggerBitConfig->GetTriggerTypesEnd() + fTriggerBitConfig->GetGammaLowBit()) |
569 1 << (fTriggerBitConfig->GetTriggerTypesEnd() + fTriggerBitConfig->GetGammaHighBit()) | 1 << (fTriggerBitConfig->GetGammaLowBit()) | 1 << (fTriggerBitConfig->GetGammaHighBit()));
573 // save the trigger object
574 AliEmcalTriggerPatchInfo *trigger =
575 new ((*fCaloTriggersOut)[fITrigger]) AliEmcalTriggerPatchInfo();
577 trigger->SetTriggerBitConfig(fTriggerBitConfig);
578 trigger->SetCenterGeo(centerGeo, amp);
579 trigger->SetCenterMass(centerMass, amp);
580 trigger->SetEdge1(edge1, amp);
581 trigger->SetEdge2(edge2, amp);
582 trigger->SetADCAmp(adcAmp);
583 trigger->SetTriggerBits(tBits);
584 trigger->SetOffSet(offSet);
585 trigger->SetEdgeCell(globCol*2, globRow*2); // from triggers to cells
587 fQAHistos->FillTH2(Form("RCPos%s", trtypenames[type].Data()), globCol, globRow);
588 fQAHistos->FillTH2(Form("EPCentPos%s", trtypenames[type].Data()), centerGeo.Eta(), centerGeo.Phi());
589 fQAHistos->FillTH2(Form("PatchADCvsE%s", trtypenames[type].Data()), adcAmp, trigger->GetPatchE());
590 // Redo checking of found trigger bits after masking of unwanted triggers
591 for(unsigned int ibit = 0; ibit < sizeof(tBits)*8; ibit++) {
592 if(tBits & (1 << ibit)){
593 fQAHistos->FillTH1("triggerBitsSel", ibit);
600 //________________________________________________________________________
601 void AliEmcalTriggerMaker::RunSimpleOfflineTrigger()
603 // Runs a simple offline trigger algorithm.
604 // It creates separate patches for jet and gamma triggers
605 // on the same positions (different from STU reconstruction behavior)
606 // TODO:: change to merge
608 TArrayI tBitsArray, rowArray, colArray;
610 // 0 thresholds = no processing
611 if (fCaloTriggerSetupOut->GetThresholdJetLowSimple() == 0 &&
612 fCaloTriggerSetupOut->GetThresholdJetHighSimple() == 0 )
615 // run the trigger algo, stepping by 8 towers (= 4 trigger channels)
617 Int_t maxRow = fGeom->GetNTotalTRU()*2;
618 for (Int_t i = 0; i < (maxCol-16); i += 4) {
619 for (Int_t j = 0; j < (maxRow-16); j += 4) {
623 for (Int_t k = 0; k < 16; ++k)
624 for (Int_t l = 0; l < 16; ++l)
625 tSum += (ULong64_t)fPatchADCSimple[i+k][j+l];
628 if (tSum > fCaloTriggerSetupOut->GetThresholdJetLowSimple())
629 tBits = tBits | ( 1 << ( fTriggerBitConfig->GetTriggerTypesEnd() + fTriggerBitConfig->GetJetLowBit() ));
630 if (tSum > fCaloTriggerSetupOut->GetThresholdJetHighSimple())
631 tBits = tBits | ( 1 << ( fTriggerBitConfig->GetTriggerTypesEnd() + fTriggerBitConfig->GetJetHighBit() ));
633 // add trigger values
636 tBits = tBits | ( 1 << 25 );
637 tBitsArray.Set( tBitsArray.GetSize() + 1 );
638 colArray.Set( colArray.GetSize() + 1 );
639 rowArray.Set( rowArray.GetSize() + 1 );
640 tBitsArray[tBitsArray.GetSize()-1] = tBits;
641 colArray[colArray.GetSize()-1] = i;
642 rowArray[rowArray.GetSize()-1] = j;
647 // 4x4 trigger algo, stepping by 2 towers (= 1 trigger channel)
648 for (Int_t i = 0; i < (maxCol-2); ++i) {
649 for (Int_t j = 0; j < (maxRow-2); ++j) {
654 for (Int_t k = 0; k < 2; ++k)
655 for (Int_t l = 0; l < 2; ++l)
656 tSum += (ULong64_t)fPatchADCSimple[i+k][j+l];
659 if (tSum > fCaloTriggerSetupOut->GetThresholdGammaLowSimple())
660 tBits = tBits | ( 1 << ( fTriggerBitConfig->GetTriggerTypesEnd() + fTriggerBitConfig->GetGammaLowBit() ));
661 if (tSum > fCaloTriggerSetupOut->GetThresholdGammaHighSimple())
662 tBits = tBits | ( 1 << ( fTriggerBitConfig->GetTriggerTypesEnd() + fTriggerBitConfig->GetGammaHighBit() ));
664 // add trigger values
667 tBits = tBits | ( 1 << 25 );
668 tBitsArray.Set( tBitsArray.GetSize() + 1 );
669 colArray.Set( colArray.GetSize() + 1 );
670 rowArray.Set( rowArray.GetSize() + 1 );
671 tBitsArray[tBitsArray.GetSize()-1] = tBits;
672 colArray[colArray.GetSize()-1] = i;
673 rowArray[rowArray.GetSize()-1] = j;
679 fSimpleOfflineTriggers->DeAllocate();
680 fSimpleOfflineTriggers->Allocate(tBitsArray.GetSize());
681 for (Int_t i = 0; i < tBitsArray.GetSize(); ++i){
682 fSimpleOfflineTriggers->Add(colArray[i],rowArray[i], 0, 0, 0, 0, 0, tBitsArray[i]);
686 //________________________________________________________________________
687 Bool_t AliEmcalTriggerMaker::NextTrigger(Bool_t &isOfflineSimple)
691 isOfflineSimple = kFALSE;
692 Bool_t loopContinue = fCaloTriggers->Next();
694 loopContinue = fSimpleOfflineTriggers->Next();
695 isOfflineSimple = kTRUE;
700 //________________________________________________________________________
701 Bool_t AliEmcalTriggerMaker::CheckForL0(const AliVCaloTrigger& trg) const {
702 // Check whether the patch is a level0 patch
704 // For Monte-Carlo select
706 trg.GetTriggerBits(tbits);
707 return tbits & (1 << fTriggerBitConfig->GetLevel0Bit());
709 // For Data check from the level0 times if the trigger has fired at level0
711 Bool_t l0fired(kFALSE);
712 trg.GetNL0Times(nl0times);
714 TArrayI l0times(nl0times);
715 trg.GetL0Times(l0times.GetArray());
716 // Apply timing cut to see if a L0 has fired
717 for(Int_t *l0timeIter = l0times.GetArray(); l0timeIter < l0times.GetArray() + l0times.GetSize(); l0timeIter++){
718 if(*l0timeIter > 7 && *l0timeIter < 10){