improve the fitting procedure of the cluster-track residuals. Add new plots to study...
authormartinez <martinez@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 14 Jul 2011 17:23:08 +0000 (17:23 +0000)
committermartinez <martinez@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 14 Jul 2011 17:23:08 +0000 (17:23 +0000)
PWG3/muondep/AddTaskMuonResolution.C
PWG3/muondep/AliAnalysisTaskMuonResolution.cxx
PWG3/muondep/AliAnalysisTaskMuonResolution.h
PWG3/muondep/MuonResolution.C

index 69f0dc9..5582f54 100644 (file)
@@ -28,6 +28,7 @@ AliAnalysisTaskMuonResolution *AddTaskMuonResolution(Bool_t selectPhysics = kFAL
   }
   task->SelectPhysics(selectPhysics);
   task->SelectTrigger(selectTrigger);
+//  task->SelectTrigger(selectTrigger, AliVEvent::kMB);
   task->MatchTrigger(matchTrig);
   task->ApplyAccCut(applyAccCut);
   task->SetMinMomentum(minMomentum);
@@ -51,14 +52,16 @@ AliAnalysisTaskMuonResolution *AddTaskMuonResolution(Bool_t selectPhysics = kFAL
   // Create and connect output containers
   AliAnalysisDataContainer *cout_histo1 = mgr->CreateContainer("Residuals", TObjArray::Class(), AliAnalysisManager::kOutputContainer, outputfile);
   AliAnalysisDataContainer *cout_histo2 = mgr->CreateContainer("ResidualsVsP", TObjArray::Class(), AliAnalysisManager::kOutputContainer, outputfile);
-  AliAnalysisDataContainer *cout_histo3 = mgr->CreateContainer("LocalChi2", TObjArray::Class(), AliAnalysisManager::kParamContainer, outputfile);
-  AliAnalysisDataContainer *cout_histo4 = mgr->CreateContainer("ChamberRes", TObjArray::Class(), AliAnalysisManager::kParamContainer, outputfile);
-  AliAnalysisDataContainer *cout_histo5 = mgr->CreateContainer("TrackRes", TObjArray::Class(), AliAnalysisManager::kOutputContainer, outputfile);
+  AliAnalysisDataContainer *cout_histo3 = mgr->CreateContainer("ResidualsVsCent", TObjArray::Class(), AliAnalysisManager::kOutputContainer, outputfile);
+  AliAnalysisDataContainer *cout_histo4 = mgr->CreateContainer("LocalChi2", TObjArray::Class(), AliAnalysisManager::kParamContainer, outputfile);
+  AliAnalysisDataContainer *cout_histo5 = mgr->CreateContainer("ChamberRes", TObjArray::Class(), AliAnalysisManager::kParamContainer, outputfile);
+  AliAnalysisDataContainer *cout_histo6 = mgr->CreateContainer("TrackRes", TObjArray::Class(), AliAnalysisManager::kOutputContainer, outputfile);
   mgr->ConnectOutput(task, 1, cout_histo1);
   mgr->ConnectOutput(task, 2, cout_histo2);
   mgr->ConnectOutput(task, 3, cout_histo3);
   mgr->ConnectOutput(task, 4, cout_histo4);
   mgr->ConnectOutput(task, 5, cout_histo5);
+  mgr->ConnectOutput(task, 6, cout_histo6);
   
   return task;
 }   
index bce332a..d06d09a 100644 (file)
@@ -43,6 +43,7 @@
 #include "AliAnalysisManager.h"
 #include "AliInputEventHandler.h"
 #include "AliAnalysisTaskMuonResolution.h"
+#include "AliCentrality.h"
 
 // MUON includes
 #include "AliMUONCDB.h"
 #include "AliMUONTrackParam.h"
 #include "AliMUONTrackExtrap.h"
 #include "AliMUONVCluster.h"
+#include "AliMUONVDigit.h"
 #include "AliMUONGeometryTransformer.h"
 #include "AliMUONGeometryModuleTransformer.h"
 #include "AliMUONGeometryDetElement.h"
 #include "AliMpDEIterator.h"
+#include "AliMpSegmentation.h"
+#include "AliMpVSegmentation.h"
+#include "AliMpConstants.h"
+#include "AliMpDDLStore.h"
+#include "AliMpPad.h"
+#include "AliMpDetElement.h"
+#include "AliMpCathodType.h"
 
 #ifndef SafeDelete
 #define SafeDelete(x) if (x != NULL) { delete x; x = NULL; }
@@ -71,6 +80,7 @@ AliAnalysisTaskMuonResolution::AliAnalysisTaskMuonResolution() :
   AliAnalysisTaskSE(), 
   fResiduals(NULL),
   fResidualsVsP(NULL),
+  fResidualsVsCent(NULL),
   fLocalChi2(NULL),
   fChamberRes(NULL),
   fTrackRes(NULL),
@@ -89,6 +99,8 @@ AliAnalysisTaskMuonResolution::AliAnalysisTaskMuonResolution() :
   fTriggerMask(0),
   fExtrapMode(1),
   fCorrectForSystematics(kTRUE),
+  fRemoveMonoCathCl(kFALSE),
+  fCheckAllPads(kFALSE),
   fOCDBLoaded(kFALSE),
   fNDE(0),
   fReAlign(kFALSE),
@@ -106,6 +118,7 @@ AliAnalysisTaskMuonResolution::AliAnalysisTaskMuonResolution(const char *name) :
   AliAnalysisTaskSE(name), 
   fResiduals(NULL),
   fResidualsVsP(NULL),
+  fResidualsVsCent(NULL),
   fLocalChi2(NULL),
   fChamberRes(NULL),
   fTrackRes(NULL),
@@ -124,6 +137,8 @@ AliAnalysisTaskMuonResolution::AliAnalysisTaskMuonResolution(const char *name) :
   fTriggerMask(0),
   fExtrapMode(1),
   fCorrectForSystematics(kTRUE),
+  fRemoveMonoCathCl(kFALSE),
+  fCheckAllPads(kFALSE),
   fOCDBLoaded(kFALSE),
   fNDE(0),
   fReAlign(kFALSE),
@@ -149,6 +164,8 @@ AliAnalysisTaskMuonResolution::AliAnalysisTaskMuonResolution(const char *name) :
   DefineOutput(4,TObjArray::Class());
   // Output slot #5 writes into a TObjArray container
   DefineOutput(5,TObjArray::Class());
+  // Output slot #5 writes into a TObjArray container
+  DefineOutput(6,TObjArray::Class());
 }
 
 //________________________________________________________________________
@@ -158,6 +175,7 @@ AliAnalysisTaskMuonResolution::~AliAnalysisTaskMuonResolution()
   if (!AliAnalysisManager::GetAnalysisManager()->IsProofMode()) {
     SafeDelete(fResiduals);
     SafeDelete(fResidualsVsP);
+    SafeDelete(fResidualsVsCent);
     SafeDelete(fTrackRes);
   }
   SafeDelete(fChamberRes);
@@ -189,6 +207,8 @@ void AliAnalysisTaskMuonResolution::UserCreateOutputObjects()
   fResiduals->SetOwner();
   fResidualsVsP = new TObjArray(1000);
   fResidualsVsP->SetOwner();
+  fResidualsVsCent = new TObjArray(1000);
+  fResidualsVsCent->SetOwner();
   fTrackRes = new TObjArray(1000);
   fTrackRes->SetOwner();
   TH2F* h2;
@@ -205,6 +225,8 @@ void AliAnalysisTaskMuonResolution::UserCreateOutputObjects()
   const Int_t nSigma = 10;
   const Int_t pNBins = 20;
   const Double_t pEdges[2] = {0., 50.};
+  Int_t nCentBins = 12;
+  Double_t centRange[2] = {-10., 110.};
   
   for (Int_t ia = 0; ia < 2; ia++) {
     
@@ -223,7 +245,7 @@ void AliAnalysisTaskMuonResolution::UserCreateOutputObjects()
     for (Int_t i = 0; i < 10; i++) { h2->GetXaxis()->SetBinLabel(2*i+1, Form("%d-I",i+1)); h2->GetXaxis()->SetBinLabel(2*i+2, Form("%d-O",i+1)); }
     fResiduals->AddAtAndExpand(h2, kResidualPerHalfChClusterOut+ia);
     
-    h2 = new TH2F(Form("hResidual%sPerDE_ClusterIn",axes[ia]), Form("cluster-track residual-%s distribution per DE (cluster not attached to the track);DE ID;#Delta_{%s} (cm)",axes[ia],axes[ia]), fNDE, 0.5, fNDE+0.5, nBins, -maxRes, maxRes);
+    h2 = new TH2F(Form("hResidual%sPerDE_ClusterIn",axes[ia]), Form("cluster-track residual-%s distribution per DE (cluster attached to the track);DE ID;#Delta_{%s} (cm)",axes[ia],axes[ia]), fNDE, 0.5, fNDE+0.5, nBins, -maxRes, maxRes);
     for (Int_t i = 1; i <= fNDE; i++) h2->GetXaxis()->SetBinLabel(i, Form("%d",fDEIds[i]));
     fResiduals->AddAtAndExpand(h2, kResidualPerDEClusterIn+ia);
     h2 = new TH2F(Form("hResidual%sPerDE_ClusterOut",axes[ia]), Form("cluster-track residual-%s distribution per DE (cluster not attached to the track);DE ID;#Delta_{%s} (cm)",axes[ia],axes[ia]), fNDE, 0.5, fNDE+0.5, nBins, -2.*maxRes, 2.*maxRes);
@@ -251,14 +273,29 @@ void AliAnalysisTaskMuonResolution::UserCreateOutputObjects()
     h2 = new TH2F(Form("hClusterRes2%sPerCh",axes[ia]), Form("cluster #sigma_{%s}^{2} per Ch;chamber ID;#sigma_{%s}^{2} (cm^{2})",axes[ia],axes[ia]), 10, 0.5, 10.5, nSigma*nBins, -0.1*maxRes*maxRes, maxRes*maxRes);
     fResiduals->AddAtAndExpand(h2, kClusterRes2PerCh+ia);
     
-    // List of residual vs. p histos
+    // List of residual vs. p or vs. centrality histos
     for (Int_t i = 0; i < AliMUONConstants::NTrackingCh(); i++) {
       h2 = new TH2F(Form("hResidual%sInCh%dVsP_ClusterIn",axes[ia],i+1), Form("cluster-track residual-%s distribution in chamber %d versus momentum (cluster attached to the track);p (GeV/c^{2});#Delta_{%s} (cm)",axes[ia],i+1,axes[ia]), pNBins, pEdges[0], pEdges[1], nBins, -maxRes, maxRes);
       fResidualsVsP->AddAtAndExpand(h2, kResidualInChVsPClusterIn+10*ia+i);
       h2 = new TH2F(Form("hResidual%sInCh%dVsP_ClusterOut",axes[ia],i+1), Form("cluster-track residual-%s distribution in chamber %d versus momentum (cluster not attached to the track);p (GeV/c^{2});#Delta_{%s} (cm)",axes[ia],i+1,axes[ia]), pNBins, pEdges[0], pEdges[1], nBins, -2.*maxRes, 2.*maxRes);
       fResidualsVsP->AddAtAndExpand(h2, kResidualInChVsPClusterOut+10*ia+i);
+      
+      h2 = new TH2F(Form("hResidual%sInCh%dVsCent_ClusterIn",axes[ia],i+1), Form("cluster-track residual-%s distribution in chamber %d versus centrality (cluster attached to the track);centrality (%%);#Delta_{%s} (cm)",axes[ia],i+1,axes[ia]), nCentBins, centRange[0], centRange[1], nBins, -maxRes, maxRes);
+      fResidualsVsCent->AddAtAndExpand(h2, kResidualInChVsCentClusterIn+10*ia+i);
+      h2 = new TH2F(Form("hResidual%sInCh%dVsCent_ClusterOut",axes[ia],i+1), Form("cluster-track residual-%s distribution in chamber %d versus centrality (cluster not attached to the track);centrality (%%);#Delta_{%s} (cm)",axes[ia],i+1,axes[ia]), nCentBins, centRange[0], centRange[1], nBins, -2.*maxRes, 2.*maxRes);
+      fResidualsVsCent->AddAtAndExpand(h2, kResidualInChVsCentClusterOut+10*ia+i);
     }
     
+    h2 = new TH2F(Form("hResidual%sVsP_ClusterIn",axes[ia]), Form("cluster-track residual-%s distribution integrated over chambers versus momentum (cluster attached to the track);p (GeV/c^{2});#Delta_{%s} (cm)",axes[ia],axes[ia]), pNBins, pEdges[0], pEdges[1], nBins, -maxRes, maxRes);
+    fResidualsVsP->AddAtAndExpand(h2, kResidualVsPClusterIn+ia);
+    h2 = new TH2F(Form("hResidual%sVsP_ClusterOut",axes[ia]), Form("cluster-track residual-%s distribution integrated over chambers versus momentum (cluster not attached to the track);p (GeV/c^{2});#Delta_{%s} (cm)",axes[ia],axes[ia]), pNBins, pEdges[0], pEdges[1], nBins, -2.*maxRes, 2.*maxRes);
+    fResidualsVsP->AddAtAndExpand(h2, kResidualVsPClusterOut+ia);
+    
+    h2 = new TH2F(Form("hResidual%sVsCent_ClusterIn",axes[ia]), Form("cluster-track residual-%s distribution integrated over chambers versus centrality (cluster attached to the track);centrality (%%);#Delta_{%s} (cm)",axes[ia],axes[ia]), nCentBins, centRange[0], centRange[1], nBins, -maxRes, maxRes);
+    fResidualsVsCent->AddAtAndExpand(h2, kResidualVsCentClusterIn+ia);
+    h2 = new TH2F(Form("hResidual%sVsCent_ClusterOut",axes[ia]), Form("cluster-track residual-%s distribution integrated over chambers versus centrality (cluster not attached to the track);centrality (%%);#Delta_{%s} (cm)",axes[ia],axes[ia]), nCentBins, centRange[0], centRange[1], nBins, -2.*maxRes, 2.*maxRes);
+    fResidualsVsCent->AddAtAndExpand(h2, kResidualVsCentClusterOut+ia);
+    
     // local chi2
     h2 = new TH2F(Form("hLocalChi2%sPerCh",axes[ia]), Form("local chi2-%s distribution per chamber;chamber ID;local #chi^{2}_{%s}", axes[ia], axes[ia]), 10, 0.5, 10.5, 1000, 0., 25.);
     fResiduals->AddAtAndExpand(h2, kLocalChi2PerCh+ia);
@@ -293,7 +330,8 @@ void AliAnalysisTaskMuonResolution::UserCreateOutputObjects()
   // Post data at least once per task to ensure data synchronisation (required for merging)
   PostData(1, fResiduals);
   PostData(2, fResidualsVsP);
-  PostData(5, fTrackRes);
+  PostData(3, fResidualsVsCent);
+  PostData(6, fTrackRes);
 }
 
 //________________________________________________________________________
@@ -318,6 +356,9 @@ void AliAnalysisTaskMuonResolution::UserExec(Option_t *)
   if (!fSelectPhysics) triggerWord = BuildTriggerWord(firedTriggerClasses);
   if (fSelectTrigger && (triggerWord & fTriggerMask) == 0) return;
   
+  // get the centrality
+  Float_t centrality = esd->GetCentrality()->GetCentralityPercentileUnchecked("V0M");
+  
   // get tracker to refit
   AliMUONVTrackReconstructor* tracker = AliMUONESDInterface::GetTracker();
   
@@ -337,7 +378,7 @@ void AliAnalysisTaskMuonResolution::UserExec(Option_t *)
     // skip tracks that do not pass the acceptance cuts if required
     Double_t thetaAbs = TMath::ATan(esdTrack->GetRAtAbsorberEnd()/505.) * TMath::RadToDeg();
     Double_t eta = esdTrack->Eta();
-    if (fApplyAccCut && (thetaAbs < 2. || thetaAbs > 9. || eta < -4. || eta > -2.5)) continue;
+    if (fApplyAccCut && (thetaAbs < 2. || thetaAbs > 10. || eta < -4. || eta > -2.5)) continue;
     
     // skip low momentum tracks
     if (esdTrack->PUncorrected() < fMinMomentum) continue;
@@ -418,6 +459,14 @@ void AliAnalysisTaskMuonResolution::UserExec(Option_t *)
        break;
       }
       
+      // remove mono-cathod clusters if required
+      if (fRemoveMonoCathCl) {
+       Bool_t hasBending, hasNonBending;
+       if (fCheckAllPads) CheckPads(trackParam->GetClusterPtr(), hasBending, hasNonBending);
+       else CheckPadsBelow(trackParam->GetClusterPtr(), hasBending, hasNonBending);
+       if (!hasBending || !hasNonBending) continue;
+      }
+      
       // save current trackParam and remove it from the track
       AliMUONTrackParam currentTrackParam(*trackParam);
       track.RemoveTrackParamAtCluster(trackParam);
@@ -464,6 +513,12 @@ void AliAnalysisTaskMuonResolution::UserExec(Option_t *)
          ((TH2F*)fResiduals->UncheckedAt(kResidualPerDEClusterIn+1))->Fill(fDEIndices[deId], deltaY);
          ((TH2F*)fResidualsVsP->UncheckedAt(kResidualInChVsPClusterIn+chId))->Fill(pUncorr, deltaX);
          ((TH2F*)fResidualsVsP->UncheckedAt(kResidualInChVsPClusterIn+10+chId))->Fill(pUncorr, deltaY);
+         ((TH2F*)fResidualsVsP->UncheckedAt(kResidualVsPClusterIn))->Fill(pUncorr, deltaX);
+         ((TH2F*)fResidualsVsP->UncheckedAt(kResidualVsPClusterIn+1))->Fill(pUncorr, deltaY);
+         ((TH2F*)fResidualsVsCent->UncheckedAt(kResidualInChVsCentClusterIn+chId))->Fill(centrality, deltaX);
+         ((TH2F*)fResidualsVsCent->UncheckedAt(kResidualInChVsCentClusterIn+10+chId))->Fill(centrality, deltaY);
+         ((TH2F*)fResidualsVsCent->UncheckedAt(kResidualVsCentClusterIn))->Fill(centrality, deltaX);
+         ((TH2F*)fResidualsVsCent->UncheckedAt(kResidualVsCentClusterIn+1))->Fill(centrality, deltaY);
          
          // find the track parameters closest to the current cluster position
          Double_t dZWithPrevious = (previousTrackParam) ? TMath::Abs(previousTrackParam->GetClusterPtr()->GetZ() - cluster->GetZ()) : FLT_MAX;
@@ -509,6 +564,12 @@ void AliAnalysisTaskMuonResolution::UserExec(Option_t *)
            ((TH2F*)fResiduals->UncheckedAt(kResidualPerDEClusterOut+1))->Fill(fDEIndices[deId], deltaY);
            ((TH2F*)fResidualsVsP->UncheckedAt(kResidualInChVsPClusterOut+chId))->Fill(pUncorr, deltaX);
            ((TH2F*)fResidualsVsP->UncheckedAt(kResidualInChVsPClusterOut+10+chId))->Fill(pUncorr, deltaY);
+           ((TH2F*)fResidualsVsP->UncheckedAt(kResidualVsPClusterOut))->Fill(pUncorr, deltaX);
+           ((TH2F*)fResidualsVsP->UncheckedAt(kResidualVsPClusterOut+1))->Fill(pUncorr, deltaY);
+           ((TH2F*)fResidualsVsCent->UncheckedAt(kResidualInChVsCentClusterOut+chId))->Fill(centrality, deltaX);
+           ((TH2F*)fResidualsVsCent->UncheckedAt(kResidualInChVsCentClusterOut+10+chId))->Fill(centrality, deltaY);
+           ((TH2F*)fResidualsVsCent->UncheckedAt(kResidualVsCentClusterOut))->Fill(centrality, deltaX);
+           ((TH2F*)fResidualsVsCent->UncheckedAt(kResidualVsCentClusterOut+1))->Fill(centrality, deltaY);
            ((TH2F*)fResiduals->UncheckedAt(kTrackResPerCh))->Fill(chId+1, TMath::Sqrt(trackResX2));
            ((TH2F*)fResiduals->UncheckedAt(kTrackResPerCh+1))->Fill(chId+1, TMath::Sqrt(trackResY2));
            ((TH2F*)fResiduals->UncheckedAt(kTrackResPerHalfCh))->Fill(halfChId+1, TMath::Sqrt(trackResX2));
@@ -539,7 +600,8 @@ void AliAnalysisTaskMuonResolution::UserExec(Option_t *)
   // Post final data. It will be written to a file with option "RECREATE"
   PostData(1, fResiduals);
   PostData(2, fResidualsVsP);
-  PostData(5, fTrackRes);
+  PostData(3, fResidualsVsCent);
+  PostData(6, fTrackRes);
 }
 
 //________________________________________________________________________
@@ -619,9 +681,13 @@ void AliAnalysisTaskMuonResolution::NotifyRun()
     
     // load geometry for track extrapolation to vertex
     if (cdbm->GetEntryCache()->Contains("GRP/Geometry/Data")) cdbm->UnloadFromCache("GRP/Geometry/Data");
+    if (cdbm->GetEntryCache()->Contains("MUON/Align/Data")) cdbm->UnloadFromCache("MUON/Align/Data");
     if (AliGeomManager::GetGeometry()) AliGeomManager::GetGeometry()->UnlockGeometry();
     AliGeomManager::LoadGeometry();
     if (!AliGeomManager::GetGeometry()) return;
+    AliGeomManager::ApplyAlignObjsFromCDB("MUON");
+    fNewGeoTransformer = new AliMUONGeometryTransformer();
+    fNewGeoTransformer->LoadGeometryData();
     
   }
   
@@ -649,7 +715,8 @@ void AliAnalysisTaskMuonResolution::Terminate(Option_t *)
   // recover output objects
   fResiduals = static_cast<TObjArray*> (GetOutputData(1));
   fResidualsVsP = static_cast<TObjArray*> (GetOutputData(2));
-  fTrackRes = static_cast<TObjArray*> (GetOutputData(5));
+  fResidualsVsCent = static_cast<TObjArray*> (GetOutputData(3));
+  fTrackRes = static_cast<TObjArray*> (GetOutputData(6));
   if (!fResiduals || !fResidualsVsP || !fTrackRes) return;
   
   // summary graphs
@@ -744,6 +811,28 @@ void AliAnalysisTaskMuonResolution::Terminate(Option_t *)
     }
     fChamberRes->AddAtAndExpand(mg, kCombinedResidualSigmaVsP+ia);
     
+    g = new TGraphErrors(((TH2F*)fResidualsVsP->UncheckedAt(kResidualVsPClusterIn+ia))->GetNbinsX());
+    g->SetName(Form("gCombinedResidual%sSigmaVsP",axes[ia]));
+    g->SetTitle(Form("cluster %s-resolution integrated over chambers versus momentum: sigma;p (GeV/c^{2});#sigma_{%s} (cm)",axes[ia],axes[ia]));
+    g->SetMarkerStyle(kFullDotLarge);
+    fChamberRes->AddAtAndExpand(g, kCombinedResidualAllChSigmaVsP+ia);
+    
+    mg = new TMultiGraph(Form("mgCombinedResidual%sSigmaVsCent",axes[ia]),Form("cluster %s-resolution per chamber versus centrality;centrality (%%);#sigma_{%s} (cm)",axes[ia],axes[ia]));
+    for (Int_t i = 0; i < AliMUONConstants::NTrackingCh(); i++) {
+      g = new TGraphErrors(((TH2F*)fResidualsVsCent->UncheckedAt(kResidualInChVsCentClusterIn+10*ia+i))->GetNbinsX());
+      g->SetName(Form("gRes%sVsCent_ch%d",axes[ia],i+1));
+      g->SetMarkerStyle(kFullDotMedium);
+      g->SetMarkerColor(i+1+i/9);
+      mg->Add(g,"p");
+    }
+    fChamberRes->AddAtAndExpand(mg, kCombinedResidualSigmaVsCent+ia);
+    
+    g = new TGraphErrors(((TH2F*)fResidualsVsCent->UncheckedAt(kResidualVsCentClusterIn+ia))->GetNbinsX());
+    g->SetName(Form("gCombinedResidual%sSigmaVsCent",axes[ia]));
+    g->SetTitle(Form("cluster %s-resolution integrated over chambers versus centrality: sigma;centrality (%%);#sigma_{%s} (cm)",axes[ia],axes[ia]));
+    g->SetMarkerStyle(kFullDotLarge);
+    fChamberRes->AddAtAndExpand(g, kCombinedResidualAllChSigmaVsCent+ia);
+    
     g = new TGraphErrors(AliMUONConstants::NTrackingCh());
     g->SetName(Form("gTrackRes%sPerCh",axes[ia]));
     g->SetTitle(Form("track <#sigma_{%s}> per Ch;chamber ID;#sigma_{%s} (cm)",axes[ia],axes[ia]));
@@ -792,6 +881,16 @@ void AliAnalysisTaskMuonResolution::Terminate(Option_t *)
     g->SetMarkerStyle(kFullDotLarge);
     fLocalChi2->AddAtAndExpand(g, kLocalChi2PerDEMean+ia);
     
+    // compute residual mean and dispersion integrated over chambers versus p
+    FillSigmaClusterVsP((TH2F*)fResidualsVsP->UncheckedAt(kResidualVsPClusterIn+ia),
+                       (TH2F*)fResidualsVsP->UncheckedAt(kResidualVsPClusterOut+ia),
+                       (TGraphErrors*)fChamberRes->UncheckedAt(kCombinedResidualAllChSigmaVsP+ia));
+    
+    // compute residual mean and dispersion integrated over chambers versus centrality
+    FillSigmaClusterVsCent((TH2F*)fResidualsVsCent->UncheckedAt(kResidualVsCentClusterIn+ia),
+                          (TH2F*)fResidualsVsCent->UncheckedAt(kResidualVsCentClusterOut+ia),
+                          (TGraphErrors*)fChamberRes->UncheckedAt(kCombinedResidualAllChSigmaVsCent+ia));
+    
     // compute residual mean and dispersion and averaged local chi2 per chamber and half chamber
     Double_t meanIn, meanInErr, meanOut, meanOutErr, sigma, sigmaIn, sigmaInErr, sigmaOut, sigmaOutErr;
     Double_t sigmaTrack, sigmaTrackErr, sigmaMCS, sigmaMCSErr, clusterRes, clusterResErr, sigmaCluster, sigmaClusterErr;
@@ -865,6 +964,11 @@ void AliAnalysisTaskMuonResolution::Terminate(Option_t *)
                          (TH2F*)fResidualsVsP->UncheckedAt(kResidualInChVsPClusterOut+10*ia+i),
                          (TGraphErrors*)((TMultiGraph*)fChamberRes->UncheckedAt(kCombinedResidualSigmaVsP+ia))->GetListOfGraphs()->FindObject(Form("gRes%sVsP_ch%d",axes[ia],i+1)));
       
+      // method 1 versus centrality
+      FillSigmaClusterVsCent((TH2F*)fResidualsVsCent->UncheckedAt(kResidualInChVsCentClusterIn+10*ia+i),
+                            (TH2F*)fResidualsVsCent->UncheckedAt(kResidualInChVsCentClusterOut+10*ia+i),
+                            (TGraphErrors*)((TMultiGraph*)fChamberRes->UncheckedAt(kCombinedResidualSigmaVsCent+ia))->GetListOfGraphs()->FindObject(Form("gRes%sVsCent_ch%d",axes[ia],i+1)));
+      
       // compute residual mean and dispersion per half chamber
       for (Int_t j = 0; j < 2; j++) {
        Int_t k = 2*i+j;
@@ -1190,6 +1294,15 @@ void AliAnalysisTaskMuonResolution::Terminate(Option_t *)
   }
   fCanvases->AddAtAndExpand(cResPerChVsP, kResPerChVsP);
   
+  TCanvas* cResPerChVsCent = new TCanvas("cResPerChVsCent","cResPerChVsCent");
+  cResPerChVsCent->Divide(1,2);
+  for (Int_t ia = 0; ia < 2; ia++) {
+    cResPerChVsCent->cd(1+ia);
+    mg = (TMultiGraph*)fChamberRes->UncheckedAt(kCombinedResidualSigmaVsCent+ia);
+    mg->Draw("ap");
+  }
+  fCanvases->AddAtAndExpand(cResPerChVsCent, kResPerChVsCent);
+  
   // print results
   if (fPrintClResPerCh) {
     printf("\nchamber resolution:\n");
@@ -1217,8 +1330,8 @@ void AliAnalysisTaskMuonResolution::Terminate(Option_t *)
   }
   
   // Post final data.
-  PostData(3, fLocalChi2);
-  PostData(4, fChamberRes);
+  PostData(4, fLocalChi2);
+  PostData(5, fChamberRes);
 }
 
 //________________________________________________________________________
@@ -1312,22 +1425,35 @@ void AliAnalysisTaskMuonResolution::GetMean(TH1* h, Double_t& mean, Double_t& me
     
     fGaus->SetParameters(h->GetEntries(), 0., 0.1);
     
-    h->Fit("fGaus", "WWNQ");
+    if (h->GetUniqueID() != 10) {
+      
+      // first fit
+      h->Fit("fGaus", "WWNQ");
+      
+      // rebin histo
+      Int_t rebin = TMath::Max(static_cast<Int_t>(0.2*fGaus->GetParameter(2)/h->GetBinWidth(1)),1);
+      while (h->GetNbinsX()%rebin!=0) rebin--;
+      h->Rebin(rebin);
+      
+      // use the unique ID to remember that this histogram has already been rebinned
+      h->SetUniqueID(10);
+      
+    }
+    
+    // second fit
+    h->Fit("fGaus","NQ");
     
     mean = fGaus->GetParameter(1);
     meanErr = fGaus->GetParError(1);
     
   } else { // take the mean of the distribution
     
-    Int_t firstBin = h->GetXaxis()->GetFirst();
-    Int_t lastBin = h->GetXaxis()->GetLast();
-    
     if (zoom) Zoom(h);
     
     mean = h->GetMean();
     meanErr = h->GetMeanError();
     
-    if (zoom) h->GetXaxis()->SetRange(firstBin,lastBin);
+    if (zoom) h->GetXaxis()->SetRange(0,0);
     
   }
   
@@ -1353,22 +1479,35 @@ void AliAnalysisTaskMuonResolution::GetRMS(TH1* h, Double_t& rms, Double_t& rmsE
     
     fGaus->SetParameters(h->GetEntries(), 0., 0.1);
     
-    h->Fit("fGaus", "WWNQ");
+    if (h->GetUniqueID() != 10) {
+      
+      // first fit
+      h->Fit("fGaus", "WWNQ");
+      
+      // rebin histo
+      Int_t rebin = TMath::Max(static_cast<Int_t>(0.2*fGaus->GetParameter(2)/h->GetBinWidth(1)),1);
+      while (h->GetNbinsX()%rebin!=0) rebin--;
+      h->Rebin(rebin);
+      
+      // use the unique ID to remember that this histogram has already been rebinned
+      h->SetUniqueID(10);
+      
+    }
+    
+    // second fit
+    h->Fit("fGaus","NQ");
     
     rms = fGaus->GetParameter(2);
     rmsErr = fGaus->GetParError(2);
     
   } else { // take the RMS of the distribution
     
-    Int_t firstBin = h->GetXaxis()->GetFirst();
-    Int_t lastBin = h->GetXaxis()->GetLast();
-    
     if (zoom) Zoom(h);
     
     rms = h->GetRMS();
     rmsErr = h->GetRMSError();
     
-    if (zoom) h->GetXaxis()->SetRange(firstBin,lastBin);
+    if (zoom) h->GetXaxis()->SetRange(0,0);
     
   }
   
@@ -1402,6 +1541,28 @@ void AliAnalysisTaskMuonResolution::FillSigmaClusterVsP(const TH2* hIn, const TH
   }
 }
 
+//________________________________________________________________________
+void AliAnalysisTaskMuonResolution::FillSigmaClusterVsCent(const TH2* hIn, const TH2* hOut, TGraphErrors* g, Bool_t zoom)
+{
+  /// Fill graph with cluster resolution from combined residuals with cluster in/out (zooming if required)
+  Double_t sigmaIn, sigmaInErr, sigmaOut, sigmaOutErr, clusterRes, clusterResErr;
+  for (Int_t j = 1; j <= hIn->GetNbinsX(); j++) {
+    TH1D* tmp = hIn->ProjectionY("tmp",j,j,"e");
+    GetRMS(tmp, sigmaIn, sigmaInErr, 0x0, 0, 0., zoom);
+    delete tmp;
+    tmp = hOut->ProjectionY("tmp",j,j,"e");
+    GetRMS(tmp, sigmaOut, sigmaOutErr, 0x0, 0, 0., zoom);
+    delete tmp;
+    Double_t cent = 0.5 * (hIn->GetBinLowEdge(j) + hIn->GetBinLowEdge(j+1));
+    Double_t centErr = cent - hIn->GetBinLowEdge(j);
+    clusterRes = TMath::Sqrt(sigmaIn*sigmaOut);
+    //clusterResErr = (clusterRes > 0.) ? 0.5 * TMath::Sqrt(sigmaInErr*sigmaInErr*sigmaOut*sigmaOut + sigmaIn*sigmaIn*sigmaOutErr*sigmaOutErr) / clusterRes : 0.;
+    clusterResErr = TMath::Sqrt(sigmaInErr*sigmaOutErr);
+    g->SetPoint(j, cent, clusterRes);
+    g->SetPointError(j, centErr, clusterResErr);
+  }
+}
+
 //__________________________________________________________________________
 void AliAnalysisTaskMuonResolution::Cov2CovP(const AliMUONTrackParam &param, TMatrixD &covP)
 {
@@ -1453,3 +1614,84 @@ UInt_t AliAnalysisTaskMuonResolution::BuildTriggerWord(const TString& firedTrigg
   return word;
 }
 
+//__________________________________________________________________________
+void AliAnalysisTaskMuonResolution::CheckPads(AliMUONVCluster *cl, Bool_t &hasBending, Bool_t &hasNonBending) const
+{
+  /// Check that this cluster contains pads on both cathods
+  
+  // reset
+  hasBending = kFALSE;
+  hasNonBending = kFALSE;
+  
+  // loop over digits contained in the cluster
+  for (Int_t iDigit = 0; iDigit < cl->GetNDigits(); iDigit++) {
+    
+    Int_t manuId = AliMUONVDigit::ManuId(cl->GetDigitId(iDigit));
+    
+    // check the location of the manu the digit belongs to
+    if (manuId > 0) {
+      if (manuId & AliMpConstants::ManuMask(AliMp::kNonBendingPlane)) hasNonBending = kTRUE;
+      else hasBending = kTRUE;
+    }
+    
+  }
+  
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskMuonResolution::CheckPadsBelow(AliMUONVCluster *cl, Bool_t &hasBending, Bool_t &hasNonBending) const
+{
+  /// Check that this cluster contains pads on both cathods just under its position
+  
+  // reset
+  hasBending = kFALSE;
+  hasNonBending = kFALSE;
+  
+  // get the cathod corresponding to the bending/non-bending plane
+  Int_t deId = cl->GetDetElemId();
+  AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(deId, kFALSE);
+  if (!de) return;
+  AliMp::CathodType cath1 = de->GetCathodType(AliMp::kBendingPlane); 
+  AliMp::CathodType cath2 = de->GetCathodType(AliMp::kNonBendingPlane); 
+  
+  // get the corresponding segmentation
+  const AliMpVSegmentation* seg1 = AliMpSegmentation::Instance()->GetMpSegmentation(deId, cath1);
+  const AliMpVSegmentation* seg2 = AliMpSegmentation::Instance()->GetMpSegmentation(deId, cath2);
+  if (!seg1 || !seg2) return;
+  
+  // get local coordinate of the cluster
+  Double_t lX,lY,lZ;
+  Double_t gX = cl->GetX();
+  Double_t gY = cl->GetY();
+  Double_t gZ = cl->GetZ();
+  fNewGeoTransformer->Global2Local(deId,gX,gY,gZ,lX,lY,lZ);
+  
+  // find pads below the cluster
+  AliMpPad pad1 = seg1->PadByPosition(lX, lY, kFALSE);
+  AliMpPad pad2 = seg2->PadByPosition(lX, lY, kFALSE);
+  
+  // build their ID if pads are valid
+  UInt_t padId1 = (pad1.IsValid()) ? AliMUONVDigit::BuildUniqueID(deId, pad1.GetManuId(), pad1.GetManuChannel(), cath1) : 0;
+  UInt_t padId2 = (pad2.IsValid()) ? AliMUONVDigit::BuildUniqueID(deId, pad2.GetManuId(), pad2.GetManuChannel(), cath2) : 0;
+  
+  // check if the cluster contains these pads 
+  for (Int_t iDigit = 0; iDigit < cl->GetNDigits(); iDigit++) {
+    
+    UInt_t digitId = cl->GetDigitId(iDigit);
+    
+    if (digitId == padId1) {
+      
+      hasBending = kTRUE;
+      if (hasNonBending) break;
+      
+    } else if (digitId == padId2) {
+      
+      hasNonBending = kTRUE;
+      if (hasBending) break;
+      
+    }
+    
+  }
+  
+}
+
index 12f1bc7..0a23399 100644 (file)
@@ -24,6 +24,7 @@ class TList;
 class AliMUONTrack;
 class AliMUONTrackParam;
 class AliMUONGeometryTransformer;
+class AliMUONVCluster;
 
 class AliAnalysisTaskMuonResolution : public AliAnalysisTaskSE {
 public:
@@ -76,6 +77,9 @@ public:
   
   void FitResiduals(Bool_t flag = kTRUE);
   
+  /// set the flag to remove mono-cathod clusters (either considering all the pads or only the ones directly below)
+  void RemoveMonoCathodClusters(Bool_t flag = kTRUE, Bool_t checkAllPads = kTRUE) {fRemoveMonoCathCl = flag; fCheckAllPads = checkAllPads;}
+  
   virtual void   UserCreateOutputObjects();
   virtual void   UserExec(Option_t *);
   virtual void   NotifyRun();
@@ -95,8 +99,11 @@ private:
   void GetMean(TH1* h, Double_t& mean, Double_t& meanErr, TGraphErrors* g = 0x0, Int_t i = 0, Double_t x = 0, Bool_t zoom = kTRUE, Bool_t enableFit = kTRUE);
   void GetRMS(TH1* h, Double_t& rms, Double_t& rmsErr, TGraphErrors* g = 0x0, Int_t i = 0, Double_t x = 0, Bool_t zoom = kTRUE);
   void FillSigmaClusterVsP(const TH2* hIn, const TH2* hOut, TGraphErrors* g, Bool_t zoom = kTRUE);
+  void FillSigmaClusterVsCent(const TH2* hIn, const TH2* hOut, TGraphErrors* g, Bool_t zoom = kTRUE);
   void Cov2CovP(const AliMUONTrackParam &param, TMatrixD &covP);
   UInt_t BuildTriggerWord(const TString& FiredTriggerClasses);
+  void CheckPads(AliMUONVCluster *cl, Bool_t &hasBending, Bool_t &hasNonBending) const;
+  void CheckPadsBelow(AliMUONVCluster *cl, Bool_t &hasBending, Bool_t &hasNonBending) const;
   
 private:
   
@@ -120,7 +127,16 @@ private:
   
   enum eResidualsVsP {
     kResidualInChVsPClusterIn           = 0,  ///< cluster-track residual-X/Y distribution in chamber i versus momentum (cluster attached to the track)
-    kResidualInChVsPClusterOut          = 20  ///< cluster-track residual-X/Y distribution in chamber i versus momentum (cluster not attached to the track)
+    kResidualInChVsPClusterOut          = 20, ///< cluster-track residual-X/Y distribution in chamber i versus momentum (cluster not attached to the track)
+    kResidualVsPClusterIn               = 40, ///< cluster-track residual-X/Y distribution integrated over chambers versus momentum (cluster attached to the track)
+    kResidualVsPClusterOut              = 42  ///< cluster-track residual-X/Y distribution integrated over chambers versus momentum (cluster not attached to the track)
+  };
+  
+  enum eResidualsVsCent {
+    kResidualInChVsCentClusterIn        = 0,  ///< cluster-track residual-X/Y distribution in chamber i versus centrality (cluster attached to the track)
+    kResidualInChVsCentClusterOut       = 20, ///< cluster-track residual-X/Y distribution in chamber i versus centrality (cluster not attached to the track)
+    kResidualVsCentClusterIn            = 40, ///< cluster-track residual-X/Y distribution integrated over chambers versus centrality (cluster attached to the track)
+    kResidualVsCentClusterOut           = 42  ///< cluster-track residual-X/Y distribution integrated over chambers versus centrality (cluster not attached to the track)
   };
   
   enum eLocalChi2 {
@@ -147,7 +163,10 @@ private:
     kResidualPerHalfChMeanClusterIn     = 30, ///< cluster-track residual-X/Y per half chamber: mean (cluster in)
     kResidualPerHalfChMeanClusterOut    = 32, ///< cluster-track residual-X/Y per half chamber: mean (cluster out)
     kCombinedResidualPerHalfChSigma     = 34, ///< combined cluster-track residual-X/Y per half chamber
-    kClusterResPerHalfCh                = 36  ///< cluster X/Y-resolution per half chamber
+    kClusterResPerHalfCh                = 36, ///< cluster X/Y-resolution per half chamber
+    kCombinedResidualSigmaVsCent        = 38, ///< cluster X/Y-resolution per chamber versus centrality
+    kCombinedResidualAllChSigmaVsP      = 40, ///< cluster X/Y-resolution integrated over chambers versus momentum
+    kCombinedResidualAllChSigmaVsCent   = 42  ///< cluster X/Y-resolution integrated over chambers versus centrality
   };
   
   enum eTrackRes {
@@ -163,17 +182,19 @@ private:
     kResPerCh                           = 0,  ///< summary canvas
     kResPerChVsP                        = 1,  ///< summary canvas
     kResPerDE                           = 2,  ///< summary canvas
-    kResPerHalfCh                       = 3   ///< summary canvas
+    kResPerHalfCh                       = 3,  ///< summary canvas
+    kResPerChVsCent                     = 4   ///< summary canvas
   };
   
   static const Int_t fgkMinEntries; ///< minimum number of entries needed to compute resolution
   
-  TObjArray*  fResiduals;    //!< List of residual histos
-  TObjArray*  fResidualsVsP; //!< List of residual vs. p histos
-  TObjArray*  fLocalChi2;    //!< List of plots related to local chi2 per chamber/DE
-  TObjArray*  fChamberRes;   //!< List of plots related to chamber/DE resolution
-  TObjArray*  fTrackRes;     //!< List of plots related to track resolution (p, pT, ...)
-  TObjArray*  fCanvases;     //!< List of canvases summarizing the results
+  TObjArray*  fResiduals;       //!< List of residual histos
+  TObjArray*  fResidualsVsP;    //!< List of residual vs. p histos
+  TObjArray*  fResidualsVsCent; //!< List of residual vs. centrality histos
+  TObjArray*  fLocalChi2;       //!< List of plots related to local chi2 per chamber/DE
+  TObjArray*  fChamberRes;      //!< List of plots related to chamber/DE resolution
+  TObjArray*  fTrackRes;        //!< List of plots related to track resolution (p, pT, ...)
+  TObjArray*  fCanvases;        //!< List of canvases summarizing the results
   
   Double_t fClusterResNB[10]; ///< cluster resolution in non-bending direction
   Double_t fClusterResB[10];  ///< cluster resolution in bending direction
@@ -192,6 +213,8 @@ private:
   UInt_t   fTriggerMask;           ///< trigger mask to be used when selecting tracks
   Int_t    fExtrapMode;            ///< extrapolation mode to get the track parameters and covariances at a given cluster
   Bool_t   fCorrectForSystematics; ///< add or not the systematic shifts of the residuals to the resolution
+  Bool_t   fRemoveMonoCathCl;      ///< remove or not the mono-cathod clusters
+  Bool_t   fCheckAllPads;          ///< use all pads or only the ones directly below the cluster to look for mono-cathods
   Bool_t   fOCDBLoaded;            //!< flag telling if the OCDB has been properly loaded or not
   Int_t    fNDE;                   //!< total number of DE
   Int_t    fDEIndices[1100];       //!< index of DE in histograms refered by ID
@@ -204,7 +227,7 @@ private:
   
   TList* fSelectTriggerClass; //!< list of trigger class that can be selected to fill histograms
   
-  ClassDef(AliAnalysisTaskMuonResolution, 2); // chamber resolution analysis
+  ClassDef(AliAnalysisTaskMuonResolution, 3); // chamber resolution analysis
 };
 
 //________________________________________________________________________
index f4d0916..58b808f 100644 (file)
@@ -40,6 +40,7 @@
 #include "AliPhysicsSelectionTask.h"
 #include "AliPhysicsSelection.h"
 #include "AliBackgroundSelection.h"
+#include "AliCentralitySelectionTask.h"
 #include "AliAnalysisDataContainer.h"
 #include "AliAnalysisTaskMuonResolution.h"
 
 #include "AliMUONTrackerDataWrapper.h"
 
 #include "AddTaskPhysicsSelection.C"
+#include "AddTaskCentrality.C"
 #include "AddTaskMuonResolution.C"
 
 #endif
 
 enum {kLocal, kInteractif_xml, kInteractif_ESDList, kProof};
 
-void    LoadAlirootOnProof(TString alirootVersion, TString& extraLibs, Int_t iStep);
+void    LoadAlirootOnProof(TString& aaf, TString alirootVersion, TString& extraLibs, Int_t iStep);
 AliAnalysisTaskMuonResolution* CreateAnalysisTrain(Int_t mode, Int_t iStep, Bool_t selectPhysics, Bool_t selectTrigger, Bool_t matchTrig,
                                                   Bool_t applyAccCut, Double_t minMomentum, Bool_t correctForSystematics, Int_t extrapMode,
                                                   Double_t clusterResNB[10], Double_t clusterResB[10]);
@@ -145,7 +147,7 @@ void MuonResolution(TString smode, TString inputFileName, TString alirootVersion
     cout<<"step "<<iStep+1<<"/"<<nSteps<<endl;
     
     // Connect to proof if needed and prepare environment
-    if (mode == kProof) LoadAlirootOnProof(alirootVersion, extraLibs, iStep);
+    if (mode == kProof) LoadAlirootOnProof(smode, alirootVersion, extraLibs, iStep);
     
     // create the analysis train
     AliAnalysisTaskMuonResolution *muonResolution = CreateAnalysisTrain(mode, iStep, selectPhysics, selectTrigger, matchTrig,
@@ -226,7 +228,7 @@ void MuonResolution(TString smode, TString inputFileName, TString alirootVersion
 }
 
 //______________________________________________________________________________
-void LoadAlirootOnProof(TString alirootVersion, TString& extraLibs, Int_t iStep)
+void LoadAlirootOnProof(TString& aaf, TString alirootVersion, TString& extraLibs, Int_t iStep)
 {
   /// Load aliroot packages and set environment on Proof
   
@@ -235,8 +237,9 @@ void LoadAlirootOnProof(TString alirootVersion, TString& extraLibs, Int_t iStep)
   else gProof->Close("s");
   
   // connect
-  TString location = "alice-caf.cern.ch";
-  TString nWorkers = "";
+  TString location = (aaf == "caf") ? "alice-caf.cern.ch" : "nansafmaster.in2p3.fr";
+  //TString location = (aaf == "caf") ? "alice-caf.cern.ch" : "localhost:1093";
+  TString nWorkers = (aaf == "caf") ? "workers=80" : "";
   if (gSystem->Getenv("alien_API_USER") == NULL) TProof::Open(location.Data(), nWorkers.Data());
   else TProof::Open(Form("%s@%s",gSystem->Getenv("alien_API_USER"), location.Data()), nWorkers.Data());
   if (!gProof) return;
@@ -268,32 +271,44 @@ AliAnalysisTaskMuonResolution* CreateAnalysisTrain(Int_t mode, Int_t iStep, Bool
   // ESD input handler
   AliESDInputHandler* esdH = new AliESDInputHandler();
   esdH->SetReadFriends(kFALSE);
-  esdH->SetInactiveBranches(" FMD PHOS  EMCAL  Pmd Trd V0s TPC "
-                           "Cascades Kinks CaloClusters ACORDE RawData HLT TZERO ZDC"
-                           " Cells ACORDE Pileup");
+  esdH->SetInactiveBranches("*");
+  esdH->SetActiveBranches("MuonTracks AliESDRun. AliESDHeader. AliMultiplicity. AliESDFMD. AliESDVZERO. SPDVertex. PrimaryVertex. AliESDZDC.");
   mgr->SetInputEventHandler(esdH);
   
   // event selection
   if (selectPhysics) {
     AliPhysicsSelectionTask* physicsSelection = AddTaskPhysicsSelection();
     if (!physicsSelection) {
-      Error("run","AliPhysicsSelectionTask not created!");
+      Error("CreateAnalysisTrain","AliPhysicsSelectionTask not created!");
       return 0x0;
     }
   }
   
+  // centrality selection
+  AliCentralitySelectionTask* centralityTask = AddTaskCentrality();
+  if (!centralityTask) {
+    Error("CreateAnalysisTrain","AliCentralitySelectionTask not created!");
+    return 0x0;
+  }
+  centralityTask->SetPass(1);
+  
   // Muon Resolution analysis
   TString outputFileName = Form("chamberResolution_step%d.root", iStep);
   AliAnalysisManager::SetCommonFileName(outputFileName.Data());
   AliAnalysisTaskMuonResolution *muonResolution = AddTaskMuonResolution(selectPhysics, selectTrigger, matchTrig, applyAccCut, minMomentum, correctForSystematics, extrapMode);
   if (!muonResolution) {
-    Error("run","AliAnalysisTaskMuonResolution not created!");
+    Error("CreateAnalysisTrain","AliAnalysisTaskMuonResolution not created!");
     return 0x0;
   }
-  if (mode == kLocal) muonResolution->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
+  //if (mode == kLocal) muonResolution->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
+  muonResolution->SetDefaultStorage("alien://folder=/alice/data/2011/OCDB");
   if (mode != kProof) muonResolution->ShowProgressBar();
   muonResolution->PrintClusterRes(kTRUE, kTRUE);
   muonResolution->SetStartingResolution(clusterResNB, clusterResB);
+  //muonResolution->RemoveMonoCathodClusters(kTRUE, kFALSE);
+//  muonResolution->FitResiduals(kFALSE);
+//  muonResolution->ReAlign("alien://folder=/alice/cern.ch/user/p/ppillot/OCDB2011","");
+//  muonResolution->ReAlign("alien://folder=/alice/cern.ch/user/p/ppillot/OCDB2011", "alien://folder=/alice/cern.ch/user/p/ppillot/OCDB2011_Align2");
   
   return muonResolution;
   
@@ -423,7 +438,7 @@ Int_t GetMode(TString smode, TString input)
     if ( input.EndsWith(".xml") ) return kInteractif_xml;
     else if ( input.EndsWith(".txt") ) return kInteractif_ESDList;
     else if ( input.EndsWith(".root") ) return kLocal;    
-  } else if (smode == "proof") return kProof;
+  } else if (smode == "caf" || smode == "saf") return kProof;
   return -1;
 }