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