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 //_________________________________________________________________________
19 // A singleton. This class should be used in the analysis stage to get
20 // reconstructed objects: Digits, RecPoints, TrackSegments and RecParticles,
21 // instead of directly reading them from galice.root file.
24 // The AliEMCALLoader now holds the TClonesArray and TObjArray for reading
25 // Hits, Dgits, SDigits and RecPoints. Filling is managed in the GetEvent()
28 // Creation/writing of files is managed by the relevant parts of the
29 // reconstruction software (AliEMCALDigitiser etx)
31 //*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
32 //*-- Completely redesigned by Dmitri Peressounko March 2001
34 //*-- YS June 2001 : renamed the original AliEMCALIndexToObject and make
35 //*-- systematic usage of TFolders without changing the interface
37 //*-- Marco van Leeuwen, Jan 2006: complete revision to simplify reading
38 //*-- and fit better in general ALICE scheme
40 //////////////////////////////////////////////////////////////////////////////
42 // --- ROOT system ---
46 // --- Standard library ---
48 // --- AliRoot header files ---
49 #include "AliEMCALLoader.h"
51 #include "AliCDBLocal.h"
52 #include "AliCDBStorage.h"
53 #include "AliCDBManager.h"
54 #include "AliCDBEntry.h"
55 #include "AliEMCALHit.h"
57 ClassImp(AliEMCALLoader)
59 const TString AliEMCALLoader::fgkECARecPointsBranchName("EMCALECARP");//Name for branch with ECA Reconstructed Points
60 AliEMCALCalibData* AliEMCALLoader::fgCalibData = 0; //calibation data
61 AliEMCALRecParam * AliEMCALLoader::fgRecParam = 0; //reconstruction parameters
63 //____________________________________________________________________________
64 AliEMCALLoader::AliEMCALLoader()
71 //Default constructor for EMCAL Loader Class
74 fHits = new TClonesArray("AliEMCALHit");
75 fDigits = new TClonesArray("AliEMCALDigit");
76 fSDigits = new TClonesArray("AliEMCALDigit");
77 fRecPoints = new TObjArray();
80 //____________________________________________________________________________
81 AliEMCALLoader::AliEMCALLoader(const Char_t *detname,const Char_t *eventfoldername)
82 : AliLoader(detname,eventfoldername),
89 //Specific constructor for EMCAL Loader class
92 fHits = new TClonesArray("AliEMCALHit");
93 fDigits = new TClonesArray("AliEMCALDigit");
94 fSDigits = new TClonesArray("AliEMCALDigit");
95 fRecPoints = new TObjArray();
98 //____________________________________________________________________________
99 AliEMCALLoader::AliEMCALLoader(const Char_t *name, TFolder *topfolder)
100 : AliLoader(name,topfolder),
107 //Specific constructor for EMCAL Loader class
110 fHits = new TClonesArray("AliEMCALHit");
111 fDigits = new TClonesArray("AliEMCALDigit");
112 fSDigits = new TClonesArray("AliEMCALDigit");
113 fRecPoints = new TObjArray();
116 //____________________________________________________________________________
117 AliEMCALLoader::AliEMCALLoader(const AliEMCALLoader & obj)
121 fDigits(obj.fDigits),
122 fSDigits(obj.fSDigits),
123 fRecPoints(obj.fRecPoints)
128 //____________________________________________________________________________
129 AliEMCALLoader::~AliEMCALLoader()
131 // Disconnect trees and remove arrays
133 TreeH()->SetBranchAddress(fDetectorName,0);
135 TreeD()->SetBranchAddress(fDetectorName,0);
137 TreeS()->SetBranchAddress(fDetectorName,0);
139 TreeR()->SetBranchAddress(fgkECARecPointsBranchName,0);
149 //____________________________________________________________________________
150 AliEMCALCalibData* AliEMCALLoader::CalibData()
152 // Check if the instance of AliEMCALCalibData exists, if not, create it if
153 // the OCDB is available, and finally return it.
155 if(!fgCalibData && (AliCDBManager::Instance()->IsDefaultStorageSet()))
157 AliCDBEntry *entry = (AliCDBEntry*)
158 AliCDBManager::Instance()->Get("EMCAL/Calib/Data");
159 if (entry) fgCalibData = (AliEMCALCalibData*) entry->GetObject();
163 AliFatal("Calibration parameters not found in CDB!");
169 //____________________________________________________________________________
170 AliEMCALRecParam* AliEMCALLoader::RecParam()
172 // Check if the instance of AliEMCALRecParam exists, if not, create it if
173 // the OCDB is available, and finally return it.
175 if(!fgRecParam && (AliCDBManager::Instance()->IsDefaultStorageSet())) {
176 AliCDBEntry *entry = (AliCDBEntry*)
177 AliCDBManager::Instance()->Get("EMCAL/Config/RecParam/");
178 if (entry) fgRecParam = (AliEMCALRecParam*) entry->GetObject();
182 AliWarning("Recostruction parameters not found in CDB!");
188 //____________________________________________________________________________
189 Int_t AliEMCALLoader::CalibrateRaw(Double_t energy, Int_t module,
190 Int_t column, Int_t row)
192 // Convert energy into digitized amplitude for a cell relId
193 // It is a user responsilibity to open CDB and set
194 // AliEMCALCalibData object by the following operators:
196 // AliCDBLocal *loc = new AliCDBLocal("deCalibDB");
197 // AliEMCALCalibData* clb = (AliEMCALCalibData*)AliCDBStorage::Instance()
198 // ->Get(path_to_calibdata,run_number);
199 // AliEMCALGetter* gime = AliEMCALGetter::Instance("galice.root");
200 // gime->SetCalibData(clb);
202 if (CalibData() == 0)
203 Warning("CalibrateRaw","Calibration DB is not initiated!");
205 Float_t gainFactor = 0.00305;//0.0015; // width of one ADC channel in GeV
206 Float_t pedestal = 0.009;//0.005; // pedestals
209 gainFactor = CalibData()->GetADCchannel (module,column,row);
210 pedestal = CalibData()->GetADCpedestal(module,column,row);
213 Int_t amp = static_cast<Int_t>( (energy - pedestal) / gainFactor + 0.5 ) ;
217 //____________________________________________________________________________
218 Int_t AliEMCALLoader::GetEvent()
220 //Method to load all of the data
221 //members of the EMCAL for a given
222 //event from the Trees
224 AliLoader::GetEvent(); // First call AliLoader to do all the groundwork
226 // Now connect and fill TClonesArray
229 TTree *treeH = TreeH();
232 Int_t nEnt = treeH->GetEntries(); // TreeH has array of hits for every primary
235 TClonesArray *tempArr = 0x0;
236 TBranch * branchH = treeH->GetBranch(fDetectorName);
237 branchH->SetAddress(&tempArr);
238 for (Int_t iEnt = 0; iEnt < nEnt; iEnt++) {
239 treeH->GetEntry(iEnt);
240 Int_t nHit = tempArr->GetEntriesFast();
241 for (Int_t iHit = 0; iHit < nHit; iHit++) {
242 new ((*fHits)[index]) AliEMCALHit(*((AliEMCALHit*)tempArr->At(iHit)));
246 branchH->ResetAddress();
254 TTree *treeS = TreeS();
256 TBranch * branchS = treeS->GetBranch(fDetectorName);
257 branchS->ResetAddress();
261 branchS->SetAddress(&fSDigits);
266 TTree *treeD = TreeD();
268 TBranch * branchD = treeD->GetBranch(fDetectorName);
269 branchD->ResetAddress();
273 branchD->SetAddress(&fDigits);
278 TTree *treeR = TreeR();
280 TBranch * branchR = treeR->GetBranch(fgkECARecPointsBranchName);
281 branchR->ResetAddress();
285 branchR->SetAddress(&fRecPoints);