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