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