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 "AliEMCALHit.h"
56 ClassImp(AliEMCALLoader)
58 const TString AliEMCALLoader::fgkECARecPointsBranchName("EMCALECARP");//Name for branch with ECA Reconstructed Points
59 AliEMCALCalibData* AliEMCALLoader::fgCalibData = 0; //calibation data
61 //____________________________________________________________________________
62 AliEMCALLoader::AliEMCALLoader()
69 //Default constructor for EMCAL Loader Class
72 fHits = new TClonesArray("AliEMCALHit");
73 fDigits = new TClonesArray("AliEMCALDigit");
74 fSDigits = new TClonesArray("AliEMCALDigit");
75 fRecPoints = new TObjArray();
78 //____________________________________________________________________________
79 AliEMCALLoader::AliEMCALLoader(const Char_t *detname,const Char_t *eventfoldername)
80 : AliLoader(detname,eventfoldername),
87 //Specific constructor for EMCAL Loader class
90 fHits = new TClonesArray("AliEMCALHit");
91 fDigits = new TClonesArray("AliEMCALDigit");
92 fSDigits = new TClonesArray("AliEMCALDigit");
93 fRecPoints = new TObjArray();
96 //____________________________________________________________________________
97 AliEMCALLoader::AliEMCALLoader(const AliEMCALLoader & obj)
101 fDigits(obj.fDigits),
102 fSDigits(obj.fSDigits),
103 fRecPoints(obj.fRecPoints)
108 //____________________________________________________________________________
109 AliEMCALLoader::~AliEMCALLoader()
111 // Disconnect trees and remove arrays
113 TreeH()->SetBranchAddress(fDetectorName,0);
115 TreeD()->SetBranchAddress(fDetectorName,0);
117 TreeS()->SetBranchAddress(fDetectorName,0);
119 TreeR()->SetBranchAddress(fgkECARecPointsBranchName,0);
129 //____________________________________________________________________________
130 AliEMCALCalibData* AliEMCALLoader::CalibData()
132 // Check if the instance of AliEMCALCalibData exists, and return it
134 if( !(AliCDBManager::Instance()->IsDefaultStorageSet()) )
141 //____________________________________________________________________________
142 Int_t AliEMCALLoader::CalibrateRaw(Double_t energy, Int_t module,
143 Int_t column, Int_t row)
145 // Convert energy into digitized amplitude for a cell relId
146 // It is a user responsilibity to open CDB and set
147 // AliEMCALCalibData object by the following operators:
149 // AliCDBLocal *loc = new AliCDBLocal("deCalibDB");
150 // AliEMCALCalibData* clb = (AliEMCALCalibData*)AliCDBStorage::Instance()
151 // ->Get(path_to_calibdata,run_number);
152 // AliEMCALGetter* gime = AliEMCALGetter::Instance("galice.root");
153 // gime->SetCalibData(clb);
155 if (CalibData() == 0)
156 Warning("CalibrateRaw","Calibration DB is not initiated!");
158 Float_t gainFactor = 0.00305;//0.0015; // width of one ADC channel in GeV
159 Float_t pedestal = 0.009;//0.005; // pedestals
162 gainFactor = CalibData()->GetADCchannel (module,column,row);
163 pedestal = CalibData()->GetADCpedestal(module,column,row);
166 Int_t amp = static_cast<Int_t>( (energy - pedestal) / gainFactor + 0.5 ) ;
170 //____________________________________________________________________________
171 Int_t AliEMCALLoader::GetEvent()
173 //Method to load all of the data
174 //members of the EMCAL for a given
175 //event from the Trees
177 AliLoader::GetEvent(); // First call AliLoader to do all the groundwork
179 // Now connect and fill TClonesArray
182 TTree *treeH = TreeH();
185 Int_t nEnt = treeH->GetEntries(); // TreeH has array of hits for every primary
188 TClonesArray *tempArr = 0x0;
189 TBranch * branchH = treeH->GetBranch(fDetectorName);
190 branchH->SetAddress(&tempArr);
191 for (Int_t iEnt = 0; iEnt < nEnt; iEnt++) {
192 treeH->GetEntry(iEnt);
193 Int_t nHit = tempArr->GetEntriesFast();
194 for (Int_t iHit = 0; iHit < nHit; iHit++) {
195 new ((*fHits)[index]) AliEMCALHit(*((AliEMCALHit*)tempArr->At(iHit)));
199 branchH->ResetAddress();
207 TTree *treeS = TreeS();
209 TBranch * branchS = treeS->GetBranch(fDetectorName);
210 branchS->ResetAddress();
216 branchS->SetAddress(&fSDigits);
221 TTree *treeD = TreeD();
223 TBranch * branchD = treeD->GetBranch(fDetectorName);
224 branchD->ResetAddress();
230 branchD->SetAddress(&fDigits);
235 TTree *treeR = TreeR();
237 TBranch * branchR = treeR->GetBranch(fgkECARecPointsBranchName);
238 branchR->ResetAddress();
240 fRecPoints->Delete();
244 branchR->SetAddress(&fRecPoints);