]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
All: Add possibility to recalculate track matching in EMCAL
authorgconesab <gconesab@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 1 Nov 2010 22:43:51 +0000 (22:43 +0000)
committergconesab <gconesab@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 1 Nov 2010 22:43:51 +0000 (22:43 +0000)
EMCALCalibTask: Read geometry matrices if gGeoManager not existing

12 files changed:
PWG4/CaloCalib/AliAnalysisTaskCaloFilter.cxx
PWG4/CaloCalib/AliAnalysisTaskEMCALPi0CalibSelection.cxx
PWG4/PartCorrBase/AliAnaPartCorrBaseClass.h
PWG4/PartCorrBase/AliAnalysisTaskParticleCorrelationM.cxx
PWG4/PartCorrBase/AliCaloPID.cxx
PWG4/PartCorrBase/AliCaloPID.h
PWG4/PartCorrBase/AliCaloTrackReader.cxx
PWG4/PartCorrBase/AliCalorimeterUtils.cxx
PWG4/PartCorrBase/AliCalorimeterUtils.h
PWG4/PartCorrDep/AliAnaPhoton.cxx
PWG4/PartCorrDep/AliAnaPi0EbE.cxx
PWG4/PartCorrDep/AliAnaShowerParameter.cxx

index 3ca24840c96a9441717323b488f269527b5cf4f9..c21d018f9641c7d0bbd4af6eda7e0331834f8ade 100644 (file)
@@ -196,28 +196,24 @@ void AliAnalysisTaskCaloFilter::UserExec(Option_t */*option*/)
   TClonesArray &caloClusters = *(AODEvent()->GetCaloClusters());
   Int_t jClusters=0;
   
-  for (Int_t iClust=0; iClust<nCaloClus; ++iClust) {
-    
-    AliVCluster * cluster = event->GetCaloCluster(iClust);
-    
-    //Check which calorimeter information we want to keep.
-    
-    if(fCaloFilter!=kBoth){
-      if     (fCaloFilter==kPHOS  && cluster->IsEMCAL()) continue ;
-      else if(fCaloFilter==kEMCAL && cluster->IsPHOS())  continue ;
-    }  
-    
-    //--------------------------------------------------------------
-    //If EMCAL, and requested, correct energy, position ...
-    if(cluster->IsEMCAL() && fCorrect){
+  //Do Corrections in EMCAL 
+  //If EMCAL, and requested, correct energy, position ...
+  //Need to do this in a separate loop before filling the ESDs because of the track matching recalculations
+  if(fCorrect && (fCaloFilter==kEMCAL || fCaloFilter==kBoth) ) {
+    //Cluster Loop
+    for (Int_t iClust=0; iClust<nCaloClus; ++iClust) {
+      
+      AliVCluster * cluster = event->GetCaloCluster(iClust);
+      if(cluster->IsPHOS()) continue ;
+
       Float_t position[]={0,0,0};
       if(DebugLevel() > 2)
         printf("Check cluster %d for bad channels and close to border\n",cluster->GetID());
       if(fEMCALRecoUtils->ClusterContainsBadChannel(fEMCALGeo,cluster->GetCellsAbsId(), cluster->GetNCells())) continue;       
-//      if(!fEMCALRecoUtils->CheckCellFiducialRegion(fEMCALGeo, cluster, event->GetEMCALCells())) {
-//        printf("Finally reject\n");
-//        continue;
-//      }
+      //      if(!fEMCALRecoUtils->CheckCellFiducialRegion(fEMCALGeo, cluster, event->GetEMCALCells())) {
+      //        printf("Finally reject\n");
+      //        continue;
+      //      }
       if(DebugLevel() > 2)
       { 
         printf("Filter, before  : i %d, E %f, dispersion %f, m02 %f, m20 %f\n",iClust,cluster->E(),
@@ -225,17 +221,16 @@ void AliAnalysisTaskCaloFilter::UserExec(Option_t */*option*/)
         cluster->GetPosition(position);
         printf("Filter, before  : i %d, x %f, y %f, z %f\n",cluster->GetID(), position[0], position[1], position[2]);
       }
-            
+      
       if(fEMCALRecoUtils->IsRecalibrationOn()) {
         fEMCALRecoUtils->RecalibrateClusterEnergy(fEMCALGeo, cluster, event->GetEMCALCells());
         fEMCALRecoUtils->RecalculateClusterShowerShapeParameters(fEMCALGeo, event->GetEMCALCells(),cluster);
         fEMCALRecoUtils->RecalculateClusterPID(cluster);
-
       }
       cluster->SetE(fEMCALRecoUtils->CorrectClusterEnergyLinearity(cluster));
       
       fEMCALRecoUtils->RecalculateClusterPosition(fEMCALGeo, event->GetEMCALCells(),cluster);
-
+      
       if(DebugLevel() > 2)
       { 
         printf("Filter, after   : i %d, E %f, dispersion %f, m02 %f, m20 %f\n",cluster->GetID(),cluster->E(),
@@ -244,10 +239,49 @@ void AliAnalysisTaskCaloFilter::UserExec(Option_t */*option*/)
         printf("Filter, after   : i %d, x %f, y %f, z %f\n",cluster->GetID(), position[0], position[1], position[2]);
       }    
       
+    }
+    //Recalculate track-matching
+    fEMCALRecoUtils->FindMatches(event);
+    
+  } // corrections in EMCAL
+  
+  //Now loop on clusters to fill AODs
+  for (Int_t iClust=0; iClust<nCaloClus; ++iClust) {
+    
+    AliVCluster * cluster = event->GetCaloCluster(iClust);
+    
+    //Check which calorimeter information we want to keep.
+    
+    if(fCaloFilter!=kBoth){
+      if     (fCaloFilter==kPHOS  && cluster->IsEMCAL()) continue ;
+      else if(fCaloFilter==kEMCAL && cluster->IsPHOS())  continue ;
+    }  
+    
+    //Temporary trick, FIXME
+    Float_t dR = cluster->GetTrackDx();
+    Float_t dZ = cluster->GetTrackDz();
+    if(DebugLevel() > 2)
+      printf("Original residuals : dZ %f, dR %f\n ",dZ, dR);
+    //--------------------------------------------------------------
+    //If EMCAL and corrections done, get the new matching parameters, do not copy noisy clusters
+    if(cluster->IsEMCAL() && fCorrect){
+      if(DebugLevel() > 2)
+        printf("Check cluster %d for bad channels and close to border\n",cluster->GetID());
+      if(fEMCALRecoUtils->ClusterContainsBadChannel(fEMCALGeo,cluster->GetCellsAbsId(), cluster->GetNCells())) continue;       
+      //      if(!fEMCALRecoUtils->CheckCellFiducialRegion(fEMCALGeo, cluster, event->GetEMCALCells())) {
+      //        printf("Finally reject\n");
+      //        continue;
+      //      }
+      
+      fEMCALRecoUtils->GetMatchedResiduals(cluster->GetID(),dR,dZ);
+      if(DebugLevel() > 2)
+        printf("Corrected Residuals : dZ %f, dR %f\n ",dZ, dR);
+
     }
     //--------------------------------------------------------------
 
     //Now fill AODs
+    
     Int_t id       = cluster->GetID();
     Float_t energy = cluster->E();
     cluster->GetPosition(posF);
@@ -261,10 +295,11 @@ void AliAnalysisTaskCaloFilter::UserExec(Option_t */*option*/)
                        NULL,
                        cluster->GetType());
     
+    caloCluster->SetChi2(dZ);//Temporary trick, FIXME
     caloCluster->SetCaloCluster(cluster->GetDistanceToBadChannel(),
                                cluster->GetDispersion(),
                                cluster->GetM20(), cluster->GetM02(),
-                               cluster->GetEmcCpvDistance(),  
+                               dR,  //Temporary trick, FIXME
                                cluster->GetNExMax(),cluster->GetTOF()) ;
     
     caloCluster->SetPIDFromESD(cluster->GetPID());
@@ -274,23 +309,29 @@ void AliAnalysisTaskCaloFilter::UserExec(Option_t */*option*/)
     
     if(DebugLevel() > 2)
     { 
-      printf("Filter, aod       : i %d, E %f, dispersion %f, m02 %f, m20 %f\n",caloCluster->GetID(),caloCluster->E(),
+      printf("Filter, aod     : i %d, E %f, dispersion %f, m02 %f, m20 %f\n",caloCluster->GetID(),caloCluster->E(),
              caloCluster->GetDispersion(),caloCluster->GetM02(),caloCluster->GetM20());
       caloCluster->GetPosition(posF);
-      printf("Filter, aod       : i %d, x %f, y %f, z %f\n",caloCluster->GetID(), posF[0], posF[1], posF[2]);
+      printf("Filter, aod     : i %d, x %f, y %f, z %f\n",caloCluster->GetID(), posF[0], posF[1], posF[2]);
     }    
     
     //Matched tracks, just to know if there was any match, the track pointer is useless.
+    //Temporary trick, FIXME
     if(bESD){
-      TArrayI* matchedT =      ((AliESDCaloCluster*)cluster)->GetTracksMatched();
-      if (InputEvent()->GetNumberOfTracks() > 0 && matchedT && cluster->GetTrackMatchedIndex() >= 0) { 
-        for (Int_t im = 0; im < matchedT->GetSize(); im++) {
-          Int_t iESDtrack = matchedT->At(im);;
-          if ((AliVTrack*)InputEvent()->GetTrack(iESDtrack) != 0) {
-            caloCluster->AddTrackMatched((AliVTrack*)InputEvent()->GetTrack(iESDtrack));
-          }
-        }
-      }// There is at least a match with a track
+      if(TMath::Abs(dR) < 990 && TMath::Abs(dZ) < 990) { //Default value in PHOS 999, in EMCAL 1024, why?
+        if(DebugLevel() > 2) 
+          printf("*** Cluster Track-Matched *** dR %f, dZ %f\n",caloCluster->GetEmcCpvDistance(),caloCluster->Chi2());
+        caloCluster->AddTrackMatched(0x0); 
+      }// fill the array with one entry to signal a possible match
+      //TArrayI* matchedT =    ((AliESDCaloCluster*)cluster)->GetTracksMatched();
+      //if (InputEvent()->GetNumberOfTracks() > 0 && matchedT && cluster->GetTrackMatchedIndex() >= 0) {       
+      //  for (Int_t im = 0; im < matchedT->GetSize(); im++) {
+      //    Int_t iESDtrack = matchedT->At(im);;
+      //    if ((AliVTrack*)InputEvent()->GetTrack(iESDtrack) != 0) {
+      //      caloCluster->AddTrackMatched((AliVTrack*)InputEvent()->GetTrack(iESDtrack));
+      //    }
+      //  }
+      //}// There is at least a match with a track
     }
   } 
   caloClusters.Expand(jClusters); // resize TObjArray to 'remove' slots for pseudo clusters     
index ef22467de8188f3e82083073b011d3ba97c04d3e..5a4a50dc466f96a56d510ea9a888d1525c246cd7 100644 (file)
@@ -370,24 +370,27 @@ void AliAnalysisTaskEMCALPi0CalibSelection::UserExec(Option_t* /* option */)
   //Int_t runNum = aod->GetRunNumber();
   //if(DebugLevel() > 1) printf("Run number: %d\n",runNum);
   
-  //FIXME Not need the matrices for the moment MEFIX
   //Get the matrix with geometry information
   //Still not implemented in AOD, just a workaround to be able to work at least with ESDs      
-  //  if(!strcmp(InputEvent()->GetName(),"AliAODEvent")) {
-  //    if(DebugLevel() > 1) 
-  //      printf("AliAnalysisTaskEMCALPi0CalibSelection Use ideal geometry, values geometry matrix not kept in AODs.\n");
-  //  }
-  //  else{    
-  //    if(DebugLevel() > 1) printf("AliAnalysisTaskEMCALPi0CalibSelection Load Misaligned matrices. \n");
-  //    AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent()) ;
-  //    if(!esd) {
-  //      printf("AliAnalysisTaskEMCALPi0CalibSelection::UserExec() - This event does not contain ESDs?");
-  //      return;
-  //    }
-  //    for(Int_t mod=0; mod < (fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){ 
-  //      if(esd->GetEMCALMatrix(mod)) fEMCALGeo->SetMisalMatrix(esd->GetEMCALMatrix(mod),mod) ;
-  //    }
-  //  }
+  if(!gGeoManager && fhNEvents->GetEntries()==1){
+    printf("AliAnalysisTaskEMCALPi0CalibSelection::UserExec() - Get geo matrices from data\n");
+    if(!strcmp(event->GetName(),"AliAODEvent")) {
+        if(DebugLevel() > 1) 
+          printf("AliAnalysisTaskEMCALPi0CalibSelection Use ideal geometry, values geometry matrix not kept in AODs.\n");
+    }//AOD
+    else {     
+      if(DebugLevel() > 1) printf("AliAnalysisTaskEMCALPi0CalibSelection Load Misaligned matrices. \n");
+        AliESDEvent* esd = dynamic_cast<AliESDEvent*>(event) ;
+        if(!esd) {
+          printf("AliAnalysisTaskEMCALPi0CalibSelection::UserExec() - This event does not contain ESDs?");
+        return;
+        }
+        for(Int_t mod=0; mod < (fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){
+          if(DebugLevel() > 1) esd->GetEMCALMatrix(mod)->Print();
+          if(esd->GetEMCALMatrix(mod)) fEMCALGeo->SetMisalMatrix(esd->GetEMCALMatrix(mod),mod) ;
+        } 
+    }//ESD
+  }//first event
   
   if(DebugLevel() > 1) printf("AliAnalysisTaskEMCALPi0CalibSelection Will use fLogWeight %.3f .\n",fLogWeight);
   Int_t absId1   = -1;
@@ -538,22 +541,24 @@ void AliAnalysisTaskEMCALPi0CalibSelection::UserExec(Option_t* /* option */)
             Float_t opangle = p1.Angle(p2.Vect())*TMath::RadToDeg();
             //printf("*******>>>>>>>> In PEAK pt %f, angle %f \n",p12.Pt(),opangle);
             
-            //Inciden angle of each photon
-            Float_t posSM1cen[3]={0.,0.,0.};
-            Float_t depth = fRecoUtils->GetDepth(p1.Energy(),fRecoUtils->GetParticleType(),iSupMod1);
-            fEMCALGeo->RecalculateTowerPosition(11.5, 23.5, iSupMod1, depth, fRecoUtils->GetMisalTransShiftArray(),fRecoUtils->GetMisalRotShiftArray(),posSM1cen); 
-            Float_t posSM2cen[3]={0.,0.,0.}; 
-            depth = fRecoUtils->GetDepth(p2.Energy(),fRecoUtils->GetParticleType(),iSupMod2);
-            fEMCALGeo->RecalculateTowerPosition(11.5, 23.5, iSupMod2, depth, fRecoUtils->GetMisalTransShiftArray(),fRecoUtils->GetMisalRotShiftArray(),posSM2cen); 
-            //printf("SM1 %d pos (%2.3f,%2.3f,%2.3f) \n",iSupMod1,posSM1cen[0],posSM1cen[1],posSM1cen[2]);
-            //printf("SM2 %d pos (%2.3f,%2.3f,%2.3f) \n",iSupMod2,posSM2cen[0],posSM2cen[1],posSM2cen[2]);
-            
-            TVector3 vecSM1cen(posSM1cen[0]-v[0],posSM1cen[1]-v[1],posSM1cen[2]-v[2]); 
-            TVector3 vecSM2cen(posSM2cen[0]-v[0],posSM2cen[1]-v[1],posSM2cen[2]-v[2]); 
-            Float_t inangle1 = p1.Angle(vecSM1cen)*TMath::RadToDeg();
-            Float_t inangle2 = p2.Angle(vecSM2cen)*TMath::RadToDeg();
-            //printf("Incident angle: cluster 1 %2.3f; cluster 2 %2.3f\n",inangle1,inangle2);
-            
+            //Incident angle of each photon
+            Float_t inangle1 =0., inangle2=0.;
+            if(gGeoManager){
+              Float_t posSM1cen[3]={0.,0.,0.};
+              Float_t depth = fRecoUtils->GetDepth(p1.Energy(),fRecoUtils->GetParticleType(),iSupMod1);
+              fEMCALGeo->RecalculateTowerPosition(11.5, 23.5, iSupMod1, depth, fRecoUtils->GetMisalTransShiftArray(),fRecoUtils->GetMisalRotShiftArray(),posSM1cen); 
+              Float_t posSM2cen[3]={0.,0.,0.}; 
+              depth = fRecoUtils->GetDepth(p2.Energy(),fRecoUtils->GetParticleType(),iSupMod2);
+              fEMCALGeo->RecalculateTowerPosition(11.5, 23.5, iSupMod2, depth, fRecoUtils->GetMisalTransShiftArray(),fRecoUtils->GetMisalRotShiftArray(),posSM2cen); 
+              //printf("SM1 %d pos (%2.3f,%2.3f,%2.3f) \n",iSupMod1,posSM1cen[0],posSM1cen[1],posSM1cen[2]);
+              //printf("SM2 %d pos (%2.3f,%2.3f,%2.3f) \n",iSupMod2,posSM2cen[0],posSM2cen[1],posSM2cen[2]);
+              
+              TVector3 vecSM1cen(posSM1cen[0]-v[0],posSM1cen[1]-v[1],posSM1cen[2]-v[2]); 
+              TVector3 vecSM2cen(posSM2cen[0]-v[0],posSM2cen[1]-v[1],posSM2cen[2]-v[2]); 
+              inangle1 = p1.Angle(vecSM1cen)*TMath::RadToDeg();
+              inangle2 = p2.Angle(vecSM2cen)*TMath::RadToDeg();
+              //printf("Incident angle: cluster 1 %2.3f; cluster 2 %2.3f\n",inangle1,inangle2);
+            }
             fHOpeningAngle ->Fill(opangle,p12.Pt()); 
             fHIncidentAngle->Fill(inangle1,p1.Pt()); 
             fHIncidentAngle->Fill(inangle2,p2.Pt()); 
index b0e5233117acf4260482cc44c601494d30c55b0f..d9ac191305d789c9598f8b399637f1ff52eee0b2 100755 (executable)
@@ -244,7 +244,7 @@ public:
   virtual void      GetVertex(Double_t vertex[3],const Int_t evtIndex) const { GetReader()->GetVertex(vertex,evtIndex) ; } 
   virtual Double_t* GetVertex(const Int_t evtIndex) const { return GetReader()->GetVertex(evtIndex) ; } 
 
-       virtual Bool_t IsTrackMatched(const AliVCluster * cluster) const { return fCaloPID->IsTrackMatched(cluster); } 
+       virtual Bool_t IsTrackMatched(const AliVCluster * cluster) const { return fCaloPID->IsTrackMatched(cluster, fCaloUtils); } 
   
   void SwitchOnPlotsMaking()  {fMakePlots = kTRUE  ;}
   void SwitchOffPlotsMaking() {fMakePlots = kFALSE ;}
index 973c4b7515f7235a5cbceda4b2986d5d7a75d18e..cab8074570ec73ac34241124aa99b7752004fb49 100755 (executable)
@@ -41,6 +41,7 @@
 #include "AliMixedEvent.h"
 #include "AliAODEvent.h"
 #include "AliESDEvent.h"
+#include "AliAnalysisDataSlot.h"
 
 ClassImp(AliAnalysisTaskParticleCorrelationM)
 
@@ -213,12 +214,14 @@ void AliAnalysisTaskParticleCorrelationM::UserExec(Option_t */*option*/)
   fAna->ProcessEvent((Int_t) Entry(), CurrentFileName());
   //printf("AliAnalysisTaskParticleCorrelationM::Current Event %d; Current File Name : %s\n",(Int_t) Entry(), CurrentFileName());
   if (DebugLevel() > 1) printf("AliAnalysisTaskParticleCorrelationM::UserExec() - End\n");
-       
+    
   PostData(1, fOutputContainer);
        
+  AliAnalysisDataSlot *out0 = GetOutputSlot(0);
+  if (out0 && out0->IsConnected()) PostData(0, fTreeA);  
+  
   //gObjectTable->Print();
 
-  
 }
 
 //_____________________________________________________
index f52013f57f8dd03cd135af8e46283cd153ed86bc..49c5b7b5cfd388b3c04b0f621c50f1f276797d8d 100755 (executable)
@@ -49,6 +49,8 @@
 #include "AliVCluster.h"
 #include "AliAODPWG4Particle.h"
 #include "AliEMCALPIDUtils.h"
+#include "AliCalorimeterUtils.h"
+
 ClassImp(AliCaloPID)
 
 
@@ -62,7 +64,8 @@ fPHOSElectronWeight(0.), fPHOSChargeWeight(0.) ,
 fPHOSNeutralWeight(0.), //fPHOSWeightFormula(0), 
 //fPHOSPhotonWeightFormula(0x0), fPHOSPi0WeightFormula(0x0),
 fDispCut(0.),fTOFCut(0.), fDebug(-1), 
-fRecalculateBayesian(kFALSE), fParticleFlux(kLow), fEMCALPIDUtils(new AliEMCALPIDUtils)
+fRecalculateBayesian(kFALSE), fParticleFlux(kLow), 
+fEMCALPIDUtils(new AliEMCALPIDUtils)
 {
   //Ctor
   
@@ -80,7 +83,8 @@ fPHOSElectronWeight(0.), fPHOSChargeWeight(0.) ,
 fPHOSNeutralWeight(0.), //fPHOSWeightFormula(0), 
 //fPHOSPhotonWeightFormula(0x0), fPHOSPi0WeightFormula(0x0),
 fDispCut(0.),fTOFCut(0.), fDebug(-1), 
-fRecalculateBayesian(kTRUE), fParticleFlux(flux), fEMCALPIDUtils(new AliEMCALPIDUtils)
+fRecalculateBayesian(kTRUE), fParticleFlux(flux), 
+fEMCALPIDUtils(new AliEMCALPIDUtils)
 {
        //Ctor
        
@@ -98,7 +102,8 @@ fPHOSElectronWeight(0.), fPHOSChargeWeight(0.) ,
 fPHOSNeutralWeight(0.), //fPHOSWeightFormula(0), 
 //fPHOSPhotonWeightFormula(0x0), fPHOSPi0WeightFormula(0x0),
 fDispCut(0.),fTOFCut(0.), fDebug(-1), 
-fRecalculateBayesian(kTRUE), fParticleFlux(-1), fEMCALPIDUtils( (AliEMCALPIDUtils*) emcalpid)
+fRecalculateBayesian(kTRUE), fParticleFlux(-1), 
+fEMCALPIDUtils( (AliEMCALPIDUtils*) emcalpid)
 {
        //Ctor
        
@@ -416,7 +421,7 @@ void AliCaloPID::Print(const Option_t * opt) const
 } 
 
 //_______________________________________________________________
-void AliCaloPID::SetPIDBits(const TString calo, const AliVCluster * cluster, AliAODPWG4Particle * ph) {
+void AliCaloPID::SetPIDBits(const TString calo, const AliVCluster * cluster, AliAODPWG4Particle * ph, const AliCalorimeterUtils* cu) {
   //Set Bits for PID selection
   
   //Dispersion/lambdas
@@ -454,7 +459,7 @@ void AliCaloPID::SetPIDBits(const TString calo, const AliVCluster * cluster, Ali
   //Bool_t isNeutral = kTRUE ;
   //if(cluster->IsPHOS())  isNeutral = cluster->GetEmcCpvDistance() > 5. ;
   //else 
-  Bool_t isNeutral = IsTrackMatched(cluster);
+  Bool_t isNeutral = IsTrackMatched(cluster,cu);
   
   ph->SetChargedBit(isNeutral);
   
@@ -469,7 +474,7 @@ void AliCaloPID::SetPIDBits(const TString calo, const AliVCluster * cluster, Ali
 }
 
 //__________________________________________________________________________
-Bool_t AliCaloPID::IsTrackMatched(const AliVCluster* cluster) const {
+Bool_t AliCaloPID::IsTrackMatched(const AliVCluster* cluster, const AliCalorimeterUtils * cu) const {
   //Check if there is any track attached to this cluster
   
   Int_t nMatches = cluster->GetNTracksMatched();
@@ -478,8 +483,17 @@ Bool_t AliCaloPID::IsTrackMatched(const AliVCluster* cluster) const {
   //  if     (cluster->GetTrackMatched(0))        printf("\t matched track id %d\n",((AliVTrack*)cluster->GetTrackMatched(0))->GetID()) ;
   //  else if(cluster->GetTrackMatchedIndex()>=0) printf("\t matched track id %d\n",((AliVTrack*) GetReader()->GetInputEvent()->GetTrack(cluster->GetTrackMatchedIndex()))->GetID()) ;
   
+  
   if(!strcmp("AliESDCaloCluster",Form("%s",cluster->ClassName())))
   {
+    //If EMCAL track matching needs to be recalculated
+    if(cluster->IsEMCAL() && cu && cu->IsRecalculationOfClusterTrackMatchingOn()){
+      Float_t dR = 999., dZ = 999.;
+      cu->GetEMCALRecoUtils()->GetMatchedResiduals(cluster->GetID(),dR,dZ);
+      if(dR < 999) return kTRUE;
+      else         return kFALSE;
+    }
+    
     if (nMatches > 0) {
       if (nMatches == 1 ) {
         Int_t iESDtrack = cluster->GetTrackMatchedIndex();
@@ -495,9 +509,15 @@ Bool_t AliCaloPID::IsTrackMatched(const AliVCluster* cluster) const {
   else
   {
     //AODs
-    if(nMatches > 0) return kTRUE; //There is at least one match.
-    else             return kFALSE;
-    
+    if(cu && cu->IsRecalculationOfClusterTrackMatchingOn()){
+      Float_t dR = TMath::Abs(cluster->GetEmcCpvDistance()) ; //FIXME
+      if(dR > cu->GetCutR()) return kFALSE;
+      else                   return kTRUE;
+    }
+    else {
+      if(nMatches > 0) return kTRUE; //There is at least one match.
+      else             return kFALSE;
+    }
   }//AODs or MC (copy into AOD)
   
   return kFALSE;
index f270cef9b5ea5d719831a0add046fcbdec4c579e..22c597bae67a31fc9d024e5df12ad6e8b4497070 100755 (executable)
@@ -38,6 +38,7 @@ class TTask;
 class AliVCluster;
 class AliAODPWG4Particle;
 class AliEMCALPIDUtils;
+class AliCalorimeterUtils;
 
 class AliCaloPID : public TObject {
        
@@ -76,7 +77,7 @@ public:
   
   TString      GetPIDParametersList();
   
-  void SetPIDBits(const TString calo,  const AliVCluster * cluster, AliAODPWG4Particle *aodph);
+  void SetPIDBits(const TString calo,  const AliVCluster * cluster, AliAODPWG4Particle *aodph, const AliCalorimeterUtils* cu);
   
   void Print(const Option_t * opt)const;
   
@@ -114,7 +115,7 @@ public:
   
   //PID bits setters and getters
   
-  Bool_t IsTrackMatched(const AliVCluster * cluster) const ;  
+  Bool_t IsTrackMatched(const AliVCluster * cluster, const AliCalorimeterUtils* cu) const ;  
   
   void SetDispersionCut(Float_t dcut ) {fDispCut = dcut; }
   Float_t GetDispersionCut() const {return fDispCut ;}   
@@ -131,7 +132,7 @@ public:
   void SetLowParticleFlux()  {fParticleFlux = kLow;}
   void SetHighParticleFlux() {fParticleFlux = kHigh;}
 
- private:
+private:
   
   Float_t      fEMCALPhotonWeight; //Bayesian PID weight for photons in EMCAL 
   Float_t      fEMCALPi0Weight;  //Bayesian PID weight for pi0 in EMCAL 
@@ -153,10 +154,9 @@ public:
   
   Int_t         fDebug; //Debug level
        
-  Bool_t fRecalculateBayesian; // Recalculate PID bayesian or use simple PID?
-  Int_t  fParticleFlux;        // Particle flux for setting PID parameters
-  AliEMCALPIDUtils * fEMCALPIDUtils; //Pointer to EMCALPID to redo the PID Bayesian calculation
-       
+  Bool_t fRecalculateBayesian;        // Recalculate PID bayesian or use simple PID?
+  Int_t  fParticleFlux;               // Particle flux for setting PID parameters
+  AliEMCALPIDUtils * fEMCALPIDUtils;  // Pointer to EMCALPID to redo the PID Bayesian calculation
        
   ClassDef(AliCaloPID,4)
 } ;
index a331d006e13a43ebf99ba07334a47dfe03ee9d9f..aee77b775b260781c7139fd287690553a8483c71 100755 (executable)
@@ -706,6 +706,10 @@ void AliCaloTrackReader::FillInputEMCAL() {
       }//EMCAL cluster
     }// cluster exists
   }// cluster loop
+  
+  //Recalculate track matching
+  GetCaloUtils()->RecalculateClusterTrackMatching(fInputEvent);
+  
   //fAODEMCALNormalInputEntries = fAODEMCAL->GetEntriesFast();
   if(fDebug > 1) printf("AliCaloTrackReader::FillInputEMCAL() - aod entries %d\n",  fAODEMCAL->GetEntriesFast());//fAODEMCALNormalInputEntries);
   
index 21bea800cc286e2164993ed206fd40b7ca537451..886dd8de47bf4507363f9e6ee10d78b0aaa42c7f 100755 (executable)
@@ -49,7 +49,8 @@ ClassImp(AliCalorimeterUtils)
     fNCellsFromPHOSBorder(0), fRecalibration(kFALSE),
     fPHOSRecalibrationFactors(),
     fEMCALRecoUtils(new AliEMCALRecoUtils),
-    fRecalculatePosition(kFALSE),fCorrectELinearity(kFALSE)
+    fRecalculatePosition(kFALSE),fCorrectELinearity(kFALSE),
+    fRecalculateMatching(kFALSE),fCutR(20), fCutZ(20)
 {
   //Ctor
   
@@ -510,6 +511,7 @@ void AliCalorimeterUtils::Print(const Option_t * opt) const
   printf("Recalibrate Clusters? %d\n",fRecalibration);
   printf("Recalculate Clusters Position? %d\n",fRecalculatePosition);
   printf("Recalculate Clusters Energy? %d\n",fCorrectELinearity);
+  printf("Matching criteria: dR < %2.2f[cm], dZ < %2.2f[cm]\n",fCutR,fCutZ);
 
   printf("    \n") ;
 } 
index e5828cce5fd34866263edce4dcee48db9f022122..d2a1e1fec624e309c9b22c38af419e78a60c0a25 100755 (executable)
@@ -137,6 +137,7 @@ class AliCalorimeterUtils : public TObject {
 
   Float_t RecalibrateClusterEnergy(AliVCluster* cluster, AliVCaloCells * cells);
 
+  //EMCAL specific utils for the moment
   void SetEMCALRecoUtils(AliEMCALRecoUtils * ru) {fEMCALRecoUtils = ru;}
   AliEMCALRecoUtils* GetEMCALRecoUtils() const {return fEMCALRecoUtils;}
   
@@ -154,6 +155,19 @@ class AliCalorimeterUtils : public TObject {
   }
   void RecalculateClusterPID(AliVCluster* clu) {fEMCALRecoUtils->RecalculateClusterPID(clu);}
 
+  //Track matching recalculation
+  void RecalculateClusterTrackMatching(AliVEvent * event)         {if (fRecalculateMatching) fEMCALRecoUtils->FindMatches(event);}
+  void GetMatchedResiduals(Int_t index, Float_t &dR, Float_t &dZ) {if (fRecalculateMatching) fEMCALRecoUtils->GetMatchedResiduals(index,dR,dZ);}
+  //This could be used for PHOS ...
+  void SwitchOnRecalculateClusterTrackMatching()      { fRecalculateMatching = kTRUE; } 
+  void SwitchOffRecalculateClusterTrackMatching()     { fRecalculateMatching = kFALSE; } 
+  Bool_t IsRecalculationOfClusterTrackMatchingOn()  const { return fRecalculateMatching ; }
+  Float_t GetCutR() const { return fCutR; }
+  Float_t GetCutZ() const { return fCutZ; }
+  
+  void SetCutR(Float_t cutR) { fCutR=cutR; fEMCALRecoUtils->SetCutR(cutR); }
+  void SetCutZ(Float_t cutZ) { fCutZ=cutZ; fEMCALRecoUtils->SetCutZ(cutZ);}
+  
  private:
 
   Int_t              fDebug;                 //  Debugging level
@@ -171,8 +185,11 @@ class AliCalorimeterUtils : public TObject {
   AliEMCALRecoUtils* fEMCALRecoUtils;        //  EMCAL utils for cluster rereconstruction
   Bool_t             fRecalculatePosition;   // Recalculate cluster position
   Bool_t             fCorrectELinearity  ;   // Correct cluster energy linearity
-  
-  ClassDef(AliCalorimeterUtils,3)
+  Bool_t             fRecalculateMatching;   // Recalculate cluster position
+  Float_t            fCutR;                  // dR cut on matching
+  Float_t            fCutZ;                  // dZ cut on matching
+
+  ClassDef(AliCalorimeterUtils,4)
 } ;
 
 
index 771e18322dba6caf65e8ef6fa111dd049184a628..2f6049e6e66c7011151d6d1aa75df79def203964 100755 (executable)
@@ -495,7 +495,7 @@ void  AliAnaPhoton::MakeAnalysisFillAOD()
     else{
       //Set PID bits for later selection (AliAnaPi0 for example)
       //GetPDG already called in SetPIDBits.
-      GetCaloPID()->SetPIDBits(fCalorimeter,calo,&aodph);
+      GetCaloPID()->SetPIDBits(fCalorimeter,calo,&aodph, GetCaloUtils());
       if(GetDebug() > 1) printf("AliAnaPhoton::MakeAnalysisFillAOD() - PID Bits set \n");              
     }
     
index 900fa5fc177c40d8ce28da4a0abcc6afe8f06e94..11dd298cc88a07a72090a7e78b9f5edf0c88ede9 100755 (executable)
@@ -612,7 +612,7 @@ void  AliAnaPi0EbE::MakeShowerShapeIdentification()
     else{
       //Set PID bits for later selection (AliAnaPi0 for example)
       //GetPDG already called in SetPIDBits.
-      GetCaloPID()->SetPIDBits(fCalorimeter,calo,&aodpi0);
+      GetCaloPID()->SetPIDBits(fCalorimeter,calo,&aodpi0, GetCaloUtils());
       if(GetDebug() > 1) printf("AliAnaPi0EbE::MakeShowerShapeIdentification() - PID Bits set \n");            
     }
     
index dc90d23f147bab97b419ec780485c61e91bc3f69..08f5e183f41a38992f04bd254a6caff2f97fd6d5 100644 (file)
@@ -728,7 +728,7 @@ void  AliAnaShowerParameter::MakeAnalysisFillAOD()
     
     //Set PID bits for later selection (AliAnaPi0 for example)
     //GetPDG already called in SetPIDBits.
-    GetCaloPID()->SetPIDBits(fCalorimeter,calo,&aodph);
+    GetCaloPID()->SetPIDBits(fCalorimeter,calo,&aodph, GetCaloUtils());
     if(GetDebug() > 1) printf("AliAnaShowerParameter::MakeAnalysisFillAOD() - PID Bits set \n");                   
     
     //Play with the MC stack if available