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