]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALReconstructor.cxx
Removed debugging printf and unused variables
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALReconstructor.cxx
CommitLineData
f6019cda 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//*--
20//*-- Yves Schutz (SUBATECH)
21// Reconstruction class. Redesigned from the old AliReconstructionner class and
22// derived from STEER/AliReconstructor.
23//
24// --- ROOT system ---
25
26// --- Standard library ---
27
28// --- AliRoot header files ---
f6019cda 29#include "AliEMCALReconstructor.h"
5dee926e 30
31#include "AliESD.h"
32#include "AliRunLoader.h"
33#include "AliEMCALLoader.h"
f6019cda 34#include "AliEMCALClusterizerv1.h"
5dee926e 35#include "AliEMCALRecPoint.h"
dc293ae9 36#include "AliEMCALPID.h"
1d59832c 37#include "AliRawReader.h"
38
f6019cda 39
40ClassImp(AliEMCALReconstructor)
41
42//____________________________________________________________________________
18a21c7c 43AliEMCALReconstructor::AliEMCALReconstructor()
44 : fDebug(kFALSE)
f6019cda 45{
46 // ctor
f6019cda 47}
48
0a4cb131 49//____________________________________________________________________________
18a21c7c 50AliEMCALReconstructor::AliEMCALReconstructor(const AliEMCALReconstructor & rec)
51 : AliReconstructor(rec),
52 fDebug(rec.fDebug)
0a4cb131 53{
54 //copy ctor
0a4cb131 55}
f6019cda 56
57//____________________________________________________________________________
58AliEMCALReconstructor::~AliEMCALReconstructor()
59{
60 // dtor
61}
62
63//____________________________________________________________________________
64void AliEMCALReconstructor::Reconstruct(AliRunLoader* runLoader) const
65{
66 // method called by AliReconstruction;
67 // Only the clusterization is performed,; the rest of the reconstruction is done in FillESD because the track
68 // segment maker needs access to the AliESD object to retrieve the tracks reconstructed by
69 // the global tracking.
70
71 TString headerFile(runLoader->GetFileName()) ;
b4975670 72 TString branchName(runLoader->GetEventFolder()->GetName() ) ;
f6019cda 73
74 AliEMCALClusterizerv1 clu(headerFile, branchName);
75 clu.SetEventRange(0, -1) ; // do all the events
76 if ( Debug() )
77 clu.ExecuteTask("deb all") ;
78 else
85c60a8e 79 clu.ExecuteTask("pseudo") ;
80
f6019cda 81}
82
a68156e6 83//____________________________________________________________________________
5dee926e 84void AliEMCALReconstructor::Reconstruct(AliRunLoader* runLoader, AliRawReader* rawreader) const
a68156e6 85{
86 // method called by AliReconstruction;
87 // Only the clusterization is performed,; the rest of the reconstruction is done in FillESD because the track
88 // segment maker needs access to the AliESD object to retrieve the tracks reconstructed by
89 // the global tracking.
90 // Here we reconstruct from Raw Data
91
92 rawreader->Reset() ;
93 TString headerFile(runLoader->GetFileName()) ;
94 TString branchName(runLoader->GetEventFolder()->GetName()) ;
85c60a8e 95
a68156e6 96 AliEMCALClusterizerv1 clu(headerFile, branchName);
97 clu.SetEventRange(0, -1) ; // do all the events
98 if ( Debug() )
85c60a8e 99 clu.ExecuteTask("deb pseudo all") ;
a68156e6 100 else
85c60a8e 101 clu.ExecuteTask("pseudo") ;
a68156e6 102
103}
104
f6019cda 105//____________________________________________________________________________
106void AliEMCALReconstructor::FillESD(AliRunLoader* runLoader, AliESD* esd) const
107{
108 // Called by AliReconstruct after Reconstruct() and global tracking and vertxing
92da3372 109
b4975670 110 Int_t eventNumber = runLoader->GetEventNumber() ;
111
1963b290 112 TString headerFile(runLoader->GetFileName()) ;
113 TString branchName(runLoader->GetEventFolder()->GetName()) ;
85c60a8e 114 // Creates AliESDCaloCluster from AliEMCALRecPoints
5dee926e 115 AliRunLoader *rl = AliRunLoader::GetRunLoader();
116 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(rl->GetDetectorLoader("EMCAL"));
117 rl->LoadRecPoints();
92da3372 118 rl->LoadKinematics(); // To get the primary label
119 rl->LoadDigits(); // To get the primary label
120 rl->LoadHits(); // To get the primary label
5dee926e 121 rl->GetEvent(eventNumber);
122 TObjArray *clusters = emcalLoader->RecPoints();
a7a5421e 123 Int_t nClusters = clusters->GetEntries(), nClustersNew=0;
5d9e7bd7 124 // Int_t nRP=0, nPC=0; // in input
a7a5421e 125 esd->SetFirstEMCALCluster(esd->GetNumberOfCaloClusters()); // Put after Phos clusters
126 // esd->SetNumberOfEMCALClusters(nClusters); // have to be change - Feb 25, 2007; some cluster may be discard
92da3372 127
5dee926e 128 for (Int_t iClust = 0 ; iClust < nClusters ; iClust++) {
129 const AliEMCALRecPoint * clust = emcalLoader->RecPoint(iClust);
5d9e7bd7 130 //if(clust->GetClusterType()== AliESDCaloCluster::kClusterv1) nRP++; else nPC++;
85c60a8e 131 if (Debug()) clust->Print();
a7a5421e 132 // Get information from EMCAL reconstruction points
85c60a8e 133 Float_t xyz[3];
5dee926e 134 TVector3 gpos;
135 clust->GetGlobalPosition(gpos);
f6019cda 136 for (Int_t ixyz=0; ixyz<3; ixyz++)
5dee926e 137 xyz[ixyz] = gpos[ixyz];
92da3372 138
85c60a8e 139 Int_t digitMult = clust->GetMultiplicity();
140 UShort_t *amplList = new UShort_t[digitMult];
141 UShort_t *timeList = new UShort_t[digitMult];
142 UShort_t *digiList = new UShort_t[digitMult];
143 Float_t *amplFloat = clust->GetEnergiesList();
144 Float_t *timeFloat = clust->GetTimeList();
145 Int_t *digitInts = clust->GetAbsId();
8a11aef1 146 Float_t elipAxis[2];
92da3372 147 clust->GetElipsAxis(elipAxis);
85c60a8e 148
a7a5421e 149 // Convert Float_t* and Int_t* to UShort_t* to save memory
150 // Problem : we should recalculate a cluster characteristics when discard digit(s)
151 Int_t newdigitMult = 0;
92da3372 152 for (Int_t iDigit=0; iDigit<digitMult; iDigit++) {
a7a5421e 153 if(timeFloat[iDigit] < 65536/1e9*100) {
154 amplList[newdigitMult] = (UShort_t)(amplFloat[iDigit]*500);
155 if(amplList[newdigitMult] > 0) { // accept digit if poztive amplitude
156 timeList[newdigitMult] = (UShort_t)(timeFloat[iDigit]*1e9*100); // Time in units of 100 ns = 0.1 ps
157 digiList[newdigitMult] = (UShort_t)(digitInts[iDigit]);
158 newdigitMult++;
159 }
92da3372 160 }
92da3372 161 }
a7a5421e 162
163 if(newdigitMult > 0) { // accept cluster if it has some digit
164 nClustersNew++;
165 if(newdigitMult != digitMult) { // some digits were deleted
166 UShort_t *amplListNew = new UShort_t[newdigitMult];
167 UShort_t *timeListNew = new UShort_t[newdigitMult];
168 UShort_t *digiListNew = new UShort_t[newdigitMult];
169 for (Int_t iDigit=0; iDigit<newdigitMult; iDigit++) {
170 amplListNew[iDigit] = amplList[iDigit];
171 timeListNew[iDigit] = timeList[iDigit];
172 digiListNew[iDigit] = digiList[iDigit];
173 }
174
175 delete [] amplList;
176 delete [] timeList;
177 delete [] digiList;
178
179 amplList = amplListNew;
180 timeList = timeListNew;
181 digiList = digiListNew;
182 }
183 // fills the ESDCaloCluster
184 AliESDCaloCluster * ec = new AliESDCaloCluster() ;
185 ec->SetClusterType(clust->GetClusterType());
186 ec->SetGlobalPosition(xyz);
187 ec->SetClusterEnergy(clust->GetEnergy());
188
189 ec->SetNumberOfDigits(newdigitMult);
190 ec->SetDigitAmplitude(amplList); //energies
191 ec->SetDigitTime(timeList); //times
192 ec->SetDigitIndex(digiList); //indices
193 if(clust->GetClusterType()== AliESDCaloCluster::kClusterv1){
194 ec->SetClusterDisp(clust->GetDispersion());
195 ec->SetClusterChi2(-1); //not yet implemented
196 ec->SetM02(elipAxis[0]*elipAxis[0]) ;
197 ec->SetM20(elipAxis[1]*elipAxis[1]) ;
198 ec->SetM11(-1) ; //not yet implemented
199 ec->SetPrimaryIndex(clust->GetPrimaryIndex());
200 }
85c60a8e 201 // add the cluster to the esd object
a7a5421e 202 esd->AddCaloCluster(ec);
203 delete ec;
204 } else { // no new ESD cluster
205 delete [] amplList;
206 delete [] timeList;
207 delete [] digiList;
208 }
209 } // cycle on clusters
d948db41 210 // printf(" %i : nClusters %i : RP %i PC %i \n", eventNumber, nClusters, nRP, nPC);
a7a5421e 211 esd->SetNumberOfEMCALClusters(nClustersNew);
5d9e7bd7 212 //if(nClustersNew != nClusters)
213 //printf(" ##### nClusters %i -> new %i ##### \n", nClusters, nClustersNew );
dc293ae9 214
dc293ae9 215 //Fill ESDCaloCluster with PID weights
dc293ae9 216 AliEMCALPID *pid = new AliEMCALPID;
217 //pid->SetPrintInfo(kTRUE);
218 pid->SetReconstructor(kTRUE);
219 pid->RunPID(esd);
f6019cda 220}
dc293ae9 221