]>
Commit | Line | Data |
---|---|---|
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 | |
69db97f5 | 31 | #include "AliRun.h" |
5dee926e | 32 | #include "AliESD.h" |
33 | #include "AliRunLoader.h" | |
34 | #include "AliEMCALLoader.h" | |
98e9578e | 35 | #include "AliEMCALRawUtils.h" |
f6019cda | 36 | #include "AliEMCALClusterizerv1.h" |
5dee926e | 37 | #include "AliEMCALRecPoint.h" |
dc293ae9 | 38 | #include "AliEMCALPID.h" |
0964c2e9 | 39 | #include "AliEMCALTrigger.h" |
1d59832c | 40 | #include "AliRawReader.h" |
41 | ||
f6019cda | 42 | |
43 | ClassImp(AliEMCALReconstructor) | |
44 | ||
45 | //____________________________________________________________________________ | |
18a21c7c | 46 | AliEMCALReconstructor::AliEMCALReconstructor() |
47 | : fDebug(kFALSE) | |
f6019cda | 48 | { |
49 | // ctor | |
f6019cda | 50 | } |
51 | ||
0a4cb131 | 52 | //____________________________________________________________________________ |
18a21c7c | 53 | AliEMCALReconstructor::AliEMCALReconstructor(const AliEMCALReconstructor & rec) |
54 | : AliReconstructor(rec), | |
55 | fDebug(rec.fDebug) | |
0a4cb131 | 56 | { |
57 | //copy ctor | |
0a4cb131 | 58 | } |
f6019cda | 59 | |
60 | //____________________________________________________________________________ | |
61 | AliEMCALReconstructor::~AliEMCALReconstructor() | |
62 | { | |
63 | // dtor | |
64 | } | |
65 | ||
66 | //____________________________________________________________________________ | |
67 | void AliEMCALReconstructor::Reconstruct(AliRunLoader* runLoader) const | |
68 | { | |
69 | // method called by AliReconstruction; | |
70 | // Only the clusterization is performed,; the rest of the reconstruction is done in FillESD because the track | |
71 | // segment maker needs access to the AliESD object to retrieve the tracks reconstructed by | |
72 | // the global tracking. | |
73 | ||
74 | TString headerFile(runLoader->GetFileName()) ; | |
b4975670 | 75 | TString branchName(runLoader->GetEventFolder()->GetName() ) ; |
f6019cda | 76 | |
77 | AliEMCALClusterizerv1 clu(headerFile, branchName); | |
98e9578e | 78 | AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(runLoader->GetDetectorLoader("EMCAL")); |
79 | ||
80 | Int_t nEvents = runLoader->GetNumberOfEvents(); | |
81 | runLoader->LoadDigits("EMCAL"); | |
82 | for (Int_t ievent = 0; ievent < nEvents; ievent++) { | |
83 | runLoader->GetEvent(ievent); | |
84 | if ( Debug() ) | |
85 | clu.ExecuteTask("deb all") ; | |
86 | else | |
87 | clu.ExecuteTask("pseudo") ; | |
88 | } | |
89 | // Unload the Digits and RecPoints | |
90 | emcalLoader->UnloadDigits() ; | |
91 | emcalLoader->UnloadRecPoints() ; | |
f6019cda | 92 | } |
93 | ||
a68156e6 | 94 | //____________________________________________________________________________ |
98e9578e | 95 | void AliEMCALReconstructor::Reconstruct(AliRunLoader* runLoader, AliRawReader* rawReader) const |
96 | ||
a68156e6 | 97 | { |
98e9578e | 98 | // Reconstruction loop for Raw Data processing |
99 | // | |
100 | // Only the clusterization is performed | |
101 | // Track-cluster matching is done in FillESD because the track | |
102 | // segment maker needs access to the AliESD object to retrieve | |
103 | // the tracks reconstructed by the global tracking. | |
a68156e6 | 104 | |
a68156e6 | 105 | TString headerFile(runLoader->GetFileName()) ; |
106 | TString branchName(runLoader->GetEventFolder()->GetName()) ; | |
85c60a8e | 107 | |
98e9578e | 108 | static AliEMCALRawUtils rawUtils; |
a68156e6 | 109 | AliEMCALClusterizerv1 clu(headerFile, branchName); |
98e9578e | 110 | AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(runLoader->GetDetectorLoader("EMCAL")); |
111 | ||
112 | Int_t iEvent = 0; | |
113 | rawReader->Reset() ; | |
114 | while (rawReader->NextEvent()) { | |
115 | runLoader->GetEvent(iEvent++); | |
116 | ||
117 | rawUtils.Raw2Digits(rawReader); | |
118 | ||
119 | if ( Debug() ) | |
120 | clu.ExecuteTask("deb pseudo all") ; | |
121 | else | |
122 | clu.ExecuteTask("pseudo") ; | |
123 | // Unload the RecPoints | |
124 | emcalLoader->UnloadRecPoints() ; | |
125 | } | |
a68156e6 | 126 | } |
127 | ||
f6019cda | 128 | //____________________________________________________________________________ |
129 | void AliEMCALReconstructor::FillESD(AliRunLoader* runLoader, AliESD* esd) const | |
130 | { | |
98e9578e | 131 | // Called by AliReconstruct after Reconstruct() and global tracking and vertexing |
132 | const double timeScale = 1.e+11; // transition constant from sec to 0.01 ns | |
92da3372 | 133 | |
b4975670 | 134 | Int_t eventNumber = runLoader->GetEventNumber() ; |
135 | ||
85c60a8e | 136 | // Creates AliESDCaloCluster from AliEMCALRecPoints |
98e9578e | 137 | AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(runLoader->GetDetectorLoader("EMCAL")); |
138 | runLoader->LoadRecPoints("EMCAL"); | |
139 | runLoader->GetEvent(eventNumber); | |
5dee926e | 140 | TObjArray *clusters = emcalLoader->RecPoints(); |
a7a5421e | 141 | Int_t nClusters = clusters->GetEntries(), nClustersNew=0; |
98e9578e | 142 | AliDebug(1,Form("Event %d: %d clusters",eventNumber,nClusters)); |
5d9e7bd7 | 143 | // Int_t nRP=0, nPC=0; // in input |
a7a5421e | 144 | esd->SetFirstEMCALCluster(esd->GetNumberOfCaloClusters()); // Put after Phos clusters |
92da3372 | 145 | |
0964c2e9 | 146 | //#########Calculate trigger and set trigger info########### |
147 | ||
148 | AliEMCALTrigger tr ; | |
149 | // tr.SetPatchSize(1);//create 4x4 patches | |
150 | tr.Trigger(); | |
151 | ||
152 | Float_t maxAmp2x2 = tr.Get2x2MaxAmplitude(); | |
153 | Float_t maxAmpnxn = tr.GetnxnMaxAmplitude(); | |
154 | Float_t ampOutOfPatch2x2 = tr.Get2x2AmpOutOfPatch() ; | |
155 | Float_t ampOutOfPatchnxn = tr.GetnxnAmpOutOfPatch() ; | |
156 | ||
98e9578e | 157 | AliEMCALGeometry * geom = 0; |
158 | if (runLoader->GetAliRun() && runLoader->GetAliRun()->GetDetector("EMCAL")) | |
159 | geom = dynamic_cast<AliEMCAL*>(runLoader->GetAliRun()->GetDetector("EMCAL"))->GetGeometry(); | |
160 | if (geom == 0) | |
161 | geom = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaulGeometryName()); | |
162 | ||
0964c2e9 | 163 | Int_t iSM2x2 = tr.Get2x2SuperModule(); |
164 | Int_t iSMnxn = tr.GetnxnSuperModule(); | |
165 | Int_t iCellPhi2x2 = tr.Get2x2CellPhi(); | |
166 | Int_t iCellPhinxn = tr.GetnxnCellPhi(); | |
167 | Int_t iCellEta2x2 = tr.Get2x2CellEta(); | |
168 | Int_t iCellEtanxn = tr.GetnxnCellEta(); | |
169 | ||
170 | AliDebug(2, Form("Trigger 2x2 max amp %f, out amp %f, SM %d, iphi %d ieta %d", maxAmp2x2, ampOutOfPatch2x2, iSM2x2,iCellPhi2x2, iCellEta2x2)); | |
171 | AliDebug(2, Form("Trigger 4x4 max amp %f , out amp %f, SM %d, iphi %d, ieta %d", maxAmpnxn, ampOutOfPatchnxn, iSMnxn,iCellPhinxn, iCellEtanxn)); | |
172 | ||
173 | TVector3 pos2x2(-1,-1,-1); | |
174 | TVector3 posnxn(-1,-1,-1); | |
175 | ||
176 | Int_t iAbsId2x2 = geom->GetAbsCellIdFromCellIndexes( iSM2x2, iCellPhi2x2, iCellEta2x2) ; | |
177 | Int_t iAbsIdnxn = geom->GetAbsCellIdFromCellIndexes( iSMnxn, iCellPhinxn, iCellEtanxn) ; | |
178 | geom->GetGlobal(iAbsId2x2, pos2x2); | |
179 | geom->GetGlobal(iAbsIdnxn, posnxn); | |
180 | ||
181 | TArrayF triggerPosition(6); | |
182 | triggerPosition[0] = pos2x2(0) ; | |
183 | triggerPosition[1] = pos2x2(1) ; | |
184 | triggerPosition[2] = pos2x2(2) ; | |
185 | triggerPosition[3] = posnxn(0) ; | |
186 | triggerPosition[4] = posnxn(1) ; | |
187 | triggerPosition[5] = posnxn(2) ; | |
188 | ||
189 | TArrayF triggerAmplitudes(4); | |
190 | triggerAmplitudes[0] = maxAmp2x2 ; | |
191 | triggerAmplitudes[1] = ampOutOfPatch2x2 ; | |
192 | triggerAmplitudes[2] = maxAmpnxn ; | |
193 | triggerAmplitudes[3] = ampOutOfPatchnxn ; | |
194 | ||
195 | esd->AddEMCALTriggerPosition(triggerPosition); | |
196 | esd->AddEMCALTriggerAmplitudes(triggerAmplitudes); | |
197 | ||
198 | //###################################### | |
199 | ||
200 | //Fill CaloClusters | |
201 | ||
5dee926e | 202 | for (Int_t iClust = 0 ; iClust < nClusters ; iClust++) { |
203 | const AliEMCALRecPoint * clust = emcalLoader->RecPoint(iClust); | |
5d9e7bd7 | 204 | //if(clust->GetClusterType()== AliESDCaloCluster::kClusterv1) nRP++; else nPC++; |
85c60a8e | 205 | if (Debug()) clust->Print(); |
a7a5421e | 206 | // Get information from EMCAL reconstruction points |
85c60a8e | 207 | Float_t xyz[3]; |
5dee926e | 208 | TVector3 gpos; |
209 | clust->GetGlobalPosition(gpos); | |
f6019cda | 210 | for (Int_t ixyz=0; ixyz<3; ixyz++) |
5dee926e | 211 | xyz[ixyz] = gpos[ixyz]; |
92da3372 | 212 | |
85c60a8e | 213 | Int_t digitMult = clust->GetMultiplicity(); |
214 | UShort_t *amplList = new UShort_t[digitMult]; | |
215 | UShort_t *timeList = new UShort_t[digitMult]; | |
216 | UShort_t *digiList = new UShort_t[digitMult]; | |
217 | Float_t *amplFloat = clust->GetEnergiesList(); | |
218 | Float_t *timeFloat = clust->GetTimeList(); | |
219 | Int_t *digitInts = clust->GetAbsId(); | |
8a11aef1 | 220 | Float_t elipAxis[2]; |
92da3372 | 221 | clust->GetElipsAxis(elipAxis); |
85c60a8e | 222 | |
a7a5421e | 223 | // Convert Float_t* and Int_t* to UShort_t* to save memory |
224 | // Problem : we should recalculate a cluster characteristics when discard digit(s) | |
f1487f22 | 225 | Int_t newdigitMult = 0; |
92da3372 | 226 | for (Int_t iDigit=0; iDigit<digitMult; iDigit++) { |
98e9578e | 227 | if (amplFloat[iDigit] > 0) { |
a7a5421e | 228 | amplList[newdigitMult] = (UShort_t)(amplFloat[iDigit]*500); |
98e9578e | 229 | // Time in units of 0.01 ns = 10 ps |
230 | if(timeFloat[iDigit] < 65536./timeScale) | |
231 | timeList[newdigitMult] = (UShort_t)(timeFloat[iDigit]*timeScale); | |
232 | else | |
233 | timeList[newdigitMult] = 65535; | |
234 | digiList[newdigitMult] = (UShort_t)(digitInts[iDigit]); | |
235 | newdigitMult++; | |
92da3372 | 236 | } |
98e9578e | 237 | else if (clust->GetClusterType() != AliESDCaloCluster::kPseudoCluster) |
238 | Warning("FillESD()","Negative or 0 digit amplitude in cluster"); | |
92da3372 | 239 | } |
a7a5421e | 240 | |
241 | if(newdigitMult > 0) { // accept cluster if it has some digit | |
242 | nClustersNew++; | |
243 | if(newdigitMult != digitMult) { // some digits were deleted | |
244 | UShort_t *amplListNew = new UShort_t[newdigitMult]; | |
245 | UShort_t *timeListNew = new UShort_t[newdigitMult]; | |
246 | UShort_t *digiListNew = new UShort_t[newdigitMult]; | |
247 | for (Int_t iDigit=0; iDigit<newdigitMult; iDigit++) { | |
248 | amplListNew[iDigit] = amplList[iDigit]; | |
249 | timeListNew[iDigit] = timeList[iDigit]; | |
250 | digiListNew[iDigit] = digiList[iDigit]; | |
251 | } | |
252 | ||
253 | delete [] amplList; | |
254 | delete [] timeList; | |
255 | delete [] digiList; | |
256 | ||
257 | amplList = amplListNew; | |
258 | timeList = timeListNew; | |
259 | digiList = digiListNew; | |
260 | } | |
65721814 | 261 | |
262 | //Primaries | |
263 | Int_t primMult = 0; | |
264 | Int_t *primInts = clust->GetPrimaries(primMult); | |
265 | UShort_t *primList = new UShort_t[primMult]; | |
266 | for (Int_t ipr=0; ipr<primMult; ipr++) | |
267 | primList[ipr] = (UShort_t)(primInts[ipr]); | |
268 | ||
269 | ||
a7a5421e | 270 | // fills the ESDCaloCluster |
271 | AliESDCaloCluster * ec = new AliESDCaloCluster() ; | |
69db97f5 | 272 | ec->SetEMCAL(kTRUE); |
a7a5421e | 273 | ec->SetClusterType(clust->GetClusterType()); |
98e9578e | 274 | ec->SetGlobalPosition(xyz); |
275 | ec->SetClusterEnergy(clust->GetEnergy()); | |
276 | ||
a7a5421e | 277 | ec->SetNumberOfDigits(newdigitMult); |
278 | ec->SetDigitAmplitude(amplList); //energies | |
279 | ec->SetDigitTime(timeList); //times | |
280 | ec->SetDigitIndex(digiList); //indices | |
281 | if(clust->GetClusterType()== AliESDCaloCluster::kClusterv1){ | |
65721814 | 282 | ec->SetPrimaryIndex(clust->GetPrimaryIndex()); |
283 | ec->SetNumberOfPrimaries(primMult); //primary multiplicity | |
284 | ec->SetListOfPrimaries(primList); //primary List for a cluster | |
a7a5421e | 285 | ec->SetClusterDisp(clust->GetDispersion()); |
286 | ec->SetClusterChi2(-1); //not yet implemented | |
287 | ec->SetM02(elipAxis[0]*elipAxis[0]) ; | |
288 | ec->SetM20(elipAxis[1]*elipAxis[1]) ; | |
289 | ec->SetM11(-1) ; //not yet implemented | |
a7a5421e | 290 | } |
85c60a8e | 291 | // add the cluster to the esd object |
a7a5421e | 292 | esd->AddCaloCluster(ec); |
293 | delete ec; | |
294 | } else { // no new ESD cluster | |
295 | delete [] amplList; | |
296 | delete [] timeList; | |
297 | delete [] digiList; | |
298 | } | |
299 | } // cycle on clusters | |
300 | esd->SetNumberOfEMCALClusters(nClustersNew); | |
5d9e7bd7 | 301 | //if(nClustersNew != nClusters) |
302 | //printf(" ##### nClusters %i -> new %i ##### \n", nClusters, nClustersNew ); | |
dc293ae9 | 303 | |
dc293ae9 | 304 | //Fill ESDCaloCluster with PID weights |
dc293ae9 | 305 | AliEMCALPID *pid = new AliEMCALPID; |
306 | //pid->SetPrintInfo(kTRUE); | |
307 | pid->SetReconstructor(kTRUE); | |
308 | pid->RunPID(esd); | |
f6019cda | 309 | } |
dc293ae9 | 310 | |
98e9578e | 311 |