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