]>
Commit | Line | Data |
---|---|---|
f6019cda | 1 | /************************************************************************** |
d874f457 | 2 | #/eliza17/alice/esdfiles/data/2011/LHC11a/000146805/ESDs/pass2_without_SDD/11000146805038.550/root_archive.zip#AliESDs.root |
f6019cda | 3 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * |
4 | * * | |
5 | * Author: The ALICE Off-line Project. * | |
6 | * Contributors are mentioned in the code where appropriate. * | |
7 | * * | |
8 | * Permission to use, copy, modify and distribute this software and its * | |
9 | * documentation strictly for non-commercial purposes is hereby granted * | |
10 | * without fee, provided that the above copyright notice appears in all * | |
11 | * copies and that both the copyright notice and this permission notice * | |
12 | * appear in the supporting documentation. The authors make no claims * | |
13 | * about the suitability of this software for any purpose. It is * | |
14 | * provided "as is" without express or implied warranty. * | |
15 | **************************************************************************/ | |
16 | ||
17 | /* $Id$ */ | |
18 | ||
19 | //_________________________________________________________________________ | |
fa42b1f3 | 20 | //-- |
21 | //-- Yves Schutz (SUBATECH) | |
f6019cda | 22 | // Reconstruction class. Redesigned from the old AliReconstructionner class and |
23 | // derived from STEER/AliReconstructor. | |
24 | // | |
29c9d15f | 25 | |
85c25c2e | 26 | |
f6019cda | 27 | // --- ROOT system --- |
85c25c2e | 28 | #include <TClonesArray.h> |
0c5b726e | 29 | #include "TGeoManager.h" |
30 | #include "TGeoMatrix.h" | |
f6019cda | 31 | |
32 | // --- Standard library --- | |
33 | ||
34 | // --- AliRoot header files --- | |
f6019cda | 35 | #include "AliEMCALReconstructor.h" |
5dee926e | 36 | |
aaa3cb7c | 37 | #include "AliCodeTimer.h" |
23ca956b | 38 | #include "AliCaloCalibPedestal.h" |
39 | #include "AliEMCALCalibData.h" | |
af885e0f | 40 | #include "AliESDEvent.h" |
89ffc0b0 | 41 | #include "AliESDCaloCluster.h" |
0e7c6655 | 42 | #include "AliESDCaloCells.h" |
6a0cf740 | 43 | #include "AliESDtrack.h" |
5dee926e | 44 | #include "AliEMCALLoader.h" |
98e9578e | 45 | #include "AliEMCALRawUtils.h" |
0e7c6655 | 46 | #include "AliEMCALDigit.h" |
f6019cda | 47 | #include "AliEMCALClusterizerv1.h" |
783153ff | 48 | #include "AliEMCALClusterizerv2.h" |
ee08edde | 49 | #include "AliEMCALClusterizerNxN.h" |
5dee926e | 50 | #include "AliEMCALRecPoint.h" |
dc293ae9 | 51 | #include "AliEMCALPID.h" |
ee602376 | 52 | #include "AliEMCALRecoUtils.h" |
1d59832c | 53 | #include "AliRawReader.h" |
fa42b1f3 | 54 | #include "AliCDBEntry.h" |
55 | #include "AliCDBManager.h" | |
65bdc82f | 56 | #include "AliEMCALGeometry.h" |
ac8ae9fe | 57 | #include "AliEMCAL.h" |
85c25c2e | 58 | #include "AliESDVZERO.h" |
0c5b726e | 59 | #include "AliCDBManager.h" |
72c58de0 | 60 | #include "AliRunLoader.h" |
61 | #include "AliRun.h" | |
916f1e76 | 62 | #include "AliEMCALTriggerData.h" |
63 | #include "AliEMCALTriggerElectronics.h" | |
fff39dd1 | 64 | #include "AliEMCALTriggerDCSConfigDB.h" |
65 | #include "AliEMCALTriggerDCSConfig.h" | |
de39a0ff | 66 | #include "AliEMCALTriggerData.h" |
67 | #include "AliEMCALTriggerRawDigit.h" | |
68 | #include "AliEMCALTriggerPatch.h" | |
69 | #include "AliEMCALTriggerTypes.h" | |
1d59832c | 70 | |
85c25c2e | 71 | ClassImp(AliEMCALReconstructor) |
95ffa314 | 72 | |
5970dfe2 | 73 | const AliEMCALRecParam* AliEMCALReconstructor::fgkRecParam = 0; // EMCAL rec. parameters |
b57cc9b9 | 74 | AliEMCALRawUtils* AliEMCALReconstructor::fgRawUtils = 0; // EMCAL raw utilities class |
75 | AliEMCALClusterizer* AliEMCALReconstructor::fgClusterizer = 0; // EMCAL clusterizer class | |
76 | TClonesArray* AliEMCALReconstructor::fgDigitsArr = 0; // list of digits, to be used multiple times | |
77 | TObjArray* AliEMCALReconstructor::fgClustersArr = 0; // list of clusters, to be used multiple times | |
4bd37bd4 | 78 | TClonesArray* AliEMCALReconstructor::fgTriggerDigits = 0; // list of trigger digits, to be used multiple times |
916f1e76 | 79 | AliEMCALTriggerElectronics* AliEMCALReconstructor::fgTriggerProcessor = 0x0; |
f6019cda | 80 | //____________________________________________________________________________ |
18a21c7c | 81 | AliEMCALReconstructor::AliEMCALReconstructor() |
5970dfe2 | 82 | : fGeom(0),fCalibData(0),fPedestalData(0),fTriggerData(0x0), fMatches(0x0) |
f6019cda | 83 | { |
84 | // ctor | |
c828bc97 | 85 | |
86 | // AliDebug(2, "Mark."); | |
87 | ||
65bdc82f | 88 | fgRawUtils = new AliEMCALRawUtils; |
29c9d15f | 89 | |
72c58de0 | 90 | //To make sure we match with the geometry in a simulation file, |
91 | //let's try to get it first. If not, take the default geometry | |
33c3c91a | 92 | AliRunLoader *rl = AliRunLoader::Instance(); |
7e1d9a9b | 93 | if (rl->GetAliRun()){ |
94 | AliEMCAL * emcal = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL")); | |
95 | if(emcal) fGeom = emcal->GetGeometry(); | |
96 | } | |
97 | ||
98 | if(!fGeom) { | |
72c58de0 | 99 | AliInfo(Form("Using default geometry in reconstruction")); |
937d0661 | 100 | fGeom = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName()); |
65bdc82f | 101 | } |
29c9d15f | 102 | |
0c5b726e | 103 | //Get calibration parameters |
104 | if(!fCalibData) | |
105 | { | |
29c9d15f | 106 | AliCDBEntry *entry = (AliCDBEntry*) |
107 | AliCDBManager::Instance()->Get("EMCAL/Calib/Data"); | |
108 | if (entry) fCalibData = (AliEMCALCalibData*) entry->GetObject(); | |
0c5b726e | 109 | } |
29c9d15f | 110 | |
0c5b726e | 111 | if(!fCalibData) |
29c9d15f | 112 | AliFatal("Calibration parameters not found in CDB!"); |
113 | ||
40164976 | 114 | //Get calibration parameters |
115 | if(!fPedestalData) | |
116 | { | |
de39a0ff | 117 | AliCDBEntry *entry = (AliCDBEntry*) |
29c9d15f | 118 | AliCDBManager::Instance()->Get("EMCAL/Calib/Pedestals"); |
de39a0ff | 119 | if (entry) fPedestalData = (AliCaloCalibPedestal*) entry->GetObject(); |
40164976 | 120 | } |
de39a0ff | 121 | |
ee08edde | 122 | if(!fPedestalData) |
123 | AliFatal("Dead map not found in CDB!"); | |
29c9d15f | 124 | |
72c58de0 | 125 | if(!fGeom) AliFatal(Form("Could not get geometry!")); |
29c9d15f | 126 | |
f62c044a | 127 | AliEMCALTriggerDCSConfigDB* dcsConfigDB = AliEMCALTriggerDCSConfigDB::Instance(); |
29c9d15f | 128 | |
f62c044a | 129 | const AliEMCALTriggerDCSConfig* dcsConfig = dcsConfigDB->GetTriggerDCSConfig(); |
29c9d15f | 130 | |
f62c044a | 131 | if (!dcsConfig) AliFatal("No Trigger DCS Configuration from OCDB!"); |
132 | fgTriggerProcessor = new AliEMCALTriggerElectronics( dcsConfig ); | |
29c9d15f | 133 | |
f62c044a | 134 | fTriggerData = new AliEMCALTriggerData(); |
29c9d15f | 135 | |
f62c044a | 136 | //Init temporary list of digits |
4bd37bd4 | 137 | fgDigitsArr = new TClonesArray("AliEMCALDigit",1000); |
138 | fgClustersArr = new TObjArray(1000); | |
139 | fgTriggerDigits = new TClonesArray("AliEMCALTriggerRawDigit",1000); | |
5970dfe2 | 140 | |
141 | //Track matching | |
142 | fMatches = new TList(); | |
143 | fMatches->SetOwner(kTRUE); | |
f6019cda | 144 | } |
145 | ||
f6019cda | 146 | //____________________________________________________________________________ |
147 | AliEMCALReconstructor::~AliEMCALReconstructor() | |
148 | { | |
149 | // dtor | |
c828bc97 | 150 | |
151 | //AliDebug(2, "Mark."); | |
152 | ||
23ca956b | 153 | if(fGeom) delete fGeom; |
80453a9f | 154 | |
155 | //No need to delete, recovered from OCDB | |
156 | //if(fCalibData) delete fCalibData; | |
157 | //if(fPedestalData) delete fPedestalData; | |
de39a0ff | 158 | |
b57cc9b9 | 159 | if(fgDigitsArr){ |
160 | fgDigitsArr->Clear("C"); | |
161 | delete fgDigitsArr; | |
162 | } | |
163 | ||
164 | if(fgClustersArr){ | |
165 | fgClustersArr->Clear(); | |
166 | delete fgClustersArr; | |
167 | } | |
168 | ||
4bd37bd4 | 169 | if(fgTriggerDigits){ |
7dbb454b | 170 | fgTriggerDigits->Clear(); |
4bd37bd4 | 171 | delete fgTriggerDigits; |
172 | } | |
173 | ||
23ca956b | 174 | if(fgRawUtils) delete fgRawUtils; |
175 | if(fgClusterizer) delete fgClusterizer; | |
f62c044a | 176 | if(fgTriggerProcessor) delete fgTriggerProcessor; |
b57cc9b9 | 177 | |
5970dfe2 | 178 | if(fMatches) { fMatches->Delete(); delete fMatches; fMatches = 0;} |
179 | ||
aaa3cb7c | 180 | AliCodeTimer::Instance()->Print(); |
f6019cda | 181 | } |
182 | ||
9519e3e3 | 183 | //____________________________________________________________________________ |
184 | void AliEMCALReconstructor::InitClusterizer() const | |
ee08edde | 185 | { |
9519e3e3 | 186 | //Init the clusterizer with geometry and calibration pointers, avoid doing it twice. |
187 | Int_t clusterizerType = -1; | |
188 | Int_t eventType = -1; | |
189 | if(GetRecParam()) { | |
190 | clusterizerType = GetRecParam()->GetClusterizerFlag(); | |
191 | eventType = GetRecParam()->GetEventSpecie(); | |
7e1d9a9b | 192 | } |
193 | else{ | |
9519e3e3 | 194 | AliCDBEntry *entry = (AliCDBEntry*) |
29c9d15f | 195 | AliCDBManager::Instance()->Get("EMCAL/Calib/RecoParam"); |
9519e3e3 | 196 | //Get The reco param for the default event specie |
197 | if (entry) { | |
198 | AliEMCALRecParam *recParam = (AliEMCALRecParam*)((TObjArray *) entry->GetObject())->At(0); | |
199 | if(recParam) clusterizerType = recParam->GetClusterizerFlag(); | |
de39a0ff | 200 | } |
7e1d9a9b | 201 | } |
ee08edde | 202 | |
9519e3e3 | 203 | //Check if clusterizer previously set corresponds to what is needed for this event type |
204 | if(fgClusterizer){ | |
205 | if(eventType!=AliRecoParam::kCalib){ | |
206 | //printf("ReCreate clusterizer? Clusterizer set <%d>, Clusterizer in use <%s>\n", | |
29c9d15f | 207 | // clusterizerType, fgClusterizer->Version()); |
9519e3e3 | 208 | |
783153ff | 209 | if (clusterizerType == AliEMCALRecParam::kClusterizerv1 && !strcmp(fgClusterizer->Version(),"clu-v1")) return; |
9519e3e3 | 210 | |
211 | else if(clusterizerType == AliEMCALRecParam::kClusterizerNxN && !strcmp(fgClusterizer->Version(),"clu-NxN")) return; | |
212 | ||
783153ff | 213 | else if(clusterizerType == AliEMCALRecParam::kClusterizerv2 && !strcmp(fgClusterizer->Version(),"clu-v2")) return; |
214 | ||
9519e3e3 | 215 | //Need to create new clusterizer, the one set previously is not the correct one |
216 | delete fgClusterizer; | |
217 | } | |
218 | else return; | |
219 | } | |
29c9d15f | 220 | |
783153ff | 221 | if (clusterizerType == AliEMCALRecParam::kClusterizerv1) |
29c9d15f | 222 | { |
783153ff | 223 | fgClusterizer = new AliEMCALClusterizerv1 (fGeom, fCalibData,fPedestalData); |
29c9d15f | 224 | } |
783153ff | 225 | else if (clusterizerType == AliEMCALRecParam::kClusterizerNxN) |
29c9d15f | 226 | { |
227 | fgClusterizer = new AliEMCALClusterizerNxN(fGeom, fCalibData,fPedestalData); | |
228 | } | |
783153ff | 229 | else if (clusterizerType == AliEMCALRecParam::kClusterizerv2) |
230 | { | |
231 | fgClusterizer = new AliEMCALClusterizerv2 (fGeom, fCalibData,fPedestalData); | |
232 | } | |
233 | else | |
234 | { | |
235 | AliFatal(Form("Unknown clusterizer %d ", clusterizerType)); | |
236 | } | |
ee08edde | 237 | } |
238 | ||
f6019cda | 239 | //____________________________________________________________________________ |
c47157cd | 240 | void AliEMCALReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const |
f6019cda | 241 | { |
242 | // method called by AliReconstruction; | |
243 | // Only the clusterization is performed,; the rest of the reconstruction is done in FillESD because the track | |
244 | // segment maker needs access to the AliESD object to retrieve the tracks reconstructed by | |
245 | // the global tracking. | |
c47157cd | 246 | // Works on the current event. |
29c9d15f | 247 | |
1a429a6b | 248 | AliCodeTimerAuto("",0) |
29c9d15f | 249 | |
250 | //Get input digits and put them in fgDigitsArr, clear the list before | |
85c25c2e | 251 | ReadDigitsArrayFromTree(digitsTree); |
29c9d15f | 252 | |
9519e3e3 | 253 | InitClusterizer(); |
254 | ||
0832a2bf | 255 | fgClusterizer->InitParameters(); |
4601e3a7 | 256 | fgClusterizer->SetOutput(clustersTree); |
9519e3e3 | 257 | |
e853f058 | 258 | //Skip clusterization of LED events |
259 | if (GetRecParam()->GetEventSpecie()!=AliRecoParam::kCalib){ | |
9517d886 | 260 | |
29c9d15f | 261 | if(fgDigitsArr && fgDigitsArr->GetEntries()) { |
262 | ||
263 | fgClusterizer->SetInput(digitsTree); | |
264 | ||
265 | //fgClusterizer->Digits2Clusters("deb all") ; //For debugging | |
266 | fgClusterizer->Digits2Clusters(""); | |
267 | ||
268 | fgClusterizer->Clear(); | |
269 | ||
270 | }//digits array exists and has somethind | |
e853f058 | 271 | }//not a LED event |
29c9d15f | 272 | |
916f1e76 | 273 | clustersTree->Fill(); |
c828bc97 | 274 | |
275 | // Deleting the recpoints at the end of the reconstruction call | |
276 | fgClusterizer->DeleteRecPoints(); | |
f6019cda | 277 | } |
278 | ||
a68156e6 | 279 | //____________________________________________________________________________ |
c47157cd | 280 | void AliEMCALReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const |
29c9d15f | 281 | |
a68156e6 | 282 | { |
c47157cd | 283 | // Conversion from raw data to |
284 | // EMCAL digits. | |
285 | // Works on a single-event basis | |
95ffa314 | 286 | |
98e9578e | 287 | rawReader->Reset() ; |
29c9d15f | 288 | |
de39a0ff | 289 | fTriggerData->SetMode(1); |
29c9d15f | 290 | |
b57cc9b9 | 291 | if(fgDigitsArr) fgDigitsArr->Clear("C"); |
29c9d15f | 292 | |
de39a0ff | 293 | TClonesArray *digitsTrg = new TClonesArray("AliEMCALTriggerRawDigit", 32 * 96); |
29c9d15f | 294 | |
c47157cd | 295 | Int_t bufsize = 32000; |
b57cc9b9 | 296 | digitsTree->Branch("EMCAL", &fgDigitsArr, bufsize); |
916f1e76 | 297 | digitsTree->Branch("EMTRG", &digitsTrg, bufsize); |
29c9d15f | 298 | |
e853f058 | 299 | //Skip calibration events do the rest |
300 | Bool_t doFit = kTRUE; | |
95ffa314 | 301 | if ( !(GetRecParam()->FitLEDEvents()) && GetRecParam()->GetEventSpecie()==AliRecoParam::kCalib) doFit = kFALSE; |
e853f058 | 302 | if (doFit){ |
29c9d15f | 303 | //must be done here because, in constructor, option is not yet known |
304 | fgRawUtils->SetOption(GetOption()); | |
305 | ||
92d9f317 | 306 | // fgRawUtils->SetRawFormatHighLowGainFactor(GetRecParam()->GetHighLowGainFactor()); |
95ffa314 | 307 | |
92d9f317 | 308 | // fgRawUtils->SetRawFormatOrder(GetRecParam()->GetOrderParameter()); |
309 | // fgRawUtils->SetRawFormatTau(GetRecParam()->GetTau()); | |
29c9d15f | 310 | fgRawUtils->SetNoiseThreshold(GetRecParam()->GetNoiseThreshold()); |
311 | fgRawUtils->SetNPedSamples(GetRecParam()->GetNPedSamples()); | |
312 | fgRawUtils->SetRemoveBadChannels(GetRecParam()->GetRemoveBadChannels()); | |
48b634ff | 313 | if (!fgRawUtils->GetFittingAlgorithm()) fgRawUtils->SetFittingAlgorithm(GetRecParam()->GetFittingAlgorithm()); |
29c9d15f | 314 | fgRawUtils->SetFALTROUsage(GetRecParam()->UseFALTRO()); |
92d9f317 | 315 | |
316 | //fgRawUtils->SetTimeMin(GetRecParam()->GetTimeMin()); | |
317 | //fgRawUtils->SetTimeMax(GetRecParam()->GetTimeMax()); | |
318 | ||
319 | // fgRawUtils->SetTimeMin(-99999 ); | |
320 | // fgRawUtils->SetTimeMax( 99999 ); | |
29c9d15f | 321 | |
322 | fgRawUtils->Raw2Digits(rawReader,fgDigitsArr,fPedestalData,digitsTrg,fTriggerData); | |
92d9f317 | 323 | |
793176c1 | 324 | }//skip calibration event |
e853f058 | 325 | else{ |
29c9d15f | 326 | AliDebug(1," Calibration Event, skip!"); |
e853f058 | 327 | } |
29c9d15f | 328 | |
c615db53 | 329 | digitsTree->Fill(); |
916f1e76 | 330 | digitsTrg->Delete(); |
916f1e76 | 331 | delete digitsTrg; |
29c9d15f | 332 | |
a68156e6 | 333 | } |
334 | ||
85c25c2e | 335 | |
f6019cda | 336 | //____________________________________________________________________________ |
0e7c6655 | 337 | void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree, |
c47157cd | 338 | AliESDEvent* esd) const |
f6019cda | 339 | { |
98e9578e | 340 | // Called by AliReconstruct after Reconstruct() and global tracking and vertexing |
85c25c2e | 341 | // and V0 |
c47157cd | 342 | // Works on the current event |
de39a0ff | 343 | // printf(" ## AliEMCALReconstructor::FillESD() is started ### \n "); |
85c25c2e | 344 | //return; |
29c9d15f | 345 | |
7ba18c0e | 346 | //######################################## |
347 | // Trigger | |
348 | //######################################## | |
de39a0ff | 349 | |
da6062af | 350 | static int saveOnce = 0; |
95ffa314 | 351 | |
29c9d15f | 352 | Int_t v0M[2] = {0, 0}; |
353 | ||
354 | AliESDVZERO* esdV0 = esd->GetVZEROData(); | |
355 | ||
356 | if (esdV0) | |
357 | { | |
358 | for (Int_t i = 0; i < 32; i++) | |
359 | { | |
360 | v0M[0] += (Int_t)esdV0->GetAdcV0C(i); | |
361 | v0M[1] += (Int_t)esdV0->GetAdcV0A(i); | |
362 | } | |
363 | } | |
364 | else | |
365 | { | |
366 | AliWarning("Cannot retrieve V0 ESD! Run w/ null V0 charges"); | |
367 | } | |
368 | ||
369 | if (fgTriggerDigits) fgTriggerDigits->Clear(); | |
370 | ||
371 | TBranch *branchtrg = digitsTree->GetBranch("EMTRG"); | |
372 | ||
373 | if (!branchtrg) | |
374 | { | |
375 | AliError("Can't get the branch with the EMCAL trigger digits!"); | |
376 | return; | |
377 | } | |
378 | ||
379 | branchtrg->SetAddress(&fgTriggerDigits); | |
380 | branchtrg->GetEntry(0); | |
381 | ||
382 | // Note: fgTriggerProcessor reset done at the end of this method | |
3d1b5170 | 383 | // fgTriggerProcessor->Digits2Trigger(fgTriggerDigits, v0M, fTriggerData); |
29c9d15f | 384 | |
385 | // Fill ESD | |
386 | AliESDCaloTrigger* trgESD = esd->GetCaloTrigger("EMCAL"); | |
387 | ||
388 | if (trgESD) | |
389 | { | |
390 | trgESD->Allocate(fgTriggerDigits->GetEntriesFast()); | |
391 | ||
392 | for (Int_t i = 0; i < fgTriggerDigits->GetEntriesFast(); i++) | |
393 | { | |
394 | AliEMCALTriggerRawDigit* rdig = (AliEMCALTriggerRawDigit*)fgTriggerDigits->At(i); | |
de39a0ff | 395 | |
29c9d15f | 396 | Int_t px, py; |
397 | if (fGeom->GetPositionInEMCALFromAbsFastORIndex(rdig->GetId(), px, py)) | |
398 | { | |
399 | Int_t a = -1, t = -1, times[10]; | |
400 | ||
401 | rdig->GetMaximum(a, t); | |
402 | rdig->GetL0Times(times); | |
403 | ||
404 | trgESD->Add(px, py, a, t, times, rdig->GetNL0Times(), rdig->GetL1TimeSum(), rdig->GetTriggerBits()); | |
405 | } | |
406 | } | |
407 | ||
408 | trgESD->SetL1Threshold(0, fTriggerData->GetL1GammaThreshold()); | |
409 | ||
410 | trgESD->SetL1Threshold(1, fTriggerData->GetL1JetThreshold() ); | |
95ffa314 | 411 | |
412 | Int_t v0[2]; | |
413 | fTriggerData->GetL1V0(v0); | |
414 | ||
415 | trgESD->SetL1V0(v0); | |
416 | trgESD->SetL1FrameMask(fTriggerData->GetL1FrameMask()); | |
417 | ||
418 | if (!saveOnce && fTriggerData->GetL1DataDecoded()) | |
419 | { | |
420 | int type[8] = {0}; | |
421 | fTriggerData->GetL1TriggerType(type); | |
422 | ||
423 | esd->SetCaloTriggerType(type); | |
424 | ||
425 | saveOnce = 1; | |
426 | } | |
29c9d15f | 427 | } |
428 | ||
429 | // Resetting | |
430 | fTriggerData->Reset(); | |
de39a0ff | 431 | |
0e7c6655 | 432 | //######################################## |
433 | //##############Fill CaloCells############### | |
434 | //######################################## | |
29c9d15f | 435 | |
436 | //Get input digits and put them in fgDigitsArr, clear the list before | |
b57cc9b9 | 437 | ReadDigitsArrayFromTree(digitsTree); |
29c9d15f | 438 | |
b57cc9b9 | 439 | Int_t nDigits = fgDigitsArr->GetEntries(), idignew = 0 ; |
0e7c6655 | 440 | AliDebug(1,Form("%d digits",nDigits)); |
0e7c6655 | 441 | AliESDCaloCells &emcCells = *(esd->GetEMCALCells()); |
442 | emcCells.CreateContainer(nDigits); | |
c8fe2783 | 443 | emcCells.SetType(AliVCaloCells::kEMCALCell); |
0c5b726e | 444 | Float_t energy = 0; |
783153ff | 445 | Float_t time = 0; |
0e7c6655 | 446 | for (Int_t idig = 0 ; idig < nDigits ; idig++) { |
b57cc9b9 | 447 | const AliEMCALDigit * dig = (const AliEMCALDigit*)fgDigitsArr->At(idig); |
783153ff | 448 | time = dig->GetTime(); // Time already calibrated in clusterizer |
449 | energy = dig->GetAmplitude(); // energy calibrated in clusterizer | |
450 | if(energy > 0 ){ | |
451 | fgClusterizer->Calibrate(energy,time,dig->GetId()); //Digits already calibrated in clusterizers | |
452 | if(energy > 0){ //Digits tagged as bad (dead, hot, not alive) are set to 0 in calibrate, remove them | |
453 | emcCells.SetCell(idignew,dig->GetId(),energy, time); | |
95ffa314 | 454 | idignew++; |
29c9d15f | 455 | } |
0e7c6655 | 456 | } |
457 | } | |
458 | emcCells.SetNumberOfCells(idignew); | |
459 | emcCells.Sort(); | |
29c9d15f | 460 | |
0e7c6655 | 461 | //------------------------------------------------------------ |
462 | //-----------------CLUSTERS----------------------------- | |
463 | //------------------------------------------------------------ | |
9dce5a21 | 464 | clustersTree->SetBranchStatus("*",0); //disable all branches |
465 | clustersTree->SetBranchStatus("EMCALECARP",1); //Enable only the branch we need | |
b57cc9b9 | 466 | if(fgClustersArr) fgClustersArr->Clear(); |
0e7c6655 | 467 | TBranch *branch = clustersTree->GetBranch("EMCALECARP"); |
b57cc9b9 | 468 | branch->SetAddress(&fgClustersArr); |
9dce5a21 | 469 | branch->GetEntry(0); |
470 | //clustersTree->GetEvent(0); | |
29c9d15f | 471 | |
b57cc9b9 | 472 | Int_t nClusters = fgClustersArr->GetEntries(), nClustersNew=0; |
0e7c6655 | 473 | AliDebug(1,Form("%d clusters",nClusters)); |
5970dfe2 | 474 | |
85c25c2e | 475 | |
6a0cf740 | 476 | //######################################## |
85c25c2e | 477 | //##############Fill CaloClusters############# |
6a0cf740 | 478 | //######################################## |
5dee926e | 479 | for (Int_t iClust = 0 ; iClust < nClusters ; iClust++) { |
b57cc9b9 | 480 | const AliEMCALRecPoint * clust = (const AliEMCALRecPoint*)fgClustersArr->At(iClust); |
5970dfe2 | 481 | if(!clust) continue; |
c8fe2783 | 482 | //if(clust->GetClusterType()== AliVCluster::kEMCALClusterv1) nRP++; else nPC++; |
29c9d15f | 483 | // clust->Print(); //For debugging |
a7a5421e | 484 | // Get information from EMCAL reconstruction points |
85c60a8e | 485 | Float_t xyz[3]; |
5dee926e | 486 | TVector3 gpos; |
487 | clust->GetGlobalPosition(gpos); | |
35397e76 | 488 | for (Int_t ixyz=0; ixyz<3; ixyz++) |
5dee926e | 489 | xyz[ixyz] = gpos[ixyz]; |
85c25c2e | 490 | Float_t elipAxis[2]; |
491 | clust->GetElipsAxis(elipAxis); | |
29c9d15f | 492 | //Create digits lists |
35397e76 | 493 | Int_t cellMult = clust->GetMultiplicity(); |
494 | //TArrayS digiList(digitMult); | |
495 | Float_t *amplFloat = clust->GetEnergiesList(); | |
496 | Int_t *digitInts = clust->GetAbsId(); | |
497 | TArrayS absIdList(cellMult); | |
eb972628 | 498 | TArrayD fracList(cellMult); |
29c9d15f | 499 | |
35397e76 | 500 | Int_t newCellMult = 0; |
501 | for (Int_t iCell=0; iCell<cellMult; iCell++) { | |
502 | if (amplFloat[iCell] > 0) { | |
95ffa314 | 503 | absIdList[newCellMult] = (UShort_t)(digitInts[iCell]); |
504 | //Calculate Fraction | |
505 | if(emcCells.GetCellAmplitude(digitInts[iCell])>0 && GetRecParam()->GetUnfold()){ | |
506 | fracList[newCellMult] = amplFloat[iCell]/(emcCells.GetCellAmplitude(digitInts[iCell]));//get cell calibration value | |
507 | ||
508 | } | |
509 | else{ | |
510 | fracList[newCellMult] = 0; | |
511 | } | |
512 | newCellMult++; | |
92da3372 | 513 | } |
92da3372 | 514 | } |
29c9d15f | 515 | |
eb972628 | 516 | absIdList.Set(newCellMult); |
517 | fracList.Set(newCellMult); | |
518 | ||
35397e76 | 519 | if(newCellMult > 0) { // accept cluster if it has some digit |
520 | nClustersNew++; | |
65721814 | 521 | //Primaries |
7592dfc4 | 522 | Int_t parentMult = 0; |
fa42b1f3 | 523 | Int_t *parentList = clust->GetParents(parentMult); |
a7a5421e | 524 | // fills the ESDCaloCluster |
35397e76 | 525 | AliESDCaloCluster * ec = new AliESDCaloCluster() ; |
c8fe2783 | 526 | ec->SetType(AliVCluster::kEMCALClusterv1); |
7592dfc4 | 527 | ec->SetPosition(xyz); |
528 | ec->SetE(clust->GetEnergy()); | |
29c9d15f | 529 | |
ee08edde | 530 | //Distance to the nearest bad crystal |
531 | ec->SetDistanceToBadChannel(clust->GetDistanceToBadTower()); | |
29c9d15f | 532 | |
35397e76 | 533 | ec->SetNCells(newCellMult); |
534 | //Change type of list from short to ushort | |
535 | UShort_t *newAbsIdList = new UShort_t[newCellMult]; | |
ee08edde | 536 | Double_t *newFracList = new Double_t[newCellMult]; |
35397e76 | 537 | for(Int_t i = 0; i < newCellMult ; i++) { |
538 | newAbsIdList[i]=absIdList[i]; | |
de39a0ff | 539 | newFracList[i] =fracList[i]; |
35397e76 | 540 | } |
541 | ec->SetCellsAbsId(newAbsIdList); | |
eb972628 | 542 | ec->SetCellsAmplitudeFraction(newFracList); |
c8fe2783 | 543 | ec->SetDispersion(clust->GetDispersion()); |
544 | ec->SetChi2(-1); //not yet implemented | |
35397e76 | 545 | ec->SetM02(elipAxis[0]*elipAxis[0]) ; |
546 | ec->SetM20(elipAxis[1]*elipAxis[1]) ; | |
78902954 | 547 | ec->SetTOF(clust->GetTime()) ; //time-of-fligh |
225cd96d | 548 | ec->SetNExMax(clust->GetNExMax()); //number of local maxima |
5970dfe2 | 549 | |
29c9d15f | 550 | |
35397e76 | 551 | TArrayI arrayParents(parentMult,parentList); |
552 | ec->AddLabels(arrayParents); | |
5970dfe2 | 553 | // |
554 | //Track matching | |
555 | // | |
556 | fMatches->Clear(); | |
557 | Int_t nTracks = esd->GetNumberOfTracks(); | |
558 | for (Int_t itrack = 0; itrack < nTracks; itrack++) | |
559 | { | |
560 | AliESDtrack * track = esd->GetTrack(itrack) ; // retrieve track | |
561 | if(track->GetEMCALcluster()==iClust) | |
562 | { | |
ee602376 | 563 | Float_t dEta=-999, dPhi=-999; |
5970dfe2 | 564 | Bool_t isMatch = CalculateResidual(track, ec, dEta, dPhi); |
565 | if(!isMatch) | |
566 | { | |
a8fbdc61 | 567 | // AliDebug(10, "Not good"); |
5970dfe2 | 568 | continue; |
5970dfe2 | 569 | } |
570 | AliEMCALMatch *match = new AliEMCALMatch(); | |
571 | match->SetIndexT(itrack); | |
572 | match->SetDistance(TMath::Sqrt(dEta*dEta+dPhi*dPhi)); | |
573 | match->SetdEta(dEta); | |
574 | match->SetdPhi(dPhi); | |
575 | fMatches->Add(match); | |
576 | } | |
577 | } | |
578 | fMatches->Sort(kSortAscending); //Sort matched tracks from closest to furthest | |
579 | Int_t nMatch = fMatches->GetEntries(); | |
580 | TArrayI arrayTrackMatched(nMatch); | |
581 | for(Int_t imatch=0; imatch<nMatch; imatch++) | |
582 | { | |
583 | AliEMCALMatch *match = (AliEMCALMatch*)fMatches->At(imatch); | |
584 | arrayTrackMatched[imatch] = match->GetIndexT(); | |
585 | if(imatch==0) | |
586 | { | |
587 | ec->SetTrackDistance(match->GetdPhi(), match->GetdEta()); | |
588 | } | |
589 | } | |
590 | ec->AddTracksMatched(arrayTrackMatched); | |
591 | ||
592 | //add the cluster to the esd object | |
eb972628 | 593 | esd->AddCaloCluster(ec); |
5970dfe2 | 594 | |
a7a5421e | 595 | delete ec; |
85d4cbde | 596 | delete [] newAbsIdList ; |
eb972628 | 597 | delete [] newFracList ; |
29c9d15f | 598 | } |
599 | } // cycle on clusters | |
5970dfe2 | 600 | |
601 | // | |
602 | //Reset the index of matched cluster for tracks | |
603 | //to the one in CaloCluster array | |
604 | Int_t ncls = esd->GetNumberOfCaloClusters(); | |
605 | for(Int_t icl=0; icl<ncls; icl++) | |
606 | { | |
607 | AliESDCaloCluster *cluster = esd->GetCaloCluster(icl); | |
608 | if(!cluster || !cluster->IsEMCAL()) continue; | |
609 | TArrayI *trackIndex = cluster->GetTracksMatched(); | |
610 | for(Int_t itr=0; itr<trackIndex->GetSize(); itr++) | |
611 | { | |
612 | AliESDtrack *track = esd->GetTrack(trackIndex->At(itr)); | |
613 | track->SetEMCALcluster(cluster->GetID()); | |
614 | } | |
615 | } | |
29c9d15f | 616 | |
29c9d15f | 617 | |
618 | //Fill ESDCaloCluster with PID weights | |
619 | AliEMCALPID *pid = new AliEMCALPID; | |
620 | //pid->SetPrintInfo(kTRUE); | |
621 | pid->SetReconstructor(kTRUE); | |
622 | pid->RunPID(esd); | |
623 | delete pid; | |
624 | ||
625 | //Store EMCAL misalignment matrixes | |
626 | FillMisalMatrixes(esd) ; | |
627 | ||
0c5b726e | 628 | } |
629 | ||
630 | //================================================================================== | |
631 | void AliEMCALReconstructor::FillMisalMatrixes(AliESDEvent* esd)const{ | |
29c9d15f | 632 | //Store EMCAL matrixes in ESD Header |
633 | ||
634 | //Check, if matrixes was already stored | |
635 | for(Int_t sm = 0 ; sm < fGeom->GetNumberOfSuperModules(); sm++){ | |
636 | if(esd->GetEMCALMatrix(sm)!=0) | |
637 | return ; | |
638 | } | |
639 | ||
640 | //Create and store matrixes | |
641 | if(!gGeoManager){ | |
642 | AliError("Can not store misal. matrixes: no gGeoManager! \n") ; | |
643 | return ; | |
644 | } | |
645 | //Note, that owner of copied marixes will be header | |
7e1d9a9b | 646 | const Int_t bufsize = 255; |
29c9d15f | 647 | char path[bufsize] ; |
648 | TGeoHMatrix * m = 0x0; | |
649 | for(Int_t sm = 0; sm < fGeom->GetNumberOfSuperModules(); sm++){ | |
650 | snprintf(path,bufsize,"/ALIC_1/XEN1_1/SMOD_%d",sm+1) ; //In Geometry modules numbered 1,2,.,5 | |
651 | if(sm >= 10) snprintf(path,bufsize,"/ALIC_1/XEN1_1/SM10_%d",sm-10+1) ; | |
652 | ||
653 | if (gGeoManager->CheckPath(path)){ | |
654 | gGeoManager->cd(path); | |
655 | m = gGeoManager->GetCurrentMatrix() ; | |
656 | // printf("================================================= \n"); | |
657 | // printf("AliEMCALReconstructor::FixMisalMatrixes(), sm %d, \n",sm); | |
658 | // m->Print(""); | |
659 | esd->SetEMCALMatrix(new TGeoHMatrix(*m),sm) ; | |
660 | // printf("================================================= \n"); | |
661 | } | |
662 | else{ | |
663 | esd->SetEMCALMatrix(NULL,sm) ; | |
664 | } | |
665 | } | |
f6019cda | 666 | } |
dc293ae9 | 667 | |
9517d886 | 668 | //__________________________________________________________________________ |
85c25c2e | 669 | void AliEMCALReconstructor::ReadDigitsArrayFromTree(TTree *digitsTree) const |
670 | { | |
29c9d15f | 671 | // Read the digits from the input tree |
672 | // See AliEMCALClusterizer::SetInput(TTree *digitsTree); | |
673 | ||
674 | // Clear previous digits in the list | |
675 | if(fgDigitsArr){ | |
b57cc9b9 | 676 | fgDigitsArr->Clear("C"); |
85c25c2e | 677 | } |
29c9d15f | 678 | else{ |
679 | // It should not happen, but just in case ... | |
680 | fgDigitsArr = new TClonesArray("AliEMCALDigit",100); | |
681 | } | |
682 | ||
85c25c2e | 683 | // Read the digits from the input tree |
684 | TBranch *branch = digitsTree->GetBranch("EMCAL"); | |
685 | if (!branch) { | |
686 | AliError("can't get the branch with the EMCAL digits !"); | |
687 | return; | |
29c9d15f | 688 | } |
689 | ||
85c25c2e | 690 | branch->SetAddress(&fgDigitsArr); |
691 | branch->GetEntry(0); | |
692 | } | |
98e9578e | 693 | |
5970dfe2 | 694 | //================================================================================== |
ee602376 | 695 | Bool_t AliEMCALReconstructor::CalculateResidual(AliESDtrack *track, AliESDCaloCluster *cluster, Float_t &dEta, Float_t &dPhi)const |
5970dfe2 | 696 | { |
697 | // | |
698 | // calculate the residual between track and cluster | |
699 | // | |
700 | ||
701 | // If the esdFriend is available, use the TPCOuter point as the starting point of extrapolation | |
702 | // Otherwise use the TPCInner point | |
8fc351e3 | 703 | |
704 | dEta = -999, dPhi = -999; | |
705 | ||
456126ad | 706 | AliExternalTrackParam *trkParam = 0; |
5970dfe2 | 707 | const AliESDfriendTrack* friendTrack = track->GetFriendTrack(); |
708 | if(friendTrack && friendTrack->GetTPCOut()) | |
709 | trkParam = const_cast<AliExternalTrackParam*>(friendTrack->GetTPCOut()); | |
710 | else | |
711 | trkParam = const_cast<AliExternalTrackParam*>(track->GetInnerParam()); | |
712 | if(!trkParam) return kFALSE; | |
713 | ||
456126ad | 714 | AliExternalTrackParam trkParamTmp (*trkParam); |
ee602376 | 715 | if(!AliEMCALRecoUtils::ExtrapolateTrackToCluster(&trkParamTmp, cluster, track->GetMass(), GetRecParam()->GetExtrapolateStep(), dEta, dPhi)) return kFALSE; |
5970dfe2 | 716 | |
717 | return kTRUE; | |
718 | } | |
719 | ||
720 | // | |
721 | //================================================================================== | |
722 | // | |
723 | AliEMCALReconstructor::AliEMCALMatch::AliEMCALMatch() | |
724 | : TObject(), | |
725 | fIndexT(-1), | |
726 | fDistance(-999.), | |
727 | fdEta(-999.), | |
728 | fdPhi(-999.) | |
729 | { | |
730 | //default constructor | |
916f1e76 | 731 | |
5970dfe2 | 732 | } |
733 | ||
734 | // | |
735 | //================================================================================== | |
736 | // | |
737 | AliEMCALReconstructor::AliEMCALMatch::AliEMCALMatch(const AliEMCALMatch& copy) | |
738 | : TObject(), | |
739 | fIndexT(copy.fIndexT), | |
740 | fDistance(copy.fDistance), | |
741 | fdEta(copy.fdEta), | |
742 | fdPhi(copy.fdPhi) | |
743 | { | |
744 | //copy ctor | |
745 | } | |
746 | ||
747 | // | |
748 | //================================================================================== | |
749 | // | |
750 | Int_t AliEMCALReconstructor::AliEMCALMatch::Compare(const TObject *obj) const | |
751 | { | |
752 | // | |
753 | // Compare wrt the residual | |
754 | // | |
755 | ||
756 | AliEMCALReconstructor::AliEMCALMatch *that = (AliEMCALReconstructor::AliEMCALMatch*)obj; | |
757 | ||
758 | Double_t thisDist = fDistance;//fDistance; | |
759 | Double_t thatDist = that->fDistance;//that->GetDistance(); | |
760 | ||
761 | if (thisDist > thatDist) return 1; | |
762 | else if (thisDist < thatDist) return -1; | |
763 | return 0; | |
764 | } |