]>
Commit | Line | Data |
---|---|---|
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 --- | |
29 | #include "AliEMCALReconstructor.h" | |
30 | ||
31 | #include "AliCodeTimer.h" | |
32 | #include "AliESDEvent.h" | |
33 | #include "AliESDCaloCluster.h" | |
34 | #include "AliESDCaloCells.h" | |
35 | #include "AliESDtrack.h" | |
36 | #include "AliEMCALLoader.h" | |
37 | #include "AliEMCALRawUtils.h" | |
38 | #include "AliEMCALDigit.h" | |
39 | #include "AliEMCALClusterizerv1.h" | |
40 | #include "AliEMCALRecPoint.h" | |
41 | #include "AliEMCALPID.h" | |
42 | #include "AliEMCALTrigger.h" | |
43 | #include "AliRawReader.h" | |
44 | #include "AliCDBEntry.h" | |
45 | #include "AliCDBManager.h" | |
46 | #include "AliEMCALRecParam.h" | |
47 | // to be removed - it is here just because of geom | |
48 | #include "AliRun.h" | |
49 | #include "AliRunLoader.h" | |
50 | ||
51 | ClassImp(AliEMCALReconstructor) | |
52 | ||
53 | AliEMCALRecParam* AliEMCALReconstructor::fgkRecParam = 0; // EMCAL rec. parameters | |
54 | ||
55 | //____________________________________________________________________________ | |
56 | AliEMCALReconstructor::AliEMCALReconstructor() | |
57 | : fDebug(kFALSE) | |
58 | { | |
59 | // ctor | |
60 | ||
61 | } | |
62 | ||
63 | //____________________________________________________________________________ | |
64 | AliEMCALReconstructor::AliEMCALReconstructor(const AliEMCALReconstructor & rec) | |
65 | : AliReconstructor(rec), | |
66 | fDebug(rec.fDebug) | |
67 | { | |
68 | //copy ctor | |
69 | } | |
70 | ||
71 | //____________________________________________________________________________ | |
72 | AliEMCALReconstructor::~AliEMCALReconstructor() | |
73 | { | |
74 | // dtor | |
75 | ||
76 | AliCodeTimer::Instance()->Print(); | |
77 | } | |
78 | ||
79 | //____________________________________________________________________________ | |
80 | void AliEMCALReconstructor::InitRecParam() const | |
81 | { | |
82 | // Check if the instance of AliEMCALRecParam exists, | |
83 | // if not, get it from OCDB if available, otherwise create a default one | |
84 | ||
85 | if (!fgkRecParam && (AliCDBManager::Instance()->IsDefaultStorageSet())) { | |
86 | AliCDBEntry *entry = (AliCDBEntry*) | |
87 | AliCDBManager::Instance()->Get("EMCAL/Config/RecParam"); | |
88 | if (entry) fgkRecParam = (AliEMCALRecParam*) entry->GetObject(); | |
89 | } | |
90 | ||
91 | if(!fgkRecParam){ | |
92 | AliWarning("The Reconstruction parameters for EMCAL nonitialized - Used default one"); | |
93 | fgkRecParam = new AliEMCALRecParam; | |
94 | } | |
95 | } | |
96 | ||
97 | //____________________________________________________________________________ | |
98 | void AliEMCALReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const | |
99 | { | |
100 | // method called by AliReconstruction; | |
101 | // Only the clusterization is performed,; the rest of the reconstruction is done in FillESD because the track | |
102 | // segment maker needs access to the AliESD object to retrieve the tracks reconstructed by | |
103 | // the global tracking. | |
104 | // Works on the current event. | |
105 | ||
106 | AliCodeTimerAuto("") | |
107 | ||
108 | InitRecParam(); | |
109 | AliEMCALClusterizerv1 clu; | |
110 | clu.SetInput(digitsTree); | |
111 | clu.SetOutput(clustersTree); | |
112 | if(Debug()) | |
113 | clu.Digits2Clusters("deb all") ; | |
114 | else | |
115 | clu.Digits2Clusters("") ; | |
116 | ||
117 | } | |
118 | ||
119 | //____________________________________________________________________________ | |
120 | void AliEMCALReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const | |
121 | ||
122 | { | |
123 | // Conversion from raw data to | |
124 | // EMCAL digits. | |
125 | // Works on a single-event basis | |
126 | ||
127 | ||
128 | AliCodeTimerAuto("") | |
129 | ||
130 | rawReader->Reset() ; | |
131 | ||
132 | TClonesArray *digitsArr = new TClonesArray("AliEMCALDigit",100); | |
133 | Int_t bufsize = 32000; | |
134 | digitsTree->Branch("EMCAL", &digitsArr, bufsize); | |
135 | ||
136 | //Get Mapping RCU files from the AliEMCALRecParam | |
137 | const TObjArray* maps = AliEMCALRecParam::GetMappings(); | |
138 | if(!maps) AliFatal("Cannot retrieve ALTRO mappings!!"); | |
139 | ||
140 | AliAltroMapping * mapping[2] ; // For the moment only 2 | |
141 | for(Int_t i = 0; i < 2; i++) { | |
142 | mapping[i] = (AliAltroMapping*)maps->At(i); | |
143 | } | |
144 | ||
145 | static AliEMCALRawUtils rawUtils; | |
146 | rawUtils.SetOption(GetOption()); | |
147 | rawUtils.Raw2Digits(rawReader,digitsArr,mapping); | |
148 | ||
149 | digitsTree->Fill(); | |
150 | digitsArr->Delete(); | |
151 | delete digitsArr; | |
152 | ||
153 | } | |
154 | ||
155 | //____________________________________________________________________________ | |
156 | void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree, | |
157 | AliESDEvent* esd) const | |
158 | { | |
159 | // Called by AliReconstruct after Reconstruct() and global tracking and vertexing | |
160 | // Works on the current event | |
161 | // Creates AliESDCaloCluster from AliEMCALRecPoints | |
162 | // and AliESDCaloCells from AliEMCALDigits | |
163 | // Also, fills ESD with calorimeter trigger information | |
164 | ||
165 | //###################################################### | |
166 | //#########Calculate trigger and set trigger info########### | |
167 | //###################################################### | |
168 | ||
169 | AliCodeTimerStart(Form("JLK trigger info")); | |
170 | AliEMCALTrigger tr ; | |
171 | // tr.SetPatchSize(1);//create 4x4 patches | |
172 | tr.Trigger(); | |
173 | ||
174 | Float_t maxAmp2x2 = tr.Get2x2MaxAmplitude(); | |
175 | Float_t maxAmpnxn = tr.GetnxnMaxAmplitude(); | |
176 | Float_t ampOutOfPatch2x2 = tr.Get2x2AmpOutOfPatch() ; | |
177 | Float_t ampOutOfPatchnxn = tr.GetnxnAmpOutOfPatch() ; | |
178 | ||
179 | AliEMCALGeometry * geom = 0; | |
180 | AliRunLoader *runLoader = AliRunLoader::GetRunLoader(); | |
181 | if (runLoader->GetAliRun() && runLoader->GetAliRun()->GetDetector("EMCAL")) | |
182 | geom = dynamic_cast<AliEMCAL*>(runLoader->GetAliRun()->GetDetector("EMCAL"))->GetGeometry(); | |
183 | if (geom == 0) | |
184 | geom = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaulGeometryName()); | |
185 | ||
186 | Int_t iSM2x2 = tr.Get2x2SuperModule(); | |
187 | Int_t iSMnxn = tr.GetnxnSuperModule(); | |
188 | Int_t iCellPhi2x2 = tr.Get2x2CellPhi(); | |
189 | Int_t iCellPhinxn = tr.GetnxnCellPhi(); | |
190 | Int_t iCellEta2x2 = tr.Get2x2CellEta(); | |
191 | Int_t iCellEtanxn = tr.GetnxnCellEta(); | |
192 | ||
193 | AliDebug(2, Form("Trigger 2x2 max amp %f, out amp %f, SM %d, iphi %d ieta %d", maxAmp2x2, ampOutOfPatch2x2, iSM2x2,iCellPhi2x2, iCellEta2x2)); | |
194 | AliDebug(2, Form("Trigger 4x4 max amp %f , out amp %f, SM %d, iphi %d, ieta %d", maxAmpnxn, ampOutOfPatchnxn, iSMnxn,iCellPhinxn, iCellEtanxn)); | |
195 | ||
196 | TVector3 pos2x2(-1,-1,-1); | |
197 | TVector3 posnxn(-1,-1,-1); | |
198 | ||
199 | Int_t iAbsId2x2 = geom->GetAbsCellIdFromCellIndexes( iSM2x2, iCellPhi2x2, iCellEta2x2) ; | |
200 | Int_t iAbsIdnxn = geom->GetAbsCellIdFromCellIndexes( iSMnxn, iCellPhinxn, iCellEtanxn) ; | |
201 | geom->GetGlobal(iAbsId2x2, pos2x2); | |
202 | geom->GetGlobal(iAbsIdnxn, posnxn); | |
203 | ||
204 | TArrayF triggerPosition(6); | |
205 | triggerPosition[0] = pos2x2(0) ; | |
206 | triggerPosition[1] = pos2x2(1) ; | |
207 | triggerPosition[2] = pos2x2(2) ; | |
208 | triggerPosition[3] = posnxn(0) ; | |
209 | triggerPosition[4] = posnxn(1) ; | |
210 | triggerPosition[5] = posnxn(2) ; | |
211 | ||
212 | TArrayF triggerAmplitudes(4); | |
213 | triggerAmplitudes[0] = maxAmp2x2 ; | |
214 | triggerAmplitudes[1] = ampOutOfPatch2x2 ; | |
215 | triggerAmplitudes[2] = maxAmpnxn ; | |
216 | triggerAmplitudes[3] = ampOutOfPatchnxn ; | |
217 | ||
218 | esd->AddEMCALTriggerPosition(triggerPosition); | |
219 | esd->AddEMCALTriggerAmplitudes(triggerAmplitudes); | |
220 | ||
221 | AliCodeTimerStop(Form("JLK trigger info")); | |
222 | ||
223 | //######################################## | |
224 | //##############Fill CaloCells############### | |
225 | //######################################## | |
226 | ||
227 | AliCodeTimerStart(Form("JLK fill calocells")); | |
228 | ||
229 | TClonesArray *digits = new TClonesArray("AliEMCALDigit",1000); | |
230 | TBranch *branchdig = digitsTree->GetBranch("EMCAL"); | |
231 | if (!branchdig) { | |
232 | AliError("can't get the branch with the PHOS digits !"); | |
233 | return; | |
234 | } | |
235 | branchdig->SetAddress(&digits); | |
236 | digitsTree->GetEvent(0); | |
237 | Int_t nDigits = digits->GetEntries(), idignew = 0 ; | |
238 | AliDebug(1,Form("%d digits",nDigits)); | |
239 | ||
240 | AliESDCaloCells &emcCells = *(esd->GetEMCALCells()); | |
241 | emcCells.CreateContainer(nDigits); | |
242 | emcCells.SetType(AliESDCaloCells::kEMCALCell); | |
243 | for (Int_t idig = 0 ; idig < nDigits ; idig++) { | |
244 | const AliEMCALDigit * dig = (const AliEMCALDigit*)digits->At(idig); | |
245 | if(dig->GetAmp() > 0 ){ | |
246 | emcCells.SetCell(idignew,dig->GetId(),dig->GetAmp(), dig->GetTime()); | |
247 | idignew++; | |
248 | } | |
249 | } | |
250 | emcCells.SetNumberOfCells(idignew); | |
251 | emcCells.Sort(); | |
252 | ||
253 | AliCodeTimerStop(Form("JLK fill calocells")); | |
254 | ||
255 | //------------------------------------------------------------ | |
256 | //-----------------CLUSTERS----------------------------- | |
257 | //------------------------------------------------------------ | |
258 | TObjArray *clusters = new TObjArray(100); | |
259 | TBranch *branch = clustersTree->GetBranch("EMCALECARP"); | |
260 | branch->SetAddress(&clusters); | |
261 | clustersTree->GetEvent(0); | |
262 | ||
263 | Int_t nClusters = clusters->GetEntries(), nClustersNew=0; | |
264 | AliDebug(1,Form("%d clusters",nClusters)); | |
265 | esd->SetFirstEMCALCluster(esd->GetNumberOfCaloClusters()); // Put after Phos clusters | |
266 | ||
267 | //###################################################### | |
268 | //#######################TRACK MATCHING############### | |
269 | //###################################################### | |
270 | //Fill list of integers, each one is index of track to which the cluster belongs. | |
271 | ||
272 | AliCodeTimerStart(Form("JLK track matching")); | |
273 | ||
274 | // step 1 - initialize array of matched track indexes | |
275 | Int_t *matchedTrack = new Int_t[nClusters]; | |
276 | for (Int_t iclus = 0; iclus < nClusters; iclus++) | |
277 | matchedTrack[iclus] = -1; // neg. index --> no matched track | |
278 | ||
279 | // step 2, change the flag for all matched clusters found in tracks | |
280 | Int_t iemcalMatch = -1; | |
281 | Int_t endtpc = esd->GetNumberOfTracks(); | |
282 | for (Int_t itrack = 0; itrack < endtpc; itrack++) { | |
283 | AliESDtrack * track = esd->GetTrack(itrack) ; // retrieve track | |
284 | iemcalMatch = track->GetEMCALcluster(); | |
285 | if(iemcalMatch >= 0) matchedTrack[iemcalMatch] = itrack; | |
286 | } | |
287 | ||
288 | AliCodeTimerStop(Form("JLK track matching")); | |
289 | ||
290 | //######################################## | |
291 | //##############Fill CaloClusters############ | |
292 | //######################################## | |
293 | ||
294 | AliCodeTimerStart(Form("JLK fill caloclusters")); | |
295 | ||
296 | esd->SetNumberOfEMCALClusters(nClusters); | |
297 | for (Int_t iClust = 0 ; iClust < nClusters ; iClust++) { | |
298 | const AliEMCALRecPoint * clust = (const AliEMCALRecPoint*)clusters->At(iClust); | |
299 | //if(clust->GetClusterType()== AliESDCaloCluster::kEMCALClusterv1) nRP++; else nPC++; | |
300 | if (Debug()) clust->Print(); | |
301 | // Get information from EMCAL reconstruction points | |
302 | Float_t xyz[3]; | |
303 | TVector3 gpos; | |
304 | clust->GetGlobalPosition(gpos); | |
305 | for (Int_t ixyz=0; ixyz<3; ixyz++) | |
306 | xyz[ixyz] = gpos[ixyz]; | |
307 | Float_t elipAxis[2]; | |
308 | clust->GetElipsAxis(elipAxis); | |
309 | ||
310 | //Create digits lists | |
311 | Int_t cellMult = clust->GetMultiplicity(); | |
312 | //TArrayS digiList(digitMult); | |
313 | Float_t *amplFloat = clust->GetEnergiesList(); | |
314 | Int_t *digitInts = clust->GetAbsId(); | |
315 | TArrayS absIdList(cellMult); | |
316 | //Uncomment when unfolding is done | |
317 | //TArrayD fracList(cellMult); | |
318 | ||
319 | Int_t newCellMult = 0; | |
320 | for (Int_t iCell=0; iCell<cellMult; iCell++) { | |
321 | if (amplFloat[iCell] > 0) { | |
322 | absIdList[newCellMult] = (UShort_t)(digitInts[iCell]); | |
323 | //Uncomment when unfolding is done | |
324 | //fracList[newCellMult] = amplFloat[iCell]/emcCells.GetCellAmplitude(digitInts[iCell]); | |
325 | newCellMult++; | |
326 | } | |
327 | } | |
328 | absIdList.Set(newCellMult); | |
329 | //Uncomment when unfolding is done | |
330 | //fracList.Set(newCellMult); | |
331 | ||
332 | if(newCellMult > 0) { // accept cluster if it has some digit | |
333 | nClustersNew++; | |
334 | //Primaries | |
335 | Int_t parentMult = 0; | |
336 | Int_t *parentList = clust->GetParents(parentMult); | |
337 | ||
338 | // fills the ESDCaloCluster | |
339 | AliESDCaloCluster * ec = new AliESDCaloCluster() ; | |
340 | ec->SetClusterType(AliESDCaloCluster::kEMCALClusterv1); | |
341 | ec->SetPosition(xyz); | |
342 | ec->SetE(clust->GetEnergy()); | |
343 | ec->SetNCells(newCellMult); | |
344 | //Change type of list from short to ushort | |
345 | UShort_t *newAbsIdList = new UShort_t[newCellMult]; | |
346 | //Uncomment when unfolding is done | |
347 | //Double_t *newFracList = new Double_t[newCellMult]; | |
348 | for(Int_t i = 0; i < newCellMult ; i++) { | |
349 | newAbsIdList[i]=absIdList[i]; | |
350 | //Uncomment when unfolding is done | |
351 | //newFracList[i]=fracList[i]; | |
352 | } | |
353 | ec->SetCellsAbsId(newAbsIdList); | |
354 | //Uncomment when unfolding is done | |
355 | //ec->SetCellsAmplitudeFraction(newFracList); | |
356 | ||
357 | ec->SetClusterDisp(clust->GetDispersion()); | |
358 | ec->SetClusterChi2(-1); //not yet implemented | |
359 | ec->SetM02(elipAxis[0]*elipAxis[0]) ; | |
360 | ec->SetM20(elipAxis[1]*elipAxis[1]) ; | |
361 | ec->SetM11(-1) ; //not yet implemented | |
362 | ||
363 | TArrayI arrayTrackMatched(1);// Only one track, temporal solution. | |
364 | arrayTrackMatched[0]= matchedTrack[iClust]; | |
365 | ec->AddTracksMatched(arrayTrackMatched); | |
366 | ||
367 | TArrayI arrayParents(parentMult,parentList); | |
368 | ec->AddLabels(arrayParents); | |
369 | ||
370 | ||
371 | // add the cluster to the esd object | |
372 | esd->AddCaloCluster(ec); | |
373 | delete ec; | |
374 | //delete [] newAbsIdList ; | |
375 | //delete [] newFracList ; | |
376 | } | |
377 | } // cycle on clusters | |
378 | ||
379 | delete [] matchedTrack; | |
380 | ||
381 | esd->SetNumberOfEMCALClusters(nClustersNew); | |
382 | //if(nClustersNew != nClusters) | |
383 | //printf(" ##### nClusters %i -> new %i ##### \n", nClusters, nClustersNew ); | |
384 | ||
385 | //Fill ESDCaloCluster with PID weights | |
386 | AliEMCALPID *pid = new AliEMCALPID; | |
387 | //pid->SetPrintInfo(kTRUE); | |
388 | pid->SetReconstructor(kTRUE); | |
389 | pid->RunPID(esd); | |
390 | delete pid; | |
391 | ||
392 | AliCodeTimerStop(Form("JLK fill caloclusters")); | |
393 | ||
394 | } | |
395 | ||
396 |