]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALReconstructor.cxx
Fixed a bug in SubmitNext - the number of jobs to be submitted is not 0 anymore.
[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"
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"
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"
62#include "AliVZEROLoader.h"
1d59832c 63
85c25c2e 64ClassImp(AliEMCALReconstructor)
f6019cda 65
ba6de5ea 66const AliEMCALRecParam* AliEMCALReconstructor::fgkRecParam = 0; // EMCAL rec. parameters
65bdc82f 67AliEMCALRawUtils* AliEMCALReconstructor::fgRawUtils = 0; // EMCAL raw utilities class
9517d886 68AliEMCALClusterizer* AliEMCALReconstructor::fgClusterizer = 0; // EMCAL clusterizer class
85c25c2e 69TClonesArray* AliEMCALReconstructor::fgDigitsArr = 0; // shoud read just once at event
916f1e76 70AliEMCALTriggerElectronics* AliEMCALReconstructor::fgTriggerProcessor = 0x0;
f6019cda 71//____________________________________________________________________________
18a21c7c 72AliEMCALReconstructor::AliEMCALReconstructor()
40164976 73 : fDebug(kFALSE), fList(0), fGeom(0),fCalibData(0),fPedestalData(0)
f6019cda 74{
75 // ctor
65bdc82f 76
77 fgRawUtils = new AliEMCALRawUtils;
72c58de0 78
79 //To make sure we match with the geometry in a simulation file,
80 //let's try to get it first. If not, take the default geometry
33c3c91a 81 AliRunLoader *rl = AliRunLoader::Instance();
72c58de0 82 if (rl->GetAliRun() && rl->GetAliRun()->GetDetector("EMCAL")) {
83 fGeom = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"))->GetGeometry();
84 } else {
85 AliInfo(Form("Using default geometry in reconstruction"));
937d0661 86 fGeom = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName());
65bdc82f 87 }
0e7c6655 88
0c5b726e 89 //Get calibration parameters
90 if(!fCalibData)
91 {
92 AliCDBEntry *entry = (AliCDBEntry*)
93 AliCDBManager::Instance()->Get("EMCAL/Calib/Data");
94 if (entry) fCalibData = (AliEMCALCalibData*) entry->GetObject();
95 }
96
97 if(!fCalibData)
98 AliFatal("Calibration parameters not found in CDB!");
99
40164976 100 //Get calibration parameters
101 if(!fPedestalData)
102 {
103 AliCDBEntry *entry = (AliCDBEntry*)
104 AliCDBManager::Instance()->Get("EMCAL/Calib/Pedestals");
105 if (entry) fPedestalData = (AliCaloCalibPedestal*) entry->GetObject();
106 }
107
108 if(!fPedestalData)
109 AliFatal("Dead map not found in CDB!");
110
111
0c5b726e 112 //Init the clusterizer with geometry and calibration pointers, avoid doing it twice.
40164976 113 fgClusterizer = new AliEMCALClusterizerv1(fGeom, fCalibData,fPedestalData);
0c5b726e 114
72c58de0 115 if(!fGeom) AliFatal(Form("Could not get geometry!"));
116
916f1e76 117 fgTriggerProcessor = new AliEMCALTriggerElectronics();
f6019cda 118}
119
f6019cda 120//____________________________________________________________________________
121AliEMCALReconstructor::~AliEMCALReconstructor()
122{
123 // dtor
65bdc82f 124 delete fGeom;
5e3106bc 125 delete fgRawUtils;
126 delete fgClusterizer;
916f1e76 127 delete fgTriggerProcessor;
128
aaa3cb7c 129 AliCodeTimer::Instance()->Print();
f6019cda 130}
131
40871053 132// //____________________________________________________________________________
133// void AliEMCALReconstructor::Init()
134// {
135// // Trigger hists - Oct 24, 2007
136// fList = AliEMCALHistoUtilities::GetTriggersListOfHists(kTRUE);
137// }
85c25c2e 138
f6019cda 139//____________________________________________________________________________
c47157cd 140void AliEMCALReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const
f6019cda 141{
142 // method called by AliReconstruction;
143 // Only the clusterization is performed,; the rest of the reconstruction is done in FillESD because the track
144 // segment maker needs access to the AliESD object to retrieve the tracks reconstructed by
145 // the global tracking.
c47157cd 146 // Works on the current event.
fa42b1f3 147
1a429a6b 148 AliCodeTimerAuto("",0)
aaa3cb7c 149
85c25c2e 150 ReadDigitsArrayFromTree(digitsTree);
0832a2bf 151 fgClusterizer->InitParameters();
4601e3a7 152 fgClusterizer->SetOutput(clustersTree);
916f1e76 153
154 AliEMCALTriggerData* trgData = new AliEMCALTriggerData();
155
156 Int_t bufferSize = 32000;
157
158 if (TBranch* triggerBranch = clustersTree->GetBranch("EMTRG"))
159 triggerBranch->SetAddress(&trgData);
160 else
161 clustersTree->Branch("EMTRG","AliEMCALTriggerData",&trgData,bufferSize);
162
163 AliVZEROLoader* vzeroLoader = dynamic_cast<AliVZEROLoader*>(AliRunLoader::Instance()->GetDetectorLoader("VZERO"));
164
165 TTree* treeV0 = 0x0;
166
167 if (vzeroLoader)
168 {
169 vzeroLoader->LoadDigits("READ");
170 treeV0 = vzeroLoader->TreeD();
171 }
172
173 TClonesArray *trgDigits = new TClonesArray("AliEMCALRawDigit",1000);
174 TBranch *branchdig = digitsTree->GetBranch("EMTRG");
175 if (!branchdig)
176 {
177 AliError("Can't get the branch with the EMCAL trigger digits !");
178 return;
179 }
180
181 branchdig->SetAddress(&trgDigits);
182 branchdig->GetEntry(0);
183
184 fgTriggerProcessor->Digits2Trigger(trgDigits, treeV0, trgData);
185
186 trgDigits->Delete();
0c5b726e 187
85c25c2e 188 if(fgDigitsArr && fgDigitsArr->GetEntries()) {
189
9517d886 190 fgClusterizer->SetInput(digitsTree);
9517d886 191
85c25c2e 192 if(Debug())
9517d886 193 fgClusterizer->Digits2Clusters("deb all") ;
85c25c2e 194 else
9517d886 195 fgClusterizer->Digits2Clusters("");
196
197 fgClusterizer->Clear();
85c25c2e 198
199 }
9517d886 200
8437dee9 201 if (vzeroLoader)
202 {
203 vzeroLoader->UnloadDigits();
204 }
205
916f1e76 206 clustersTree->Fill();
207
208 delete trgData;
f6019cda 209}
210
a68156e6 211//____________________________________________________________________________
c47157cd 212void AliEMCALReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
98e9578e 213
a68156e6 214{
c47157cd 215 // Conversion from raw data to
216 // EMCAL digits.
217 // Works on a single-event basis
85c60a8e 218
98e9578e 219 rawReader->Reset() ;
98e9578e 220
3e5fa09c 221 TClonesArray *digitsArr = new TClonesArray("AliEMCALDigit",200);
916f1e76 222 TClonesArray *digitsTrg = new TClonesArray("AliEMCALRawDigit", 200);
223
c47157cd 224 Int_t bufsize = 32000;
225 digitsTree->Branch("EMCAL", &digitsArr, bufsize);
916f1e76 226 digitsTree->Branch("EMTRG", &digitsTrg, bufsize);
98e9578e 227
65bdc82f 228 //must be done here because, in constructor, option is not yet known
229 fgRawUtils->SetOption(GetOption());
b4133f05 230
0832a2bf 231 fgRawUtils->SetRawFormatHighLowGainFactor(GetRecParam()->GetHighLowGainFactor());
232 fgRawUtils->SetRawFormatOrder(GetRecParam()->GetOrderParameter());
233 fgRawUtils->SetRawFormatTau(GetRecParam()->GetTau());
234 fgRawUtils->SetNoiseThreshold(GetRecParam()->GetNoiseThreshold());
235 fgRawUtils->SetNPedSamples(GetRecParam()->GetNPedSamples());
9f467289 236 fgRawUtils->SetRemoveBadChannels(GetRecParam()->GetRemoveBadChannels());
237 fgRawUtils->SetFittingAlgorithm(GetRecParam()->GetFittingAlgorithm());
46f1d25f 238 fgRawUtils->SetFALTROUsage(GetRecParam()->UseFALTRO());
239
916f1e76 240 fgRawUtils->Raw2Digits(rawReader,digitsArr,fPedestalData,digitsTrg);
c615db53 241
242 digitsTree->Fill();
89d338a6 243 digitsArr->Delete();
916f1e76 244 digitsTrg->Delete();
89d338a6 245 delete digitsArr;
916f1e76 246 delete digitsTrg;
c615db53 247
a68156e6 248}
249
85c25c2e 250
f6019cda 251//____________________________________________________________________________
0e7c6655 252void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree,
c47157cd 253 AliESDEvent* esd) const
f6019cda 254{
98e9578e 255 // Called by AliReconstruct after Reconstruct() and global tracking and vertexing
85c25c2e 256 // and V0
c47157cd 257 // Works on the current event
85c25c2e 258 // printf(" ## AliEMCALReconstructor::FillESD() is started ### \n ");
259 //return;
92da3372 260
6a0cf740 261 //######################################################
0964c2e9 262 //#########Calculate trigger and set trigger info###########
6a0cf740 263 //######################################################
46f1d25f 264 // Obsolete, to be changed with new trigger emulator when consensus is achieved about what is stored in ESDs.
85c25c2e 265 AliEMCALTrigger tr;
266 // tr.SetPatchSize(1); // create 4x4 patches
267 tr.SetSimulation(kFALSE); // Reconstruction mode
268 tr.SetDigitsList(fgDigitsArr);
269 // Get VZERO total multiplicity for jet trigger simulation
270 // The simulation of jey trigger will be incorrect if no VZERO data
271 // at ESD
272 AliESDVZERO* vZero = esd->GetVZEROData();
273 if(vZero) {
274 tr.SetVZER0Multiplicity(vZero->GetMTotV0A() + vZero->GetMTotV0C());
275 }
276 //
0964c2e9 277 tr.Trigger();
85c25c2e 278
0964c2e9 279 Float_t maxAmp2x2 = tr.Get2x2MaxAmplitude();
280 Float_t maxAmpnxn = tr.GetnxnMaxAmplitude();
281 Float_t ampOutOfPatch2x2 = tr.Get2x2AmpOutOfPatch() ;
282 Float_t ampOutOfPatchnxn = tr.GetnxnAmpOutOfPatch() ;
283
0964c2e9 284 Int_t iSM2x2 = tr.Get2x2SuperModule();
285 Int_t iSMnxn = tr.GetnxnSuperModule();
85c25c2e 286 Int_t iModulePhi2x2 = tr.Get2x2ModulePhi();
287 Int_t iModulePhinxn = tr.GetnxnModulePhi();
288 Int_t iModuleEta2x2 = tr.Get2x2ModuleEta();
289 Int_t iModuleEtanxn = tr.GetnxnModuleEta();
0964c2e9 290
85c25c2e 291 AliDebug(2, Form("Trigger 2x2 max amp %f, out amp %f, SM %d, iphi %d ieta %d", maxAmp2x2, ampOutOfPatch2x2, iSM2x2,iModulePhi2x2, iModuleEta2x2));
292 AliDebug(2, Form("Trigger 4x4 max amp %f , out amp %f, SM %d, iphi %d, ieta %d", maxAmpnxn, ampOutOfPatchnxn, iSMnxn,iModulePhinxn, iModuleEtanxn));
0964c2e9 293
294 TVector3 pos2x2(-1,-1,-1);
295 TVector3 posnxn(-1,-1,-1);
296
85c25c2e 297 Int_t iAbsId2x2 = fGeom->GetAbsCellIdFromCellIndexes( iSM2x2, iModulePhi2x2, iModuleEta2x2) ; // should be changed to Module
298 Int_t iAbsIdnxn = fGeom->GetAbsCellIdFromCellIndexes( iSMnxn, iModulePhinxn, iModuleEtanxn) ;
65bdc82f 299 fGeom->GetGlobal(iAbsId2x2, pos2x2);
300 fGeom->GetGlobal(iAbsIdnxn, posnxn);
85c25c2e 301 //printf(" iAbsId2x2 %i iAbsIdnxn %i \n", iAbsId2x2, iAbsIdnxn);
0964c2e9 302
303 TArrayF triggerPosition(6);
304 triggerPosition[0] = pos2x2(0) ;
305 triggerPosition[1] = pos2x2(1) ;
306 triggerPosition[2] = pos2x2(2) ;
307 triggerPosition[3] = posnxn(0) ;
308 triggerPosition[4] = posnxn(1) ;
85c25c2e 309 triggerPosition[5] = posnxn(2) ;
310 //printf(" triggerPosition ");
311 //for(int i=0; i<6; i++) printf(" %i %f : ", i, triggerPosition[i]);
0964c2e9 312
313 TArrayF triggerAmplitudes(4);
314 triggerAmplitudes[0] = maxAmp2x2 ;
315 triggerAmplitudes[1] = ampOutOfPatch2x2 ;
316 triggerAmplitudes[2] = maxAmpnxn ;
317 triggerAmplitudes[3] = ampOutOfPatchnxn ;
85c25c2e 318 //printf("\n triggerAmplitudes ");
319 //for(int i=0; i<4; i++) printf(" %i %f : ", i, triggerAmplitudes[i]);
320 //printf("\n");
85d4cbde 321 //tr.Print("");
60d8ad94 322 //
323 // Trigger jet staff
324 //
325 if(tr.GetNJetThreshold()>0) {
326 // Jet phi/eta
327 Int_t n0 = triggerPosition.GetSize();
328 const TH2F *hpatch = tr.GetJetMatrixE();
329 triggerPosition.Set(n0 + 2);
330 for(Int_t i=0; i<2; i++) triggerPosition[n0+i] = hpatch->GetMean(i+1);
331 // Add jet ampitudes
332 n0 = triggerAmplitudes.GetSize();
333 triggerAmplitudes.Set(n0 + tr.GetNJetThreshold());
334 Double_t *ampJet = tr.GetL1JetThresholds();
335 for(Int_t i=0; i<tr.GetNJetThreshold(); i++){
336 triggerAmplitudes[n0 + i] = Float_t(ampJet[i]);
337 }
338 }
0964c2e9 339 esd->AddEMCALTriggerPosition(triggerPosition);
340 esd->AddEMCALTriggerAmplitudes(triggerAmplitudes);
85c25c2e 341 // Fill trigger hists
40871053 342 // AliEMCALHistoUtilities::FillTriggersListOfHists(fList,&triggerPosition,&triggerAmplitudes);
aaa3cb7c 343
0e7c6655 344 //########################################
345 //##############Fill CaloCells###############
346 //########################################
aaa3cb7c 347
0e7c6655 348 TClonesArray *digits = new TClonesArray("AliEMCALDigit",1000);
349 TBranch *branchdig = digitsTree->GetBranch("EMCAL");
350 if (!branchdig) {
0c5b726e 351 AliError("can't get the branch with the EMCAL digits !");
0e7c6655 352 return;
353 }
354 branchdig->SetAddress(&digits);
355 digitsTree->GetEvent(0);
356 Int_t nDigits = digits->GetEntries(), idignew = 0 ;
357 AliDebug(1,Form("%d digits",nDigits));
358
359 AliESDCaloCells &emcCells = *(esd->GetEMCALCells());
360 emcCells.CreateContainer(nDigits);
361 emcCells.SetType(AliESDCaloCells::kEMCALCell);
0c5b726e 362 Float_t energy = 0;
0e7c6655 363 for (Int_t idig = 0 ; idig < nDigits ; idig++) {
364 const AliEMCALDigit * dig = (const AliEMCALDigit*)digits->At(idig);
829ba234 365 if(dig->GetAmplitude() > 0 ){
366 energy = (static_cast<AliEMCALClusterizerv1*> (fgClusterizer))->Calibrate(dig->GetAmplitude(),dig->GetTime(),dig->GetId()); //TimeR or Time?
40164976 367 if(energy > 0){ //Digits tagged as bad (dead, hot, not alive) are set to 0 in calibrate, remove them
368 emcCells.SetCell(idignew,dig->GetId(),energy, dig->GetTime());
369 idignew++;
370 }
0e7c6655 371 }
372 }
373 emcCells.SetNumberOfCells(idignew);
374 emcCells.Sort();
375
376 //------------------------------------------------------------
377 //-----------------CLUSTERS-----------------------------
378 //------------------------------------------------------------
379 TObjArray *clusters = new TObjArray(100);
380 TBranch *branch = clustersTree->GetBranch("EMCALECARP");
381 branch->SetAddress(&clusters);
382 clustersTree->GetEvent(0);
383
384 Int_t nClusters = clusters->GetEntries(), nClustersNew=0;
385 AliDebug(1,Form("%d clusters",nClusters));
85c25c2e 386
6a0cf740 387 //######################################################
388 //#######################TRACK MATCHING###############
389 //######################################################
390 //Fill list of integers, each one is index of track to which the cluster belongs.
391
392 // step 1 - initialize array of matched track indexes
393 Int_t *matchedTrack = new Int_t[nClusters];
394 for (Int_t iclus = 0; iclus < nClusters; iclus++)
395 matchedTrack[iclus] = -1; // neg. index --> no matched track
396
397 // step 2, change the flag for all matched clusters found in tracks
398 Int_t iemcalMatch = -1;
399 Int_t endtpc = esd->GetNumberOfTracks();
400 for (Int_t itrack = 0; itrack < endtpc; itrack++) {
401 AliESDtrack * track = esd->GetTrack(itrack) ; // retrieve track
402 iemcalMatch = track->GetEMCALcluster();
65f4a419 403 if(iemcalMatch >= 0) matchedTrack[iemcalMatch] = itrack;
6a0cf740 404 }
85c25c2e 405
6a0cf740 406 //########################################
85c25c2e 407 //##############Fill CaloClusters#############
6a0cf740 408 //########################################
5dee926e 409 for (Int_t iClust = 0 ; iClust < nClusters ; iClust++) {
c47157cd 410 const AliEMCALRecPoint * clust = (const AliEMCALRecPoint*)clusters->At(iClust);
8ada0ffe 411 //if(clust->GetClusterType()== AliESDCaloCluster::kEMCALClusterv1) nRP++; else nPC++;
85c60a8e 412 if (Debug()) clust->Print();
a7a5421e 413 // Get information from EMCAL reconstruction points
85c60a8e 414 Float_t xyz[3];
5dee926e 415 TVector3 gpos;
416 clust->GetGlobalPosition(gpos);
35397e76 417 for (Int_t ixyz=0; ixyz<3; ixyz++)
5dee926e 418 xyz[ixyz] = gpos[ixyz];
85c25c2e 419 Float_t elipAxis[2];
420 clust->GetElipsAxis(elipAxis);
35397e76 421 //Create digits lists
422 Int_t cellMult = clust->GetMultiplicity();
423 //TArrayS digiList(digitMult);
424 Float_t *amplFloat = clust->GetEnergiesList();
425 Int_t *digitInts = clust->GetAbsId();
426 TArrayS absIdList(cellMult);
eb972628 427 TArrayD fracList(cellMult);
35397e76 428
429 Int_t newCellMult = 0;
430 for (Int_t iCell=0; iCell<cellMult; iCell++) {
431 if (amplFloat[iCell] > 0) {
432 absIdList[newCellMult] = (UShort_t)(digitInts[iCell]);
eb972628 433 //Uncomment when unfolding is done
434 //if(emcCells.GetCellAmplitude(digitInts[iCell])>0)
435 //fracList[newCellMult] = amplFloat[iCell]/(emcCells.GetCellAmplitude(digitInts[iCell])*calibration);//get cell calibration value
436 //else
437 fracList[newCellMult] = 0;
35397e76 438 newCellMult++;
92da3372 439 }
92da3372 440 }
85c25c2e 441
eb972628 442 absIdList.Set(newCellMult);
443 fracList.Set(newCellMult);
444
35397e76 445 if(newCellMult > 0) { // accept cluster if it has some digit
446 nClustersNew++;
65721814 447 //Primaries
7592dfc4 448 Int_t parentMult = 0;
fa42b1f3 449 Int_t *parentList = clust->GetParents(parentMult);
a7a5421e 450 // fills the ESDCaloCluster
35397e76 451 AliESDCaloCluster * ec = new AliESDCaloCluster() ;
452 ec->SetClusterType(AliESDCaloCluster::kEMCALClusterv1);
7592dfc4 453 ec->SetPosition(xyz);
454 ec->SetE(clust->GetEnergy());
40164976 455
456 //Distance to the nearest bad crystal
457 ec->SetDistanceToBadChannel(clust->GetDistanceToBadTower());
458
35397e76 459 ec->SetNCells(newCellMult);
460 //Change type of list from short to ushort
461 UShort_t *newAbsIdList = new UShort_t[newCellMult];
eb972628 462 Double_t *newFracList = new Double_t[newCellMult];
35397e76 463 for(Int_t i = 0; i < newCellMult ; i++) {
464 newAbsIdList[i]=absIdList[i];
eb972628 465 newFracList[i]=fracList[i];
35397e76 466 }
467 ec->SetCellsAbsId(newAbsIdList);
eb972628 468 ec->SetCellsAmplitudeFraction(newFracList);
35397e76 469 ec->SetClusterDisp(clust->GetDispersion());
470 ec->SetClusterChi2(-1); //not yet implemented
471 ec->SetM02(elipAxis[0]*elipAxis[0]) ;
472 ec->SetM20(elipAxis[1]*elipAxis[1]) ;
78902954 473 ec->SetTOF(clust->GetTime()) ; //time-of-fligh
225cd96d 474 ec->SetNExMax(clust->GetNExMax()); //number of local maxima
35397e76 475 TArrayI arrayTrackMatched(1);// Only one track, temporal solution.
476 arrayTrackMatched[0]= matchedTrack[iClust];
477 ec->AddTracksMatched(arrayTrackMatched);
478
479 TArrayI arrayParents(parentMult,parentList);
480 ec->AddLabels(arrayParents);
481
6a0cf740 482 // add the cluster to the esd object
eb972628 483 esd->AddCaloCluster(ec);
a7a5421e 484 delete ec;
85d4cbde 485 delete [] newAbsIdList ;
eb972628 486 delete [] newFracList ;
35397e76 487 }
488 } // cycle on clusters
85c25c2e 489
35397e76 490 delete [] matchedTrack;
85c25c2e 491
35397e76 492 //Fill ESDCaloCluster with PID weights
1942834a 493 AliEMCALPID *pid = new AliEMCALPID;
494 //pid->SetPrintInfo(kTRUE);
495 pid->SetReconstructor(kTRUE);
496 pid->RunPID(esd);
497 delete pid;
eb972628 498
1942834a 499 delete digits;
500 delete clusters;
eb972628 501
1942834a 502 //Store EMCAL misalignment matrixes
503 FillMisalMatrixes(esd) ;
0c5b726e 504
505}
506
507//==================================================================================
508void AliEMCALReconstructor::FillMisalMatrixes(AliESDEvent* esd)const{
509 //Store EMCAL matrixes in ESD Header
510
511 //Check, if matrixes was already stored
cb8a44fb 512 for(Int_t sm = 0 ; sm < fGeom->GetNumberOfSuperModules(); sm++){
0c5b726e 513 if(esd->GetEMCALMatrix(sm)!=0)
514 return ;
515 }
516
517 //Create and store matrixes
518 if(!gGeoManager){
519 AliError("Can not store misal. matrixes: no gGeoManager! \n") ;
520 return ;
521 }
522 //Note, that owner of copied marixes will be header
523 char path[255] ;
5e3106bc 524 TGeoHMatrix * m = 0x0;
cb8a44fb 525 for(Int_t sm = 0; sm < fGeom->GetNumberOfSuperModules(); sm++){
0c5b726e 526 sprintf(path,"/ALIC_1/XEN1_1/SMOD_%d",sm+1) ; //In Geometry modules numbered 1,2,.,5
527 if(sm >= 10) sprintf(path,"/ALIC_1/XEN1_1/SM10_%d",sm-10+1) ;
528
9ddc5deb 529 if (gGeoManager->CheckPath(path)){
cb8a44fb 530 gGeoManager->cd(path);
0c5b726e 531 m = gGeoManager->GetCurrentMatrix() ;
cb8a44fb 532// printf("================================================= \n");
533// printf("AliEMCALReconstructor::FixMisalMatrixes(), sm %d, \n",sm);
534// m->Print("");
0c5b726e 535 esd->SetEMCALMatrix(new TGeoHMatrix(*m),sm) ;
cb8a44fb 536// printf("================================================= \n");
0c5b726e 537 }
538 else{
539 esd->SetEMCALMatrix(NULL,sm) ;
540 }
541 }
f6019cda 542}
dc293ae9 543
0c5b726e 544
545
9517d886 546//__________________________________________________________________________
85c25c2e 547void AliEMCALReconstructor::ReadDigitsArrayFromTree(TTree *digitsTree) const
548{
549 // See AliEMCALClusterizer::SetInput(TTree *digitsTree);
550 if(fgDigitsArr) {
551 // Clear previous digits
552 fgDigitsArr->Delete();
553 delete fgDigitsArr;
554 }
555 // Read the digits from the input tree
556 TBranch *branch = digitsTree->GetBranch("EMCAL");
557 if (!branch) {
558 AliError("can't get the branch with the EMCAL digits !");
559 return;
560 }
561 fgDigitsArr = new TClonesArray("AliEMCALDigit",100);
562 branch->SetAddress(&fgDigitsArr);
563 branch->GetEntry(0);
564}
98e9578e 565
916f1e76 566