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