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 "AliRawReader.h"
53 #include "AliCDBEntry.h"
54 #include "AliCDBManager.h"
55 #include "AliEMCALGeometry.h"
57 #include "AliESDVZERO.h"
58 #include "AliCDBManager.h"
59 #include "AliRunLoader.h"
61 #include "AliEMCALTriggerData.h"
62 #include "AliEMCALTriggerElectronics.h"
63 #include "AliEMCALTriggerDCSConfigDB.h"
64 #include "AliEMCALTriggerDCSConfig.h"
65 #include "AliEMCALTriggerData.h"
66 #include "AliEMCALTriggerRawDigit.h"
67 #include "AliEMCALTriggerPatch.h"
68 #include "AliEMCALTriggerTypes.h"
70 ClassImp(AliEMCALReconstructor)
72 const AliEMCALRecParam* AliEMCALReconstructor::fgkRecParam = 0; // EMCAL rec. parameters
73 AliEMCALRawUtils* AliEMCALReconstructor::fgRawUtils = 0; // EMCAL raw utilities class
74 AliEMCALClusterizer* AliEMCALReconstructor::fgClusterizer = 0; // EMCAL clusterizer class
75 TClonesArray* AliEMCALReconstructor::fgDigitsArr = 0; // list of digits, to be used multiple times
76 TObjArray* AliEMCALReconstructor::fgClustersArr = 0; // list of clusters, to be used multiple times
77 TClonesArray* AliEMCALReconstructor::fgTriggerDigits = 0; // list of trigger digits, to be used multiple times
78 AliEMCALTriggerElectronics* AliEMCALReconstructor::fgTriggerProcessor = 0x0;
79 //____________________________________________________________________________
80 AliEMCALReconstructor::AliEMCALReconstructor()
81 : fGeom(0),fCalibData(0),fPedestalData(0),fTriggerData(0x0), fMatches(0x0)
85 // AliDebug(2, "Mark.");
87 fgRawUtils = new AliEMCALRawUtils;
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
91 AliRunLoader *rl = AliRunLoader::Instance();
93 AliEMCAL * emcal = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"));
94 if(emcal) fGeom = emcal->GetGeometry();
98 AliInfo(Form("Using default geometry in reconstruction"));
99 fGeom = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName());
102 //Get calibration parameters
105 AliCDBEntry *entry = (AliCDBEntry*)
106 AliCDBManager::Instance()->Get("EMCAL/Calib/Data");
107 if (entry) fCalibData = (AliEMCALCalibData*) entry->GetObject();
111 AliFatal("Calibration parameters not found in CDB!");
113 //Get calibration parameters
116 AliCDBEntry *entry = (AliCDBEntry*)
117 AliCDBManager::Instance()->Get("EMCAL/Calib/Pedestals");
118 if (entry) fPedestalData = (AliCaloCalibPedestal*) entry->GetObject();
122 AliFatal("Dead map not found in CDB!");
124 if(!fGeom) AliFatal(Form("Could not get geometry!"));
126 AliEMCALTriggerDCSConfigDB* dcsConfigDB = AliEMCALTriggerDCSConfigDB::Instance();
128 const AliEMCALTriggerDCSConfig* dcsConfig = dcsConfigDB->GetTriggerDCSConfig();
130 if (!dcsConfig) AliFatal("No Trigger DCS Configuration from OCDB!");
131 fgTriggerProcessor = new AliEMCALTriggerElectronics( dcsConfig );
133 fTriggerData = new AliEMCALTriggerData();
135 //Init temporary list of digits
136 fgDigitsArr = new TClonesArray("AliEMCALDigit",1000);
137 fgClustersArr = new TObjArray(1000);
138 fgTriggerDigits = new TClonesArray("AliEMCALTriggerRawDigit",1000);
141 fMatches = new TList();
142 fMatches->SetOwner(kTRUE);
145 //____________________________________________________________________________
146 AliEMCALReconstructor::~AliEMCALReconstructor()
150 //AliDebug(2, "Mark.");
152 if(fGeom) delete fGeom;
154 //No need to delete, recovered from OCDB
155 //if(fCalibData) delete fCalibData;
156 //if(fPedestalData) delete fPedestalData;
159 fgDigitsArr->Clear("C");
164 fgClustersArr->Clear();
165 delete fgClustersArr;
169 fgTriggerDigits->Clear();
170 delete fgTriggerDigits;
173 if(fgRawUtils) delete fgRawUtils;
174 if(fgClusterizer) delete fgClusterizer;
175 if(fgTriggerProcessor) delete fgTriggerProcessor;
177 if(fMatches) { fMatches->Delete(); delete fMatches; fMatches = 0;}
179 AliCodeTimer::Instance()->Print();
182 //____________________________________________________________________________
183 void AliEMCALReconstructor::InitClusterizer() const
185 //Init the clusterizer with geometry and calibration pointers, avoid doing it twice.
186 Int_t clusterizerType = -1;
187 Int_t eventType = -1;
189 clusterizerType = GetRecParam()->GetClusterizerFlag();
190 eventType = GetRecParam()->GetEventSpecie();
193 AliCDBEntry *entry = (AliCDBEntry*)
194 AliCDBManager::Instance()->Get("EMCAL/Calib/RecoParam");
195 //Get The reco param for the default event specie
197 AliEMCALRecParam *recParam = (AliEMCALRecParam*)((TObjArray *) entry->GetObject())->At(0);
198 if(recParam) clusterizerType = recParam->GetClusterizerFlag();
202 //Check if clusterizer previously set corresponds to what is needed for this event type
204 if(eventType!=AliRecoParam::kCalib){
205 //printf("ReCreate clusterizer? Clusterizer set <%d>, Clusterizer in use <%s>\n",
206 // clusterizerType, fgClusterizer->Version());
208 if (clusterizerType == AliEMCALRecParam::kClusterizerv1 && !strcmp(fgClusterizer->Version(),"clu-v1")) return;
210 else if(clusterizerType == AliEMCALRecParam::kClusterizerNxN && !strcmp(fgClusterizer->Version(),"clu-NxN")) return;
212 else if(clusterizerType == AliEMCALRecParam::kClusterizerv2 && !strcmp(fgClusterizer->Version(),"clu-v2")) return;
214 //Need to create new clusterizer, the one set previously is not the correct one
215 delete fgClusterizer;
220 if (clusterizerType == AliEMCALRecParam::kClusterizerv1)
222 fgClusterizer = new AliEMCALClusterizerv1 (fGeom, fCalibData,fPedestalData);
224 else if (clusterizerType == AliEMCALRecParam::kClusterizerNxN)
226 fgClusterizer = new AliEMCALClusterizerNxN(fGeom, fCalibData,fPedestalData);
228 else if (clusterizerType == AliEMCALRecParam::kClusterizerv2)
230 fgClusterizer = new AliEMCALClusterizerv2 (fGeom, fCalibData,fPedestalData);
234 AliFatal(Form("Unknown clusterizer %d ", clusterizerType));
238 //____________________________________________________________________________
239 void AliEMCALReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const
241 // method called by AliReconstruction;
242 // Only the clusterization is performed,; the rest of the reconstruction is done in FillESD because the track
243 // segment maker needs access to the AliESD object to retrieve the tracks reconstructed by
244 // the global tracking.
245 // Works on the current event.
247 AliCodeTimerAuto("",0)
249 //Get input digits and put them in fgDigitsArr, clear the list before
250 ReadDigitsArrayFromTree(digitsTree);
254 fgClusterizer->InitParameters();
255 fgClusterizer->SetOutput(clustersTree);
257 //Skip clusterization of LED events
258 if (GetRecParam()->GetEventSpecie()!=AliRecoParam::kCalib){
260 if(fgDigitsArr && fgDigitsArr->GetEntries()) {
262 fgClusterizer->SetInput(digitsTree);
264 //fgClusterizer->Digits2Clusters("deb all") ; //For debugging
265 fgClusterizer->Digits2Clusters("");
267 fgClusterizer->Clear();
269 }//digits array exists and has somethind
272 clustersTree->Fill();
274 // Deleting the recpoints at the end of the reconstruction call
275 fgClusterizer->DeleteRecPoints();
278 //____________________________________________________________________________
279 void AliEMCALReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
282 // Conversion from raw data to
284 // Works on a single-event basis
288 fTriggerData->SetMode(1);
290 if(fgDigitsArr) fgDigitsArr->Clear("C");
292 TClonesArray *digitsTrg = new TClonesArray("AliEMCALTriggerRawDigit", 32 * 96);
294 Int_t bufsize = 32000;
295 digitsTree->Branch("EMCAL", &fgDigitsArr, bufsize);
296 digitsTree->Branch("EMTRG", &digitsTrg, bufsize);
298 //Skip calibration events do the rest
299 Bool_t doFit = kTRUE;
300 if ( !(GetRecParam()->FitLEDEvents()) && GetRecParam()->GetEventSpecie()==AliRecoParam::kCalib) doFit = kFALSE;
302 //must be done here because, in constructor, option is not yet known
303 fgRawUtils->SetOption(GetOption());
305 // fgRawUtils->SetRawFormatHighLowGainFactor(GetRecParam()->GetHighLowGainFactor());
307 // fgRawUtils->SetRawFormatOrder(GetRecParam()->GetOrderParameter());
308 // fgRawUtils->SetRawFormatTau(GetRecParam()->GetTau());
309 fgRawUtils->SetNoiseThreshold(GetRecParam()->GetNoiseThreshold());
310 fgRawUtils->SetNPedSamples(GetRecParam()->GetNPedSamples());
311 fgRawUtils->SetRemoveBadChannels(GetRecParam()->GetRemoveBadChannels());
312 if (!fgRawUtils->GetFittingAlgorithm()) fgRawUtils->SetFittingAlgorithm(GetRecParam()->GetFittingAlgorithm());
313 fgRawUtils->SetFALTROUsage(GetRecParam()->UseFALTRO());
315 //fgRawUtils->SetTimeMin(GetRecParam()->GetTimeMin());
316 //fgRawUtils->SetTimeMax(GetRecParam()->GetTimeMax());
318 // fgRawUtils->SetTimeMin(-99999 );
319 // fgRawUtils->SetTimeMax( 99999 );
321 fgRawUtils->Raw2Digits(rawReader,fgDigitsArr,fPedestalData,digitsTrg,fTriggerData);
323 }//skip calibration event
325 AliDebug(1," Calibration Event, skip!");
335 //____________________________________________________________________________
336 void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree,
337 AliESDEvent* esd) const
339 // Called by AliReconstruct after Reconstruct() and global tracking and vertexing
341 // Works on the current event
342 // printf(" ## AliEMCALReconstructor::FillESD() is started ### \n ");
345 //########################################
347 //########################################
349 static int saveOnce = 0;
351 Int_t v0M[2] = {0, 0};
353 AliESDVZERO* esdV0 = esd->GetVZEROData();
357 for (Int_t i = 0; i < 32; i++)
359 v0M[0] += (Int_t)esdV0->GetAdcV0C(i);
360 v0M[1] += (Int_t)esdV0->GetAdcV0A(i);
365 AliWarning("Cannot retrieve V0 ESD! Run w/ null V0 charges");
368 if (fgTriggerDigits) fgTriggerDigits->Clear();
370 TBranch *branchtrg = digitsTree->GetBranch("EMTRG");
374 AliError("Can't get the branch with the EMCAL trigger digits!");
378 branchtrg->SetAddress(&fgTriggerDigits);
379 branchtrg->GetEntry(0);
381 // Note: fgTriggerProcessor reset done at the end of this method
382 fgTriggerProcessor->Digits2Trigger(fgTriggerDigits, v0M, fTriggerData);
385 AliESDCaloTrigger* trgESD = esd->GetCaloTrigger("EMCAL");
389 trgESD->Allocate(fgTriggerDigits->GetEntriesFast());
391 for (Int_t i = 0; i < fgTriggerDigits->GetEntriesFast(); i++)
393 AliEMCALTriggerRawDigit* rdig = (AliEMCALTriggerRawDigit*)fgTriggerDigits->At(i);
396 if (fGeom->GetPositionInEMCALFromAbsFastORIndex(rdig->GetId(), px, py))
398 Int_t a = -1, t = -1, times[10];
400 rdig->GetMaximum(a, t);
401 rdig->GetL0Times(times);
403 trgESD->Add(px, py, a, t, times, rdig->GetNL0Times(), rdig->GetL1TimeSum(), rdig->GetTriggerBits());
407 trgESD->SetL1Threshold(0, fTriggerData->GetL1GammaThreshold());
409 trgESD->SetL1Threshold(1, fTriggerData->GetL1JetThreshold() );
412 fTriggerData->GetL1V0(v0);
415 trgESD->SetL1FrameMask(fTriggerData->GetL1FrameMask());
417 if (!saveOnce && fTriggerData->GetL1DataDecoded())
420 fTriggerData->GetL1TriggerType(type);
422 esd->SetCaloTriggerType(type);
429 fTriggerData->Reset();
431 //########################################
432 //##############Fill CaloCells###############
433 //########################################
435 //Get input digits and put them in fgDigitsArr, clear the list before
436 ReadDigitsArrayFromTree(digitsTree);
438 Int_t nDigits = fgDigitsArr->GetEntries(), idignew = 0 ;
439 AliDebug(1,Form("%d digits",nDigits));
440 AliESDCaloCells &emcCells = *(esd->GetEMCALCells());
441 emcCells.CreateContainer(nDigits);
442 emcCells.SetType(AliVCaloCells::kEMCALCell);
445 for (Int_t idig = 0 ; idig < nDigits ; idig++) {
446 const AliEMCALDigit * dig = (const AliEMCALDigit*)fgDigitsArr->At(idig);
447 time = dig->GetTime(); // Time already calibrated in clusterizer
448 energy = dig->GetAmplitude(); // energy calibrated in clusterizer
450 fgClusterizer->Calibrate(energy,time,dig->GetId()); //Digits already calibrated in clusterizers
451 if(energy > 0){ //Digits tagged as bad (dead, hot, not alive) are set to 0 in calibrate, remove them
452 emcCells.SetCell(idignew,dig->GetId(),energy, time);
457 emcCells.SetNumberOfCells(idignew);
460 //------------------------------------------------------------
461 //-----------------CLUSTERS-----------------------------
462 //------------------------------------------------------------
463 clustersTree->SetBranchStatus("*",0); //disable all branches
464 clustersTree->SetBranchStatus("EMCALECARP",1); //Enable only the branch we need
465 if(fgClustersArr) fgClustersArr->Clear();
466 TBranch *branch = clustersTree->GetBranch("EMCALECARP");
467 branch->SetAddress(&fgClustersArr);
469 //clustersTree->GetEvent(0);
471 Int_t nClusters = fgClustersArr->GetEntries(), nClustersNew=0;
472 AliDebug(1,Form("%d clusters",nClusters));
475 //########################################
476 //##############Fill CaloClusters#############
477 //########################################
478 for (Int_t iClust = 0 ; iClust < nClusters ; iClust++) {
479 const AliEMCALRecPoint * clust = (const AliEMCALRecPoint*)fgClustersArr->At(iClust);
481 //if(clust->GetClusterType()== AliVCluster::kEMCALClusterv1) nRP++; else nPC++;
482 // clust->Print(); //For debugging
483 // Get information from EMCAL reconstruction points
486 clust->GetGlobalPosition(gpos);
487 for (Int_t ixyz=0; ixyz<3; ixyz++)
488 xyz[ixyz] = gpos[ixyz];
490 clust->GetElipsAxis(elipAxis);
491 //Create digits lists
492 Int_t cellMult = clust->GetMultiplicity();
493 //TArrayS digiList(digitMult);
494 Float_t *amplFloat = clust->GetEnergiesList();
495 Int_t *digitInts = clust->GetAbsId();
496 TArrayS absIdList(cellMult);
497 TArrayD fracList(cellMult);
499 Int_t newCellMult = 0;
500 for (Int_t iCell=0; iCell<cellMult; iCell++) {
501 if (amplFloat[iCell] > 0) {
502 absIdList[newCellMult] = (UShort_t)(digitInts[iCell]);
504 if(emcCells.GetCellAmplitude(digitInts[iCell])>0 && GetRecParam()->GetUnfold()){
505 fracList[newCellMult] = amplFloat[iCell]/(emcCells.GetCellAmplitude(digitInts[iCell]));//get cell calibration value
509 fracList[newCellMult] = 0;
515 absIdList.Set(newCellMult);
516 fracList.Set(newCellMult);
518 if(newCellMult > 0) { // accept cluster if it has some digit
521 Int_t parentMult = 0;
522 Int_t *parentList = clust->GetParents(parentMult);
523 // fills the ESDCaloCluster
524 AliESDCaloCluster * ec = new AliESDCaloCluster() ;
525 ec->SetType(AliVCluster::kEMCALClusterv1);
526 ec->SetPosition(xyz);
527 ec->SetE(clust->GetEnergy());
529 //Distance to the nearest bad crystal
530 ec->SetDistanceToBadChannel(clust->GetDistanceToBadTower());
532 ec->SetNCells(newCellMult);
533 //Change type of list from short to ushort
534 UShort_t *newAbsIdList = new UShort_t[newCellMult];
535 Double_t *newFracList = new Double_t[newCellMult];
536 for(Int_t i = 0; i < newCellMult ; i++) {
537 newAbsIdList[i]=absIdList[i];
538 newFracList[i] =fracList[i];
540 ec->SetCellsAbsId(newAbsIdList);
541 ec->SetCellsAmplitudeFraction(newFracList);
542 ec->SetDispersion(clust->GetDispersion());
543 ec->SetChi2(-1); //not yet implemented
544 ec->SetM02(elipAxis[0]*elipAxis[0]) ;
545 ec->SetM20(elipAxis[1]*elipAxis[1]) ;
546 ec->SetTOF(clust->GetTime()) ; //time-of-fligh
547 ec->SetNExMax(clust->GetNExMax()); //number of local maxima
550 TArrayI arrayParents(parentMult,parentList);
551 ec->AddLabels(arrayParents);
556 Int_t nTracks = esd->GetNumberOfTracks();
557 for (Int_t itrack = 0; itrack < nTracks; itrack++)
559 AliESDtrack * track = esd->GetTrack(itrack) ; // retrieve track
560 if(track->GetEMCALcluster()==iClust)
562 Double_t dEta=-999, dPhi=-999;
563 Bool_t isMatch = CalculateResidual(track, ec, dEta, dPhi);
566 // AliDebug(10, "Not good");
569 AliEMCALMatch *match = new AliEMCALMatch();
570 match->SetIndexT(itrack);
571 match->SetDistance(TMath::Sqrt(dEta*dEta+dPhi*dPhi));
572 match->SetdEta(dEta);
573 match->SetdPhi(dPhi);
574 fMatches->Add(match);
577 fMatches->Sort(kSortAscending); //Sort matched tracks from closest to furthest
578 Int_t nMatch = fMatches->GetEntries();
579 TArrayI arrayTrackMatched(nMatch);
580 for(Int_t imatch=0; imatch<nMatch; imatch++)
582 AliEMCALMatch *match = (AliEMCALMatch*)fMatches->At(imatch);
583 arrayTrackMatched[imatch] = match->GetIndexT();
586 ec->SetTrackDistance(match->GetdPhi(), match->GetdEta());
589 ec->AddTracksMatched(arrayTrackMatched);
591 //add the cluster to the esd object
592 esd->AddCaloCluster(ec);
595 delete [] newAbsIdList ;
596 delete [] newFracList ;
598 } // cycle on clusters
601 //Reset the index of matched cluster for tracks
602 //to the one in CaloCluster array
603 Int_t ncls = esd->GetNumberOfCaloClusters();
604 for(Int_t icl=0; icl<ncls; icl++)
606 AliESDCaloCluster *cluster = esd->GetCaloCluster(icl);
607 if(!cluster || !cluster->IsEMCAL()) continue;
608 TArrayI *trackIndex = cluster->GetTracksMatched();
609 for(Int_t itr=0; itr<trackIndex->GetSize(); itr++)
611 AliESDtrack *track = esd->GetTrack(trackIndex->At(itr));
612 track->SetEMCALcluster(cluster->GetID());
617 //Fill ESDCaloCluster with PID weights
618 AliEMCALPID *pid = new AliEMCALPID;
619 //pid->SetPrintInfo(kTRUE);
620 pid->SetReconstructor(kTRUE);
624 //Store EMCAL misalignment matrixes
625 FillMisalMatrixes(esd) ;
629 //==================================================================================
630 void AliEMCALReconstructor::FillMisalMatrixes(AliESDEvent* esd)const{
631 //Store EMCAL matrixes in ESD Header
633 //Check, if matrixes was already stored
634 for(Int_t sm = 0 ; sm < fGeom->GetNumberOfSuperModules(); sm++){
635 if(esd->GetEMCALMatrix(sm)!=0)
639 //Create and store matrixes
641 AliError("Can not store misal. matrixes: no gGeoManager! \n") ;
644 //Note, that owner of copied marixes will be header
645 const Int_t bufsize = 255;
647 TGeoHMatrix * m = 0x0;
648 for(Int_t sm = 0; sm < fGeom->GetNumberOfSuperModules(); sm++){
649 snprintf(path,bufsize,"/ALIC_1/XEN1_1/SMOD_%d",sm+1) ; //In Geometry modules numbered 1,2,.,5
650 if(sm >= 10) snprintf(path,bufsize,"/ALIC_1/XEN1_1/SM10_%d",sm-10+1) ;
652 if (gGeoManager->CheckPath(path)){
653 gGeoManager->cd(path);
654 m = gGeoManager->GetCurrentMatrix() ;
655 // printf("================================================= \n");
656 // printf("AliEMCALReconstructor::FixMisalMatrixes(), sm %d, \n",sm);
658 esd->SetEMCALMatrix(new TGeoHMatrix(*m),sm) ;
659 // printf("================================================= \n");
662 esd->SetEMCALMatrix(NULL,sm) ;
667 //__________________________________________________________________________
668 void AliEMCALReconstructor::ReadDigitsArrayFromTree(TTree *digitsTree) const
670 // Read the digits from the input tree
671 // See AliEMCALClusterizer::SetInput(TTree *digitsTree);
673 // Clear previous digits in the list
675 fgDigitsArr->Clear("C");
678 // It should not happen, but just in case ...
679 fgDigitsArr = new TClonesArray("AliEMCALDigit",100);
682 // Read the digits from the input tree
683 TBranch *branch = digitsTree->GetBranch("EMCAL");
685 AliError("can't get the branch with the EMCAL digits !");
689 branch->SetAddress(&fgDigitsArr);
693 //==================================================================================
694 Bool_t AliEMCALReconstructor::CalculateResidual(AliESDtrack *track, AliESDCaloCluster *cluster, Double_t &dEta, Double_t &dPhi)const
697 // calculate the residual between track and cluster
700 // If the esdFriend is available, use the TPCOuter point as the starting point of extrapolation
701 // Otherwise use the TPCInner point
702 AliExternalTrackParam *trkParam = 0;
703 const AliESDfriendTrack* friendTrack = track->GetFriendTrack();
704 if(friendTrack && friendTrack->GetTPCOut())
705 trkParam = const_cast<AliExternalTrackParam*>(friendTrack->GetTPCOut());
707 trkParam = const_cast<AliExternalTrackParam*>(track->GetInnerParam());
708 if(!trkParam) return kFALSE;
710 //Perform extrapolation
714 AliExternalTrackParam trkParamTmp (*trkParam);
715 cluster->GetPosition(clsPos);
716 TVector3 vec(clsPos[0],clsPos[1],clsPos[2]);
717 Double_t alpha = ((int)(vec.Phi()*TMath::RadToDeg()/20)+0.5)*20*TMath::DegToRad();
718 //Rotate to proper local coordinate
720 //extrapolation is done here
721 if(!AliTrackerBase::PropagateTrackToBxByBz(&trkParamTmp, vec.X(), track->GetMass(), GetRecParam()->GetExtrapolateStep(), kTRUE, 0.8, -1))
724 //Calculate the residuals
725 trkParamTmp.GetXYZ(trkPos);
727 TVector3 clsPosVec(clsPos[0],clsPos[1],clsPos[2]);
728 TVector3 trkPosVec(trkPos[0],trkPos[1],trkPos[2]);
730 dPhi = clsPosVec.DeltaPhi(trkPosVec);
731 dEta = clsPosVec.Eta()-trkPosVec.Eta();
737 //==================================================================================
739 AliEMCALReconstructor::AliEMCALMatch::AliEMCALMatch()
746 //default constructor
751 //==================================================================================
753 AliEMCALReconstructor::AliEMCALMatch::AliEMCALMatch(const AliEMCALMatch& copy)
755 fIndexT(copy.fIndexT),
756 fDistance(copy.fDistance),
764 //==================================================================================
766 Int_t AliEMCALReconstructor::AliEMCALMatch::Compare(const TObject *obj) const
769 // Compare wrt the residual
772 AliEMCALReconstructor::AliEMCALMatch *that = (AliEMCALReconstructor::AliEMCALMatch*)obj;
774 Double_t thisDist = fDistance;//fDistance;
775 Double_t thatDist = that->fDistance;//that->GetDistance();
777 if (thisDist > thatDist) return 1;
778 else if (thisDist < thatDist) return -1;