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