3 // Class to put cells into trigger patches
7 #include <TClonesArray.h>
12 #include "AliAnalysisManager.h"
14 #include "AliEMCALGeometry.h"
15 #include "AliEmcalTriggerPatchInfo.h"
17 #include "AliEmcalPatchFromCellMaker.h"
19 ClassImp(AliEmcalPatchFromCellMaker)
21 //________________________________________________________________________
22 AliEmcalPatchFromCellMaker::AliEmcalPatchFromCellMaker() :
23 AliAnalysisTaskEmcal("AliEmcalPatchFromCellMaker",kTRUE),
24 fCaloTriggersOutName("EmcalPatches32x32"),
32 fh2CellEnergyVsTime(0),
36 for (Int_t i = 0; i < kPatchCols; i++) {
37 for (Int_t j = 0; j < kPatchRows; j++) {
38 fPatchADCSimple[i][j] = 0.;
39 fPatchESimple[i][j] = 0.;
43 SetMakeGeneralHistograms(kTRUE);
46 //________________________________________________________________________
47 AliEmcalPatchFromCellMaker::AliEmcalPatchFromCellMaker(const char *name) :
48 AliAnalysisTaskEmcal(name,kTRUE),
49 fCaloTriggersOutName("EmcalPatches32x32"),
57 fh2CellEnergyVsTime(0),
61 for (Int_t i = 0; i < kPatchCols; i++) {
62 for (Int_t j = 0; j < kPatchRows; j++) {
63 fPatchADCSimple[i][j] = 0.;
64 fPatchESimple[i][j] = 0.;
68 SetMakeGeneralHistograms(kTRUE);
71 //________________________________________________________________________
72 AliEmcalPatchFromCellMaker::~AliEmcalPatchFromCellMaker()
77 //________________________________________________________________________
78 void AliEmcalPatchFromCellMaker::ExecOnce()
82 AliAnalysisTaskEmcal::ExecOnce();
87 if (!fCaloTriggersOutName.IsNull()) {
88 fCaloTriggersOut = new TClonesArray("AliEmcalTriggerPatchInfo");
89 fCaloTriggersOut->SetName(fCaloTriggersOutName);
91 if (!(InputEvent()->FindListObject(fCaloTriggersOutName))) {
92 InputEvent()->AddObject(fCaloTriggersOut);
95 fInitialized = kFALSE;
96 AliFatal(Form("%s: Container with same name %s already present. Aborting", GetName(), fCaloTriggersOutName.Data()));
103 //________________________________________________________________________
104 void AliEmcalPatchFromCellMaker::UserCreateOutputObjects()
106 // Create user output.
108 AliAnalysisTaskEmcal::UserCreateOutputObjects();
110 Int_t fgkNPhiBins = 18*8;
111 Float_t kMinPhi = 0.;
112 Float_t kMaxPhi = 2.*TMath::Pi();
113 Double_t *binsPhi = new Double_t[fgkNPhiBins+1];
114 for(Int_t i=0; i<=fgkNPhiBins; i++) binsPhi[i]=(Double_t)kMinPhi + (kMaxPhi-kMinPhi)/fgkNPhiBins*(Double_t)i ;
116 Int_t fgkNEtaBins = 100;
117 Float_t fgkEtaMin = -1.;
118 Float_t fgkEtaMax = 1.;
119 Double_t *binsEta=new Double_t[fgkNEtaBins+1];
120 for(Int_t i=0; i<=fgkNEtaBins; i++) binsEta[i]=(Double_t)fgkEtaMin + (fgkEtaMax-fgkEtaMin)/fgkNEtaBins*(Double_t)i ;
122 Int_t fgkNTimeBins = 600;
123 Float_t kMinTime = -200.;
124 Float_t kMaxTime = 1000;
125 Double_t *binsTime = new Double_t[fgkNTimeBins+1];
126 for(Int_t i=0; i<=fgkNTimeBins; i++) binsTime[i]=(Double_t)kMinTime + (kMaxTime-kMinTime)/fgkNTimeBins*(Double_t)i ;
128 Double_t enBinEdges[3][2];
129 enBinEdges[0][0] = 1.; //10 bins
130 enBinEdges[0][1] = 0.1;
131 enBinEdges[1][0] = 5.; //8 bins
132 enBinEdges[1][1] = 0.5;
133 enBinEdges[2][0] = 100.;//95 bins
134 enBinEdges[2][1] = 1.;
136 const Float_t enmin1 = 0;
137 const Float_t enmax1 = enBinEdges[0][0];
138 const Float_t enmin2 = enmax1 ;
139 const Float_t enmax2 = enBinEdges[1][0];
140 const Float_t enmin3 = enmax2 ;
141 const Float_t enmax3 = enBinEdges[2][0];//fgkEnMax;
142 const Int_t nbin11 = (int)((enmax1-enmin1)/enBinEdges[0][1]);
143 const Int_t nbin12 = (int)((enmax2-enmin2)/enBinEdges[1][1])+nbin11;
144 const Int_t nbin13 = (int)((enmax3-enmin3)/enBinEdges[2][1])+nbin12;
146 Int_t fgkNEnBins=nbin13;
147 Double_t *binsEn=new Double_t[fgkNEnBins+1];
148 for(Int_t i=0; i<=fgkNEnBins; i++) {
149 if(i<=nbin11) binsEn[i]=(Double_t)enmin1 + (enmax1-enmin1)/nbin11*(Double_t)i ;
150 if(i<=nbin12 && i>nbin11) binsEn[i]=(Double_t)enmin2 + (enmax2-enmin2)/(nbin12-nbin11)*((Double_t)i-(Double_t)nbin11) ;
151 if(i<=nbin13 && i>nbin12) binsEn[i]=(Double_t)enmin3 + (enmax3-enmin3)/(nbin13-nbin12)*((Double_t)i-(Double_t)nbin12) ;
154 fh3EEtaPhiCell = new TH3F("fh3EEtaPhiCell","fh3EEtaPhiCell;E_{cell};#eta;#phi",fgkNEnBins,binsEn,fgkNEtaBins,binsEta,fgkNPhiBins,binsPhi);
155 fOutput->Add(fh3EEtaPhiCell);
157 fh2CellEnergyVsTime = new TH2F("fh2CellEnergyVsTime","fh2CellEnergyVsTime;E_{cell};time",fgkNEnBins,binsEn,fgkNTimeBins,binsTime);
158 fOutput->Add(fh2CellEnergyVsTime);
160 fh1CellEnergySum = new TH1F("fh1CellEnergySum","fh1CellEnergySum;E_{cell};time",fgkNEnBins,binsEn);
161 fOutput->Add(fh1CellEnergySum);
163 PostData(1, fOutput); // Post data for ALL output slots > 0 here.
165 if(binsEn) delete [] binsEn;
166 if(binsPhi) delete [] binsPhi;
167 if(binsEta) delete [] binsEta;
168 if(binsTime) delete [] binsTime;
171 //________________________________________________________________________
172 Bool_t AliEmcalPatchFromCellMaker::Run()
174 // Main loop, called for each event.
176 fCaloTriggersOut->Delete();
179 AliError(Form("Calo cells container %s not available.", fCaloCellsName.Data()));
183 for (Int_t i = 0; i < kPatchCols; i++) {
184 for (Int_t j = 0; j < kPatchRows; j++) {
185 fPatchADCSimple[i][j] = 0.;
186 fPatchESimple[i][j] = 0.;
190 if(!FillPatchADCSimple()) {
191 AliError(Form("%s Could not create simple ADC patches",GetName()));
195 RunSimpleOfflineTrigger();
198 for (Int_t i = 0; i < kPatchCols; i++) {
199 for (Int_t j = 0; j < kPatchRows; j++) {
200 sum+=fPatchESimple[i][j];
207 //________________________________________________________________________
208 Bool_t AliEmcalPatchFromCellMaker::FillPatchADCSimple()
211 // fill the array for offline trigger processing
213 // fill the patch ADCs from cells
215 Int_t nCell = fCaloCells->GetNumberOfCells();
216 for(Int_t iCell = 0; iCell < nCell; ++iCell) {
217 // get the cell info, based in index in array
218 Short_t cellId = fCaloCells->GetCellNumber(iCell);
220 Double_t cellT = fCaloCells->GetCellTime(cellId);
221 Double_t amp = fCaloCells->GetAmplitude(iCell);
222 fh2CellEnergyVsTime->Fill(amp,cellT*1e9);
225 if(cellT<fCellTimeMin || cellT>fCellTimeMax) continue;
227 if(amp<fMinCellE) continue;
232 fGeom->GetFastORIndexFromCellIndex(cellId, absId);
233 Int_t globCol=-1, globRow=-1;
234 fGeom->GetPositionInEMCALFromAbsFastORIndex(absId, globCol, globRow);
236 fPatchADCSimple[globCol][globRow] += amp/kEMCL1ADCtoGeV;
237 fPatchESimple[globCol][globRow] += amp;
240 fGeom->GetGlobal(cellId, pos);
241 TLorentzVector lv(pos,amp);
242 Double_t cellEta = lv.Eta();
243 Double_t cellPhi = lv.Phi();
244 if(cellPhi<0.) cellPhi+=TMath::TwoPi();
245 if(cellPhi>TMath::TwoPi()) cellPhi-=TMath::TwoPi();
246 fh3EEtaPhiCell->Fill(amp,cellEta,cellPhi);
248 fh1CellEnergySum->Fill(sum);
253 //________________________________________________________________________
254 void AliEmcalPatchFromCellMaker::RunSimpleOfflineTrigger()
256 // Runs a simple offline trigger algorithm.
257 // It creates separate patches with dimension fPatchDim
259 // run the trigger algo, stepping by stepsize (in trigger tower units)
261 Int_t patchSize = GetDimFastor();
262 Int_t stepSize = GetSlidingStepSizeFastor();
263 Int_t maxCol = kPatchCols - patchSize;
264 Int_t maxRow = kPatchRows - patchSize;
266 for (Int_t i = 0; i <= maxCol; i += stepSize) {
267 for (Int_t j = 0; j <= maxRow; j += stepSize) {
268 // get the trigger towers composing the patch
272 for (Int_t k = 0; k < patchSize; ++k) {
273 for (Int_t l = 0; l < patchSize; ++l) {
275 adcAmp += (ULong64_t)fPatchADCSimple[i+k][j+l];
276 enAmp += fPatchESimple[i+k][j+l];
281 AliDebug(2,"EMCal trigger patch with 0 ADC counts.");
286 Int_t cellAbsId[4]={-1,-1,-1,-1};
288 // get low left edge (eta max, phi min)
289 fGeom->GetAbsFastORIndexFromPositionInEMCAL(i, j, absId);
290 // convert to the 4 absId of the cells composing the trigger channel
291 fGeom->GetCellIndexFromFastORIndex(absId, cellAbsId);
293 fGeom->GetGlobal(cellAbsId[0], edge1);
295 // get up right edge (eta min, phi max)
296 fGeom->GetAbsFastORIndexFromPositionInEMCAL(i+patchSize-1, j+patchSize-1, absId);
297 fGeom->GetCellIndexFromFastORIndex(absId, cellAbsId);
299 fGeom->GetGlobal(cellAbsId[3], edge2);
301 // get the center of the patch
302 Int_t offsetCenter = TMath::FloorNint(0.5*patchSize);
303 fGeom->GetAbsFastORIndexFromPositionInEMCAL(i+offsetCenter-1, j+offsetCenter-1, absId);
304 fGeom->GetCellIndexFromFastORIndex(absId, cellAbsId);
306 fGeom->GetGlobal(cellAbsId[3], center1);
308 fGeom->GetAbsFastORIndexFromPositionInEMCAL(i+offsetCenter, j+offsetCenter, absId);
309 fGeom->GetCellIndexFromFastORIndex(absId, cellAbsId);
311 fGeom->GetGlobal(cellAbsId[0], center2);
313 TVector3 centerGeo(center1);
314 centerGeo += center2;
317 // save the trigger object
318 AliEmcalTriggerPatchInfo *trigger =
319 new ((*fCaloTriggersOut)[itrig]) AliEmcalTriggerPatchInfo();
321 trigger->SetCenterGeo(centerGeo, enAmp);
322 trigger->SetEdge1(edge1, enAmp);
323 trigger->SetEdge2(edge2, enAmp);
324 trigger->SetADCAmp(adcAmp);
325 trigger->SetEdgeCell(i*2, j*2); // from triggers to cells
328 AliDebug(2,Form("Created %d trigger patches (%d) in this event",itrig,patchSize));
332 //________________________________________________________________________
333 Int_t AliEmcalPatchFromCellMaker::GetDimFastor() const {
335 Int_t dim = TMath::FloorNint((Double_t)(fPatchDim/2.));
339 //________________________________________________________________________
340 Int_t AliEmcalPatchFromCellMaker::GetSlidingStepSizeFastor() const {
342 Int_t dim = GetDimFastor();
343 if(!fL1Slide) return dim;
346 else if(dim==4) return 4;
347 else if(dim==8) return 4;
348 else if(dim==16) return 8;