2 /**************************************************************************
3 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * Author: The ALICE Off-line Project. *
6 * Contributors are mentioned in the code where appropriate. *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
17 //---------------------------------------------------------------------
19 // Called by ESD reader for jet analysis
20 // Author: Magali Estienne (magali.estienne@ires.in2p3.fr)
21 //---------------------------------------------------------------------
23 // --- ROOT system ---
24 #include <TLorentzVector.h>
27 // --- AliRoot header files ---
28 #include "AliESDCaloCluster.h"
29 #include "AliESDCaloCells.h"
30 #include "AliJetUnitArray.h"
31 #include "AliJetESDFillUnitArrayEMCalDigits.h"
32 // #include "AliEMCALCalibData.h"
33 // #include "AliCDBManager.h"
34 // // class AliCDBStorage;
35 // #include "AliCDBEntry.h"
37 // --- ROOT system ---
42 // --- AliRoot header files ---
45 class AliJetESDReader;
46 // class AliEMCALCalibData;
47 // class AliCDBManager;
48 // class AliCDBStorage;
51 ClassImp(AliJetESDFillUnitArrayEMCalDigits)
53 //_____________________________________________________________________________
54 AliJetESDFillUnitArrayEMCalDigits::AliJetESDFillUnitArrayEMCalDigits()
55 : AliJetFillUnitArray(),
64 fApplyElectronCorrection(kFALSE),
65 fApplyFractionHadronicCorrection(kFALSE),
66 fFractionHadronicCorrection(0.3),
74 //_____________________________________________________________________________
75 AliJetESDFillUnitArrayEMCalDigits::AliJetESDFillUnitArrayEMCalDigits(AliESDEvent *esd)
76 : AliJetFillUnitArray(),
85 fApplyElectronCorrection(kFALSE),
86 fApplyFractionHadronicCorrection(kFALSE),
87 fFractionHadronicCorrection(0.3),
95 //_____________________________________________________________________________
96 AliJetESDFillUnitArrayEMCalDigits::AliJetESDFillUnitArrayEMCalDigits(const AliJetESDFillUnitArrayEMCalDigits &det)
97 : AliJetFillUnitArray(det),
101 fCluster(det.fCluster),
103 fNCEMCAL(det.fNCEMCAL),
104 fNCPHOS(det.fNCPHOS),
105 fNCCalo(det.fNCCalo),
106 fApplyElectronCorrection(det.fApplyElectronCorrection),
107 fApplyFractionHadronicCorrection(det.fApplyFractionHadronicCorrection),
108 fFractionHadronicCorrection(det.fFractionHadronicCorrection),
110 fNDigitEmcal(det.fNDigitEmcal),
111 fNDigitEmcalCut(det.fNDigitEmcalCut)
116 //_____________________________________________________________________________
117 AliJetESDFillUnitArrayEMCalDigits& AliJetESDFillUnitArrayEMCalDigits::operator=(const AliJetESDFillUnitArrayEMCalDigits& other)
124 fCluster = other.fCluster;
125 fDebug = other.fDebug;
126 fNCEMCAL = other.fNCEMCAL;
127 fNCPHOS = other.fNCPHOS;
128 fNCCalo = other.fNCCalo;
129 fApplyElectronCorrection = other.fApplyElectronCorrection;
130 fApplyFractionHadronicCorrection = other.fApplyFractionHadronicCorrection;
131 fFractionHadronicCorrection = other.fFractionHadronicCorrection;
133 fNDigitEmcal = other.fNDigitEmcal;
134 fNDigitEmcalCut = other.fNDigitEmcalCut;
140 //_____________________________________________________________________________
141 AliJetESDFillUnitArrayEMCalDigits::~AliJetESDFillUnitArrayEMCalDigits()
146 //_____________________________________________________________________________
147 void AliJetESDFillUnitArrayEMCalDigits::Exec(Option_t* const /*option*/)
151 // Fill the unit array with the neutral particle information from the EMCal cells in ESD
154 fDebug = fReaderHeader->GetDebug();
155 fOpt = fReaderHeader->GetDetector();
156 fCluster = fReaderHeader->GetCluster();
161 //(not used ?) Int_t nDigitTot = 0;
163 //(not used ?) Int_t beg = 0;
164 //(not used ?) Int_t end = 0;
166 //(not used ?) Int_t count = 0;
168 //(not used ?) Int_t nRefEnt = fRefArray->GetEntries();
170 if(!fCluster) { // Keep all digit information
171 // Loop over all cell information
172 //------------------------------------------------------------------
173 AliESDCaloCells &cells= *(fESD->GetEMCALCells());
174 Int_t ncell = cells.GetNumberOfCells() ;
175 //(not used ?) Int_t type = cells.GetType();
177 for (Int_t icell= 0; icell < ncell; icell++) {
178 Int_t digitID = cells.GetCellNumber(icell);
179 Float_t digitAmp = cells.GetAmplitude(icell);
180 //(not used ?) Float_t digitTime = cells.GetTime(icell);
181 Float_t digitEn = digitAmp*0.0153; // Last correct
182 // Float_t digitEn = Calibrate(digitAmp,digitID);
184 Float_t etaD=-10., phiD=-10.;
185 fGeom->EtaPhiFromIndex(digitID,etaD,phiD);
186 // fEMCalGrid->GetEtaPhiFromIndex2(digitID,phiD,etaD);
188 phiD = ((phiD < 0) ? phiD + 2.* TMath::Pi() : phiD);
190 Float_t digitEt = digitEn*TMath::Abs(TMath::Sin(EtaToTheta(etaD)));
192 AliJetUnitArray *uArray = (AliJetUnitArray*)fUnitArray->At(digitID);
194 if(uArray->GetUnitEnergy() == 0.) goodDigit++;
195 uArray->SetUnitTrackID(digitID);
197 Float_t unitEnergy = 0.;
199 unitEnergy = uArray->GetUnitEnergy();
203 new(fRefArray) TRefArray(TProcessID::GetProcessWithUID(uArray));
206 fRefArray->Add(uArray);
213 uArray->SetUnitDetectorFlag(kAll);
214 else uArray->SetUnitDetectorFlag(kEmcal);
216 uArray->SetUnitEnergy(unitEnergy+digitEt);
218 uArray->SetUnitCutFlag(kPtHigher);
220 // To be modified !!!
221 uArray->SetUnitSignalFlag(kGood);
223 // This is for jet multiplicity
224 uArray->SetUnitClusterID(index);
226 if(fDebug > 1) printf("goodDigit : %d\n", goodDigit);
228 } // End loop over cells
229 } // end if !fCluster
230 else { // Keep digit information from clusterization
232 // Loop over calo clusters
233 //------------------------------------------------------------------
235 //select EMCAL clusters only
236 TRefArray * caloClusters = new TRefArray();
237 fESD->GetEMCALClusters(caloClusters);
239 // Total number of EMCAL cluster
240 Int_t nclus = caloClusters->GetEntries() ;
244 // Get reconstructed vertex position
245 Double_t vertexPosition[3] ;
246 fESD->GetVertex()->GetXYZ(vertexPosition) ;
249 AliESDCaloCells &cells= *(fESD->GetEMCALCells());
250 //(not used ?) Int_t ncell = cells.GetNumberOfCells() ;
251 //(not used ?) Int_t type = cells.GetType();
253 for(Int_t j = beg; j < nclus; j++) { // loop over clusters
254 // Retrieve cluster from esd
255 fClus = (AliESDCaloCluster *) caloClusters->At(j) ;
257 // Get the cluster info
258 //(not used ?) Float_t energy = fClus->E() ;
259 //(not used ?) Int_t iprim = fClus->GetLabel();
261 fClus->GetPosition(pos) ;
262 TVector3 vpos(pos[0],pos[1],pos[2]) ;
264 fClus->GetMomentum(p,vertexPosition);
266 Int_t digMult = fClus->GetNCells() ;
267 UShort_t *digID = fClus->GetCellsAbsId() ;
268 //(not used ?) Double_t *digAmpFrac = fClus->GetCellsAmplitudeFraction() ;
269 Int_t trackIndex = fClus->GetTrackMatched();
271 // Do double-counted electron correction
272 if (fApplyElectronCorrection != 0 && trackIndex !=-1 )
274 // The electron correction go there
275 // Under construction !!!!
276 } // End of Electron correction
278 // Get CaloCells of cluster and fill the unitArray
279 for(Int_t i = 0; i < digMult ; i++){
280 Int_t digitID = digID[i]; // or clus->GetCellNumber(i) ;
281 //(not used ?) Double_t digitAmpFrac = digAmpFrac[i];
282 Float_t digitAmp = cells.GetCellAmplitude(digitID) ;
283 //(not used ?) Float_t digitTime = cells.GetCellTime(digitID);
285 // Calibration for an energy in GeV
286 Float_t digitEn = digitAmp*0.0153;
288 Float_t etaD=-10., phiD=-10.;
289 fGeom->EtaPhiFromIndex(digitID,etaD,phiD);
290 // fEMCalGrid->GetEtaPhiFromIndex2(digitID,phiD,etaD);
292 phiD = ((phiD < 0) ? phiD + 2.* TMath::Pi() : phiD);
294 Float_t digitEt = digitEn*TMath::Abs(TMath::Sin(EtaToTheta(etaD)));
296 cout << "Digit " << i << ", eta: " << etaD << ", phi: " << phiD << endl;
298 AliJetUnitArray *uArray = (AliJetUnitArray*)fUnitArray->At(digitID);
299 if(uArray->GetUnitEnergy() == 0.) goodDigit++;
300 uArray->SetUnitTrackID(digitID);
302 Float_t unitEnergy = 0.;
304 unitEnergy = uArray->GetUnitEnergy();
308 new(fRefArray) TRefArray(TProcessID::GetProcessWithUID(uArray));
311 fRefArray->Add(uArray);
318 uArray->SetUnitDetectorFlag(kAll);
319 else uArray->SetUnitDetectorFlag(kEmcal);
321 uArray->SetUnitEnergy(unitEnergy+digitEt);
323 uArray->SetUnitCutFlag(kPtHigher);
325 // To be modified !!!
326 uArray->SetUnitSignalFlag(kGood);
328 // This is for jet multiplicity
329 uArray->SetUnitClusterID(index);
331 if(fDebug > 12) printf("goodDigit : %d\n", goodDigit);
333 } // End loop over cells
334 } // End loop over clusters
341 printf("End of digits %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
342 printf("goodDigit : %d\n", goodDigit);
347 //____________________________________________________________________________
348 void AliJetESDFillUnitArrayEMCalDigits::GetCalibrationParameters()
350 // Set calibration parameters:
351 // if calibration database exists, they are read from database,
352 // otherwise, they are taken from digitizer.
354 // It is a user responsilibity to open CDB before reconstruction,
356 // AliCDBStorage* storage = AliCDBManager::Instance()->GetStorage("local://CalibDB");
358 //Check if calibration is stored in data base
360 if(!fCalibData && (AliCDBManager::Instance()->IsDefaultStorageSet()))
362 AliCDBEntry *entry = (AliCDBEntry*)
363 AliCDBManager::Instance()->Get("EMCAL/Calib/Data");
364 if (entry) fCalibData = (AliEMCALCalibData*) entry->GetObject();
368 printf("************* Calibration parameters not found in CDB! ****************");
369 // AliFatal("Calibration parameters not found in CDB!");
374 //____________________________________________________________________________
375 Float_t AliJetESDFillUnitArrayEMCalDigits::Calibrate(Int_t amp, Int_t AbsId)
378 // Convert digitized amplitude into energy.
379 // Calibration parameters are taken from calibration data base for raw data,
380 // or from digitizer parameters for simulated data.
385 printf("************* Did not get geometry from EMCALLoader ***************");
386 // AliFatal("Did not get geometry from EMCALLoader") ;
395 Bool_t bCell = fGeom->GetCellIndex(AbsId, iSupMod, nModule, nIphi, nIeta) ;
397 // fGeom->PrintGeometry();
398 Error("Calibrate()"," Wrong cell id number : %i", AbsId);
402 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,nModule,nIphi, nIeta,iphi,ieta);
404 fADCchannelECA = fCalibData->GetADCchannel (iSupMod,ieta,iphi);
405 fADCpedestalECA = fCalibData->GetADCpedestal(iSupMod,ieta,iphi);
407 return -fADCpedestalECA + amp * fADCchannelECA ;
410 else //Return energy with default parameters if calibration is not available
411 return -fADCpedestalECA + amp * fADCchannelECA ;