]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Add possibility to recalculate EMCAL distance to bad channels
authorgconesab <gconesab@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 12 Nov 2010 21:59:37 +0000 (21:59 +0000)
committergconesab <gconesab@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 12 Nov 2010 21:59:37 +0000 (21:59 +0000)
Add possibility to pass the geometry matrix through configuration

PWG4/CaloCalib/AliAnalysisTaskCaloFilter.cxx
PWG4/CaloCalib/AliAnalysisTaskCaloFilter.h
PWG4/CaloCalib/AliAnalysisTaskEMCALPi0CalibSelection.cxx
PWG4/CaloCalib/AliAnalysisTaskEMCALPi0CalibSelection.h
PWG4/PartCorrBase/AliCaloTrackReader.cxx
PWG4/PartCorrBase/AliCalorimeterUtils.cxx
PWG4/PartCorrBase/AliCalorimeterUtils.h

index c21d018f9641c7d0bbd4af6eda7e0331834f8ade..65b7994ecb97b546f6da9da99c5ec32da614c36a 100644 (file)
@@ -37,6 +37,7 @@
 #include "AliAnalysisManager.h"
 #include "AliInputEventHandler.h"
 #include "AliESDtrackCuts.h"
+#include "TGeoManager.h"
 
 ClassImp(AliAnalysisTaskCaloFilter)
   
@@ -45,12 +46,16 @@ ClassImp(AliAnalysisTaskCaloFilter)
 AliAnalysisTaskCaloFilter::AliAnalysisTaskCaloFilter():
   AliAnalysisTaskSE(), //fCuts(0x0),
   fCaloFilter(0), fCorrect(kFALSE), 
-  fEMCALGeo(0x0),fEMCALGeoName("EMCAL_FIRSTYEAR"), 
+  fEMCALGeo(0x0),fEMCALGeoName("EMCAL_FIRSTYEARV1"), 
   fEMCALRecoUtils(new AliEMCALRecoUtils),
-  fESDtrackCuts(0), fTrackMultEtaCut(0.9)
+  fESDtrackCuts(0), fTrackMultEtaCut(0.8),
+  fLoadEMCALMatrices(kFALSE), //fLoadPHOSMatrices(kFALSE),
+  fGeoMatrixSet(kFALSE)
 {
   // Default constructor
   fESDtrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010();
+  for(Int_t i = 0; i < 10; i++) fEMCALMatrix[i] = 0 ;
+  //for(Int_t i = 0; i < 5 ; i++) fPHOSMatrix[i]  = 0 ;
 
 }
 
@@ -58,12 +63,16 @@ AliAnalysisTaskCaloFilter::AliAnalysisTaskCaloFilter():
 AliAnalysisTaskCaloFilter::AliAnalysisTaskCaloFilter(const char* name):
   AliAnalysisTaskSE(name), //fCuts(0x0),
   fCaloFilter(0), fCorrect(kFALSE),
-  fEMCALGeo(0x0),fEMCALGeoName("EMCAL_FIRSTYEAR"), 
+  fEMCALGeo(0x0),fEMCALGeoName("EMCAL_FIRSTYEARV1"), 
   fEMCALRecoUtils(new AliEMCALRecoUtils),
-  fESDtrackCuts(0), fTrackMultEtaCut(0.9)
+  fESDtrackCuts(0), fTrackMultEtaCut(0.8),
+  fLoadEMCALMatrices(kFALSE), //fLoadPHOSMatrices(kFALSE),
+  fGeoMatrixSet(kFALSE)
 {
   // Constructor
   fESDtrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010();
+  for(Int_t i = 0; i < 10; i++) fEMCALMatrix[i] = 0 ;
+  //for(Int_t i = 0; i < 5 ; i++) fPHOSMatrix[i]  = 0 ;
 
 }
 
@@ -75,6 +84,7 @@ AliAnalysisTaskCaloFilter::~AliAnalysisTaskCaloFilter()
   if(fEMCALGeo)       delete fEMCALGeo;        
   if(fEMCALRecoUtils) delete fEMCALRecoUtils;
   if(fESDtrackCuts)   delete fESDtrackCuts;
+
 }
 
 //__________________________________________________
@@ -118,7 +128,7 @@ void AliAnalysisTaskCaloFilter::UserExec(Option_t */*option*/)
     for (Int_t itrack =  0; itrack <  nTracks; itrack++) {////////////// track loop
       AliVTrack * track = (AliVTrack*)InputEvent()->GetTrack(itrack) ; // retrieve track from esd
       if(!fESDtrackCuts->AcceptTrack((AliESDtrack*)track)) continue;
-      //Count the tracks in eta < 0.9
+      //Count the tracks in eta < 0.8
       if(TMath::Abs(track->Eta())< fTrackMultEtaCut) trackMult++;
     }    
   }
@@ -200,6 +210,44 @@ void AliAnalysisTaskCaloFilter::UserExec(Option_t */*option*/)
   //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) ) {
+    
+    if(!fGeoMatrixSet){
+      if(fLoadEMCALMatrices){
+        printf("AliAnalysisTaskCaloFilter::UserExec() - Load user defined geometry matrices\n");
+        for(Int_t mod=0; mod < (fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){
+          if(fEMCALMatrix[mod]){
+            if(DebugLevel() > 1) 
+              fEMCALMatrix[mod]->Print();
+            fEMCALGeo->SetMisalMatrix(fEMCALMatrix[mod],mod) ;  
+          }
+          fGeoMatrixSet=kTRUE;
+        }//SM loop
+      }//Load matrices
+      else if(!gGeoManager){
+        printf("AliAnalysisTaskCaloFilter::UserExec() - Get geo matrices from data\n");
+        //Still not implemented in AOD, just a workaround to be able to work at least with ESDs        
+        if(!strcmp(event->GetName(),"AliAODEvent")) {
+          if(DebugLevel() > 1) 
+            printf("AliAnalysisTaskCaloFilter Use ideal geometry, values geometry matrix not kept in AODs.\n");
+        }//AOD
+        else { 
+          if(DebugLevel() > 1) printf("AliAnalysisTaskCaloFilter Load Misaligned matrices. \n");
+          AliESDEvent* esd = dynamic_cast<AliESDEvent*>(event) ;
+          if(!esd) {
+            printf("AliAnalysisTaskCaloFilter::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) ;
+          } 
+          fGeoMatrixSet=kTRUE;
+        }//ESD
+      }//Load matrices from Data 
+    }//first event
+    
+    
     //Cluster Loop
     for (Int_t iClust=0; iClust<nCaloClus; ++iClust) {
       
@@ -216,25 +264,29 @@ void AliAnalysisTaskCaloFilter::UserExec(Option_t */*option*/)
       //      }
       if(DebugLevel() > 2)
       { 
-        printf("Filter, before  : i %d, E %f, dispersion %f, m02 %f, m20 %f\n",iClust,cluster->E(),
-               cluster->GetDispersion(),cluster->GetM02(),cluster->GetM20());
+        printf("Filter, before  : i %d, E %f, dispersion %f, m02 %f, m20 %f, distToBad %f\n",iClust,cluster->E(),
+               cluster->GetDispersion(),cluster->GetM02(),cluster->GetM20(), cluster->GetDistanceToBadChannel());
         cluster->GetPosition(position);
         printf("Filter, before  : i %d, x %f, y %f, z %f\n",cluster->GetID(), position[0], position[1], position[2]);
       }
       
+      //Recalculate distance to bad channels, if new list of bad channels provided
+      fEMCALRecoUtils->RecalculateClusterDistanceToBadChannel(fEMCALGeo, event->GetEMCALCells(), cluster);
+
       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(),
-               cluster->GetDispersion(),cluster->GetM02(),cluster->GetM20());
+        printf("Filter, after   : i %d, E %f, dispersion %f, m02 %f, m20 %f, distToBad %f\n",cluster->GetID(),cluster->E(),
+               cluster->GetDispersion(),cluster->GetM02(),cluster->GetM20(), cluster->GetDistanceToBadChannel());
         cluster->GetPosition(position);
         printf("Filter, after   : i %d, x %f, y %f, z %f\n",cluster->GetID(), position[0], position[1], position[2]);
       }    
@@ -394,6 +446,8 @@ void AliAnalysisTaskCaloFilter::PrintInfo(){
   printf("TASK: AnalysisCaloFilter \n");
   printf("\t Not only filter, correct Clusters? %d\n",fCorrect);
   printf("\t Calorimeter Filtering Option     ? %d\n",fCaloFilter);
+  //printf("\t Use handmade geo matrices?   EMCAL %d, PHOS %d\n",fLoadEMCALMatrices, fLoadPHOSMatrices);
+  printf("\t Use handmade geo matrices?   EMCAL %d, PHOS 0\n",fLoadEMCALMatrices);
 
 }
 
index ec8ce73f742eedeef427ef6dcc17389fbc1cd41b..a5cacb2333b58d43265f04105f0bdd0cd9ca5b1d 100644 (file)
@@ -45,8 +45,16 @@ public:
   void SetCaloFilter(Int_t calo) {fCaloFilter = calo;}
   TString GetCaloFilter() const  {return fCaloFilter;}
 
-  void SetGeometryName(TString name) { fEMCALGeoName = name ; }
-  TString GeometryName() const       { return fEMCALGeoName ; }
+  void SetEMCALGeometryName(TString name) { fEMCALGeoName = name ; }
+  TString EMCALGeometryName() const       { return fEMCALGeoName ; }
+  
+  void SwitchOnLoadOwnEMCALGeometryMatrices()              { fLoadEMCALMatrices = kTRUE  ; }
+  void SwitchOffLoadOwnEMCALGeometryMatrices()             { fLoadEMCALMatrices = kFALSE ; }
+  void SetEMCALGeometryMatrixInSM(TGeoHMatrix* m, Int_t i) { fEMCALMatrix[i]    = m      ; }
+  
+  //void SwitchOnLoadOwnPHOSGeometryMatrices()               { fLoadPHOSMatrices = kTRUE  ; }
+  //void SwitchOffLoadOwnPHOSGeometryMatrices()              { fLoadPHOSMatrices = kFALSE ; }
+  //void SetPHOSGeometryMatrixInSM(TGeoHMatrix* m, Int_t i)  { fPHOSMatrix[i]    = m      ; }
   
   void SetEMCALRecoUtils(AliEMCALRecoUtils * ru) {fEMCALRecoUtils = ru;}
   AliEMCALRecoUtils* GetEMCALRecoUtils() const   {return fEMCALRecoUtils;}
@@ -59,7 +67,6 @@ public:
   Float_t GetTrackMultiplicityEtaCut()     const  { return fTrackMultEtaCut ; }
   void    SetTrackMultiplicityEtaCut(Float_t eta) { fTrackMultEtaCut = eta  ; }                
   
-  
   void PrintInfo();
   
 private:
@@ -75,8 +82,13 @@ private:
   AliESDtrackCuts *fESDtrackCuts       ; // Track cut  
   Float_t          fTrackMultEtaCut    ; // Track multiplicity eta cut
   
+  Bool_t        fLoadEMCALMatrices; // Matrices set from configuration, not get from geometry.root or from ESDs/AODs
+  TGeoHMatrix * fEMCALMatrix[10];   // Geometry matrices with alignments
+  //Bool_t        fLoadPHOSMatrices;  // Matrices set from configuration, not get from geometry.root or from ESDs/AODs
+  //TGeoHMatrix * fPHOSMatrix[5];     // Geometry matrices with alignments
+  Bool_t        fGeoMatrixSet;      // Set geometry matrices only once, for the first event.         
   
-  ClassDef(AliAnalysisTaskCaloFilter, 3); // Analysis task for standard ESD filtering
+  ClassDef(AliAnalysisTaskCaloFilter, 4); // Analysis task for standard ESD filtering
 };
 
 #endif
index 5a4a50dc466f96a56d510ea9a888d1525c246cd7..1cc7a009eb69d9713565cc11828eb0d980eaec76 100644 (file)
@@ -50,14 +50,14 @@ AliAnalysisTaskEMCALPi0CalibSelection::AliAnalysisTaskEMCALPi0CalibSelection(con
   AliAnalysisTaskSE(name),fEMCALGeo(0x0),//fCalibData(0x0), 
   fEmin(0.5), fEmax(15.), fAsyCut(1.),fMinNCells(2), fGroupNCells(0),
   fLogWeight(4.5), fSameSM(kFALSE), fOldAOD(kFALSE), fFilteredInput(kFALSE),
-  fCorrectClusters(kFALSE), fEMCALGeoName("EMCAL_FIRSTYEAR"), 
+  fCorrectClusters(kFALSE), fEMCALGeoName("EMCAL_FIRSTYEARV1"), 
   fRecoUtils(new AliEMCALRecoUtils),
   fNbins(300), fMinBin(0.), fMaxBin(300.),fOutputContainer(0x0),
   fHmgg(0x0),           fHmggDifferentSM(0x0), 
   fHOpeningAngle(0x0),  fHOpeningAngleDifferentSM(0x0),  
   fHIncidentAngle(0x0), fHIncidentAngleDifferentSM(0x0),
   fHAsymmetry(0x0),  fHAsymmetryDifferentSM(0x0),  
-  fhNEvents(0x0),fCuts(0x0)
+  fhNEvents(0x0),fCuts(0x0),fLoadMatrices(0)
 {
   //Named constructor which should be used.
   
@@ -81,6 +81,7 @@ AliAnalysisTaskEMCALPi0CalibSelection::AliAnalysisTaskEMCALPi0CalibSelection(con
     fhTowerDecayPhotonHit[iSM] =0;
     fhTowerDecayPhotonEnergy[iSM]=0;
     fhTowerDecayPhotonAsymmetry[iSM]=0;
+    fMatrix[iSM] = 0x0;
   }
   
   DefineOutput(1, TList::Class());
@@ -99,9 +100,8 @@ AliAnalysisTaskEMCALPi0CalibSelection::~AliAnalysisTaskEMCALPi0CalibSelection()
   }
        
   //if(fCalibData)  delete fCalibData;
-  if(fEMCALGeo)   delete fEMCALGeo;
-       
-  if(fRecoUtils) delete fRecoUtils ;
+  if(fEMCALGeo)   delete fEMCALGeo  ;
+  if(fRecoUtils)  delete fRecoUtils ;
 
 }
 
@@ -126,7 +126,7 @@ void AliAnalysisTaskEMCALPi0CalibSelection::LocalInit()
        snprintf(onePar,buffersize, "Switchs: Remove Bad Channels? %d; Use filtered input? %d;  Correct Clusters? %d, Analyze Old AODs? %d, Mass per channel same SM clusters? %d ",
             fRecoUtils->IsBadChannelsRemovalSwitchedOn(),fFilteredInput,fCorrectClusters, fOldAOD, fSameSM) ;
        fCuts->Add(new TObjString(onePar));
-       snprintf(onePar,buffersize, "EMCAL Geometry name: < %s >",fEMCALGeoName.Data()) ;
+       snprintf(onePar,buffersize, "EMCAL Geometry name: < %s >, Load Matrices? %d",fEMCALGeoName.Data(),fLoadMatrices) ;
        fCuts->Add(new TObjString(onePar));
 
        // Post Data
@@ -371,25 +371,38 @@ void AliAnalysisTaskEMCALPi0CalibSelection::UserExec(Option_t* /* option */)
   //if(DebugLevel() > 1) printf("Run number: %d\n",runNum);
   
   //Get the matrix with geometry information
-  //Still not implemented in AOD, just a workaround to be able to work at least with ESDs      
-  if(!gGeoManager && fhNEvents->GetEntries()==1){
-    printf("AliAnalysisTaskEMCALPi0CalibSelection::UserExec() - Get geo matrices from data\n");
-    if(!strcmp(event->GetName(),"AliAODEvent")) {
+  if(fhNEvents->GetEntries()==1){
+    if(fLoadMatrices){
+      printf("AliAnalysisTaskEMCALPi0CalibSelection::UserExec() - Load user defined geometry matrices\n");
+      for(Int_t mod=0; mod < (fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){
+        if(fMatrix[mod]){
+          if(DebugLevel() > 1) 
+            fMatrix[mod]->Print();
+          fEMCALGeo->SetMisalMatrix(fMatrix[mod],mod) ;   
+        }
+      }//SM loop
+    }//Load matrices
+    else if(!gGeoManager){
+      printf("AliAnalysisTaskEMCALPi0CalibSelection::UserExec() - Get geo matrices from data\n");
+      //Still not implemented in AOD, just a workaround to be able to work at least with ESDs  
+      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");
+      }//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;
+          return;
         }
         for(Int_t mod=0; mod < (fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){
-          if(DebugLevel() > 1) esd->GetEMCALMatrix(mod)->Print();
+          //if(DebugLevel() > 1) 
+            esd->GetEMCALMatrix(mod)->Print();
           if(esd->GetEMCALMatrix(mod)) fEMCALGeo->SetMisalMatrix(esd->GetEMCALMatrix(mod),mod) ;
         } 
-    }//ESD
+      }//ESD
+    }//Load matrices from Data 
   }//first event
   
   if(DebugLevel() > 1) printf("AliAnalysisTaskEMCALPi0CalibSelection Will use fLogWeight %.3f .\n",fLogWeight);
@@ -401,7 +414,8 @@ void AliAnalysisTaskEMCALPi0CalibSelection::UserExec(Option_t* /* option */)
   Int_t iSupMod2 = -1;
   Int_t iphi2    = -1;
   Int_t ieta2    = -1;
-       
+       Bool_t shared  = kFALSE;
+  
   TLorentzVector p1;
   TLorentzVector p2;
   TLorentzVector p12;
@@ -484,7 +498,7 @@ void AliAnalysisTaskEMCALPi0CalibSelection::UserExec(Option_t* /* option */)
     //clu1.EvalEnergy();
     //clu1.EvalAll(fLogWeight, fEMCALGeoName);
     
-    fRecoUtils->GetMaxEnergyCell(fEMCALGeo, emCells,c1,absId1,iSupMod1,ieta1,iphi1);
+    fRecoUtils->GetMaxEnergyCell(fEMCALGeo, emCells,c1,absId1,iSupMod1,ieta1,iphi1,shared);
     c1->GetMomentum(p1,v);
     //newc1.GetMomentum(p1,v);
     
@@ -506,7 +520,7 @@ void AliAnalysisTaskEMCALPi0CalibSelection::UserExec(Option_t* /* option */)
       //clu2.EvalEnergy();
       //clu2.EvalAll(fLogWeight,fEMCALGeoName);
       
-      fRecoUtils->GetMaxEnergyCell(fEMCALGeo, emCells,c2,absId2,iSupMod2,ieta2,iphi2);
+      fRecoUtils->GetMaxEnergyCell(fEMCALGeo, emCells,c2,absId2,iSupMod2,ieta2,iphi2,shared);
       c2->GetMomentum(p2,v);
       //newc2.GetMomentum(p2,v);
       p12 = p1+p2;
@@ -670,7 +684,8 @@ void AliAnalysisTaskEMCALPi0CalibSelection::PrintInfo(){
        printf("Histograms: bins %d; energy range: %2.2f < E < %2.2f GeV\n",fNbins,fMinBin,fMaxBin) ;
        printf("Switchs:\n \t Remove Bad Channels? %d; Use filtered input? %d;  Correct Clusters? %d, \n \t Analyze Old AODs? %d, Mass per channel same SM clusters? %d\n",
            fRecoUtils->IsBadChannelsRemovalSwitchedOn(),fFilteredInput,fCorrectClusters, fOldAOD, fSameSM) ;
-       printf("EMCAL Geometry name: < %s >\n",fEMCALGeoName.Data()) ;
+       printf("EMCAL Geometry name: < %s >, Load Matrices %d\n",fEMCALGeoName.Data(), fLoadMatrices) ;
+  if(fLoadMatrices) {for(Int_t ism = 0; ism < 4; ism++) fMatrix[ism]->Print();}
 
   
 }
index 74e2d4d32a5a88db754d99a3e140a2b851d78ee3..31159f99f61795d13889fff5bee98acae9cd808b 100644 (file)
@@ -60,9 +60,12 @@ public:
   void SwitchOnOldAODs()   {fOldAOD = kTRUE  ; }
   void SwitchOffOldAODs()  {fOldAOD = kFALSE ; }  
   
-  void SetGeometryName(TString name) { fEMCALGeoName = name ; }
-  TString GeometryName() const       { return fEMCALGeoName ; }
-                 
+  void SetGeometryName(TString name)                  { fEMCALGeoName = name   ; }
+  TString GeometryName() const                        { return fEMCALGeoName   ; }
+  void SwitchOnLoadOwnGeometryMatrices()              { fLoadMatrices = kTRUE  ; }
+  void SwitchOffLoadOwnGeometryMatrices()             { fLoadMatrices = kFALSE ; }
+  void SetGeometryMatrixInSM(TGeoHMatrix* m, Int_t i) { fMatrix[i]    = m      ; }
+
   void SetEMCALRecoUtils(AliEMCALRecoUtils * ru) {fRecoUtils = ru;}
   AliEMCALRecoUtils* GetEMCALRecoUtils() const   {return fRecoUtils;}
   
@@ -74,6 +77,7 @@ public:
   void UseFilteredEventAsInput() {fFilteredInput = kTRUE;}
   void UseNormalEventAsInput()   {fFilteredInput = kFALSE;}
 
+  
   void PrintInfo();
   
 private:
@@ -127,10 +131,12 @@ private:
   TH2F*   fhTowerDecayPhotonEnergy[4] ;    //! Cells ordered in column/row for different module, accumulated energy in the tower by decay photons.
   TH2F*   fhTowerDecayPhotonAsymmetry[4] ; //! Cells ordered in column/row for different module, accumulated asymmetry in the tower by decay photons.
 
-  TH1I*   fhNEvents;        //! Number of events counter histogram
-  TList * fCuts ;           //! List with analysis cuts
-
-  ClassDef(AliAnalysisTaskEMCALPi0CalibSelection,10);
+  TH1I*   fhNEvents;           //! Number of events counter histogram
+  TList * fCuts ;              //! List with analysis cuts
+  Bool_t        fLoadMatrices; // Matrices set from configuration, not get from geometry.root or from ESDs/AODs
+  TGeoHMatrix * fMatrix[4];    // Geometry matrices with alignments
+  
+  ClassDef(AliAnalysisTaskEMCALPi0CalibSelection,11);
 
 };
 
index 965c66c8e22c63eca198d88af5384cf0bad82e58..9856cbc94154aea8222bda77b55b92afc4a4d223 100755 (executable)
@@ -589,6 +589,12 @@ void AliCaloTrackReader::FillInputCTS() {
     
     if(fDataType==kESD && !fESDtrackCuts->AcceptTrack((AliESDtrack*)track)) continue;
     
+    // Track filter selection
+    //if (fTrackFilter) {
+         //  selectInfo = fTrackFilter->IsSelected(esdTrack);
+         //  if (!selectInfo && !(esd->GetPrimaryVertex())->UsesTrack(esdTrack->GetID())) continue;
+   // }
+    
     //Count the tracks in eta < 0.9
     //printf("Eta %f cut  %f\n",TMath::Abs(track->Eta()),fTrackMultEtaCut);
     if(TMath::Abs(track->Eta())< fTrackMultEtaCut) fTrackMult++;
@@ -697,6 +703,9 @@ void AliCaloTrackReader::FillInputEMCAL() {
             GetCaloUtils()->RecalculateClusterPID(clus);
 
           }
+
+          //Recalculate distance to bad channels, if new list of bad channels provided
+          GetCaloUtils()->RecalculateClusterDistanceToBadChannel(GetEMCALCells(),clus);
           
           //Correct non linearity
           if(GetCaloUtils()->IsCorrectionOfClusterEnergyOn()){
index 886dd8de47bf4507363f9e6ee10d78b0aaa42c7f..59b50791e74fb3a166a4ae40a64fbf795e2cc162 100755 (executable)
@@ -42,9 +42,10 @@ ClassImp(AliCalorimeterUtils)
 //____________________________________________________________________________
   AliCalorimeterUtils::AliCalorimeterUtils() : 
     TObject(), fDebug(0), 
-    fEMCALGeoName("EMCAL_FIRSTYEAR"),fPHOSGeoName("PHOSgeo"), 
+    fEMCALGeoName("EMCAL_FIRSTYEARV1"),fPHOSGeoName("PHOSgeo"), 
     fEMCALGeo(0x0), fPHOSGeo(0x0), 
     fEMCALGeoMatrixSet(kFALSE), fPHOSGeoMatrixSet(kFALSE), 
+    fLoadEMCALMatrices(kFALSE), fLoadPHOSMatrices(kFALSE),
     fRemoveBadChannels(kFALSE),fPHOSBadChannelMap(0x0), 
     fNCellsFromPHOSBorder(0), fRecalibration(kFALSE),
     fPHOSRecalibrationFactors(),
@@ -56,6 +57,9 @@ ClassImp(AliCalorimeterUtils)
   
   //Initialize parameters
   InitParameters();
+  for(Int_t i = 0; i < 10; i++) fEMCALMatrix[i] = 0 ;
+  for(Int_t i = 0; i < 5 ; i++) fPHOSMatrix[i]  = 0 ;
+
 }
 
 //_________________________________
@@ -404,7 +408,7 @@ Int_t AliCalorimeterUtils::GetModuleNumberCellIndexes(const Int_t absId, const T
 void AliCalorimeterUtils::InitParameters()
 {
   //Initialize the parameters of the analysis.
-  fEMCALGeoName = "EMCAL_FIRSTYEAR";
+  fEMCALGeoName = "EMCAL_FIRSTYEARV1";
   fPHOSGeoName  = "PHOSgeo";
        
   if(gGeoManager) {// geoManager was set
@@ -567,43 +571,71 @@ void AliCalorimeterUtils::SetGeometryTransformationMatrices(AliVEvent* inputEven
   //Set the calorimeters transformation matrices
        
   //Get the EMCAL transformation geometry matrices from ESD 
-  if (!gGeoManager && fEMCALGeo && !fEMCALGeoMatrixSet) { 
-         if(fDebug > 1) 
-                 printf(" AliCalorimeterUtils::SetGeometryTransformationMatrices() - Load EMCAL misalignment matrices. \n");
-         if(!strcmp(inputEvent->GetName(),"AliESDEvent"))  {
-                       for(Int_t mod=0; mod < (fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){ 
-                               if(inputEvent->GetEMCALMatrix(mod)) {
-                                       //printf("EMCAL: mod %d, matrix %p\n",mod, ((AliESDEvent*)inputEvent)->GetEMCALMatrix(mod));
-                                       fEMCALGeo->SetMisalMatrix(inputEvent->GetEMCALMatrix(mod),mod) ;
-                                       fEMCALGeoMatrixSet = kTRUE;//At least one, so good
-                               }
-                       }// loop over super modules     
-               }//ESD as input
-               else {
-                       if(fDebug > 1)
-                               printf("AliCalorimeterUtils::SetGeometryTransformationMatrices() - Setting of EMCAL transformation matrixes for AODs not implemented yet. \n Import geometry.root file\n");
-                               }//AOD as input
+  if(!fEMCALGeoMatrixSet && fEMCALGeo){
+    if(fLoadEMCALMatrices){
+      printf("AliCalorimeterUtils::SetGeometryTransformationMatrices() - Load user defined geometry matrices\n");
+      for(Int_t mod=0; mod < (fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){
+        if(fEMCALMatrix[mod]){
+          if(fDebug > 1) 
+            fEMCALMatrix[mod]->Print();
+          fEMCALGeo->SetMisalMatrix(fEMCALMatrix[mod],mod) ;  
+        }
+      }//SM loop
+      fEMCALGeoMatrixSet = kTRUE;//At least one, so good
+      
+    }//Load matrices
+    else if (!gGeoManager) { 
+      if(fDebug > 1) 
+        printf(" AliCalorimeterUtils::SetGeometryTransformationMatrices() - Load EMCAL misalignment matrices. \n");
+      if(!strcmp(inputEvent->GetName(),"AliESDEvent"))  {
+        for(Int_t mod=0; mod < (fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){ 
+          if(inputEvent->GetEMCALMatrix(mod)) {
+            //printf("EMCAL: mod %d, matrix %p\n",mod, ((AliESDEvent*)inputEvent)->GetEMCALMatrix(mod));
+            fEMCALGeo->SetMisalMatrix(inputEvent->GetEMCALMatrix(mod),mod) ;
+          }
+        }// loop over super modules    
+        fEMCALGeoMatrixSet = kTRUE;//At least one, so good
+        
+      }//ESD as input
+      else {
+        if(fDebug > 1)
+          printf("AliCalorimeterUtils::SetGeometryTransformationMatrices() - Setting of EMCAL transformation matrixes for AODs not implemented yet. \n Import geometry.root file\n");
+      }//AOD as input
+    }//Get matrix from data
   }//EMCAL geo && no geoManager
        
        //Get the PHOS transformation geometry matrices from ESD 
-       if (!gGeoManager && fPHOSGeo && !fPHOSGeoMatrixSet) {
-               if(fDebug > 1) 
-                       printf(" AliCalorimeterUtils::SetGeometryTransformationMatrices() - Load PHOS misalignment matrices. \n");
+  if(!fPHOSGeoMatrixSet && fPHOSGeo){
+    if(fLoadPHOSMatrices){
+      printf("AliCalorimeterUtils::SetGeometryTransformationMatrices() - Load user defined geometry matrices\n");
+      for(Int_t mod=0; mod < 5; mod++){
+        if(fPHOSMatrix[mod]){
+          if(fDebug > 1) 
+            fPHOSMatrix[mod]->Print();
+          fPHOSGeo->SetMisalMatrix(fPHOSMatrix[mod],mod) ;  
+        }
+      }//SM loop
+      fPHOSGeoMatrixSet = kTRUE;//At least one, so good
+    }//Load matrices
+    else if (!gGeoManager) { 
+      if(fDebug > 1) 
+        printf(" AliCalorimeterUtils::SetGeometryTransformationMatrices() - Load PHOS misalignment matrices. \n");
                        if(!strcmp(inputEvent->GetName(),"AliESDEvent"))  {
                                for(Int_t mod=0; mod < 5; mod++){ 
                                        if(inputEvent->GetPHOSMatrix(mod)) {
                                                //printf("PHOS: mod %d, matrix %p\n",mod, ((AliESDEvent*)inputEvent)->GetPHOSMatrix(mod));
                                                fPHOSGeo->SetMisalMatrix(inputEvent->GetPHOSMatrix(mod),mod) ;
-                                               fPHOSGeoMatrixSet  = kTRUE; //At least one so good
                                        }
-                               }// loop over modules   
+                               }// loop over modules
+        fPHOSGeoMatrixSet  = kTRUE; //At least one so good
                        }//ESD as input
                        else {
                                if(fDebug > 1) 
                                        printf("AliCalorimeterUtils::SetGeometryTransformationMatrices() - Setting of EMCAL transformation matrixes for AODs not implemented yet. \n Import geometry.root file\n");
-                                       }//AOD as input
+      }//AOD as input
+    }// get matrix from data
        }//PHOS geo     and  geoManager was not set
-
+  
 }
 
 //________________________________________________________________
index d2a1e1fec624e309c9b22c38af419e78a60c0a25..5334544742409e00b0d4cd947e0a699695da75d9 100755 (executable)
@@ -62,6 +62,14 @@ class AliCalorimeterUtils : public TObject {
 
   void SetGeometryTransformationMatrices(AliVEvent* inputEvent) ;
        
+  void SwitchOnLoadOwnEMCALGeometryMatrices()              { fLoadEMCALMatrices = kTRUE  ; }
+  void SwitchOffLoadOwnEMCALGeometryMatrices()             { fLoadEMCALMatrices = kFALSE ; }
+  void SetEMCALGeometryMatrixInSM(TGeoHMatrix* m, Int_t i) { fEMCALMatrix[i]    = m      ; }
+  
+  void SwitchOnLoadOwnPHOSGeometryMatrices()               { fLoadPHOSMatrices = kTRUE  ; }
+  void SwitchOffLoadOwnPHOSGeometryMatrices()              { fLoadPHOSMatrices = kFALSE ; }
+  void SetPHOSGeometryMatrixInSM(TGeoHMatrix* m, Int_t i)  { fPHOSMatrix[i]    = m      ; }
+  
   // Bad channels
   Bool_t IsBadChannelsRemovalSwitchedOn()  const { return fRemoveBadChannels ; }
   void SwitchOnBadChannelsRemoval ()  {fRemoveBadChannels = kTRUE  ; fEMCALRecoUtils->SwitchOnBadChannelsRemoval(); InitPHOSBadChannelStatusMap();}
@@ -153,6 +161,11 @@ class AliCalorimeterUtils : public TObject {
   void RecalculateClusterShowerShapeParameters(AliVCaloCells* cells, AliVCluster* clu){
     fEMCALRecoUtils->RecalculateClusterShowerShapeParameters((AliEMCALGeometry*)fEMCALGeo, cells, clu);
   }
+  
+  void RecalculateClusterDistanceToBadChannel(AliVCaloCells* cells, AliVCluster* clu){
+    fEMCALRecoUtils->RecalculateClusterDistanceToBadChannel((AliEMCALGeometry*)fEMCALGeo, cells, clu);
+  }
+  
   void RecalculateClusterPID(AliVCluster* clu) {fEMCALRecoUtils->RecalculateClusterPID(clu);}
 
   //Track matching recalculation
@@ -177,19 +190,24 @@ class AliCalorimeterUtils : public TObject {
   AliPHOSGeoUtils  * fPHOSGeo  ;             //! PHOS  geometry pointer  
   Bool_t             fEMCALGeoMatrixSet;     //  Check if the transformation matrix is set for EMCAL
   Bool_t             fPHOSGeoMatrixSet ;     //  Check if the transformation matrix is set for PHOS
+  Bool_t             fLoadEMCALMatrices;     //  Matrices set from configuration, not get from geometry.root or from ESDs/AODs
+  TGeoHMatrix *      fEMCALMatrix[10];       //  Geometry matrices with alignments
+  Bool_t             fLoadPHOSMatrices;      //  Matrices set from configuration, not get from geometry.root or from ESDs/AODs
+  TGeoHMatrix *      fPHOSMatrix[5];         //  Geometry matrices with alignments
   Bool_t             fRemoveBadChannels;     //  Check the channel status provided and remove clusters with bad channels
   TObjArray        * fPHOSBadChannelMap;     //  Array of histograms with map of bad channels, PHOS
   Int_t              fNCellsFromPHOSBorder;  //  Number of cells from PHOS  border the cell with maximum amplitude has to be.
   Bool_t             fRecalibration;         //  Switch on or off the recalibration
   TObjArray        * fPHOSRecalibrationFactors;  // Array of histograms with map of recalibration factors, PHOS
   AliEMCALRecoUtils* fEMCALRecoUtils;        //  EMCAL utils for cluster rereconstruction
-  Bool_t             fRecalculatePosition;   // Recalculate cluster position
-  Bool_t             fCorrectELinearity  ;   // Correct cluster energy linearity
-  Bool_t             fRecalculateMatching;   // Recalculate cluster position
-  Float_t            fCutR;                  // dR cut on matching
-  Float_t            fCutZ;                  // dZ cut on matching
+  Bool_t             fRecalculatePosition;   //  Recalculate cluster position
+  Bool_t             fCorrectELinearity  ;   //  Correct cluster energy linearity
+  Bool_t             fRecalculateMatching;   //  Recalculate cluster position
+  Float_t            fCutR;                  //  dR cut on matching
+  Float_t            fCutZ;                  //  dZ cut on matching
 
-  ClassDef(AliCalorimeterUtils,4)
+  
+  ClassDef(AliCalorimeterUtils,5)
 } ;