]>
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 | // | |
29c9d15f | 24 | |
85c25c2e | 25 | |
f6019cda | 26 | // --- ROOT system --- |
85c25c2e | 27 | #include <TClonesArray.h> |
0c5b726e | 28 | #include "TGeoManager.h" |
29 | #include "TGeoMatrix.h" | |
f6019cda | 30 | |
31 | // --- Standard library --- | |
32 | ||
33 | // --- AliRoot header files --- | |
f6019cda | 34 | #include "AliEMCALReconstructor.h" |
5dee926e | 35 | |
aaa3cb7c | 36 | #include "AliCodeTimer.h" |
23ca956b | 37 | #include "AliCaloCalibPedestal.h" |
38 | #include "AliEMCALCalibData.h" | |
af885e0f | 39 | #include "AliESDEvent.h" |
89ffc0b0 | 40 | #include "AliESDCaloCluster.h" |
0e7c6655 | 41 | #include "AliESDCaloCells.h" |
6a0cf740 | 42 | #include "AliESDtrack.h" |
5dee926e | 43 | #include "AliEMCALLoader.h" |
98e9578e | 44 | #include "AliEMCALRawUtils.h" |
0e7c6655 | 45 | #include "AliEMCALDigit.h" |
f6019cda | 46 | #include "AliEMCALClusterizerv1.h" |
ee08edde | 47 | #include "AliEMCALClusterizerNxN.h" |
5dee926e | 48 | #include "AliEMCALRecPoint.h" |
dc293ae9 | 49 | #include "AliEMCALPID.h" |
0964c2e9 | 50 | #include "AliEMCALTrigger.h" |
1d59832c | 51 | #include "AliRawReader.h" |
fa42b1f3 | 52 | #include "AliCDBEntry.h" |
53 | #include "AliCDBManager.h" | |
65bdc82f | 54 | #include "AliEMCALGeometry.h" |
ac8ae9fe | 55 | #include "AliEMCAL.h" |
85c25c2e | 56 | #include "AliESDVZERO.h" |
0c5b726e | 57 | #include "AliCDBManager.h" |
72c58de0 | 58 | #include "AliRunLoader.h" |
59 | #include "AliRun.h" | |
916f1e76 | 60 | #include "AliEMCALTriggerData.h" |
61 | #include "AliEMCALTriggerElectronics.h" | |
fff39dd1 | 62 | #include "AliEMCALTriggerDCSConfigDB.h" |
63 | #include "AliEMCALTriggerDCSConfig.h" | |
de39a0ff | 64 | #include "AliEMCALTriggerData.h" |
65 | #include "AliEMCALTriggerRawDigit.h" | |
66 | #include "AliEMCALTriggerPatch.h" | |
67 | #include "AliEMCALTriggerTypes.h" | |
1d59832c | 68 | |
85c25c2e | 69 | ClassImp(AliEMCALReconstructor) |
f6019cda | 70 | |
b57cc9b9 | 71 | const AliEMCALRecParam* AliEMCALReconstructor::fgkRecParam = 0; // EMCAL rec. parameters |
72 | AliEMCALRawUtils* AliEMCALReconstructor::fgRawUtils = 0; // EMCAL raw utilities class | |
73 | AliEMCALClusterizer* AliEMCALReconstructor::fgClusterizer = 0; // EMCAL clusterizer class | |
74 | TClonesArray* AliEMCALReconstructor::fgDigitsArr = 0; // list of digits, to be used multiple times | |
75 | TObjArray* AliEMCALReconstructor::fgClustersArr = 0; // list of clusters, to be used multiple times | |
4bd37bd4 | 76 | TClonesArray* AliEMCALReconstructor::fgTriggerDigits = 0; // list of trigger digits, to be used multiple times |
916f1e76 | 77 | AliEMCALTriggerElectronics* AliEMCALReconstructor::fgTriggerProcessor = 0x0; |
f6019cda | 78 | //____________________________________________________________________________ |
18a21c7c | 79 | AliEMCALReconstructor::AliEMCALReconstructor() |
29c9d15f | 80 | : fGeom(0),fCalibData(0),fPedestalData(0),fTriggerData(0x0) |
f6019cda | 81 | { |
82 | // ctor | |
65bdc82f | 83 | |
84 | fgRawUtils = new AliEMCALRawUtils; | |
29c9d15f | 85 | |
72c58de0 | 86 | //To make sure we match with the geometry in a simulation file, |
87 | //let's try to get it first. If not, take the default geometry | |
33c3c91a | 88 | AliRunLoader *rl = AliRunLoader::Instance(); |
7e1d9a9b | 89 | if (rl->GetAliRun()){ |
90 | AliEMCAL * emcal = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL")); | |
91 | if(emcal) fGeom = emcal->GetGeometry(); | |
92 | } | |
93 | ||
94 | if(!fGeom) { | |
72c58de0 | 95 | AliInfo(Form("Using default geometry in reconstruction")); |
937d0661 | 96 | fGeom = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName()); |
65bdc82f | 97 | } |
29c9d15f | 98 | |
0c5b726e | 99 | //Get calibration parameters |
100 | if(!fCalibData) | |
101 | { | |
29c9d15f | 102 | AliCDBEntry *entry = (AliCDBEntry*) |
103 | AliCDBManager::Instance()->Get("EMCAL/Calib/Data"); | |
104 | if (entry) fCalibData = (AliEMCALCalibData*) entry->GetObject(); | |
0c5b726e | 105 | } |
29c9d15f | 106 | |
0c5b726e | 107 | if(!fCalibData) |
29c9d15f | 108 | AliFatal("Calibration parameters not found in CDB!"); |
109 | ||
40164976 | 110 | //Get calibration parameters |
111 | if(!fPedestalData) | |
112 | { | |
de39a0ff | 113 | AliCDBEntry *entry = (AliCDBEntry*) |
29c9d15f | 114 | AliCDBManager::Instance()->Get("EMCAL/Calib/Pedestals"); |
de39a0ff | 115 | if (entry) fPedestalData = (AliCaloCalibPedestal*) entry->GetObject(); |
40164976 | 116 | } |
de39a0ff | 117 | |
ee08edde | 118 | if(!fPedestalData) |
119 | AliFatal("Dead map not found in CDB!"); | |
29c9d15f | 120 | |
72c58de0 | 121 | if(!fGeom) AliFatal(Form("Could not get geometry!")); |
29c9d15f | 122 | |
f62c044a | 123 | AliEMCALTriggerDCSConfigDB* dcsConfigDB = AliEMCALTriggerDCSConfigDB::Instance(); |
29c9d15f | 124 | |
f62c044a | 125 | const AliEMCALTriggerDCSConfig* dcsConfig = dcsConfigDB->GetTriggerDCSConfig(); |
29c9d15f | 126 | |
f62c044a | 127 | if (!dcsConfig) AliFatal("No Trigger DCS Configuration from OCDB!"); |
128 | fgTriggerProcessor = new AliEMCALTriggerElectronics( dcsConfig ); | |
29c9d15f | 129 | |
f62c044a | 130 | fTriggerData = new AliEMCALTriggerData(); |
29c9d15f | 131 | |
f62c044a | 132 | //Init temporary list of digits |
4bd37bd4 | 133 | fgDigitsArr = new TClonesArray("AliEMCALDigit",1000); |
134 | fgClustersArr = new TObjArray(1000); | |
135 | fgTriggerDigits = new TClonesArray("AliEMCALTriggerRawDigit",1000); | |
f6019cda | 136 | } |
137 | ||
f6019cda | 138 | //____________________________________________________________________________ |
139 | AliEMCALReconstructor::~AliEMCALReconstructor() | |
140 | { | |
141 | // dtor | |
29c9d15f | 142 | |
23ca956b | 143 | if(fGeom) delete fGeom; |
80453a9f | 144 | |
145 | //No need to delete, recovered from OCDB | |
146 | //if(fCalibData) delete fCalibData; | |
147 | //if(fPedestalData) delete fPedestalData; | |
de39a0ff | 148 | |
b57cc9b9 | 149 | if(fgDigitsArr){ |
150 | fgDigitsArr->Clear("C"); | |
151 | delete fgDigitsArr; | |
152 | } | |
153 | ||
154 | if(fgClustersArr){ | |
155 | fgClustersArr->Clear(); | |
156 | delete fgClustersArr; | |
157 | } | |
158 | ||
4bd37bd4 | 159 | if(fgTriggerDigits){ |
7dbb454b | 160 | fgTriggerDigits->Clear(); |
4bd37bd4 | 161 | delete fgTriggerDigits; |
162 | } | |
163 | ||
23ca956b | 164 | if(fgRawUtils) delete fgRawUtils; |
165 | if(fgClusterizer) delete fgClusterizer; | |
f62c044a | 166 | if(fgTriggerProcessor) delete fgTriggerProcessor; |
b57cc9b9 | 167 | |
aaa3cb7c | 168 | AliCodeTimer::Instance()->Print(); |
f6019cda | 169 | } |
170 | ||
9519e3e3 | 171 | //____________________________________________________________________________ |
172 | void AliEMCALReconstructor::InitClusterizer() const | |
ee08edde | 173 | { |
9519e3e3 | 174 | //Init the clusterizer with geometry and calibration pointers, avoid doing it twice. |
175 | Int_t clusterizerType = -1; | |
176 | Int_t eventType = -1; | |
177 | if(GetRecParam()) { | |
178 | clusterizerType = GetRecParam()->GetClusterizerFlag(); | |
179 | eventType = GetRecParam()->GetEventSpecie(); | |
7e1d9a9b | 180 | } |
181 | else{ | |
9519e3e3 | 182 | AliCDBEntry *entry = (AliCDBEntry*) |
29c9d15f | 183 | AliCDBManager::Instance()->Get("EMCAL/Calib/RecoParam"); |
9519e3e3 | 184 | //Get The reco param for the default event specie |
185 | if (entry) { | |
186 | AliEMCALRecParam *recParam = (AliEMCALRecParam*)((TObjArray *) entry->GetObject())->At(0); | |
187 | if(recParam) clusterizerType = recParam->GetClusterizerFlag(); | |
de39a0ff | 188 | } |
7e1d9a9b | 189 | } |
ee08edde | 190 | |
9519e3e3 | 191 | //Check if clusterizer previously set corresponds to what is needed for this event type |
192 | if(fgClusterizer){ | |
193 | if(eventType!=AliRecoParam::kCalib){ | |
194 | //printf("ReCreate clusterizer? Clusterizer set <%d>, Clusterizer in use <%s>\n", | |
29c9d15f | 195 | // clusterizerType, fgClusterizer->Version()); |
9519e3e3 | 196 | |
197 | if (clusterizerType == AliEMCALRecParam::kClusterizerv1 && !strcmp(fgClusterizer->Version(),"clu-v1")) return; | |
198 | ||
199 | else if(clusterizerType == AliEMCALRecParam::kClusterizerNxN && !strcmp(fgClusterizer->Version(),"clu-NxN")) return; | |
200 | ||
201 | //Need to create new clusterizer, the one set previously is not the correct one | |
202 | delete fgClusterizer; | |
203 | } | |
204 | else return; | |
205 | } | |
29c9d15f | 206 | |
9519e3e3 | 207 | if (clusterizerType == AliEMCALRecParam::kClusterizerv1) |
29c9d15f | 208 | { |
209 | fgClusterizer = new AliEMCALClusterizerv1(fGeom, fCalibData,fPedestalData); | |
210 | } | |
9519e3e3 | 211 | else |
29c9d15f | 212 | { |
213 | fgClusterizer = new AliEMCALClusterizerNxN(fGeom, fCalibData,fPedestalData); | |
214 | } | |
ee08edde | 215 | } |
216 | ||
f6019cda | 217 | //____________________________________________________________________________ |
c47157cd | 218 | void AliEMCALReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const |
f6019cda | 219 | { |
220 | // method called by AliReconstruction; | |
221 | // Only the clusterization is performed,; the rest of the reconstruction is done in FillESD because the track | |
222 | // segment maker needs access to the AliESD object to retrieve the tracks reconstructed by | |
223 | // the global tracking. | |
c47157cd | 224 | // Works on the current event. |
29c9d15f | 225 | |
1a429a6b | 226 | AliCodeTimerAuto("",0) |
29c9d15f | 227 | |
228 | //Get input digits and put them in fgDigitsArr, clear the list before | |
85c25c2e | 229 | ReadDigitsArrayFromTree(digitsTree); |
29c9d15f | 230 | |
9519e3e3 | 231 | InitClusterizer(); |
232 | ||
0832a2bf | 233 | fgClusterizer->InitParameters(); |
4601e3a7 | 234 | fgClusterizer->SetOutput(clustersTree); |
9519e3e3 | 235 | |
e853f058 | 236 | //Skip clusterization of LED events |
237 | if (GetRecParam()->GetEventSpecie()!=AliRecoParam::kCalib){ | |
9517d886 | 238 | |
29c9d15f | 239 | if(fgDigitsArr && fgDigitsArr->GetEntries()) { |
240 | ||
241 | fgClusterizer->SetInput(digitsTree); | |
242 | ||
243 | //fgClusterizer->Digits2Clusters("deb all") ; //For debugging | |
244 | fgClusterizer->Digits2Clusters(""); | |
245 | ||
246 | fgClusterizer->Clear(); | |
247 | ||
248 | }//digits array exists and has somethind | |
e853f058 | 249 | }//not a LED event |
29c9d15f | 250 | |
916f1e76 | 251 | clustersTree->Fill(); |
f6019cda | 252 | } |
253 | ||
a68156e6 | 254 | //____________________________________________________________________________ |
c47157cd | 255 | void AliEMCALReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const |
29c9d15f | 256 | |
a68156e6 | 257 | { |
c47157cd | 258 | // Conversion from raw data to |
259 | // EMCAL digits. | |
260 | // Works on a single-event basis | |
29c9d15f | 261 | |
98e9578e | 262 | rawReader->Reset() ; |
29c9d15f | 263 | |
de39a0ff | 264 | fTriggerData->SetMode(1); |
29c9d15f | 265 | |
b57cc9b9 | 266 | if(fgDigitsArr) fgDigitsArr->Clear("C"); |
29c9d15f | 267 | |
de39a0ff | 268 | TClonesArray *digitsTrg = new TClonesArray("AliEMCALTriggerRawDigit", 32 * 96); |
29c9d15f | 269 | |
c47157cd | 270 | Int_t bufsize = 32000; |
b57cc9b9 | 271 | digitsTree->Branch("EMCAL", &fgDigitsArr, bufsize); |
916f1e76 | 272 | digitsTree->Branch("EMTRG", &digitsTrg, bufsize); |
29c9d15f | 273 | |
e853f058 | 274 | //Skip calibration events do the rest |
275 | Bool_t doFit = kTRUE; | |
276 | if ( !(GetRecParam()->FitLEDEvents()) && GetRecParam()->GetEventSpecie()==AliRecoParam::kCalib) doFit = kFALSE; | |
277 | if (doFit){ | |
29c9d15f | 278 | //must be done here because, in constructor, option is not yet known |
279 | fgRawUtils->SetOption(GetOption()); | |
280 | ||
92d9f317 | 281 | // fgRawUtils->SetRawFormatHighLowGainFactor(GetRecParam()->GetHighLowGainFactor()); |
282 | ||
283 | // fgRawUtils->SetRawFormatOrder(GetRecParam()->GetOrderParameter()); | |
284 | // fgRawUtils->SetRawFormatTau(GetRecParam()->GetTau()); | |
29c9d15f | 285 | fgRawUtils->SetNoiseThreshold(GetRecParam()->GetNoiseThreshold()); |
286 | fgRawUtils->SetNPedSamples(GetRecParam()->GetNPedSamples()); | |
287 | fgRawUtils->SetRemoveBadChannels(GetRecParam()->GetRemoveBadChannels()); | |
288 | fgRawUtils->SetFittingAlgorithm(GetRecParam()->GetFittingAlgorithm()); | |
289 | fgRawUtils->SetFALTROUsage(GetRecParam()->UseFALTRO()); | |
92d9f317 | 290 | |
291 | //fgRawUtils->SetTimeMin(GetRecParam()->GetTimeMin()); | |
292 | //fgRawUtils->SetTimeMax(GetRecParam()->GetTimeMax()); | |
293 | ||
294 | // fgRawUtils->SetTimeMin(-99999 ); | |
295 | // fgRawUtils->SetTimeMax( 99999 ); | |
29c9d15f | 296 | |
297 | fgRawUtils->Raw2Digits(rawReader,fgDigitsArr,fPedestalData,digitsTrg,fTriggerData); | |
92d9f317 | 298 | |
793176c1 | 299 | }//skip calibration event |
e853f058 | 300 | else{ |
29c9d15f | 301 | AliDebug(1," Calibration Event, skip!"); |
e853f058 | 302 | } |
29c9d15f | 303 | |
c615db53 | 304 | digitsTree->Fill(); |
916f1e76 | 305 | digitsTrg->Delete(); |
916f1e76 | 306 | delete digitsTrg; |
29c9d15f | 307 | |
a68156e6 | 308 | } |
309 | ||
85c25c2e | 310 | |
f6019cda | 311 | //____________________________________________________________________________ |
0e7c6655 | 312 | void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree, |
c47157cd | 313 | AliESDEvent* esd) const |
f6019cda | 314 | { |
98e9578e | 315 | // Called by AliReconstruct after Reconstruct() and global tracking and vertexing |
85c25c2e | 316 | // and V0 |
c47157cd | 317 | // Works on the current event |
de39a0ff | 318 | // printf(" ## AliEMCALReconstructor::FillESD() is started ### \n "); |
85c25c2e | 319 | //return; |
29c9d15f | 320 | |
7ba18c0e | 321 | //######################################## |
322 | // Trigger | |
323 | //######################################## | |
de39a0ff | 324 | |
29c9d15f | 325 | Int_t v0M[2] = {0, 0}; |
326 | ||
327 | AliESDVZERO* esdV0 = esd->GetVZEROData(); | |
328 | ||
329 | if (esdV0) | |
330 | { | |
331 | for (Int_t i = 0; i < 32; i++) | |
332 | { | |
333 | v0M[0] += (Int_t)esdV0->GetAdcV0C(i); | |
334 | v0M[1] += (Int_t)esdV0->GetAdcV0A(i); | |
335 | } | |
336 | } | |
337 | else | |
338 | { | |
339 | AliWarning("Cannot retrieve V0 ESD! Run w/ null V0 charges"); | |
340 | } | |
341 | ||
342 | if (fgTriggerDigits) fgTriggerDigits->Clear(); | |
343 | ||
344 | TBranch *branchtrg = digitsTree->GetBranch("EMTRG"); | |
345 | ||
346 | if (!branchtrg) | |
347 | { | |
348 | AliError("Can't get the branch with the EMCAL trigger digits!"); | |
349 | return; | |
350 | } | |
351 | ||
352 | branchtrg->SetAddress(&fgTriggerDigits); | |
353 | branchtrg->GetEntry(0); | |
354 | ||
355 | // Note: fgTriggerProcessor reset done at the end of this method | |
356 | fgTriggerProcessor->Digits2Trigger(fgTriggerDigits, v0M, fTriggerData); | |
357 | ||
358 | // Fill ESD | |
359 | AliESDCaloTrigger* trgESD = esd->GetCaloTrigger("EMCAL"); | |
360 | ||
361 | if (trgESD) | |
362 | { | |
363 | trgESD->Allocate(fgTriggerDigits->GetEntriesFast()); | |
364 | ||
365 | for (Int_t i = 0; i < fgTriggerDigits->GetEntriesFast(); i++) | |
366 | { | |
367 | AliEMCALTriggerRawDigit* rdig = (AliEMCALTriggerRawDigit*)fgTriggerDigits->At(i); | |
de39a0ff | 368 | |
29c9d15f | 369 | Int_t px, py; |
370 | if (fGeom->GetPositionInEMCALFromAbsFastORIndex(rdig->GetId(), px, py)) | |
371 | { | |
372 | Int_t a = -1, t = -1, times[10]; | |
373 | ||
374 | rdig->GetMaximum(a, t); | |
375 | rdig->GetL0Times(times); | |
376 | ||
377 | trgESD->Add(px, py, a, t, times, rdig->GetNL0Times(), rdig->GetL1TimeSum(), rdig->GetTriggerBits()); | |
378 | } | |
379 | } | |
380 | ||
381 | trgESD->SetL1Threshold(0, fTriggerData->GetL1GammaThreshold()); | |
382 | ||
383 | trgESD->SetL1Threshold(1, fTriggerData->GetL1JetThreshold() ); | |
384 | } | |
385 | ||
386 | // Resetting | |
387 | fTriggerData->Reset(); | |
de39a0ff | 388 | |
0e7c6655 | 389 | //######################################## |
390 | //##############Fill CaloCells############### | |
391 | //######################################## | |
29c9d15f | 392 | |
393 | //Get input digits and put them in fgDigitsArr, clear the list before | |
b57cc9b9 | 394 | ReadDigitsArrayFromTree(digitsTree); |
29c9d15f | 395 | |
b57cc9b9 | 396 | Int_t nDigits = fgDigitsArr->GetEntries(), idignew = 0 ; |
0e7c6655 | 397 | AliDebug(1,Form("%d digits",nDigits)); |
29c9d15f | 398 | |
0e7c6655 | 399 | AliESDCaloCells &emcCells = *(esd->GetEMCALCells()); |
400 | emcCells.CreateContainer(nDigits); | |
c8fe2783 | 401 | emcCells.SetType(AliVCaloCells::kEMCALCell); |
0c5b726e | 402 | Float_t energy = 0; |
0e7c6655 | 403 | for (Int_t idig = 0 ; idig < nDigits ; idig++) { |
b57cc9b9 | 404 | const AliEMCALDigit * dig = (const AliEMCALDigit*)fgDigitsArr->At(idig); |
829ba234 | 405 | if(dig->GetAmplitude() > 0 ){ |
29c9d15f | 406 | energy = fgClusterizer->Calibrate(dig->GetAmplitude(),dig->GetTime(),dig->GetId()); //TimeR or Time? |
407 | if(energy > 0){ //Digits tagged as bad (dead, hot, not alive) are set to 0 in calibrate, remove them | |
408 | emcCells.SetCell(idignew,dig->GetId(),energy, dig->GetTime()); | |
409 | idignew++; | |
410 | } | |
0e7c6655 | 411 | } |
412 | } | |
413 | emcCells.SetNumberOfCells(idignew); | |
414 | emcCells.Sort(); | |
29c9d15f | 415 | |
0e7c6655 | 416 | //------------------------------------------------------------ |
417 | //-----------------CLUSTERS----------------------------- | |
418 | //------------------------------------------------------------ | |
9dce5a21 | 419 | clustersTree->SetBranchStatus("*",0); //disable all branches |
420 | clustersTree->SetBranchStatus("EMCALECARP",1); //Enable only the branch we need | |
b57cc9b9 | 421 | if(fgClustersArr) fgClustersArr->Clear(); |
0e7c6655 | 422 | TBranch *branch = clustersTree->GetBranch("EMCALECARP"); |
b57cc9b9 | 423 | branch->SetAddress(&fgClustersArr); |
9dce5a21 | 424 | branch->GetEntry(0); |
425 | //clustersTree->GetEvent(0); | |
29c9d15f | 426 | |
b57cc9b9 | 427 | Int_t nClusters = fgClustersArr->GetEntries(), nClustersNew=0; |
0e7c6655 | 428 | AliDebug(1,Form("%d clusters",nClusters)); |
29c9d15f | 429 | |
6a0cf740 | 430 | //###################################################### |
431 | //#######################TRACK MATCHING############### | |
432 | //###################################################### | |
433 | //Fill list of integers, each one is index of track to which the cluster belongs. | |
29c9d15f | 434 | |
6a0cf740 | 435 | // step 1 - initialize array of matched track indexes |
436 | Int_t *matchedTrack = new Int_t[nClusters]; | |
437 | for (Int_t iclus = 0; iclus < nClusters; iclus++) | |
438 | matchedTrack[iclus] = -1; // neg. index --> no matched track | |
439 | ||
440 | // step 2, change the flag for all matched clusters found in tracks | |
441 | Int_t iemcalMatch = -1; | |
442 | Int_t endtpc = esd->GetNumberOfTracks(); | |
443 | for (Int_t itrack = 0; itrack < endtpc; itrack++) { | |
444 | AliESDtrack * track = esd->GetTrack(itrack) ; // retrieve track | |
445 | iemcalMatch = track->GetEMCALcluster(); | |
65f4a419 | 446 | if(iemcalMatch >= 0) matchedTrack[iemcalMatch] = itrack; |
6a0cf740 | 447 | } |
85c25c2e | 448 | |
6a0cf740 | 449 | //######################################## |
85c25c2e | 450 | //##############Fill CaloClusters############# |
6a0cf740 | 451 | //######################################## |
5dee926e | 452 | for (Int_t iClust = 0 ; iClust < nClusters ; iClust++) { |
b57cc9b9 | 453 | const AliEMCALRecPoint * clust = (const AliEMCALRecPoint*)fgClustersArr->At(iClust); |
c8fe2783 | 454 | //if(clust->GetClusterType()== AliVCluster::kEMCALClusterv1) nRP++; else nPC++; |
29c9d15f | 455 | // clust->Print(); //For debugging |
a7a5421e | 456 | // Get information from EMCAL reconstruction points |
85c60a8e | 457 | Float_t xyz[3]; |
5dee926e | 458 | TVector3 gpos; |
459 | clust->GetGlobalPosition(gpos); | |
35397e76 | 460 | for (Int_t ixyz=0; ixyz<3; ixyz++) |
5dee926e | 461 | xyz[ixyz] = gpos[ixyz]; |
85c25c2e | 462 | Float_t elipAxis[2]; |
463 | clust->GetElipsAxis(elipAxis); | |
29c9d15f | 464 | //Create digits lists |
35397e76 | 465 | Int_t cellMult = clust->GetMultiplicity(); |
466 | //TArrayS digiList(digitMult); | |
467 | Float_t *amplFloat = clust->GetEnergiesList(); | |
468 | Int_t *digitInts = clust->GetAbsId(); | |
469 | TArrayS absIdList(cellMult); | |
eb972628 | 470 | TArrayD fracList(cellMult); |
29c9d15f | 471 | |
35397e76 | 472 | Int_t newCellMult = 0; |
473 | for (Int_t iCell=0; iCell<cellMult; iCell++) { | |
474 | if (amplFloat[iCell] > 0) { | |
29c9d15f | 475 | absIdList[newCellMult] = (UShort_t)(digitInts[iCell]); |
476 | //Calculate Fraction | |
477 | if(emcCells.GetCellAmplitude(digitInts[iCell])>0 && GetRecParam()->GetUnfold()){ | |
478 | fracList[newCellMult] = amplFloat[iCell]/(emcCells.GetCellAmplitude(digitInts[iCell]));//get cell calibration value | |
479 | ||
480 | } | |
481 | else{ | |
482 | fracList[newCellMult] = 0; | |
483 | } | |
484 | newCellMult++; | |
92da3372 | 485 | } |
92da3372 | 486 | } |
29c9d15f | 487 | |
eb972628 | 488 | absIdList.Set(newCellMult); |
489 | fracList.Set(newCellMult); | |
490 | ||
35397e76 | 491 | if(newCellMult > 0) { // accept cluster if it has some digit |
492 | nClustersNew++; | |
65721814 | 493 | //Primaries |
7592dfc4 | 494 | Int_t parentMult = 0; |
fa42b1f3 | 495 | Int_t *parentList = clust->GetParents(parentMult); |
a7a5421e | 496 | // fills the ESDCaloCluster |
35397e76 | 497 | AliESDCaloCluster * ec = new AliESDCaloCluster() ; |
c8fe2783 | 498 | ec->SetType(AliVCluster::kEMCALClusterv1); |
7592dfc4 | 499 | ec->SetPosition(xyz); |
500 | ec->SetE(clust->GetEnergy()); | |
29c9d15f | 501 | |
ee08edde | 502 | //Distance to the nearest bad crystal |
503 | ec->SetDistanceToBadChannel(clust->GetDistanceToBadTower()); | |
29c9d15f | 504 | |
35397e76 | 505 | ec->SetNCells(newCellMult); |
506 | //Change type of list from short to ushort | |
507 | UShort_t *newAbsIdList = new UShort_t[newCellMult]; | |
ee08edde | 508 | Double_t *newFracList = new Double_t[newCellMult]; |
35397e76 | 509 | for(Int_t i = 0; i < newCellMult ; i++) { |
510 | newAbsIdList[i]=absIdList[i]; | |
de39a0ff | 511 | newFracList[i] =fracList[i]; |
35397e76 | 512 | } |
513 | ec->SetCellsAbsId(newAbsIdList); | |
eb972628 | 514 | ec->SetCellsAmplitudeFraction(newFracList); |
c8fe2783 | 515 | ec->SetDispersion(clust->GetDispersion()); |
516 | ec->SetChi2(-1); //not yet implemented | |
35397e76 | 517 | ec->SetM02(elipAxis[0]*elipAxis[0]) ; |
518 | ec->SetM20(elipAxis[1]*elipAxis[1]) ; | |
78902954 | 519 | ec->SetTOF(clust->GetTime()) ; //time-of-fligh |
225cd96d | 520 | ec->SetNExMax(clust->GetNExMax()); //number of local maxima |
35397e76 | 521 | TArrayI arrayTrackMatched(1);// Only one track, temporal solution. |
522 | arrayTrackMatched[0]= matchedTrack[iClust]; | |
523 | ec->AddTracksMatched(arrayTrackMatched); | |
29c9d15f | 524 | |
35397e76 | 525 | TArrayI arrayParents(parentMult,parentList); |
526 | ec->AddLabels(arrayParents); | |
29c9d15f | 527 | |
6a0cf740 | 528 | // add the cluster to the esd object |
eb972628 | 529 | esd->AddCaloCluster(ec); |
a7a5421e | 530 | delete ec; |
85d4cbde | 531 | delete [] newAbsIdList ; |
eb972628 | 532 | delete [] newFracList ; |
29c9d15f | 533 | } |
534 | } // cycle on clusters | |
535 | ||
536 | delete [] matchedTrack; | |
537 | ||
538 | //Fill ESDCaloCluster with PID weights | |
539 | AliEMCALPID *pid = new AliEMCALPID; | |
540 | //pid->SetPrintInfo(kTRUE); | |
541 | pid->SetReconstructor(kTRUE); | |
542 | pid->RunPID(esd); | |
543 | delete pid; | |
544 | ||
545 | //Store EMCAL misalignment matrixes | |
546 | FillMisalMatrixes(esd) ; | |
547 | ||
0c5b726e | 548 | } |
549 | ||
550 | //================================================================================== | |
551 | void AliEMCALReconstructor::FillMisalMatrixes(AliESDEvent* esd)const{ | |
29c9d15f | 552 | //Store EMCAL matrixes in ESD Header |
553 | ||
554 | //Check, if matrixes was already stored | |
555 | for(Int_t sm = 0 ; sm < fGeom->GetNumberOfSuperModules(); sm++){ | |
556 | if(esd->GetEMCALMatrix(sm)!=0) | |
557 | return ; | |
558 | } | |
559 | ||
560 | //Create and store matrixes | |
561 | if(!gGeoManager){ | |
562 | AliError("Can not store misal. matrixes: no gGeoManager! \n") ; | |
563 | return ; | |
564 | } | |
565 | //Note, that owner of copied marixes will be header | |
7e1d9a9b | 566 | const Int_t bufsize = 255; |
29c9d15f | 567 | char path[bufsize] ; |
568 | TGeoHMatrix * m = 0x0; | |
569 | for(Int_t sm = 0; sm < fGeom->GetNumberOfSuperModules(); sm++){ | |
570 | snprintf(path,bufsize,"/ALIC_1/XEN1_1/SMOD_%d",sm+1) ; //In Geometry modules numbered 1,2,.,5 | |
571 | if(sm >= 10) snprintf(path,bufsize,"/ALIC_1/XEN1_1/SM10_%d",sm-10+1) ; | |
572 | ||
573 | if (gGeoManager->CheckPath(path)){ | |
574 | gGeoManager->cd(path); | |
575 | m = gGeoManager->GetCurrentMatrix() ; | |
576 | // printf("================================================= \n"); | |
577 | // printf("AliEMCALReconstructor::FixMisalMatrixes(), sm %d, \n",sm); | |
578 | // m->Print(""); | |
579 | esd->SetEMCALMatrix(new TGeoHMatrix(*m),sm) ; | |
580 | // printf("================================================= \n"); | |
581 | } | |
582 | else{ | |
583 | esd->SetEMCALMatrix(NULL,sm) ; | |
584 | } | |
585 | } | |
f6019cda | 586 | } |
dc293ae9 | 587 | |
9517d886 | 588 | //__________________________________________________________________________ |
85c25c2e | 589 | void AliEMCALReconstructor::ReadDigitsArrayFromTree(TTree *digitsTree) const |
590 | { | |
29c9d15f | 591 | // Read the digits from the input tree |
592 | // See AliEMCALClusterizer::SetInput(TTree *digitsTree); | |
593 | ||
594 | // Clear previous digits in the list | |
595 | if(fgDigitsArr){ | |
b57cc9b9 | 596 | fgDigitsArr->Clear("C"); |
85c25c2e | 597 | } |
29c9d15f | 598 | else{ |
599 | // It should not happen, but just in case ... | |
600 | fgDigitsArr = new TClonesArray("AliEMCALDigit",100); | |
601 | } | |
602 | ||
85c25c2e | 603 | // Read the digits from the input tree |
604 | TBranch *branch = digitsTree->GetBranch("EMCAL"); | |
605 | if (!branch) { | |
606 | AliError("can't get the branch with the EMCAL digits !"); | |
607 | return; | |
29c9d15f | 608 | } |
609 | ||
85c25c2e | 610 | branch->SetAddress(&fgDigitsArr); |
611 | branch->GetEntry(0); | |
612 | } | |
98e9578e | 613 | |
916f1e76 | 614 |