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 /* AliAnalysisTaskEMCALFastOR2Trigger.cxx
22 #include "AliAnalysisTaskEMCALFastOR2Trigger.h"
24 #include <Riostream.h>
30 #include "AliAnalysisTaskSE.h"
31 #include "AliAnalysisManager.h"
33 #include "AliESDEvent.h"
34 #include "AliESDInputHandler.h"
35 #include "AliAODEvent.h"
36 #include "AliMCEvent.h"
37 #include "AliEMCALGeometry.h"
38 #include "AliCaloCalibPedestal.h"
40 #include "AliEMCALFastORPatch.h"
42 ClassImp(AliAnalysisTaskEMCALFastOR2Trigger)
44 //________________________________________________________________________
45 AliAnalysisTaskEMCALFastOR2Trigger::AliAnalysisTaskEMCALFastOR2Trigger() // All data members should be initialised here
50 fTriggerClustersName("triggerClusters"),
52 fCheckDeadClusters(0),
56 shiftCol(1) // The last in the above list should not have a comma after it
58 // Dummy constructor ALWAYS needed for I/O.
61 //________________________________________________________________________
62 AliAnalysisTaskEMCALFastOR2Trigger::AliAnalysisTaskEMCALFastOR2Trigger(const char *name) // All data members should be initialised here
63 :AliAnalysisTaskSE(name),
67 fTriggerClustersName("triggerClusters"),
69 fCheckDeadClusters(0),
73 shiftCol(1) // The last in the above list should not have a comma after it
79 //________________________________________________________________________
80 AliAnalysisTaskEMCALFastOR2Trigger::~AliAnalysisTaskEMCALFastOR2Trigger()
85 //________________________________________________________________________
86 void AliAnalysisTaskEMCALFastOR2Trigger::UserCreateOutputObjects()
88 // Called once (on the worker node)
91 //________________________________________________________________________
92 void AliAnalysisTaskEMCALFastOR2Trigger::UserExec(Option_t *)
95 // Called for each event
97 // Create pointer to reconstructed event
98 AliVEvent *event = InputEvent();
99 if (!event) { Printf("ERROR: Could not retrieve event"); return; }
101 // create pointer to event
102 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(event);
105 AliError("Cannot get the ESD event");
109 AliESDCaloTrigger *triggers = esd->GetCaloTrigger("EMCAL");
111 if (!triggers || !(triggers->GetEntries() > 0))
114 AliEMCALGeometry *fGeom = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName());
115 Int_t nSupMod = 0, nModule = 0, nIphi = 0, nIeta = 0, iphi = 0, ieta = 0;
117 // -------------------------------
118 // Trigger clusterizer parameters
120 Int_t totalCols = 48;
121 Int_t totalRows = 60;
124 Int_t nColFastOR = totalCols / nTRUCol;
125 Int_t nRowFastOR = totalRows / nTRURow;
126 Int_t maxiShiftRow = nRow / shiftRow;
127 Int_t maxiShiftCol = nCol / shiftCol;
128 Int_t nFastORCluster = nCol * nRow;
129 Int_t nTriggerClusters = totalRows * totalCols / nCol / nRow;
130 Int_t nTotalClus = nTriggerClusters * maxiShiftCol * maxiShiftRow;
131 Int_t nClusRowNoShift = nRowFastOR / nRow;
132 Int_t nClusColNoShift = nColFastOR / nCol;
134 TClonesArray *triggers_array = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fTriggerClustersName));
137 triggers_array = new TClonesArray("AliESDCaloTrigger", nTotalClus);
138 triggers_array->SetName(fTriggerClustersName);
139 InputEvent()->AddObject(triggers_array);
143 triggers_array->Delete();
146 Bool_t *dead_clusters = new Bool_t[nTotalClus];
147 for (Int_t i = 0; i < nTotalClus; i++)
149 dead_clusters[i] = kFALSE;
151 // -------------------------------
155 while (triggers->Next())
157 Float_t L0FastORamp = 0;
159 triggers->GetAmplitude(L0FastORamp);
168 triggers->GetNL0Times(ntimes);
174 triggers->GetL0Times(trgtimes);
176 Bool_t trgInTimeWindow = 0;
177 for (Int_t i = 0; i < ntimes; i++)
179 if ((fMaxL0Time >= trgtimes[i]) && (fMinL0Time <= trgtimes[i]))
183 if (!trgInTimeWindow)
187 Int_t gCol = 0, gRow = 0;
189 triggers->GetPosition(gCol, gRow);
192 fGeom->GetAbsFastORIndexFromPositionInEMCAL(gCol, gRow, find);
197 Int_t cidx[4] = {-1};
198 Bool_t ret = fGeom->GetCellIndexFromFastORIndex(find, cidx);
203 Bool_t deadCluster = kFALSE;
205 if (fCheckDeadClusters && fPedestal)
207 for (Int_t i = 0; i < 4; i++)
209 fGeom->GetCellIndex (cidx[i], nSupMod, nModule, nIphi, nIeta);
210 fGeom->GetCellPhiEtaIndexInSModule (nSupMod, nModule, nIphi, nIeta, iphi, ieta);
212 Double_t d = fPedestal->GetDeadMap(nSupMod)->GetBinContent(ieta,iphi);
213 if (d == AliCaloCalibPedestal::kDead || d == AliCaloCalibPedestal::kHot)
220 // --------------------------
221 // Trigger clusterizer
223 for (Int_t ishiftRow = 0; ishiftRow < maxiShiftRow; ishiftRow++)
225 Int_t nClusRow = (nRowFastOR - shiftRow * ishiftRow) / nRow;
227 for (Int_t ishiftCol = 0; ishiftCol < maxiShiftCol; ishiftCol++)
229 Int_t iTotalClus = nTriggerClusters * (ishiftRow * maxiShiftCol + ishiftCol);
231 Int_t nClusCol = (nColFastOR - shiftCol * ishiftCol) / nCol;
233 Int_t irow_eff = gRow - shiftRow * ishiftRow;
234 Int_t iTRUrow = irow_eff / nRowFastOR;
235 irow_eff -= iTRUrow * nRowFastOR;
236 Int_t iClusRow = irow_eff / nRow;
238 if (irow_eff < 0 || iClusRow >= nClusRow)
241 Int_t icol_eff = gCol - shiftCol * ishiftCol;
242 Int_t iTRUcol = icol_eff / nColFastOR;
243 icol_eff -= iTRUcol * nColFastOR;
244 Int_t iClusCol = icol_eff / nCol;
246 if (icol_eff < 0 || iClusCol >= nClusCol)
249 irow_eff += iTRUrow * nRowFastOR;
250 iClusRow = irow_eff / nRow;
252 icol_eff += iTRUcol * nColFastOR;
253 iClusCol = icol_eff / nCol;
255 Int_t iTriggerCluster = iClusRow + iClusCol * nClusRowNoShift * nTRURow + iTotalClus;
256 Int_t iTriggerDigit = irow_eff % nRow + (icol_eff % nCol) * nRow;
258 if (dead_clusters[iTriggerCluster] && fCheckDeadClusters) deadCluster = kTRUE;
262 dead_clusters[iTriggerCluster] = kTRUE;
263 if (triggers_array->At(iTriggerCluster))
265 triggers_array->RemoveAt(iTriggerCluster);
270 if (!triggers_array->At(iTriggerCluster))
272 (*triggers_array)[iTriggerCluster] = new AliEMCALFastORPatch(iTriggerCluster, nFastORCluster);
275 AliEMCALFastORPatch *triggerCluster = dynamic_cast<AliEMCALFastORPatch*>(triggers_array->At(iTriggerCluster));
277 if (triggerCluster->GetFastORamplitude(iTriggerDigit) > -1)
279 AliFatal("ERROR: FastOR already added!");
283 triggerCluster->AddFastORat(L0FastORamp, gCol, gRow, iTriggerDigit);
285 } // loop on col shift
287 } // loop on row shift
289 // ------------------------------
290 } // loop on L0 FastOR triggers
292 delete[] dead_clusters;
294 triggers_array->Compress();
298 //________________________________________________________________________
299 void AliAnalysisTaskEMCALFastOR2Trigger::Terminate(Option_t *)
301 // Called once at the end of the query