1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //_________________________________________________________________________
20 //-- Yves Schutz (SUBATECH)
21 // Reconstruction class. Redesigned from the old AliReconstructionner class and
22 // derived from STEER/AliReconstructor.
26 // --- ROOT system ---
27 #include <TClonesArray.h>
28 #include "TGeoManager.h"
29 #include "TGeoMatrix.h"
31 // --- Standard library ---
33 // --- AliRoot header files ---
34 #include "AliEMCALReconstructor.h"
36 #include "AliCodeTimer.h"
37 #include "AliCaloCalibPedestal.h"
38 #include "AliEMCALCalibData.h"
39 #include "AliESDEvent.h"
40 #include "AliESDCaloCluster.h"
41 #include "AliESDCaloCells.h"
42 #include "AliESDtrack.h"
43 #include "AliEMCALLoader.h"
44 #include "AliEMCALRawUtils.h"
45 #include "AliEMCALDigit.h"
46 #include "AliEMCALClusterizerv1.h"
47 #include "AliEMCALClusterizerv2.h"
48 #include "AliEMCALClusterizerNxN.h"
49 #include "AliEMCALRecPoint.h"
50 #include "AliEMCALPID.h"
51 #include "AliEMCALRecoUtils.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);
139 const int kNTRU = fGeom->GetNTotalTRU();
140 fgTriggerDigits = new TClonesArray("AliEMCALTriggerRawDigit", kNTRU * 96);
143 fMatches = new TList();
144 fMatches->SetOwner(kTRUE);
147 //____________________________________________________________________________
148 AliEMCALReconstructor::~AliEMCALReconstructor()
152 //AliDebug(2, "Mark.");
154 ////RS if(fGeom) delete fGeom;
156 //No need to delete, recovered from OCDB
157 //if(fCalibData) delete fCalibData;
158 //if(fPedestalData) delete fPedestalData;
160 if(fgDigitsArr) fgDigitsArr->Clear("C");
164 if(fgClustersArr) fgClustersArr->Clear();
165 delete fgClustersArr;
168 if(fgTriggerDigits) fgTriggerDigits->Clear();
169 delete fgTriggerDigits;
174 delete fgClusterizer;
177 delete fgTriggerProcessor;
178 fgTriggerProcessor = 0;
180 if(fMatches) { fMatches->Delete(); delete fMatches; fMatches = 0;}
182 AliCodeTimer::Instance()->Print();
185 //____________________________________________________________________________
186 void AliEMCALReconstructor::InitClusterizer() const
188 //Init the clusterizer with geometry and calibration pointers, avoid doing it twice.
189 Int_t clusterizerType = -1;
190 Int_t eventType = -1;
192 clusterizerType = GetRecParam()->GetClusterizerFlag();
193 eventType = GetRecParam()->GetEventSpecie();
196 AliCDBEntry *entry = (AliCDBEntry*)
197 AliCDBManager::Instance()->Get("EMCAL/Calib/RecoParam");
198 //Get The reco param for the default event specie
200 AliEMCALRecParam *recParam = (AliEMCALRecParam*)((TObjArray *) entry->GetObject())->At(0);
201 if(recParam) clusterizerType = recParam->GetClusterizerFlag();
205 //Check if clusterizer previously set corresponds to what is needed for this event type
207 if(eventType!=AliRecoParam::kCalib){
208 //printf("ReCreate clusterizer? Clusterizer set <%d>, Clusterizer in use <%s>\n",
209 // clusterizerType, fgClusterizer->Version());
211 if (clusterizerType == AliEMCALRecParam::kClusterizerv1 && !strcmp(fgClusterizer->Version(),"clu-v1")) return;
213 else if(clusterizerType == AliEMCALRecParam::kClusterizerNxN && !strcmp(fgClusterizer->Version(),"clu-NxN")) return;
215 else if(clusterizerType == AliEMCALRecParam::kClusterizerv2 && !strcmp(fgClusterizer->Version(),"clu-v2")) return;
217 //Need to create new clusterizer, the one set previously is not the correct one
218 delete fgClusterizer;
223 if (clusterizerType == AliEMCALRecParam::kClusterizerv1)
225 fgClusterizer = new AliEMCALClusterizerv1 (fGeom, fCalibData,fPedestalData);
227 else if (clusterizerType == AliEMCALRecParam::kClusterizerNxN)
229 fgClusterizer = new AliEMCALClusterizerNxN(fGeom, fCalibData,fPedestalData);
231 else if (clusterizerType == AliEMCALRecParam::kClusterizerv2)
233 fgClusterizer = new AliEMCALClusterizerv2 (fGeom, fCalibData,fPedestalData);
237 AliFatal(Form("Unknown clusterizer %d ", clusterizerType));
241 //____________________________________________________________________________
242 void AliEMCALReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const
244 // method called by AliReconstruction;
245 // Only the clusterization is performed,; the rest of the reconstruction is done in FillESD because the track
246 // segment maker needs access to the AliESD object to retrieve the tracks reconstructed by
247 // the global tracking.
248 // Works on the current event.
250 AliCodeTimerAuto("",0)
252 //Get input digits and put them in fgDigitsArr, clear the list before
253 ReadDigitsArrayFromTree(digitsTree);
257 fgClusterizer->InitParameters();
258 fgClusterizer->SetOutput(clustersTree);
260 //Skip clusterization of LED events
261 if (GetRecParam()->GetEventSpecie()!=AliRecoParam::kCalib){
263 if(fgDigitsArr && fgDigitsArr->GetEntries()) {
265 fgClusterizer->SetInput(digitsTree);
267 //fgClusterizer->Digits2Clusters("deb all") ; //For debugging
268 fgClusterizer->Digits2Clusters("");
270 fgClusterizer->Clear();
272 }//digits array exists and has somethind
275 clustersTree->Fill();
277 // Deleting the recpoints at the end of the reconstruction call
278 fgClusterizer->DeleteRecPoints();
281 //____________________________________________________________________________
282 void AliEMCALReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
285 // Conversion from raw data to
287 // Works on a single-event basis
291 fTriggerData->SetMode(1);
293 if(fgDigitsArr) fgDigitsArr->Clear("C");
295 const int kNTRU = fGeom->GetNTotalTRU();
296 TClonesArray *digitsTrg = new TClonesArray("AliEMCALTriggerRawDigit", kNTRU * 96);
298 Int_t bufsize = 32000;
299 digitsTree->Branch("EMCAL", &fgDigitsArr, bufsize);
300 digitsTree->Branch("EMTRG", &digitsTrg, bufsize);
302 //Skip calibration events do the rest
303 Bool_t doFit = kTRUE;
304 if ( !(GetRecParam()->FitLEDEvents()) && GetRecParam()->GetEventSpecie()==AliRecoParam::kCalib) doFit = kFALSE;
306 //must be done here because, in constructor, option is not yet known
307 fgRawUtils->SetOption(GetOption());
309 // fgRawUtils->SetRawFormatHighLowGainFactor(GetRecParam()->GetHighLowGainFactor());
311 // fgRawUtils->SetRawFormatOrder(GetRecParam()->GetOrderParameter());
312 // fgRawUtils->SetRawFormatTau(GetRecParam()->GetTau());
313 fgRawUtils->SetNoiseThreshold(GetRecParam()->GetNoiseThreshold());
314 fgRawUtils->SetNPedSamples(GetRecParam()->GetNPedSamples());
315 fgRawUtils->SetRemoveBadChannels(GetRecParam()->GetRemoveBadChannels());
316 if (!fgRawUtils->GetFittingAlgorithm()) fgRawUtils->SetFittingAlgorithm(GetRecParam()->GetFittingAlgorithm());
317 fgRawUtils->SetFALTROUsage(GetRecParam()->UseFALTRO());
318 // fgRawUtils->SetFALTROUsage(0);
320 //fgRawUtils->SetTimeMin(GetRecParam()->GetTimeMin());
321 //fgRawUtils->SetTimeMax(GetRecParam()->GetTimeMax());
323 // fgRawUtils->SetTimeMin(-99999 );
324 // fgRawUtils->SetTimeMax( 99999 );
326 fgRawUtils->Raw2Digits(rawReader,fgDigitsArr,fPedestalData,digitsTrg,fTriggerData);
328 }//skip calibration event
330 AliDebug(1," Calibration Event, skip!");
340 //____________________________________________________________________________
341 void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree,
342 AliESDEvent* esd) const
344 // Called by AliReconstruct after Reconstruct() and global tracking and vertexing
346 // Works on the current event
347 // printf(" ## AliEMCALReconstructor::FillESD() is started ### \n ");
350 //########################################
352 //########################################
354 static int saveOnce = 0;
356 Int_t v0M[2] = {0, 0};
358 AliESDVZERO* esdV0 = esd->GetVZEROData();
362 v0M[0] = esdV0->GetTriggerChargeC();
363 v0M[1] = esdV0->GetTriggerChargeA();
367 AliWarning("No V0 ESD! Run trigger processor w/ null V0 charges");
370 if (fgTriggerDigits && fgTriggerDigits->GetEntriesFast()) fgTriggerDigits->Delete();
372 TBranch *branchtrg = digitsTree->GetBranch("EMTRG");
376 AliError("Can't get the branch with the EMCAL trigger digits!");
380 branchtrg->SetAddress(&fgTriggerDigits);
381 branchtrg->GetEntry(0);
383 // Note: fgTriggerProcessor reset done at the end of this method
384 fgTriggerProcessor->Digits2Trigger(fgTriggerDigits, v0M, fTriggerData);
387 AliESDCaloTrigger* trgESD = esd->GetCaloTrigger("EMCAL");
391 trgESD->Allocate(fgTriggerDigits->GetEntriesFast());
393 for (Int_t i = 0; i < fgTriggerDigits->GetEntriesFast(); i++)
395 AliEMCALTriggerRawDigit* rdig = (AliEMCALTriggerRawDigit*)fgTriggerDigits->At(i);
396 if (AliDebugLevel() > 999) rdig->Print("");
399 if (fGeom->GetPositionInEMCALFromAbsFastORIndex(rdig->GetId(), px, py))
401 Int_t a = -1, t = -1, times[10];
403 rdig->GetMaximum(a, t);
404 rdig->GetL0Times(times);
406 trgESD->Add(px, py, a, t, times, rdig->GetNL0Times(), rdig->GetL1TimeSum(), rdig->GetTriggerBits());
410 for (int i = 0; i < 2; i++) {
411 trgESD->SetL1Threshold(2 * i , fTriggerData->GetL1JetThreshold( i));
412 trgESD->SetL1Threshold(2 * i + 1, fTriggerData->GetL1GammaThreshold(i));
416 fTriggerData->GetL1V0(v0);
419 trgESD->SetL1FrameMask(fTriggerData->GetL1FrameMask());
421 if (!saveOnce && fTriggerData->GetL1DataDecoded())
424 fTriggerData->GetL1TriggerType(type);
426 esd->SetCaloTriggerType(type);
433 fTriggerData->Reset();
435 //########################################
436 //##############Fill CaloCells###############
437 //########################################
439 //Get input digits and put them in fgDigitsArr, clear the list before
440 ReadDigitsArrayFromTree(digitsTree);
442 Int_t nDigits = fgDigitsArr->GetEntries(), idignew = 0 ;
443 AliDebug(1,Form("%d digits",nDigits));
445 AliESDCaloCells &emcCells = *(esd->GetEMCALCells());
446 emcCells.CreateContainer(nDigits);
447 emcCells.SetType(AliVCaloCells::kEMCALCell);
451 for (Int_t idig = 0 ; idig < nDigits ; idig++)
453 const AliEMCALDigit * dig = (const AliEMCALDigit*)fgDigitsArr->At(idig);
454 time = dig->GetTime(); // Time already calibrated in clusterizer
455 energy = dig->GetAmplitude(); // energy calibrated in clusterizer
459 fgClusterizer->Calibrate(energy,time,dig->GetId()); //Digits already calibrated in clusterizers
461 if(energy > 0) //Digits tagged as bad (dead, hot, not alive) are set to 0 in calibrate, remove them
464 // Get the label of the primary particle that generated the cell
465 // Assign the particle that deposited more energy
466 Int_t nprimaries = dig->GetNprimary() ;
469 if ( nprimaries > 0 )
472 for ( jndex = 0 ; jndex < nprimaries ; jndex++ ) { // all primaries in digit
474 if(edep < dig->GetDEParent(jndex+1))
476 digLabel = dig->GetIparent (jndex+1);
477 edep = dig->GetDEParent(jndex+1);
480 } // all primaries in digit
481 } // select primary label
483 Bool_t highGain = kFALSE;
484 if( dig->GetType() == AliEMCALDigit::kHG ) highGain = kTRUE;
486 emcCells.SetCell(idignew,dig->GetId(),energy, time,digLabel,0.,highGain);
492 emcCells.SetNumberOfCells(idignew);
495 //------------------------------------------------------------
496 //-----------------CLUSTERS-----------------------------
497 //------------------------------------------------------------
498 clustersTree->SetBranchStatus("*",0); //disable all branches
499 clustersTree->SetBranchStatus("EMCALECARP",1); //Enable only the branch we need
500 if(fgClustersArr) fgClustersArr->Clear();
501 TBranch *branch = clustersTree->GetBranch("EMCALECARP");
502 branch->SetAddress(&fgClustersArr);
504 //clustersTree->GetEvent(0);
506 Int_t nClusters = fgClustersArr->GetEntries(), nClustersNew=0;
507 AliDebug(1,Form("%d clusters",nClusters));
510 //########################################
511 //##############Fill CaloClusters#############
512 //########################################
513 for (Int_t iClust = 0 ; iClust < nClusters ; iClust++) {
514 const AliEMCALRecPoint * clust = (const AliEMCALRecPoint*)fgClustersArr->At(iClust);
516 //if(clust->GetClusterType()== AliVCluster::kEMCALClusterv1) nRP++; else nPC++;
517 // clust->Print(); //For debugging
518 // Get information from EMCAL reconstruction points
521 clust->GetGlobalPosition(gpos);
522 for (Int_t ixyz=0; ixyz<3; ixyz++)
523 xyz[ixyz] = gpos[ixyz];
525 clust->GetElipsAxis(elipAxis);
526 //Create digits lists
527 Int_t cellMult = clust->GetMultiplicity();
528 //TArrayS digiList(digitMult);
529 Float_t *amplFloat = clust->GetEnergiesList();
530 Int_t *digitInts = clust->GetAbsId();
531 TArrayS absIdList(cellMult);
532 TArrayD fracList(cellMult);
534 Int_t newCellMult = 0;
535 for (Int_t iCell=0; iCell<cellMult; iCell++) {
536 if (amplFloat[iCell] > 0) {
537 absIdList[newCellMult] = (UShort_t)(digitInts[iCell]);
539 if(emcCells.GetCellAmplitude(digitInts[iCell])>0 && GetRecParam()->GetUnfold()){
540 fracList[newCellMult] = amplFloat[iCell]/(emcCells.GetCellAmplitude(digitInts[iCell]));//get cell calibration value
544 fracList[newCellMult] = 0;
550 absIdList.Set(newCellMult);
551 fracList.Set(newCellMult);
553 if(newCellMult > 0) { // accept cluster if it has some digit
556 Int_t parentMult = 0;
557 Int_t *parentList = clust->GetParents(parentMult);
558 // fills the ESDCaloCluster
559 AliESDCaloCluster * ec = new AliESDCaloCluster() ;
560 ec->SetType(AliVCluster::kEMCALClusterv1);
561 ec->SetPosition(xyz);
562 ec->SetE(clust->GetEnergy());
564 //Distance to the nearest bad crystal
565 ec->SetDistanceToBadChannel(clust->GetDistanceToBadTower());
567 ec->SetNCells(newCellMult);
568 //Change type of list from short to ushort
569 UShort_t *newAbsIdList = new UShort_t[newCellMult];
570 Double_t *newFracList = new Double_t[newCellMult];
571 for(Int_t i = 0; i < newCellMult ; i++) {
572 newAbsIdList[i]=absIdList[i];
573 newFracList[i] =fracList[i];
575 ec->SetCellsAbsId(newAbsIdList);
576 ec->SetCellsAmplitudeFraction(newFracList);
577 ec->SetDispersion(clust->GetDispersion());
578 ec->SetChi2(-1); //not yet implemented
579 ec->SetM02(elipAxis[0]*elipAxis[0]) ;
580 ec->SetM20(elipAxis[1]*elipAxis[1]) ;
581 ec->SetTOF(clust->GetTime()) ; //time-of-fligh
582 ec->SetNExMax(clust->GetNExMax()); //number of local maxima
585 TArrayI arrayParents(parentMult,parentList);
586 ec->AddLabels(arrayParents);
591 Int_t nTracks = esd->GetNumberOfTracks();
592 for (Int_t itrack = 0; itrack < nTracks; itrack++)
594 AliESDtrack * track = esd->GetTrack(itrack) ; // retrieve track
595 if(track->GetEMCALcluster()==iClust)
597 Float_t dEta=-999, dPhi=-999;
598 Bool_t isMatch = CalculateResidual(track, ec, dEta, dPhi);
601 // AliDebug(10, "Not good");
604 AliEMCALMatch *match = new AliEMCALMatch();
605 match->SetIndexT(itrack);
606 match->SetDistance(TMath::Sqrt(dEta*dEta+dPhi*dPhi));
607 match->SetdEta(dEta);
608 match->SetdPhi(dPhi);
609 fMatches->Add(match);
612 fMatches->Sort(kSortAscending); //Sort matched tracks from closest to furthest
613 Int_t nMatch = fMatches->GetEntries();
614 TArrayI arrayTrackMatched(nMatch);
615 for(Int_t imatch=0; imatch<nMatch; imatch++)
617 AliEMCALMatch *match = (AliEMCALMatch*)fMatches->At(imatch);
618 arrayTrackMatched[imatch] = match->GetIndexT();
621 ec->SetTrackDistance(match->GetdPhi(), match->GetdEta());
624 ec->AddTracksMatched(arrayTrackMatched);
626 //add the cluster to the esd object
627 esd->AddCaloCluster(ec);
630 delete [] newAbsIdList ;
631 delete [] newFracList ;
633 } // cycle on clusters
636 //Reset the index of matched cluster for tracks
637 //to the one in CaloCluster array
638 Int_t ncls = esd->GetNumberOfCaloClusters();
639 for(Int_t icl=0; icl<ncls; icl++)
641 AliESDCaloCluster *cluster = esd->GetCaloCluster(icl);
642 if(!cluster || !cluster->IsEMCAL()) continue;
643 TArrayI *trackIndex = cluster->GetTracksMatched();
644 for(Int_t itr=0; itr<trackIndex->GetSize(); itr++)
646 AliESDtrack *track = esd->GetTrack(trackIndex->At(itr));
647 track->SetEMCALcluster(cluster->GetID());
652 //Fill ESDCaloCluster with PID weights
653 AliEMCALPID *pid = new AliEMCALPID;
654 //pid->SetPrintInfo(kTRUE);
655 pid->SetReconstructor(kTRUE);
659 //Store EMCAL misalignment matrixes
660 FillMisalMatrixes(esd) ;
664 //==================================================================================
665 void AliEMCALReconstructor::FillMisalMatrixes(AliESDEvent* esd)const{
666 //Store EMCAL matrixes in ESD Header
668 //Check, if matrixes was already stored
669 for(Int_t sm = 0 ; sm < fGeom->GetNumberOfSuperModules(); sm++){
670 if(esd->GetEMCALMatrix(sm)!=0)
674 //Create and store matrixes
676 AliError("Can not store misal. matrixes: no gGeoManager! \n") ;
679 //Note, that owner of copied marixes will be header
680 const Int_t bufsize = 255;
682 TGeoHMatrix * m = 0x0;
686 for(Int_t sm = 0; sm < fGeom->GetNumberOfSuperModules(); sm++){
687 if(fGeom->GetSMType(sm) == AliEMCALGeometry::kEMCAL_Standard ) SMName = "SMOD";
688 else if(fGeom->GetSMType(sm) == AliEMCALGeometry::kEMCAL_Half ) SMName = "SM10";
689 else if(fGeom->GetSMType(sm) == AliEMCALGeometry::kEMCAL_3rd ) SMName = "SM3rd";
690 else if( fGeom->GetSMType(sm) == AliEMCALGeometry::kDCAL_Standard ) SMName = "DCSM";
691 else if( fGeom->GetSMType(sm) == AliEMCALGeometry::kDCAL_Ext ) SMName = "DCEXT";
692 else AliError("Unkown SM Type!!");
694 if(fGeom->GetSMType(sm) == tmpType) {
697 tmpType = fGeom->GetSMType(sm);
700 snprintf(path,bufsize,"/ALIC_1/XEN1_1/%s_%d", SMName.Data(), SMOrder) ;
702 if (gGeoManager->CheckPath(path)){
703 gGeoManager->cd(path);
704 m = gGeoManager->GetCurrentMatrix() ;
705 // printf("================================================= \n");
706 // printf("AliEMCALReconstructor::FixMisalMatrixes(), sm %d, \n",sm);
708 esd->SetEMCALMatrix(new TGeoHMatrix(*m),sm) ;
709 // printf("================================================= \n");
712 esd->SetEMCALMatrix(NULL,sm) ;
717 //__________________________________________________________________________
718 void AliEMCALReconstructor::ReadDigitsArrayFromTree(TTree *digitsTree) const
720 // Read the digits from the input tree
721 // See AliEMCALClusterizer::SetInput(TTree *digitsTree);
723 // Clear previous digits in the list
725 fgDigitsArr->Clear("C");
728 // It should not happen, but just in case ...
729 fgDigitsArr = new TClonesArray("AliEMCALDigit",100);
732 // Read the digits from the input tree
733 TBranch *branch = digitsTree->GetBranch("EMCAL");
735 AliError("can't get the branch with the EMCAL digits !");
739 branch->SetAddress(&fgDigitsArr);
743 //==================================================================================
744 Bool_t AliEMCALReconstructor::CalculateResidual(AliESDtrack *track, AliESDCaloCluster *cluster, Float_t &dEta, Float_t &dPhi)const
747 // calculate the residual between track and cluster
750 // If the esdFriend is available, use the TPCOuter point as the starting point of extrapolation
751 // Otherwise use the TPCInner point
753 dEta = -999, dPhi = -999;
754 Bool_t ITSTrackSA = 0;
756 AliExternalTrackParam *trkParam = 0;
758 const AliESDfriendTrack* friendTrack = track->GetFriendTrack();
759 if(friendTrack && friendTrack->GetTPCOut())
760 trkParam = const_cast<AliExternalTrackParam*>(friendTrack->GetTPCOut());
761 else if(track->GetInnerParam())
762 trkParam = const_cast<AliExternalTrackParam*>(track->GetInnerParam());
764 trkParam = new AliExternalTrackParam(*track); //If there is ITSSa track
767 if(!trkParam) return kFALSE;
769 AliExternalTrackParam trkParamTmp (*trkParam);
770 if(!AliEMCALRecoUtils::ExtrapolateTrackToCluster(&trkParamTmp, cluster, track->GetMass(kTRUE), GetRecParam()->GetExtrapolateStep(), dEta, dPhi)){
771 if(ITSTrackSA) delete trkParam;
775 if(ITSTrackSA) delete trkParam;
780 //==================================================================================
782 AliEMCALReconstructor::AliEMCALMatch::AliEMCALMatch()
789 //default constructor
794 //==================================================================================
796 AliEMCALReconstructor::AliEMCALMatch::AliEMCALMatch(const AliEMCALMatch& copy)
798 fIndexT(copy.fIndexT),
799 fDistance(copy.fDistance),
805 //_____________________________________________________________________
806 AliEMCALReconstructor::AliEMCALMatch& AliEMCALReconstructor::AliEMCALMatch::AliEMCALMatch::operator = (const AliEMCALMatch &source)
807 { // assignment operator; use copy ctor
808 if (&source == this) return *this;
810 new (this) AliEMCALMatch(source);
814 //==================================================================================
816 Int_t AliEMCALReconstructor::AliEMCALMatch::Compare(const TObject *obj) const
819 // Compare wrt the residual
822 AliEMCALReconstructor::AliEMCALMatch *that = (AliEMCALReconstructor::AliEMCALMatch*)obj;
824 Double_t thisDist = fDistance;//fDistance;
825 Double_t thatDist = that->fDistance;//that->GetDistance();
827 if (thisDist > thatDist) return 1;
828 else if (thisDist < thatDist) return -1;