1 /**************************************************************************
2 #/eliza17/alice/esdfiles/data/2011/LHC11a/000146805/ESDs/pass2_without_SDD/11000146805038.550/root_archive.zip#AliESDs.root
3 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * Author: The ALICE Off-line Project. *
6 * Contributors are mentioned in the code where appropriate. *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
19 //_________________________________________________________________________
21 //-- Yves Schutz (SUBATECH)
22 // Reconstruction class. Redesigned from the old AliReconstructionner class and
23 // derived from STEER/AliReconstructor.
27 // --- ROOT system ---
28 #include <TClonesArray.h>
29 #include "TGeoManager.h"
30 #include "TGeoMatrix.h"
32 // --- Standard library ---
34 // --- AliRoot header files ---
35 #include "AliEMCALReconstructor.h"
37 #include "AliCodeTimer.h"
38 #include "AliCaloCalibPedestal.h"
39 #include "AliEMCALCalibData.h"
40 #include "AliESDEvent.h"
41 #include "AliESDCaloCluster.h"
42 #include "AliESDCaloCells.h"
43 #include "AliESDtrack.h"
44 #include "AliEMCALLoader.h"
45 #include "AliEMCALRawUtils.h"
46 #include "AliEMCALDigit.h"
47 #include "AliEMCALClusterizerv1.h"
48 #include "AliEMCALClusterizerv2.h"
49 #include "AliEMCALClusterizerNxN.h"
50 #include "AliEMCALRecPoint.h"
51 #include "AliEMCALPID.h"
52 #include "AliEMCALRecoUtils.h"
53 #include "AliRawReader.h"
54 #include "AliCDBEntry.h"
55 #include "AliCDBManager.h"
56 #include "AliEMCALGeometry.h"
58 #include "AliESDVZERO.h"
59 #include "AliCDBManager.h"
60 #include "AliRunLoader.h"
62 #include "AliEMCALTriggerData.h"
63 #include "AliEMCALTriggerElectronics.h"
64 #include "AliEMCALTriggerDCSConfigDB.h"
65 #include "AliEMCALTriggerDCSConfig.h"
66 #include "AliEMCALTriggerData.h"
67 #include "AliEMCALTriggerRawDigit.h"
68 #include "AliEMCALTriggerPatch.h"
69 #include "AliEMCALTriggerTypes.h"
71 ClassImp(AliEMCALReconstructor)
73 const AliEMCALRecParam* AliEMCALReconstructor::fgkRecParam = 0; // EMCAL rec. parameters
74 AliEMCALRawUtils* AliEMCALReconstructor::fgRawUtils = 0; // EMCAL raw utilities class
75 AliEMCALClusterizer* AliEMCALReconstructor::fgClusterizer = 0; // EMCAL clusterizer class
76 TClonesArray* AliEMCALReconstructor::fgDigitsArr = 0; // list of digits, to be used multiple times
77 TObjArray* AliEMCALReconstructor::fgClustersArr = 0; // list of clusters, to be used multiple times
78 TClonesArray* AliEMCALReconstructor::fgTriggerDigits = 0; // list of trigger digits, to be used multiple times
79 AliEMCALTriggerElectronics* AliEMCALReconstructor::fgTriggerProcessor = 0x0;
80 //____________________________________________________________________________
81 AliEMCALReconstructor::AliEMCALReconstructor()
82 : fGeom(0),fCalibData(0),fPedestalData(0),fTriggerData(0x0), fMatches(0x0)
86 // AliDebug(2, "Mark.");
88 fgRawUtils = new AliEMCALRawUtils;
90 //To make sure we match with the geometry in a simulation file,
91 //let's try to get it first. If not, take the default geometry
92 AliRunLoader *rl = AliRunLoader::Instance();
94 AliEMCAL * emcal = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"));
95 if(emcal) fGeom = emcal->GetGeometry();
99 AliInfo(Form("Using default geometry in reconstruction"));
100 fGeom = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName());
103 //Get calibration parameters
106 AliCDBEntry *entry = (AliCDBEntry*)
107 AliCDBManager::Instance()->Get("EMCAL/Calib/Data");
108 if (entry) fCalibData = (AliEMCALCalibData*) entry->GetObject();
112 AliFatal("Calibration parameters not found in CDB!");
114 //Get calibration parameters
117 AliCDBEntry *entry = (AliCDBEntry*)
118 AliCDBManager::Instance()->Get("EMCAL/Calib/Pedestals");
119 if (entry) fPedestalData = (AliCaloCalibPedestal*) entry->GetObject();
123 AliFatal("Dead map not found in CDB!");
125 if(!fGeom) AliFatal(Form("Could not get geometry!"));
127 AliEMCALTriggerDCSConfigDB* dcsConfigDB = AliEMCALTriggerDCSConfigDB::Instance();
129 const AliEMCALTriggerDCSConfig* dcsConfig = dcsConfigDB->GetTriggerDCSConfig();
131 if (!dcsConfig) AliFatal("No Trigger DCS Configuration from OCDB!");
132 fgTriggerProcessor = new AliEMCALTriggerElectronics( dcsConfig );
134 fTriggerData = new AliEMCALTriggerData();
136 //Init temporary list of digits
137 fgDigitsArr = new TClonesArray("AliEMCALDigit",1000);
138 fgClustersArr = new TObjArray(1000);
139 fgTriggerDigits = new TClonesArray("AliEMCALTriggerRawDigit",1000);
142 fMatches = new TList();
143 fMatches->SetOwner(kTRUE);
146 //____________________________________________________________________________
147 AliEMCALReconstructor::~AliEMCALReconstructor()
151 //AliDebug(2, "Mark.");
153 if(fGeom) delete fGeom;
155 //No need to delete, recovered from OCDB
156 //if(fCalibData) delete fCalibData;
157 //if(fPedestalData) delete fPedestalData;
160 fgDigitsArr->Clear("C");
165 fgClustersArr->Clear();
166 delete fgClustersArr;
170 fgTriggerDigits->Clear();
171 delete fgTriggerDigits;
174 if(fgRawUtils) delete fgRawUtils;
175 if(fgClusterizer) delete fgClusterizer;
176 if(fgTriggerProcessor) delete fgTriggerProcessor;
178 if(fMatches) { fMatches->Delete(); delete fMatches; fMatches = 0;}
180 AliCodeTimer::Instance()->Print();
183 //____________________________________________________________________________
184 void AliEMCALReconstructor::InitClusterizer() const
186 //Init the clusterizer with geometry and calibration pointers, avoid doing it twice.
187 Int_t clusterizerType = -1;
188 Int_t eventType = -1;
190 clusterizerType = GetRecParam()->GetClusterizerFlag();
191 eventType = GetRecParam()->GetEventSpecie();
194 AliCDBEntry *entry = (AliCDBEntry*)
195 AliCDBManager::Instance()->Get("EMCAL/Calib/RecoParam");
196 //Get The reco param for the default event specie
198 AliEMCALRecParam *recParam = (AliEMCALRecParam*)((TObjArray *) entry->GetObject())->At(0);
199 if(recParam) clusterizerType = recParam->GetClusterizerFlag();
203 //Check if clusterizer previously set corresponds to what is needed for this event type
205 if(eventType!=AliRecoParam::kCalib){
206 //printf("ReCreate clusterizer? Clusterizer set <%d>, Clusterizer in use <%s>\n",
207 // clusterizerType, fgClusterizer->Version());
209 if (clusterizerType == AliEMCALRecParam::kClusterizerv1 && !strcmp(fgClusterizer->Version(),"clu-v1")) return;
211 else if(clusterizerType == AliEMCALRecParam::kClusterizerNxN && !strcmp(fgClusterizer->Version(),"clu-NxN")) return;
213 else if(clusterizerType == AliEMCALRecParam::kClusterizerv2 && !strcmp(fgClusterizer->Version(),"clu-v2")) return;
215 //Need to create new clusterizer, the one set previously is not the correct one
216 delete fgClusterizer;
221 if (clusterizerType == AliEMCALRecParam::kClusterizerv1)
223 fgClusterizer = new AliEMCALClusterizerv1 (fGeom, fCalibData,fPedestalData);
225 else if (clusterizerType == AliEMCALRecParam::kClusterizerNxN)
227 fgClusterizer = new AliEMCALClusterizerNxN(fGeom, fCalibData,fPedestalData);
229 else if (clusterizerType == AliEMCALRecParam::kClusterizerv2)
231 fgClusterizer = new AliEMCALClusterizerv2 (fGeom, fCalibData,fPedestalData);
235 AliFatal(Form("Unknown clusterizer %d ", clusterizerType));
239 //____________________________________________________________________________
240 void AliEMCALReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const
242 // method called by AliReconstruction;
243 // Only the clusterization is performed,; the rest of the reconstruction is done in FillESD because the track
244 // segment maker needs access to the AliESD object to retrieve the tracks reconstructed by
245 // the global tracking.
246 // Works on the current event.
248 AliCodeTimerAuto("",0)
250 //Get input digits and put them in fgDigitsArr, clear the list before
251 ReadDigitsArrayFromTree(digitsTree);
255 fgClusterizer->InitParameters();
256 fgClusterizer->SetOutput(clustersTree);
258 //Skip clusterization of LED events
259 if (GetRecParam()->GetEventSpecie()!=AliRecoParam::kCalib){
261 if(fgDigitsArr && fgDigitsArr->GetEntries()) {
263 fgClusterizer->SetInput(digitsTree);
265 //fgClusterizer->Digits2Clusters("deb all") ; //For debugging
266 fgClusterizer->Digits2Clusters("");
268 fgClusterizer->Clear();
270 }//digits array exists and has somethind
273 clustersTree->Fill();
275 // Deleting the recpoints at the end of the reconstruction call
276 fgClusterizer->DeleteRecPoints();
279 //____________________________________________________________________________
280 void AliEMCALReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
283 // Conversion from raw data to
285 // Works on a single-event basis
289 fTriggerData->SetMode(1);
291 if(fgDigitsArr) fgDigitsArr->Clear("C");
293 TClonesArray *digitsTrg = new TClonesArray("AliEMCALTriggerRawDigit", 32 * 96);
295 Int_t bufsize = 32000;
296 digitsTree->Branch("EMCAL", &fgDigitsArr, bufsize);
297 digitsTree->Branch("EMTRG", &digitsTrg, bufsize);
299 //Skip calibration events do the rest
300 Bool_t doFit = kTRUE;
301 if ( !(GetRecParam()->FitLEDEvents()) && GetRecParam()->GetEventSpecie()==AliRecoParam::kCalib) doFit = kFALSE;
303 //must be done here because, in constructor, option is not yet known
304 fgRawUtils->SetOption(GetOption());
306 // fgRawUtils->SetRawFormatHighLowGainFactor(GetRecParam()->GetHighLowGainFactor());
308 // fgRawUtils->SetRawFormatOrder(GetRecParam()->GetOrderParameter());
309 // fgRawUtils->SetRawFormatTau(GetRecParam()->GetTau());
310 fgRawUtils->SetNoiseThreshold(GetRecParam()->GetNoiseThreshold());
311 fgRawUtils->SetNPedSamples(GetRecParam()->GetNPedSamples());
312 fgRawUtils->SetRemoveBadChannels(GetRecParam()->GetRemoveBadChannels());
313 if (!fgRawUtils->GetFittingAlgorithm()) fgRawUtils->SetFittingAlgorithm(GetRecParam()->GetFittingAlgorithm());
314 fgRawUtils->SetFALTROUsage(GetRecParam()->UseFALTRO());
316 //fgRawUtils->SetTimeMin(GetRecParam()->GetTimeMin());
317 //fgRawUtils->SetTimeMax(GetRecParam()->GetTimeMax());
319 // fgRawUtils->SetTimeMin(-99999 );
320 // fgRawUtils->SetTimeMax( 99999 );
322 fgRawUtils->Raw2Digits(rawReader,fgDigitsArr,fPedestalData,digitsTrg,fTriggerData);
324 }//skip calibration event
326 AliDebug(1," Calibration Event, skip!");
336 //____________________________________________________________________________
337 void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree,
338 AliESDEvent* esd) const
340 // Called by AliReconstruct after Reconstruct() and global tracking and vertexing
342 // Works on the current event
343 // printf(" ## AliEMCALReconstructor::FillESD() is started ### \n ");
346 //########################################
348 //########################################
350 static int saveOnce = 0;
352 Int_t v0M[2] = {0, 0};
354 AliESDVZERO* esdV0 = esd->GetVZEROData();
358 for (Int_t i = 0; i < 32; i++)
360 v0M[0] += (Int_t)esdV0->GetAdcV0C(i);
361 v0M[1] += (Int_t)esdV0->GetAdcV0A(i);
366 AliWarning("Cannot retrieve V0 ESD! Run w/ null V0 charges");
369 if (fgTriggerDigits) fgTriggerDigits->Clear();
371 TBranch *branchtrg = digitsTree->GetBranch("EMTRG");
375 AliError("Can't get the branch with the EMCAL trigger digits!");
379 branchtrg->SetAddress(&fgTriggerDigits);
380 branchtrg->GetEntry(0);
382 // Note: fgTriggerProcessor reset done at the end of this method
383 fgTriggerProcessor->Digits2Trigger(fgTriggerDigits, v0M, fTriggerData);
386 AliESDCaloTrigger* trgESD = esd->GetCaloTrigger("EMCAL");
390 trgESD->Allocate(fgTriggerDigits->GetEntriesFast());
392 for (Int_t i = 0; i < fgTriggerDigits->GetEntriesFast(); i++)
394 AliEMCALTriggerRawDigit* rdig = (AliEMCALTriggerRawDigit*)fgTriggerDigits->At(i);
397 if (fGeom->GetPositionInEMCALFromAbsFastORIndex(rdig->GetId(), px, py))
399 Int_t a = -1, t = -1, times[10];
401 rdig->GetMaximum(a, t);
402 rdig->GetL0Times(times);
404 trgESD->Add(px, py, a, t, times, rdig->GetNL0Times(), rdig->GetL1TimeSum(), rdig->GetTriggerBits());
408 trgESD->SetL1Threshold(0, fTriggerData->GetL1GammaThreshold());
410 trgESD->SetL1Threshold(1, fTriggerData->GetL1JetThreshold() );
413 fTriggerData->GetL1V0(v0);
416 trgESD->SetL1FrameMask(fTriggerData->GetL1FrameMask());
418 if (!saveOnce && fTriggerData->GetL1DataDecoded())
421 fTriggerData->GetL1TriggerType(type);
423 esd->SetCaloTriggerType(type);
430 fTriggerData->Reset();
432 //########################################
433 //##############Fill CaloCells###############
434 //########################################
436 //Get input digits and put them in fgDigitsArr, clear the list before
437 ReadDigitsArrayFromTree(digitsTree);
439 Int_t nDigits = fgDigitsArr->GetEntries(), idignew = 0 ;
440 AliDebug(1,Form("%d digits",nDigits));
441 AliESDCaloCells &emcCells = *(esd->GetEMCALCells());
442 emcCells.CreateContainer(nDigits);
443 emcCells.SetType(AliVCaloCells::kEMCALCell);
446 for (Int_t idig = 0 ; idig < nDigits ; idig++) {
447 const AliEMCALDigit * dig = (const AliEMCALDigit*)fgDigitsArr->At(idig);
448 time = dig->GetTime(); // Time already calibrated in clusterizer
449 energy = dig->GetAmplitude(); // energy calibrated in clusterizer
451 fgClusterizer->Calibrate(energy,time,dig->GetId()); //Digits already calibrated in clusterizers
452 if(energy > 0){ //Digits tagged as bad (dead, hot, not alive) are set to 0 in calibrate, remove them
453 emcCells.SetCell(idignew,dig->GetId(),energy, time);
458 emcCells.SetNumberOfCells(idignew);
461 //------------------------------------------------------------
462 //-----------------CLUSTERS-----------------------------
463 //------------------------------------------------------------
464 clustersTree->SetBranchStatus("*",0); //disable all branches
465 clustersTree->SetBranchStatus("EMCALECARP",1); //Enable only the branch we need
466 if(fgClustersArr) fgClustersArr->Clear();
467 TBranch *branch = clustersTree->GetBranch("EMCALECARP");
468 branch->SetAddress(&fgClustersArr);
470 //clustersTree->GetEvent(0);
472 Int_t nClusters = fgClustersArr->GetEntries(), nClustersNew=0;
473 AliDebug(1,Form("%d clusters",nClusters));
476 //########################################
477 //##############Fill CaloClusters#############
478 //########################################
479 for (Int_t iClust = 0 ; iClust < nClusters ; iClust++) {
480 const AliEMCALRecPoint * clust = (const AliEMCALRecPoint*)fgClustersArr->At(iClust);
482 //if(clust->GetClusterType()== AliVCluster::kEMCALClusterv1) nRP++; else nPC++;
483 // clust->Print(); //For debugging
484 // Get information from EMCAL reconstruction points
487 clust->GetGlobalPosition(gpos);
488 for (Int_t ixyz=0; ixyz<3; ixyz++)
489 xyz[ixyz] = gpos[ixyz];
491 clust->GetElipsAxis(elipAxis);
492 //Create digits lists
493 Int_t cellMult = clust->GetMultiplicity();
494 //TArrayS digiList(digitMult);
495 Float_t *amplFloat = clust->GetEnergiesList();
496 Int_t *digitInts = clust->GetAbsId();
497 TArrayS absIdList(cellMult);
498 TArrayD fracList(cellMult);
500 Int_t newCellMult = 0;
501 for (Int_t iCell=0; iCell<cellMult; iCell++) {
502 if (amplFloat[iCell] > 0) {
503 absIdList[newCellMult] = (UShort_t)(digitInts[iCell]);
505 if(emcCells.GetCellAmplitude(digitInts[iCell])>0 && GetRecParam()->GetUnfold()){
506 fracList[newCellMult] = amplFloat[iCell]/(emcCells.GetCellAmplitude(digitInts[iCell]));//get cell calibration value
510 fracList[newCellMult] = 0;
516 absIdList.Set(newCellMult);
517 fracList.Set(newCellMult);
519 if(newCellMult > 0) { // accept cluster if it has some digit
522 Int_t parentMult = 0;
523 Int_t *parentList = clust->GetParents(parentMult);
524 // fills the ESDCaloCluster
525 AliESDCaloCluster * ec = new AliESDCaloCluster() ;
526 ec->SetType(AliVCluster::kEMCALClusterv1);
527 ec->SetPosition(xyz);
528 ec->SetE(clust->GetEnergy());
530 //Distance to the nearest bad crystal
531 ec->SetDistanceToBadChannel(clust->GetDistanceToBadTower());
533 ec->SetNCells(newCellMult);
534 //Change type of list from short to ushort
535 UShort_t *newAbsIdList = new UShort_t[newCellMult];
536 Double_t *newFracList = new Double_t[newCellMult];
537 for(Int_t i = 0; i < newCellMult ; i++) {
538 newAbsIdList[i]=absIdList[i];
539 newFracList[i] =fracList[i];
541 ec->SetCellsAbsId(newAbsIdList);
542 ec->SetCellsAmplitudeFraction(newFracList);
543 ec->SetDispersion(clust->GetDispersion());
544 ec->SetChi2(-1); //not yet implemented
545 ec->SetM02(elipAxis[0]*elipAxis[0]) ;
546 ec->SetM20(elipAxis[1]*elipAxis[1]) ;
547 ec->SetTOF(clust->GetTime()) ; //time-of-fligh
548 ec->SetNExMax(clust->GetNExMax()); //number of local maxima
551 TArrayI arrayParents(parentMult,parentList);
552 ec->AddLabels(arrayParents);
557 Int_t nTracks = esd->GetNumberOfTracks();
558 for (Int_t itrack = 0; itrack < nTracks; itrack++)
560 AliESDtrack * track = esd->GetTrack(itrack) ; // retrieve track
561 if(track->GetEMCALcluster()==iClust)
563 Float_t dEta=-999, dPhi=-999;
564 Bool_t isMatch = CalculateResidual(track, ec, dEta, dPhi);
567 // AliDebug(10, "Not good");
570 AliEMCALMatch *match = new AliEMCALMatch();
571 match->SetIndexT(itrack);
572 match->SetDistance(TMath::Sqrt(dEta*dEta+dPhi*dPhi));
573 match->SetdEta(dEta);
574 match->SetdPhi(dPhi);
575 fMatches->Add(match);
578 fMatches->Sort(kSortAscending); //Sort matched tracks from closest to furthest
579 Int_t nMatch = fMatches->GetEntries();
580 TArrayI arrayTrackMatched(nMatch);
581 for(Int_t imatch=0; imatch<nMatch; imatch++)
583 AliEMCALMatch *match = (AliEMCALMatch*)fMatches->At(imatch);
584 arrayTrackMatched[imatch] = match->GetIndexT();
587 ec->SetTrackDistance(match->GetdPhi(), match->GetdEta());
590 ec->AddTracksMatched(arrayTrackMatched);
592 //add the cluster to the esd object
593 esd->AddCaloCluster(ec);
596 delete [] newAbsIdList ;
597 delete [] newFracList ;
599 } // cycle on clusters
602 //Reset the index of matched cluster for tracks
603 //to the one in CaloCluster array
604 Int_t ncls = esd->GetNumberOfCaloClusters();
605 for(Int_t icl=0; icl<ncls; icl++)
607 AliESDCaloCluster *cluster = esd->GetCaloCluster(icl);
608 if(!cluster || !cluster->IsEMCAL()) continue;
609 TArrayI *trackIndex = cluster->GetTracksMatched();
610 for(Int_t itr=0; itr<trackIndex->GetSize(); itr++)
612 AliESDtrack *track = esd->GetTrack(trackIndex->At(itr));
613 track->SetEMCALcluster(cluster->GetID());
618 //Fill ESDCaloCluster with PID weights
619 AliEMCALPID *pid = new AliEMCALPID;
620 //pid->SetPrintInfo(kTRUE);
621 pid->SetReconstructor(kTRUE);
625 //Store EMCAL misalignment matrixes
626 FillMisalMatrixes(esd) ;
630 //==================================================================================
631 void AliEMCALReconstructor::FillMisalMatrixes(AliESDEvent* esd)const{
632 //Store EMCAL matrixes in ESD Header
634 //Check, if matrixes was already stored
635 for(Int_t sm = 0 ; sm < fGeom->GetNumberOfSuperModules(); sm++){
636 if(esd->GetEMCALMatrix(sm)!=0)
640 //Create and store matrixes
642 AliError("Can not store misal. matrixes: no gGeoManager! \n") ;
645 //Note, that owner of copied marixes will be header
646 const Int_t bufsize = 255;
648 TGeoHMatrix * m = 0x0;
649 for(Int_t sm = 0; sm < fGeom->GetNumberOfSuperModules(); sm++){
650 snprintf(path,bufsize,"/ALIC_1/XEN1_1/SMOD_%d",sm+1) ; //In Geometry modules numbered 1,2,.,5
651 if(sm >= 10) snprintf(path,bufsize,"/ALIC_1/XEN1_1/SM10_%d",sm-10+1) ;
653 if (gGeoManager->CheckPath(path)){
654 gGeoManager->cd(path);
655 m = gGeoManager->GetCurrentMatrix() ;
656 // printf("================================================= \n");
657 // printf("AliEMCALReconstructor::FixMisalMatrixes(), sm %d, \n",sm);
659 esd->SetEMCALMatrix(new TGeoHMatrix(*m),sm) ;
660 // printf("================================================= \n");
663 esd->SetEMCALMatrix(NULL,sm) ;
668 //__________________________________________________________________________
669 void AliEMCALReconstructor::ReadDigitsArrayFromTree(TTree *digitsTree) const
671 // Read the digits from the input tree
672 // See AliEMCALClusterizer::SetInput(TTree *digitsTree);
674 // Clear previous digits in the list
676 fgDigitsArr->Clear("C");
679 // It should not happen, but just in case ...
680 fgDigitsArr = new TClonesArray("AliEMCALDigit",100);
683 // Read the digits from the input tree
684 TBranch *branch = digitsTree->GetBranch("EMCAL");
686 AliError("can't get the branch with the EMCAL digits !");
690 branch->SetAddress(&fgDigitsArr);
694 //==================================================================================
695 Bool_t AliEMCALReconstructor::CalculateResidual(AliESDtrack *track, AliESDCaloCluster *cluster, Float_t &dEta, Float_t &dPhi)const
698 // calculate the residual between track and cluster
701 // If the esdFriend is available, use the TPCOuter point as the starting point of extrapolation
702 // Otherwise use the TPCInner point
704 dEta = -999, dPhi = -999;
706 AliExternalTrackParam *trkParam = 0;
707 const AliESDfriendTrack* friendTrack = track->GetFriendTrack();
708 if(friendTrack && friendTrack->GetTPCOut())
709 trkParam = const_cast<AliExternalTrackParam*>(friendTrack->GetTPCOut());
711 trkParam = const_cast<AliExternalTrackParam*>(track->GetInnerParam());
712 if(!trkParam) return kFALSE;
714 AliExternalTrackParam trkParamTmp (*trkParam);
715 if(!AliEMCALRecoUtils::ExtrapolateTrackToCluster(&trkParamTmp, cluster, track->GetMass(), GetRecParam()->GetExtrapolateStep(), dEta, dPhi)) return kFALSE;
721 //==================================================================================
723 AliEMCALReconstructor::AliEMCALMatch::AliEMCALMatch()
730 //default constructor
735 //==================================================================================
737 AliEMCALReconstructor::AliEMCALMatch::AliEMCALMatch(const AliEMCALMatch& copy)
739 fIndexT(copy.fIndexT),
740 fDistance(copy.fDistance),
748 //==================================================================================
750 Int_t AliEMCALReconstructor::AliEMCALMatch::Compare(const TObject *obj) const
753 // Compare wrt the residual
756 AliEMCALReconstructor::AliEMCALMatch *that = (AliEMCALReconstructor::AliEMCALMatch*)obj;
758 Double_t thisDist = fDistance;//fDistance;
759 Double_t thatDist = that->fDistance;//that->GetDistance();
761 if (thisDist > thatDist) return 1;
762 else if (thisDist < thatDist) return -1;