]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/AliEMCALLoader.cxx
remove EMCAL-specific alignment objects - obsolete
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALLoader.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15
16 /* $Id$ */
17
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. 
22 //                  
23 //  MvL Feb 2006:
24 //  The AliEMCALLoader now holds the TClonesArray and TObjArray for reading
25 //  Hits, Dgits, SDigits and RecPoints. Filling is managed in the GetEvent()
26 //  method.
27 //
28 //  Creation/writing of files is managed by the relevant parts of the 
29 //  reconstruction software (AliEMCALDigitiser etx)
30 //
31 //*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
32 //*--         Completely redesigned by Dmitri Peressounko March 2001  
33 //
34 //*-- YS June 2001 : renamed the original AliEMCALIndexToObject and make
35 //*--         systematic usage of TFolders without changing the interface
36 // 
37 //*-- Marco van Leeuwen, Jan 2006: complete revision to simplify reading
38 //*--         and fit better in general ALICE scheme
39 //
40 //////////////////////////////////////////////////////////////////////////////
41
42 // --- ROOT system ---
43 #include "TTree.h"
44
45 // --- Standard library ---
46
47 // --- AliRoot header files ---
48 #include "AliEMCALLoader.h"
49 #include "AliLog.h"
50 #include "AliCDBLocal.h"
51 #include "AliCDBStorage.h"
52 #include "AliCDBManager.h"
53 #include "AliEMCALHit.h"
54
55 ClassImp(AliEMCALLoader)
56   
57 const TString AliEMCALLoader::fgkECARecPointsBranchName("EMCALECARP");//Name for branch with ECA Reconstructed Points
58 AliEMCALCalibData* AliEMCALLoader::fgCalibData = 0; //calibation data
59
60 //____________________________________________________________________________ 
61 AliEMCALLoader::AliEMCALLoader()
62 {
63   //Default constructor for EMCAL Loader Class
64
65   fDebug = 0;
66   fHits = new TClonesArray("AliEMCALHit");
67   fDigits = new TClonesArray("AliEMCALDigit");
68   fSDigits = new TClonesArray("AliEMCALDigit");
69   fRecPoints = new TObjArray();
70 }
71
72 //____________________________________________________________________________ 
73 AliEMCALLoader::AliEMCALLoader(const Char_t *detname,const Char_t *eventfoldername):
74   AliLoader(detname,eventfoldername)
75 {
76   //Specific constructor for EMCAL Loader class
77
78   fDebug=0;
79   fHits = new TClonesArray("AliEMCALHit");
80   fDigits = new TClonesArray("AliEMCALDigit");
81   fSDigits = new TClonesArray("AliEMCALDigit");
82   fRecPoints = new TObjArray();
83 }
84
85 //____________________________________________________________________________
86 AliEMCALLoader::AliEMCALLoader(const AliEMCALLoader & obj):AliLoader(obj)
87 {
88   //copy ctor
89
90   fDebug = obj.fDebug;
91   fHits = obj.fHits;
92   fDigits = obj.fDigits;
93   fSDigits = obj.fSDigits;
94   fRecPoints = obj.fRecPoints;
95
96 }
97
98 //____________________________________________________________________________ 
99 AliEMCALLoader::~AliEMCALLoader()
100 {
101   // Disconnect trees and remove arrays
102   if (TreeH())
103     TreeH()->SetBranchAddress(fDetectorName,0);
104   if (TreeD())
105     TreeD()->SetBranchAddress(fDetectorName,0);
106   if (TreeS())
107     TreeS()->SetBranchAddress(fDetectorName,0);
108   if (TreeR())
109     TreeR()->SetBranchAddress(fgkECARecPointsBranchName,0);
110   delete fHits;
111   delete fDigits;
112   delete fSDigits;
113   delete fRecPoints;
114 }
115
116 //____________________________________________________________________________ 
117 AliEMCALCalibData* AliEMCALLoader::CalibData()
118
119   // Check if the instance of AliEMCALCalibData exists, and return it
120
121   if( !(AliCDBManager::Instance()->IsDefaultStorageSet()) ) 
122     fgCalibData=0x0;
123   
124   return fgCalibData;
125   
126 }
127
128 //____________________________________________________________________________ 
129 Int_t AliEMCALLoader::CalibrateRaw(Double_t energy, Int_t module, 
130                                    Int_t column, Int_t row)
131 {
132   // Convert energy into digitized amplitude for a cell relId
133   // It is a user responsilibity to open CDB and set
134   // AliEMCALCalibData object by the following operators:
135   // 
136   // AliCDBLocal *loc = new AliCDBLocal("deCalibDB");
137   // AliEMCALCalibData* clb = (AliEMCALCalibData*)AliCDBStorage::Instance()
138   //    ->Get(path_to_calibdata,run_number);
139   // AliEMCALGetter* gime = AliEMCALGetter::Instance("galice.root");
140   // gime->SetCalibData(clb);
141
142   if (CalibData() == 0)
143     Warning("CalibrateRaw","Calibration DB is not initiated!");
144
145   Float_t gainFactor = 0.00305;//0.0015; // width of one ADC channel in GeV
146   Float_t pedestal   = 0.009;//0.005;  // pedestals
147
148   if(CalibData()) {
149     gainFactor = CalibData()->GetADCchannel (module,column,row);
150     pedestal   = CalibData()->GetADCpedestal(module,column,row);
151   }
152   
153   Int_t   amp = static_cast<Int_t>( (energy - pedestal) / gainFactor + 0.5 ) ; 
154   return amp;
155 }
156
157 //____________________________________________________________________________ 
158 Int_t AliEMCALLoader::GetEvent() 
159 {
160   //Method to load all of the data
161   //members of the EMCAL for a given
162   //event from the Trees
163
164   AliLoader::GetEvent();  // First call AliLoader to do all the groundwork
165   
166   // Now connect and fill TClonesArray
167
168   // Hits
169    TTree *treeH = TreeH();
170    
171    if (treeH) {
172      Int_t nEnt = treeH->GetEntries();  // TreeH has array of hits for every primary
173      fHits->Clear();
174      Int_t index = 0;
175      TClonesArray *temp_arr = new TClonesArray("AliEMCALHit");
176      treeH->SetBranchAddress(fDetectorName,&temp_arr);
177      for (Int_t iEnt = 0; iEnt < nEnt; iEnt++) {
178        treeH->GetEntry(iEnt);
179        Int_t nHit = temp_arr->GetEntriesFast();
180        for (Int_t iHit = 0; iHit < nHit; iHit++) {
181          new ((*fHits)[index]) AliEMCALHit(*((AliEMCALHit*)temp_arr->At(iHit)));
182          index++;
183        }
184      }
185    }
186   
187    // SDigits
188    TTree *treeS = TreeS();
189    if (treeS) {
190      treeS->SetBranchAddress(fDetectorName,&fSDigits);
191      treeS->GetEvent(0);
192    }
193    
194    // Digits
195    TTree *treeD = TreeD();
196    if (treeD) {
197      treeD->SetBranchAddress(fDetectorName,&fDigits);
198      treeD->GetEvent(0);
199    }
200
201    // RecPoints
202    TTree *treeR = TreeR();
203    if (treeR) {
204      treeR->SetBranchAddress(fgkECARecPointsBranchName,&fRecPoints);
205      treeR->GetEvent(0);
206    }
207    
208    return 0;
209 }