Coverity fixes (Dmitri Peressounko)
authorfca <fca@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 16 Mar 2011 14:49:36 +0000 (14:49 +0000)
committerfca <fca@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 16 Mar 2011 14:49:36 +0000 (14:49 +0000)
PWG4/GammaConv/AliAnalysisTaskCaloConv.cxx
PWG4/GammaConv/AliAnalysisTaskCaloConv.h

index 8df0248..89c5c03 100644 (file)
@@ -25,6 +25,8 @@
 #include "TH3.h"
 #include "TH2.h"
 #include "TDirectory.h"
+#include "TLorentzVector.h"
+#include "TRandom.h"
 
 // analysis
 #include "AliAnalysisManager.h"
@@ -35,6 +37,7 @@
 #include "AliESDEvent.h"
 #include "AliESDpid.h"
 #include "AliESDtrackCuts.h"
+#include "AliESDtrackCuts.h"
 #include "AliCFContainer.h"   // for CF
 #include "AliESDCaloCluster.h" 
 #include "AliPHOSGeoUtils.h" 
@@ -56,6 +59,7 @@ AliAnalysisTaskCaloConv::AliAnalysisTaskCaloConv():
 AliAnalysisTaskSE(),
   fESDEvent(NULL),     
   fESDpid(NULL),
+  fESDtrackCuts(NULL),
   fStack(NULL),
   fOutputContainer(NULL),
   fCFOutputContainer(NULL),
@@ -63,6 +67,7 @@ AliAnalysisTaskSE(),
   fPHOSCFCont(0x0),
   fEMCALCFCont(0x0),
   fPi0CFCont(0x0),
+  fCentr(0.),
   fTriggerCINT1B(kFALSE),
   fToUseCF(kFALSE),
   fMinOpeningAngleGhostCut(0.),
@@ -70,6 +75,11 @@ AliAnalysisTaskSE(),
   fEMCALgeom(0x0),
   fPi0Thresh1(0.5),
   fPi0Thresh2(1.),
+  fBadDistCutPHOS(3.3),
+  fBadDistCutEMCAL(6.),
+  fGammaV0s(),
+  fGammaPHOS(),
+  fGammaEMCAL(),
   fConvEvent(NULL) ,
   fPHOSEvent(NULL),
   fEMCALEvent(NULL),
@@ -93,11 +103,11 @@ AliAnalysisTaskSE(),
   }
   char key[55] ;
   for(Int_t i=0; i<6; i++){
-    sprintf(key,"PHOS_BadMap_mod%d",i) ;
+    snprintf(key,55,"PHOS_BadMap_mod%d",i) ;
     fPHOSBadMap[i]=new TH2I(key,"Bad Modules map",64,0.,64.,56,0.,56.) ;
   }
   for(Int_t i=0; i<10; i++){
-    sprintf(key,"EMCAL_BadMap_mod%d",i) ;
+    snprintf(key,55,"EMCAL_BadMap_mod%d",i) ;
     fEMCALBadMap[i] = new TH2I(key,"Bad Modules map",24,0.,24.,48,0.,48.) ;
   }
 }
@@ -105,6 +115,7 @@ AliAnalysisTaskCaloConv::AliAnalysisTaskCaloConv(const char* name):
   AliAnalysisTaskSE(name),
   fESDEvent(NULL),
   fESDpid(NULL),
+  fESDtrackCuts(NULL),
   fStack(NULL),
   fOutputContainer(NULL),
   fCFOutputContainer(NULL),
@@ -112,6 +123,7 @@ AliAnalysisTaskCaloConv::AliAnalysisTaskCaloConv(const char* name):
   fPHOSCFCont(0x0),
   fEMCALCFCont(0x0),
   fPi0CFCont(0x0),
+  fCentr(0.),
   fTriggerCINT1B(kFALSE),
   fToUseCF(kFALSE),
   fMinOpeningAngleGhostCut(0.),
@@ -119,6 +131,11 @@ AliAnalysisTaskCaloConv::AliAnalysisTaskCaloConv(const char* name):
   fEMCALgeom(0x0),
   fPi0Thresh1(0.5),
   fPi0Thresh2(1.),
+  fBadDistCutPHOS(3.3),
+  fBadDistCutEMCAL(6.),
+  fGammaV0s(),
+  fGammaPHOS(),
+  fGammaEMCAL(),
   fConvEvent(NULL) ,
   fPHOSEvent(NULL),
   fEMCALEvent(NULL),
@@ -149,11 +166,11 @@ AliAnalysisTaskCaloConv::AliAnalysisTaskCaloConv(const char* name):
   }
   char key[55] ;
   for(Int_t i=0; i<6; i++){
-    sprintf(key,"PHOS_BadMap_mod%d",i) ;
+    snprintf(key,55,"PHOS_BadMap_mod%d",i) ;
     fPHOSBadMap[i]=new TH2I(key,"Bad Modules map",64,0.,64.,56,0.,56.) ;
   }
   for(Int_t i=0; i<10; i++){
-    sprintf(key,"EMCAL_BadMap_mod%d",i) ;
+    snprintf(key,55,"EMCAL_BadMap_mod%d",i) ;
     fEMCALBadMap[i] = new TH2I(key,"Bad Modules map",24,0.,24.,48,0.,48.) ;
   }
 //  fESDpid = new AliESDpid;
@@ -163,50 +180,53 @@ AliAnalysisTaskCaloConv::~AliAnalysisTaskCaloConv()
 {
   // Remove all pointers
        
-  if(fOutputContainer){
-    fOutputContainer->Clear() ; 
-    delete fOutputContainer ;
-  }
-  if(fCFOutputContainer){
-    fCFOutputContainer->Clear() ; 
-    delete fCFOutputContainer ;
-  }
-
-  if(fPHOSgeom){
-    delete fPHOSgeom ;
-    fPHOSgeom=0x0 ;
-  }
+  if (AliAnalysisManager::GetAnalysisManager()->GetAnalysisType() !=
+      AliAnalysisManager::kProofAnalysis) {
 
-  if(fEMCALgeom){
-    delete fEMCALgeom ;
-    fEMCALgeom=0x0;
-  }
+    if(fOutputContainer){
+      fOutputContainer->Clear() ; 
+      delete fOutputContainer ;
+    }
+    if(fCFOutputContainer){
+      fCFOutputContainer->Clear() ; 
+      delete fCFOutputContainer ;
+    }
 
-  for(Int_t ivtx=0; ivtx<10; ivtx++){
-    if(fPHOSEvents[ivtx]){
-      delete fPHOSEvents[ivtx] ;
-      fPHOSEvents[ivtx]=0x0 ;
+    if(fPHOSgeom){
+      delete fPHOSgeom ;
+      fPHOSgeom=0x0 ;
     }
-    if(fEMCALEvents[ivtx]){
-      delete fEMCALEvents[ivtx] ;
-      fEMCALEvents[ivtx]=0x0 ;
+
+    if(fEMCALgeom){
+      delete fEMCALgeom ;
+      fEMCALgeom=0x0;
     }
-    if(fConvEvents[ivtx]){
-      delete fConvEvents[ivtx] ;
-      fConvEvents[ivtx]=0x0 ;
+
+    for(Int_t ivtx=0; ivtx<10; ivtx++){
+      if(fPHOSEvents[ivtx]){
+        delete fPHOSEvents[ivtx] ;
+          fPHOSEvents[ivtx]=0x0 ;
     }
-  }
-  for(Int_t i=0; i<6; i++)
-    if(fPHOSBadMap[i]){
-      delete fPHOSBadMap[i] ;
-      fPHOSBadMap[i]=0 ;
+      if(fEMCALEvents[ivtx]){
+        delete fEMCALEvents[ivtx] ;
+        fEMCALEvents[ivtx]=0x0 ;
+      }
+      if(fConvEvents[ivtx]){
+        delete fConvEvents[ivtx] ;
+        fConvEvents[ivtx]=0x0 ;
+      }
     }
-  for(Int_t i=0; i<10; i++)
-    if(fEMCALBadMap[i]){
-     delete fEMCALBadMap[i];
-     fEMCALBadMap[i]=0 ;
+    for(Int_t i=0; i<6; i++)
+      if(fPHOSBadMap[i]){
+        delete fPHOSBadMap[i] ;
+          fPHOSBadMap[i]=0 ;
+      }
+    for(Int_t i=0; i<10; i++)
+      if(fEMCALBadMap[i]){
+       delete fEMCALBadMap[i];
+       fEMCALBadMap[i]=0 ;
     }
-
+  } 
 }
 //_____________________________________________________
 void AliAnalysisTaskCaloConv::Init()
@@ -220,7 +240,6 @@ void AliAnalysisTaskCaloConv::UserExec(Option_t */*option*/)
   // Execute analysis for current event
   // First select conversion and calorimeter photons 
   // then construct inv. mass distributions
-  
   //First try to find Stack information.
   if(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()){
     if(static_cast<AliMCEventHandler*>(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler())->MCEvent())
@@ -228,8 +247,8 @@ void AliAnalysisTaskCaloConv::UserExec(Option_t */*option*/)
   }
 
 
+  AliESDInputHandler *esdHandler=dynamic_cast<AliESDInputHandler*>(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
   if(!fESDpid){
-    AliESDInputHandler *esdHandler=dynamic_cast<AliESDInputHandler*>(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
     if( esdHandler && esdHandler->GetESDpid()){
       fESDpid=new AliESDpid(*(esdHandler->GetESDpid())) ;
     } 
@@ -261,15 +280,87 @@ void AliAnalysisTaskCaloConv::UserExec(Option_t */*option*/)
     }
   }
 
+  if(!fESDtrackCuts){
+//    fESDtrackCuts= AliESDtrackCuts::GetStandardITSTPCTrackCuts2010();
+    fESDtrackCuts = new AliESDtrackCuts;
+
+    // TPC
+    fESDtrackCuts->SetMinNClustersTPC(70);
+    fESDtrackCuts->SetMaxChi2PerClusterTPC(4);
+    fESDtrackCuts->SetAcceptKinkDaughters(kFALSE);
+    fESDtrackCuts->SetRequireTPCRefit(kTRUE);
+    // ITS
+    fESDtrackCuts->SetRequireITSRefit(kTRUE);
+    fESDtrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,
+                                           AliESDtrackCuts::kAny);
+//    if(selPrimaries) {
+      // 7*(0.0026+0.0050/pt^1.01)
+      fESDtrackCuts->SetMaxDCAToVertexXYPtDep("0.0182+0.0350/pt^1.01");
+//    }
+    fESDtrackCuts->SetMaxDCAToVertexZ(2);
+    fESDtrackCuts->SetDCAToVertex2D(kFALSE);
+    fESDtrackCuts->SetRequireSigmaToVertex(kFALSE);
+
+
+
+/*
+    fESDtrackCuts = new AliESDtrackCuts("AliESDtrackCuts","AliESDtrackCuts");
+
+    fESDtrackCuts->SetAcceptKinkDaughters(kFALSE); 
+    fESDtrackCuts->SetMinNClustersTPC(70); 
+    fESDtrackCuts->SetMaxChi2PerClusterTPC(4); 
+    fESDtrackCuts->SetRequireTPCRefit(kTRUE); 
+    fESDtrackCuts->SetRequireITSRefit(kTRUE); 
+//    fESDtrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny); //TEMPORARY <-> REMOVE 
+*/
+  } 
 
 
   fESDEvent=(AliESDEvent*)InputEvent();
+  FillHistogram("hEventsTrig",0.5) ;
+  Bool_t isSelected =(esdHandler->IsEventSelected()& AliVEvent::kMB) == AliVEvent::kMB;
+  if(!isSelected){
+    printf("Not selected !!!!! \n") ;
+    PostData(1, fOutputContainer);
+    return ;
+  }
+  FillHistogram("hEventsTrig",1.5) ;
+
   //Take Only events with proper trigger
   //No trigger in MC data => no check
-  if(!fStack && !fESDEvent->IsTriggerClassFired("CINT1B-ABCE-NOPF-ALL")){
+//  if(!fStack && !fESDEvent->IsTriggerClassFired("CINT1B-ABCE-NOPF-ALL")){
+  //for LHC10e
+  if(!fStack && !fESDEvent->IsTriggerClassFired("CINT1-B-NOPF-ALLNOTRD")){
+printf("Trigger failed \n") ;
+    PostData(1, fOutputContainer);
     return ;
   } 
+  FillHistogram("hEventsTrig",2.5) ;
+
+  //checks if we have a prim vertex
+  if(fESDEvent->GetPrimaryVertex()->GetNContributors()<=0) {
+    PostData(1, fOutputContainer);
+    return ;
+  }
+  FillHistogram("hEventsTrig",3.5) ;
+
+  if(TMath::Abs(fESDEvent->GetPrimaryVertex()->GetZ())>10.){
+    PostData(1, fOutputContainer);
+    return ;
+  }
+  FillHistogram("hEventsTrig",4.5) ;
+
+
+  //Calculate charged multiplicity
+  Int_t trackCounter = 0; 
+  for (Int_t i=0;i<fESDEvent->GetNumberOfTracks();++i) { 
+    AliESDtrack *track = new AliESDtrack(*fESDEvent->GetTrack(i)) ;
+    if(fESDtrackCuts->AcceptTrack(track) &&  TMath::Abs(track->Eta())< 0.9) 
+      trackCounter++; 
+    delete track; 
+  } 
+  fCentr=trackCounter+0.5 ;
+  FillHistogram("hMult",fCentr) ;
        
   //Init geometry if not done yet
   InitGeometry();
@@ -345,8 +436,8 @@ void AliAnalysisTaskCaloConv::UserCreateOutputObjects()
   //========================================================
 
   //Adding the histograms to the output container
-  Int_t firstRun= 114700 ;
-  Int_t lastRun = 128000 ;
+  Int_t firstRun= 125000 ;
+  Int_t lastRun = 135000 ;
   Int_t nRuns =lastRun-firstRun+1 ;
 
   //Run QA histigrams
@@ -357,6 +448,7 @@ void AliAnalysisTaskCaloConv::UserCreateOutputObjects()
   fOutputContainer->Add(new TH1F("hRunEMCAL","EMCAL photons per run",nRuns,float(firstRun),float(lastRun))) ;
   fOutputContainer->Add(new TH1F("hVtxBin","Vtx distribution",10,0.,10.)) ;
   fOutputContainer->Add(new TH1F("hEvents","Events processed",1,0.,1.)) ;
+  fOutputContainer->Add(new TH1F("hEventsTrig","Events processed",10,0.,10.)) ;
 
   fOutputContainer->Add(new TH2F("hQA_PHOS_mod1_soft","number of clusters per cell",64,0.,64.,56,0.,56.)) ;
   fOutputContainer->Add(new TH2F("hQA_PHOS_mod2_soft","number of clusters per cell",64,0.,64.,56,0.,56.)) ;
@@ -390,37 +482,37 @@ void AliAnalysisTaskCaloConv::UserCreateOutputObjects()
   fOutputContainer->Add(new TH2F("hQA_EMCAL_SM8_hard","number of clusters per cell",24,0.,24,48,0.,48.)) ;
   fOutputContainer->Add(new TH2F("hQA_EMCAL_SM9_hard","number of clusters per cell",24,0.,24,48,0.,48.)) ;
 
-
-  //Check of geometry
-  fOutputContainer->Add(new TH3F("PHOS_beyond","PHOS clusters not in PHOS",200,-300.,300.,200,-500.,0.,200,-100.,100.)) ;
+  fOutputContainer->Add(new TH2F("hQA_ConvPhiEta","Number of V0s phi eta",100,0.,TMath::TwoPi(),40,-1.5,1.5)) ;
 
   fOutputContainer->Add(new TH2F("hdEdx","dEdx of acceptaed electrons",1000,0.,10.,150,0.,150.)) ;
 
+  fOutputContainer->Add(new TH1F("hMult","Multiplicity",200,0.,200.)) ;
+
   Int_t npt=200 ;
   Double_t ptmax=20. ;
   //Calibration of PHOS
-  fOutputContainer->Add(new TH3F("PHOS_mod1_th1","Inv.Mass distr. per channel",64,0.,64,56,0.,56,200,0.,1.)) ;
-  fOutputContainer->Add(new TH3F("PHOS_mod2_th1","Inv.Mass distr. per channel",64,0.,64,56,0.,56,200,0.,1.)) ;
-  fOutputContainer->Add(new TH3F("PHOS_mod3_th1","Inv.Mass distr. per channel",64,0.,64,56,0.,56,200,0.,1.)) ;
-  fOutputContainer->Add(new TH3F("PHOS_mod4_th1","Inv.Mass distr. per channel",64,0.,64,56,0.,56,200,0.,1.)) ;
-  fOutputContainer->Add(new TH3F("PHOS_mod5_th1","Inv.Mass distr. per channel",64,0.,64,56,0.,56,200,0.,1.)) ;
-
-  fOutputContainer->Add(new TH3F("PHOS_mod1_th2","Inv.Mass distr. per channel",64,0.,64,56,0.,56,200,0.,1.)) ;
-  fOutputContainer->Add(new TH3F("PHOS_mod2_th2","Inv.Mass distr. per channel",64,0.,64,56,0.,56,200,0.,1.)) ;
-  fOutputContainer->Add(new TH3F("PHOS_mod3_th2","Inv.Mass distr. per channel",64,0.,64,56,0.,56,200,0.,1.)) ;
-  fOutputContainer->Add(new TH3F("PHOS_mod4_th2","Inv.Mass distr. per channel",64,0.,64,56,0.,56,200,0.,1.)) ;
-  fOutputContainer->Add(new TH3F("PHOS_mod5_th2","Inv.Mass distr. per channel",64,0.,64,56,0.,56,200,0.,1.)) ;
+  fOutputContainer->Add(new TH3F("PHOS_mod1_th1","Inv.Mass distr. per channel",64,0.,64,56,0.,56,100,0.,0.5)) ;
+  fOutputContainer->Add(new TH3F("PHOS_mod2_th1","Inv.Mass distr. per channel",64,0.,64,56,0.,56,100,0.,0.5)) ;
+  fOutputContainer->Add(new TH3F("PHOS_mod3_th1","Inv.Mass distr. per channel",64,0.,64,56,0.,56,100,0.,0.5)) ;
+  fOutputContainer->Add(new TH3F("PHOS_mod4_th1","Inv.Mass distr. per channel",64,0.,64,56,0.,56,100,0.,0.5)) ;
+  fOutputContainer->Add(new TH3F("PHOS_mod5_th1","Inv.Mass distr. per channel",64,0.,64,56,0.,56,100,0.,0.5)) ;
+
+  fOutputContainer->Add(new TH3F("PHOS_mod1_th2","Inv.Mass distr. per channel",64,0.,64,56,0.,56,100,0.,0.5)) ;
+  fOutputContainer->Add(new TH3F("PHOS_mod2_th2","Inv.Mass distr. per channel",64,0.,64,56,0.,56,100,0.,0.5)) ;
+  fOutputContainer->Add(new TH3F("PHOS_mod3_th2","Inv.Mass distr. per channel",64,0.,64,56,0.,56,100,0.,0.5)) ;
+  fOutputContainer->Add(new TH3F("PHOS_mod4_th2","Inv.Mass distr. per channel",64,0.,64,56,0.,56,100,0.,0.5)) ;
+  fOutputContainer->Add(new TH3F("PHOS_mod5_th2","Inv.Mass distr. per channel",64,0.,64,56,0.,56,100,0.,0.5)) ;
 
   //Pi0 histograms
   //Vary Conversion cuts
   fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_OnFly","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_Offline","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_On_Kink","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_Off_Kink","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH3F("PHOS_Re_mvsPt_OnFly_mult","Mass vs pt",400,0.,1.,npt,0.,ptmax,150,0.,150.)) ;
+  fOutputContainer->Add(new TH3F("PHOS_Re_mvsPt_Offline_mult","Mass vs pt",400,0.,1.,npt,0.,ptmax,150,0.,150.)) ;
   fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_On_dEdx","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_Off_dEdx","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_On_Prob","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_Off_Prob","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
+//  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_On_Prob","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
+//  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_Off_Prob","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_On_R120","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_Off_R120","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_On_Z","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
@@ -430,16 +522,18 @@ void AliAnalysisTaskCaloConv::UserCreateOutputObjects()
   fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_On_Eta","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_Off_Eta","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_On_Wcut","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_On_Wcut_Neu","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_Off_Wcut","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_Off_Wcut_Neu","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_On_ArmQt","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_Off_ArmQt","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
 
   fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_OnFly","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_Offline","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_On_Kink","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_Off_Kink","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_On_dEdx","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_Off_dEdx","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_On_Prob","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_Off_Prob","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
+//  fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_On_Prob","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
+//  fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_Off_Prob","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_On_R120","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_Off_R120","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_On_Z","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
@@ -450,15 +544,19 @@ void AliAnalysisTaskCaloConv::UserCreateOutputObjects()
   fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_Off_Eta","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_On_Wcut","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_Off_Wcut","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_On_ArmQt","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_Off_ArmQt","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
 
   fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_OnFly","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_Offline","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_On_Kink","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_Off_Kink","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH3F("EMCAL_Re_mvsPt_OnFly_mult","Mass vs pt",400,0.,1.,npt,0.,ptmax,30,0.,60.)) ;
+  fOutputContainer->Add(new TH3F("EMCAL_Re_mvsPt_Offline_mult","Mass vs pt",400,0.,1.,npt,0.,ptmax,30,0.,60.)) ;
+  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_On_ArmQt","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_Off_ArmQt","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_On_dEdx","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_Off_dEdx","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_On_Prob","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_Off_Prob","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
+//  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_On_Prob","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
+//  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_Off_Prob","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_On_R120","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_Off_R120","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_On_Z","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
@@ -472,12 +570,12 @@ void AliAnalysisTaskCaloConv::UserCreateOutputObjects()
 
   fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_OnFly","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_Offline","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_On_Kink","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_Off_Kink","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_On_ArmQt","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_Off_ArmQt","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_On_dEdx","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_Off_dEdx","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_On_Prob","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_Off_Prob","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
+//  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_On_Prob","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
+//  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_Off_Prob","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_On_R120","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_Off_R120","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_On_Z","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
@@ -493,87 +591,37 @@ void AliAnalysisTaskCaloConv::UserCreateOutputObjects()
   fOutputContainer->Add(new TH3F("PHOS_Re_mvsPt_alpha","Mass vs pt vs PHOS E",400,0.,1.,npt,0.,ptmax,10,0.,1.)) ;
   fOutputContainer->Add(new TH3F("PHOS_Re_mvsPt_E","Mass vs pt vs PHOS E",400,0.,1.,npt,0.,ptmax,100,0.,10.)) ;
   fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_all","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_all_dist","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_Disp","Mass vs pt, disp cut",400,0.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_TOF","Mass vs pt, TOF cut",400,0.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_Neutral","Mass vs pt, Neutral cut",400,0.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_DispNeutral","Mass vs pt, Disp & neutral cut",400,0.,1.,npt,0.,ptmax)) ;
 
-  //PHOS PID module-by-module
-  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_mod1_all","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_mod2_all","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_mod3_all","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_mod4_all","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_mod5_all","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_mod1_Disp","Mass vs pt, disp cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_mod2_Disp","Mass vs pt, disp cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_mod3_Disp","Mass vs pt, disp cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_mod4_Disp","Mass vs pt, disp cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_mod5_Disp","Mass vs pt, disp cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_mod1_TOF","Mass vs pt, TOF cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_mod2_TOF","Mass vs pt, TOF cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_mod3_TOF","Mass vs pt, TOF cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_mod4_TOF","Mass vs pt, TOF cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_mod5_TOF","Mass vs pt, TOF cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_mod1_Neutral","Mass vs pt, Neutral cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_mod2_Neutral","Mass vs pt, Neutral cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_mod3_Neutral","Mass vs pt, Neutral cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_mod4_Neutral","Mass vs pt, Neutral cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_mod5_Neutral","Mass vs pt, Neutral cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_mod1_DispNeutral","Mass vs pt, Disp & neutral cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_mod2_DispNeutral","Mass vs pt, Disp & neutral cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_mod3_DispNeutral","Mass vs pt, Disp & neutral cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_mod4_DispNeutral","Mass vs pt, Disp & neutral cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_mod5_DispNeutral","Mass vs pt, Disp & neutral cut",400,0.,1.,npt,0.,ptmax)) ;
-
   fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_all","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_all_dist","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_Disp","Mass vs pt, disp cut",400,0.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_TOF","Mass vs pt, TOF cut",400,0.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_Neutral","Mass vs pt, Neutral cut",400,0.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_DispNeutral","Mass vs pt, Disp & neutral cut",400,0.,1.,npt,0.,ptmax)) ;
 
-  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_mod1_single","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_mod2_single","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_mod3_single","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_mod4_single","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Re_mvsPt_mod5_single","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-
-  fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_mod1_all","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_mod2_all","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_mod3_all","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_mod4_all","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_mod5_all","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_mod1_Disp","Mass vs pt, disp cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_mod2_Disp","Mass vs pt, disp cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_mod3_Disp","Mass vs pt, disp cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_mod4_Disp","Mass vs pt, disp cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_mod5_Disp","Mass vs pt, disp cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_mod1_TOF","Mass vs pt, TOF cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_mod2_TOF","Mass vs pt, TOF cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_mod3_TOF","Mass vs pt, TOF cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_mod4_TOF","Mass vs pt, TOF cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_mod5_TOF","Mass vs pt, TOF cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_mod1_Neutral","Mass vs pt, Neutral cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_mod2_Neutral","Mass vs pt, Neutral cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_mod3_Neutral","Mass vs pt, Neutral cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_mod4_Neutral","Mass vs pt, Neutral cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_mod5_Neutral","Mass vs pt, Neutral cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_mod1_DispNeutral","Mass vs pt, Disp & neutral cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_mod2_DispNeutral","Mass vs pt, Disp & neutral cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_mod3_DispNeutral","Mass vs pt, Disp & neutral cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_mod4_DispNeutral","Mass vs pt, Disp & neutral cut",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("PHOS_Mi_mvsPt_mod5_DispNeutral","Mass vs pt, Disp & neutral cut",400,0.,1.,npt,0.,ptmax)) ;
+  char key[155] ;
+  for(Int_t mod=1; mod<=5;mod++){
+    snprintf(key,155,"PHOS_Re_mvsPt_mod%d_single",mod) ;
+    fOutputContainer->Add(new TH2F(key,"Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
+    snprintf(key,155,"PHOS_Re_mvsPt_mod%d_all",mod) ;
+    fOutputContainer->Add(new TH2F(key,"Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
+  }
 
   //Single photon spectrum
   //Conversion
-  fOutputContainer->Add(new TH1F("Single_conv","Single photon spectrum",npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH1F("Single_conv_OnFly","Single photon spectrum",npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH1F("Single_conv_Offline","Single photon spectrum",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH1F("Single_conv_On_Kink","Single photon spectrum",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH1F("Single_conv_Off_Kink","Single photon spectrum",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("Single_conv_On_ArmQt","Single photon spectrum",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("Single_conv_Off_ArmQt","Single photon spectrum",npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH1F("Single_conv_On_dEdx","Single photon spectrum",npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH1F("Single_conv_Off_dEdx","Single photon spectrum",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH1F("Single_conv_On_Prob","Single photon spectrum",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH1F("Single_conv_Off_Prob","Single photon spectrum",npt,0.,ptmax)) ;
+//  fOutputContainer->Add(new TH1F("Single_conv_On_Prob","Single photon spectrum",npt,0.,ptmax)) ;
+//  fOutputContainer->Add(new TH1F("Single_conv_Off_Prob","Single photon spectrum",npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH1F("Single_conv_On_R120","Single photon spectrum",npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH1F("Single_conv_Off_R120","Single photon spectrum",npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH1F("Single_conv_On_Z","Single photon spectrum",npt,0.,ptmax)) ;
@@ -586,145 +634,134 @@ void AliAnalysisTaskCaloConv::UserCreateOutputObjects()
   fOutputContainer->Add(new TH1F("Single_conv_Off_Wcut","Single photon spectrum",npt,0.,ptmax)) ;
 
   //PHOS
-  fOutputContainer->Add(new TH1F("PHOS_single_mod1_all","Single photon spectrum",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH1F("PHOS_single_mod2_all","Single photon spectrum",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH1F("PHOS_single_mod3_all","Single photon spectrum",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH1F("PHOS_single_mod4_all","Single photon spectrum",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH1F("PHOS_single_mod5_all","Single photon spectrum",npt,0.,ptmax)) ;
-
-  fOutputContainer->Add(new TH1F("PHOS_single_mod1_disp","Single photon spectrum",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH1F("PHOS_single_mod2_disp","Single photon spectrum",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH1F("PHOS_single_mod3_disp","Single photon spectrum",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH1F("PHOS_single_mod4_disp","Single photon spectrum",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH1F("PHOS_single_mod5_disp","Single photon spectrum",npt,0.,ptmax)) ;
-
-  fOutputContainer->Add(new TH1F("PHOS_single_mod1_neutral","Single photon spectrum",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH1F("PHOS_single_mod2_neutral","Single photon spectrum",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH1F("PHOS_single_mod3_neutral","Single photon spectrum",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH1F("PHOS_single_mod4_neutral","Single photon spectrum",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH1F("PHOS_single_mod5_neutral","Single photon spectrum",npt,0.,ptmax)) ;
-
-  fOutputContainer->Add(new TH1F("PHOS_single_mod1_dispneutral","Single photon spectrum",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH1F("PHOS_single_mod2_dispneutral","Single photon spectrum",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH1F("PHOS_single_mod3_dispneutral","Single photon spectrum",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH1F("PHOS_single_mod4_dispneutral","Single photon spectrum",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH1F("PHOS_single_mod5_dispneutral","Single photon spectrum",npt,0.,ptmax)) ;
-
-  fOutputContainer->Add(new TH1F("PHOS_single_mod1_dist1","Single photon spectrum",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH1F("PHOS_single_mod2_dist1","Single photon spectrum",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH1F("PHOS_single_mod3_dist1","Single photon spectrum",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH1F("PHOS_single_mod4_dist1","Single photon spectrum",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH1F("PHOS_single_mod5_dist1","Single photon spectrum",npt,0.,ptmax)) ;
-
-  fOutputContainer->Add(new TH1F("PHOS_single_mod1_dist2","Single photon spectrum",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH1F("PHOS_single_mod2_dist2","Single photon spectrum",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH1F("PHOS_single_mod3_dist2","Single photon spectrum",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH1F("PHOS_single_mod4_dist2","Single photon spectrum",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH1F("PHOS_single_mod5_dist2","Single photon spectrum",npt,0.,ptmax)) ;
-
-  fOutputContainer->Add(new TH3F("EMCAL_Ep_0","PHOS E/p ratio",24,0.,24,48,0.,48,200,0.,2.)) ;
-  fOutputContainer->Add(new TH3F("EMCAL_Ep_1","PHOS E/p ratio",24,0.,24,48,0.,48,200,0.,2.)) ;
-  fOutputContainer->Add(new TH3F("EMCAL_Ep_2","PHOS E/p ratio",24,0.,24,48,0.,48,200,0.,2.)) ;
-  fOutputContainer->Add(new TH3F("EMCAL_Ep_3","PHOS E/p ratio",24,0.,24,48,0.,48,200,0.,2.)) ;
-  fOutputContainer->Add(new TH3F("EMCAL_EpPE","PHOS E/p vs E vs p",200,0.,2.,npt,0.,ptmax,npt,0.,ptmax)) ;
-
-  fOutputContainer->Add(new TH3F("EMCAL_beyond","EMCAL clusters not in EMCAL",200,-300.,300.,200,-500.,0.,200,-100.,100.)) ;
-
-  fOutputContainer->Add(new TH3F("EMCAL_mod0_th1","Inv.Mass distr. per channel",24,0.,24,48,0.,48,200,0.,1.)) ;
-  fOutputContainer->Add(new TH3F("EMCAL_mod1_th1","Inv.Mass distr. per channel",24,0.,24,48,0.,48,200,0.,1.)) ;
-  fOutputContainer->Add(new TH3F("EMCAL_mod2_th1","Inv.Mass distr. per channel",24,0.,24,48,0.,48,200,0.,1.)) ;
-  fOutputContainer->Add(new TH3F("EMCAL_mod3_th1","Inv.Mass distr. per channel",24,0.,24,48,0.,48,200,0.,1.)) ;
-
-  fOutputContainer->Add(new TH3F("EMCAL_mod0_th2","Inv.Mass distr. per channel",24,0.,24,48,0.,48,200,0.,1.)) ;
-  fOutputContainer->Add(new TH3F("EMCAL_mod1_th2","Inv.Mass distr. per channel",24,0.,24,48,0.,48,200,0.,1.)) ;
-  fOutputContainer->Add(new TH3F("EMCAL_mod2_th2","Inv.Mass distr. per channel",24,0.,24,48,0.,48,200,0.,1.)) ;
-  fOutputContainer->Add(new TH3F("EMCAL_mod3_th2","Inv.Mass distr. per channel",24,0.,24,48,0.,48,200,0.,1.)) ;
-
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_mod0_single","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_mod1_single","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_mod2_single","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_mod3_single","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_mod0_all","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_mod1_all","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_mod2_all","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_mod3_all","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_mod4_all","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_mod5_all","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_mod0_Disp","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_mod1_Disp","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_mod2_Disp","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_mod3_Disp","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_mod4_Disp","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_mod5_Disp","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_mod0_TOF","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_mod1_TOF","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_mod2_TOF","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_mod3_TOF","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_mod4_TOF","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_mod5_TOF","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_mod0_Neutral","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_mod1_Neutral","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_mod2_Neutral","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_mod3_Neutral","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_mod4_Neutral","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_mod5_Neutral","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_mod0_DispNeutral","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_mod1_DispNeutral","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_mod2_DispNeutral","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_mod3_DispNeutral","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_mod4_DispNeutral","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Re_mvsPt_mod5_DispNeutral","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-
-  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_mod0_all","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_mod1_all","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_mod2_all","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_mod3_all","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_mod4_all","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_mod5_all","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_mod0_Disp","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_mod1_Disp","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_mod2_Disp","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_mod3_Disp","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_mod4_Disp","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_mod5_Disp","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_mod0_TOF","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_mod1_TOF","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_mod2_TOF","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_mod3_TOF","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_mod4_TOF","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_mod5_TOF","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_mod0_Neutral","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_mod1_Neutral","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_mod2_Neutral","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_mod3_Neutral","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_mod4_Neutral","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_mod5_Neutral","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_mod0_DispNeutral","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_mod1_DispNeutral","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_mod2_DispNeutral","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_mod3_DispNeutral","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_mod4_DispNeutral","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("EMCAL_Mi_mvsPt_mod5_DispNeutral","Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH2F("PHOS_single_all_mult","Single photon spectrum",npt,0.,ptmax,150,0.,150.)) ;
+  fOutputContainer->Add(new TH2F("PHOS_single_disp_mult","Single photon spectrum",npt,0.,ptmax,150,0.,150.)) ;
+  fOutputContainer->Add(new TH2F("PHOS_single_neu_mult","Single photon spectrum",npt,0.,ptmax,150,0.,150.)) ;
+   
+  for(Int_t mod=1; mod<=5;mod++){
+    snprintf(key,155,"PHOS_single_mod%d_all",mod) ;
+    fOutputContainer->Add(new TH1F(key,"Single photon spectrum",npt,0.,ptmax)) ;
+    snprintf(key,155,"PHOS_single_mod%d_disp",mod) ;
+    fOutputContainer->Add(new TH1F(key,"Single photon spectrum",npt,0.,ptmax)) ;
+    snprintf(key,155,"PHOS_single_mod%d_neutral",mod) ;
+    fOutputContainer->Add(new TH1F(key,"Single photon spectrum",npt,0.,ptmax)) ;
+    snprintf(key,155,"PHOS_single_mod%d_dispneutral",mod) ;
+    fOutputContainer->Add(new TH1F(key,"Single photon spectrum",npt,0.,ptmax)) ;
+    snprintf(key,155,"PHOS_single_mod%d_dist1",mod) ;
+    fOutputContainer->Add(new TH1F(key,"Single photon spectrum",npt,0.,ptmax)) ;
+    snprintf(key,155,"PHOS_single_mod%d_dist2",mod) ;
+    fOutputContainer->Add(new TH1F(key,"Single photon spectrum",npt,0.,ptmax)) ;
+  }
+
+  for(Int_t mod=0; mod<4;mod++){
+    snprintf(key,155,"EMCAL_mod%d_th1",mod) ;
+    fOutputContainer->Add(new TH3F(key,"Inv.Mass distr. per channel",24,0.,24,48,0.,48,100,0.,0.5)) ;
+    snprintf(key,155,"EMCAL_mod%d_th2",mod) ;
+    fOutputContainer->Add(new TH3F(key,"Inv.Mass distr. per channel",24,0.,24,48,0.,48,100,0.,0.5)) ;
+
+    snprintf(key,155,"EMCAL_Re_mvsPt_mod%d_single",mod) ;
+    fOutputContainer->Add(new TH2F(key,"Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
+
+    snprintf(key,155,"EMCAL_Re_mvsPt_mod%d_all",mod) ;
+    fOutputContainer->Add(new TH2F(key,"Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
+    snprintf(key,155,"EMCAL_Re_mvsPt_mod%d_Disp",mod) ;
+    fOutputContainer->Add(new TH2F(key,"Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
+    snprintf(key,155,"EMCAL_Re_mvsPt_mod%d_TOF",mod) ;
+    fOutputContainer->Add(new TH2F(key,"Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
+    snprintf(key,155,"EMCAL_Re_mvsPt_mod%d_Neutral",mod) ;
+    fOutputContainer->Add(new TH2F(key,"Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
+    snprintf(key,155,"EMCAL_Re_mvsPt_mod%d_DispNeutral",mod) ;
+    fOutputContainer->Add(new TH2F(key,"Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
+
+    snprintf(key,155,"EMCAL_Mi_mvsPt_mod%d_all",mod) ;
+    fOutputContainer->Add(new TH2F(key,"Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
+    snprintf(key,155,"EMCAL_Mi_mvsPt_mod%d_Disp",mod) ;
+    fOutputContainer->Add(new TH2F(key,"Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
+    snprintf(key,155,"EMCAL_Mi_mvsPt_mod%d_TOF",mod) ;
+    fOutputContainer->Add(new TH2F(key,"Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
+    snprintf(key,155,"EMCAL_Mi_mvsPt_mod%d_Neutral",mod) ;
+    fOutputContainer->Add(new TH2F(key,"Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
+    snprintf(key,155,"EMCAL_Mi_mvsPt_mod%d_DispNeutral",mod) ;
+    fOutputContainer->Add(new TH2F(key,"Mass vs pt",400,0.,1.,npt,0.,ptmax)) ;
+  }
 
   //MC info
-  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_unitEta","Primary #pi^{0}",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH1F("hMC_CaloConv_allPi0","Primary #pi^{0}",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH2F("hMC_CaloConv_pi0_unitEta","Primary #pi^{0}",npt,0.,ptmax,150,0.,150.)) ;
+  fOutputContainer->Add(new TH2F("hMC_CaloConv_eta_unitEta","Primary #pi^{0}",npt,0.,ptmax,150,0.,150.)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_allpi0","Primary #pi^{0}",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_alleta","Primary #pi^{0}",npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0PHOSacc","#pi^{0} decayed in PHOS acc",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_etaPHOSacc","#pi^{0} decayed in PHOS acc",npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0EMCALacc","#pi^{0} decayed in EMCAL acc",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_etaEMCALacc","#pi^{0} decayed in EMCAL acc",npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_PHOS_conv","#pi^{0} decayed in PHOS acc asnd conv. photon",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_eta_PHOS_conv","#pi^{0} decayed in PHOS acc asnd conv. photon",npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_EMCAL_conv","#pi^{0} decayed in EMCAL acc asnd conv. photon",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_eta_EMCAL_conv","#pi^{0} decayed in EMCAL acc asnd conv. photon",npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_bothphot_conv","#pi^{0} both photons converted",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0__convPhotInCalo","#pi^{0} photon in calo converted",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_v0_PHOSacc","#pi^{0} photon converted and V0 found",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_v0_EMCALacc","#pi^{0} photon converted and V0 found",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_v0_PHOSclu","#pi^{0} V0 and cluster in PHOS found",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_v0_EMCALclu_ptRec","#pi^{0} V0 and cluster in EMCAL found (rec pt)",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_v0_PHOSclu_ptRec","#pi^{0} V0 and cluster in PHOS found(rec pt)",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_v0_EMCALclu","#pi^{0} V0 and cluster in EMCAL found",npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("hMC_CaloConv_pi0_v0_PHOSclu_mvsPt","m vs pt for rec pi0s",400,0.,1.,npt,0.,ptmax)) ;
-  fOutputContainer->Add(new TH2F("hMC_CaloConv_pi0_v0_EMCALclu_mvsPt","m vs pt for rec pi0s",400,0.,1.,npt,0.,ptmax)) ;
-
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_eta_bothphot_conv","#pi^{0} both photons converted",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_convPhotInCalo","#pi^{0} photon in calo converted",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_eta_convPhotInCalo","#pi^{0} photon in calo converted",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_v0onfly_PHOSacc","#pi^{0} photon converted and V0 found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_eta_v0onfly_PHOSacc","#pi^{0} photon converted and V0 found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_v0offline_PHOSacc","#pi^{0} photon converted and V0 found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_eta_v0offline_PHOSacc","#pi^{0} photon converted and V0 found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_v0onfly_EMCALacc","#pi^{0} photon converted and V0 found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_eta_v0onfly_EMCALacc","#pi^{0} photon converted and V0 found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_v0offline_EMCALacc","#pi^{0} photon converted and V0 found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_eta_v0offline_EMCALacc","#pi^{0} photon converted and V0 found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_v0onfly_PHOSclu","#pi^{0} V0 and cluster in PHOS found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_eta_v0onfly_PHOSclu","#pi^{0} V0 and cluster in PHOS found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_v0onfly_PHOSclu_pid","#pi^{0} V0 and cluster in PHOS found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_eta_v0onfly_PHOSclu_pid","#pi^{0} V0 and cluster in PHOS found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_v0offline_PHOSclu","#pi^{0} V0 and cluster in PHOS found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_eta_v0offline_PHOSclu","#pi^{0} V0 and cluster in PHOS found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_v0offline_PHOSclu_pid","#pi^{0} V0 and cluster in PHOS found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_eta_v0offline_PHOSclu_pid","#pi^{0} V0 and cluster in PHOS found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_v0onfly_PHOSclu_good","#pi^{0} V0 and cluster in PHOS found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_eta_v0onfly_PHOSclu_good","#pi^{0} V0 and cluster in PHOS found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_v0offline_PHOSclu_good","#pi^{0} V0 and cluster in PHOS found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_eta_v0offline_PHOSclu_good","#pi^{0} V0 and cluster in PHOS found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_v0onfly_PHOSclu_mod1","#pi^{0} V0 and cluster in PHOS found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_eta_v0onfly_PHOSclu_mod1","#pi^{0} V0 and cluster in PHOS found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_v0onfly_PHOSclu_mod2","#pi^{0} V0 and cluster in PHOS found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_eta_v0onfly_PHOSclu_mod2","#pi^{0} V0 and cluster in PHOS found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_v0onfly_PHOSclu_mod3","#pi^{0} V0 and cluster in PHOS found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_eta_v0onfly_PHOSclu_mod3","#pi^{0} V0 and cluster in PHOS found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_v0onfly_PHOSclu_mod4","#pi^{0} V0 and cluster in PHOS found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_eta_v0onfly_PHOSclu_mod4","#pi^{0} V0 and cluster in PHOS found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_v0onfly_PHOSclu_mod5","#pi^{0} V0 and cluster in PHOS found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_eta_v0onfly_PHOSclu_mod5","#pi^{0} V0 and cluster in PHOS found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_v0offline_PHOSclu_mod1","#pi^{0} V0 and cluster in PHOS found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_eta_v0offline_PHOSclu_mod1","#pi^{0} V0 and cluster in PHOS found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_v0offline_PHOSclu_mod2","#pi^{0} V0 and cluster in PHOS found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_eta_v0offline_PHOSclu_mod2","#pi^{0} V0 and cluster in PHOS found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_v0offline_PHOSclu_mod3","#pi^{0} V0 and cluster in PHOS found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_eta_v0offline_PHOSclu_mod3","#pi^{0} V0 and cluster in PHOS found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_v0offline_PHOSclu_mod4","#pi^{0} V0 and cluster in PHOS found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_eta_v0offline_PHOSclu_mod4","#pi^{0} V0 and cluster in PHOS found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_v0offline_PHOSclu_mod5","#pi^{0} V0 and cluster in PHOS found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_eta_v0offline_PHOSclu_mod5","#pi^{0} V0 and cluster in PHOS found",npt,0.,ptmax)) ;
+
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_v0on_PHOSclu_ptRec","#pi^{0} V0 and cluster in PHOS found(rec pt)",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_eta_v0on_PHOSclu_ptRec","#pi^{0} V0 and cluster in PHOS found(rec pt)",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_v0off_PHOSclu_ptRec","#pi^{0} V0 and cluster in PHOS found(rec pt)",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_eta_v0off_PHOSclu_ptRec","#pi^{0} V0 and cluster in PHOS found(rec pt)",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH2F("hMC_CaloConv_pi0_v0on_PHOSclu_mvsPt","m vs pt for rec pi0s",400,0.,1.,npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH2F("hMC_CaloConv_eta_v0on_PHOSclu_mvsPt","m vs pt for rec pi0s",400,0.,1.,npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH2F("hMC_CaloConv_pi0_v0off_PHOSclu_mvsPt","m vs pt for rec pi0s",400,0.,1.,npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH2F("hMC_CaloConv_eta_v0off_PHOSclu_mvsPt","m vs pt for rec pi0s",400,0.,1.,npt,0.,ptmax)) ;
+
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_v0off_EMCALclu_ptRec","#pi^{0} V0 and cluster in EMCAL found (rec pt)",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_v0on_EMCALclu_ptRec","#pi^{0} V0 and cluster in EMCAL found (rec pt)",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_v0onfly_EMCALclu","#pi^{0} V0 and cluster in EMCAL found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_v0onfly_EMCALclu_pid","#pi^{0} V0 and cluster in EMCAL found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_v0offline_EMCALclu","#pi^{0} V0 and cluster in EMCAL found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_v0offline_EMCALclu_pid","#pi^{0} V0 and cluster in EMCAL found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_v0onfly_EMCALclu_good","#pi^{0} V0 and cluster in EMCAL found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_pi0_v0offline_EMCALclu_good","#pi^{0} V0 and cluster in EMCAL found",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH2F("hMC_CaloConv_pi0_v0on_EMCALclu_mvsPt","m vs pt for rec pi0s",400,0.,1.,npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH2F("hMC_CaloConv_pi0_v0off_EMCALclu_mvsPt","m vs pt for rec pi0s",400,0.,1.,npt,0.,ptmax)) ;
 
   fOutputContainer->Add(new TH3F("hMC_Resid_PHOS_Phot_mvsPt","m vs pt for rec pi0s",400,0.,1.,npt,0.,ptmax,10,0.,1.)) ;
   fOutputContainer->Add(new TH3F("hMC_Resid_PHOS_Pi0_mvsPt","m vs pt for rec pi0s",400,0.,1.,npt,0.,ptmax,10,0.,1.)) ;
@@ -749,13 +786,37 @@ void AliAnalysisTaskCaloConv::UserCreateOutputObjects()
   fOutputContainer->Add(new TH1F("hMC_CaloConv_gamma_v0","Converted photons with V0",npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("hMC_CaloConv_gamma_v0_devsE","Converted photons with V0",200,-1.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH1F("hMC_CaloConv_gamma_PHOSclu","Photons with cluster in PHOS",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_gamma_PHOSclu_dist1","Photons with cluster in PHOS",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_gamma_PHOSclu_dist2","Photons with cluster in PHOS",npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH1F("hMC_CaloConv_gamma_EMCALclu","Photons with cluster in EMCAL",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_gamma_EMCALclu_dist1","Photons with cluster in EMCAL",npt,0.,ptmax)) ;
+  fOutputContainer->Add(new TH1F("hMC_CaloConv_gamma_EMCALclu_dist2","Photons with cluster in EMCAL",npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH1F("hMC_CaloConv_gamma_PHOSclu_recE","Photons with cluster in PHOS",npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH1F("hMC_CaloConv_gamma_EMCALclu_recE","Photons with cluster in EMCAL",npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("hMC_CaloConv_gamma_PHOSclu_devsE","Photons with cluster in PHOS",200,-1.,1.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("hMC_CaloConv_gamma_EMCALclu_devsE","Photons with cluster in EMCAL",200,-1.,1.,npt,0.,ptmax)) ;
        
 
+  //Non-linearity test
+  char keym[55] ;
+  for(Int_t iw=0;iw<10;iw++){ //resolution
+    for(Int_t in=0;in<10;in++){
+      snprintf(keym,55,"hMC_nonlinearity_w%d_n%d",iw,in) ;
+      fOutputContainer->Add(new TH2F(keym,"m vs pt, nonlinearity test" ,200,0.,0.5,npt,0.,ptmax)) ;
+      snprintf(keym,55,"hMC_nonlinearity_ConvPHOS_w%d_n%d",iw,in) ;
+      fOutputContainer->Add(new TH2F(keym,"m vs pt, nonlinearity test" ,200,0.,0.5,npt,0.,ptmax)) ;
+      snprintf(keym,55,"hMC_nonlinearity_EMCAL_w%d_n%d",iw,in) ;
+      fOutputContainer->Add(new TH2F(keym,"m vs pt, nonlinearity test" ,200,0.,0.5,npt,0.,ptmax)) ;
+      snprintf(keym,55,"hMC_CaloConv_pi0_v0onfly_PHOSclu_w%d_n%d",iw,in) ;
+      fOutputContainer->Add(new TH1F(keym,"#pi^{0} V0 and cluster in PHOS found",npt,0.,ptmax)) ;
+      snprintf(keym,55,"hMC_CaloConv_pi0_v0onfly_ConvPHOSclu_w%d_n%d",iw,in) ;
+      fOutputContainer->Add(new TH1F(keym,"#pi^{0} V0 and cluster in PHOS found",npt,0.,ptmax)) ;
+      snprintf(keym,55,"hMC_CaloConv_pi0_v0onfly_EMCALclu_w%d_n%d",iw,in) ;
+      fOutputContainer->Add(new TH1F(keym,"#pi^{0} V0 and cluster in PHOS found",npt,0.,ptmax)) ;
+    }
+  }
+
+
   fOutputContainer->Add(new TH3F("All_chi2_eta_pt","MC chi2 vs eta vs phi",100,0.,100.,200,-2.,2.,npt,0.,ptmax)) ;
   fOutputContainer->Add(new TH2F("All_w_vs_m","MC w vs m",300,0.,TMath::Pi(),400,0.,1.)) ;
   fOutputContainer->Add(new TH3F("MC_V0_pt_eta_phi","MC pt vs eta vs phi",npt,0.,ptmax,200,-2.,2.,200,0.,TMath::TwoPi())) ;
@@ -822,10 +883,12 @@ void AliAnalysisTaskCaloConv::SelectPHOSPhotons(){
       continue ;
     TLorentzVector p ;
     clu ->GetMomentum(p ,vtx);
-    if(p.Energy()<0.25)
+    if(p.Energy()<0.25){
       continue ;
-    if(clu->GetNCells()<=2)
+    }
+    if(clu->GetNCells()<=2){
       continue ;
+    }
 
     Bool_t isNeutral = kTRUE ;
     Bool_t isDispOK = kTRUE ;
@@ -851,7 +914,6 @@ void AliAnalysisTaskCaloConv::SelectPHOSPhotons(){
     TVector3 global(xyz) ;
     Int_t relid[4] ;
     if(!fPHOSgeom->GlobalPos2RelId(global,relid)){
-      FillHistogram("PHOS_beyond",xyz[0],xyz[1],xyz[2]) ;
       printf("PHOS_beyond: x=%f, y=%f, z=%f \n",xyz[0],xyz[1],xyz[2]) ;
       continue ;
     }
@@ -861,10 +923,13 @@ void AliAnalysisTaskCaloConv::SelectPHOSPhotons(){
     if(!IsGoodChannel("PHOS",iMod,iX,iZ))
       continue ;
 
+    Bool_t closeToBad=(clu->GetDistanceToBadChannel()>fBadDistCutPHOS) ;
+
     p.SetBit(kCaloPIDdisp,isDispOK) ;
     p.SetBit(kCaloPIDtof,isTOFOK) ;
     p.SetBit(kCaloPIDneutral,isNeutral) ;
-    p.SetBit(BIT(16+iMod),kTRUE) ;
+    p.SetBit(BIT(17+iMod),kTRUE) ;
+    p.SetBit(kCaloDistBad,closeToBad) ;
     new((*fPHOSEvent)[inPHOS]) TLorentzVector(p) ;
     fGammaPHOS[inPHOS] = i ;
     inPHOS++ ;
@@ -874,24 +939,27 @@ void AliAnalysisTaskCaloConv::SelectPHOSPhotons(){
     Double_t pt= p.Pt() ;
     TString skey="PHOS_single_"; skey+="mod" ; skey+=iMod ; skey+="_all" ;
     FillHistogram(skey,pt) ;
+    FillHistogram("PHOS_single_all_mult",pt,fCentr) ;
     if(isDispOK){
       skey="PHOS_single_"; skey+="mod" ; skey+=iMod ; skey+="_disp" ;
+      FillHistogram("PHOS_single_disp_mult",pt,fCentr) ;
       FillHistogram(skey,pt) ;
     }
     if(isNeutral){
       skey="PHOS_single_"; skey+="mod" ; skey+=iMod ; skey+="_neutral" ;
       FillHistogram(skey,pt) ;
+      FillHistogram("PHOS_single_neu_mult",pt,fCentr) ;
     }
     if(isNeutral && isDispOK){
       skey="PHOS_single_"; skey+="mod" ; skey+=iMod ; skey+="_dispneutral" ;
       FillHistogram(skey,pt) ;
     }
     //Distance to bad channel
-    if(clu->GetDistanceToBadChannel()>2.2){
+    if(clu->GetDistanceToBadChannel()>fBadDistCutPHOS){
       skey="PHOS_single_"; skey+="mod" ; skey+=iMod ; skey+="_dist1" ;
       FillHistogram(skey,pt) ;
     }
-    if(clu->GetDistanceToBadChannel()>4.4){
+    if(clu->GetDistanceToBadChannel()>2.*fBadDistCutPHOS){
       skey="PHOS_single_"; skey+="mod" ; skey+=iMod ; skey+="_dist2" ;
       FillHistogram(skey,pt) ;
     }
@@ -930,6 +998,7 @@ void AliAnalysisTaskCaloConv::SelectEMCALPhotons(){
     fEMCALEvent = new TClonesArray("TLorentzVector",10) ;
   Int_t inEMCAL = 0 ; //, inEMCALRecal=0;
   TLorentzVector pi0 ;
+return ; //Untill EMCAL geometry will be fixed
 
   //vertex
   Double_t vtx[3];
@@ -979,7 +1048,7 @@ void AliAnalysisTaskCaloConv::SelectEMCALPhotons(){
       p.SetBit(kCaloPIDneutral,isNeutral) ;
       p.SetBit(BIT(17+imod),kTRUE) ;
       new((*fEMCALEvent)[inEMCAL]) TLorentzVector(p) ;
-      fGammaPHOS[inEMCAL] = i ;
+      fGammaEMCAL[inEMCAL] = i ;
       inEMCAL++ ;
  
 
@@ -1048,17 +1117,17 @@ void AliAnalysisTaskCaloConv::SelectConvPhotons(){
     AliKFParticle negKF(*paramNeg,11);
     AliKFParticle posKF(*paramPos,-11);
     AliKFParticle photKF(negKF,posKF) ;
-//printf("st 1: px=%f, py=%f, pz=%f, E=%f \n",photKF.GetPx(),photKF.GetPy(),photKF.GetPz(),photKF.GetE()) ;
     photKF.SetMassConstraint(0,cutSigmaMass);
-//printf("st 2: px=%f, py=%f, pz=%f, E=%f \n",photKF.GetPx(),photKF.GetPy(),photKF.GetPz(),photKF.GetE()) ;
 
     if(useImprovedVertex){
       AliKFVertex primaryVertexImproved(*(fESDEvent->GetPrimaryVertex()));
-      primaryVertexImproved+=photKF;
-      photKF.SetProductionVertex(primaryVertexImproved);
+      //if Vtx do created
+      if(primaryVertexImproved.GetNContributors()>1){
+        primaryVertexImproved+=photKF;
+        photKF.SetProductionVertex(primaryVertexImproved);
+      }
     }
-//printf("st 3: px=%f, py=%f, pz=%f, E=%f \n",photKF.GetPx(),photKF.GetPy(),photKF.GetPz(),photKF.GetE()) ;
-    Double_t m, width ;
+    Double_t m=0., width=0. ;
     photKF.GetMass(m,width);
 
     TLorentzVector photLV;
@@ -1091,7 +1160,6 @@ void AliAnalysisTaskCaloConv::SelectConvPhotons(){
 
     //remove like sign pairs 
     if(pos->GetSign() == neg->GetSign()){ 
-//printf("... likesign \n") ;
       continue ;
     }
     if(fToUseCF){
@@ -1103,7 +1171,6 @@ void AliAnalysisTaskCaloConv::SelectConvPhotons(){
 
     if( !(pos->GetStatus() & AliESDtrack::kTPCrefit) ||
         !(neg->GetStatus() & AliESDtrack::kTPCrefit) ){
-//printf("... status \n") ;
       continue;
     }
     if(fToUseCF){
@@ -1113,62 +1180,55 @@ void AliAnalysisTaskCaloConv::SelectConvPhotons(){
         fConvCFCont->Fill(a,6) ;
     }
  
-    Bool_t isKink=kFALSE ;
     if( neg->GetKinkIndex(0) > 0 ||
         pos->GetKinkIndex(0) > 0) {
-      isKink=kTRUE;
-    }
-    if(!isKink && fToUseCF){
-      if(isOnFly)
-        fConvCFCont->Fill(a,7) ;
-      else
-        fConvCFCont->Fill(a,8) ;
+      continue ;
     }
 
     //First rough PID
-    if( fESDpid->NumberOfSigmasTPC(pos,AliPID::kElectron)<-4. ||
-        fESDpid->NumberOfSigmasTPC(pos,AliPID::kElectron)>6. ||
-        fESDpid->NumberOfSigmasTPC(neg,AliPID::kElectron)<-4. ||
-        fESDpid->NumberOfSigmasTPC(neg,AliPID::kElectron)>6. ){
-        continue ;
-    }
-
-    Bool_t isdEdx=kTRUE;
     if( fESDpid->NumberOfSigmasTPC(pos,AliPID::kElectron)<fnSigmaBelowElectronLine ||
         fESDpid->NumberOfSigmasTPC(pos,AliPID::kElectron)>fnSigmaAboveElectronLine ||
         fESDpid->NumberOfSigmasTPC(neg,AliPID::kElectron)<fnSigmaBelowElectronLine ||
         fESDpid->NumberOfSigmasTPC(neg,AliPID::kElectron)>fnSigmaAboveElectronLine ){
-//printf("... dEdx 1 \n") ;
-         isdEdx=kFALSE;
+        continue ;
     }
-    const Double_t minPnSigmaAbovePionLine = 0.5 ;
-    const Double_t maxPnSigmaAbovePionLine = 100. ;
+    const Double_t minPnSigmaAbovePionLine = 1. ;
+    const Double_t maxPnSigmaAbovePionLine = 3. ;
     const Double_t nSigmaAbovePionLine = 0 ;
     if(pos->P()>minPnSigmaAbovePionLine && pos->P()<maxPnSigmaAbovePionLine ){
       if(fESDpid->NumberOfSigmasTPC(pos,AliPID::kPion)<nSigmaAbovePionLine){
-//printf("... dEdx 2 \n") ;
-          isdEdx=kFALSE;
+          continue ;
         }
     }
     if(neg->P()>minPnSigmaAbovePionLine && neg->P()<maxPnSigmaAbovePionLine){
       if(fESDpid->NumberOfSigmasTPC(neg,AliPID::kPion)<nSigmaAbovePionLine){
-//printf("... dEdx 3 \n") ;
-          isdEdx=kFALSE;
+          continue ;
+      }
+    }
+    //Strict dEdx
+    Bool_t isdEdx=kTRUE;
+    if(pos->P()>minPnSigmaAbovePionLine && pos->P()<maxPnSigmaAbovePionLine ){
+      if(fESDpid->NumberOfSigmasTPC(pos,AliPID::kPion)<2.){
+        isdEdx=kFALSE;
+      }
+    }
+    if(neg->P()>minPnSigmaAbovePionLine && neg->P()<maxPnSigmaAbovePionLine){
+      if(fESDpid->NumberOfSigmasTPC(neg,AliPID::kPion)<2.){
+        isdEdx=kFALSE;
       }
     }
 
     //Kaon rejection
     const Double_t minPKaonRejection=1.5 ;
     const Double_t sigmaAroundLine=1. ;
     if(neg->P()<minPKaonRejection ){
       if(TMath::Abs(fESDpid->NumberOfSigmasTPC(neg,AliPID::kKaon))<sigmaAroundLine){
-//printf("... dEdx 4 \n") ;
         isdEdx=kFALSE;
       }
     }
     if(pos->P()<minPKaonRejection ){
       if(TMath::Abs(fESDpid->NumberOfSigmasTPC(pos,AliPID::kKaon))<sigmaAroundLine){
-//printf("... dEdx 5 \n") ;
         isdEdx=kFALSE;
       }
     }
@@ -1177,13 +1237,11 @@ void AliAnalysisTaskCaloConv::SelectConvPhotons(){
     const Double_t minPProtonRejection=2. ;
     if(neg->P()<minPProtonRejection){
       if(TMath::Abs(fESDpid->NumberOfSigmasTPC(neg,AliPID::kProton))<sigmaAroundLine){
-//printf("... dEdx 6 \n") ;
         isdEdx=kFALSE;
       }
     }
     if(pos->P()<minPProtonRejection ){
       if(TMath::Abs(fESDpid->NumberOfSigmasTPC(pos,AliPID::kProton))<sigmaAroundLine){
-//printf("... dEdx 7 \n") ;
         isdEdx=kFALSE;
       }
     }
@@ -1191,13 +1249,11 @@ void AliAnalysisTaskCaloConv::SelectConvPhotons(){
     const Double_t minPPionRejection=0.5 ;
     if(neg->P()<minPPionRejection ){
       if(TMath::Abs(fESDpid->NumberOfSigmasTPC(neg,AliPID::kPion))<sigmaAroundLine){
-//printf("... dEdx 8 \n") ;
         isdEdx=kFALSE;
       }
     }
     if(pos->P()<minPPionRejection ){
       if( TMath::Abs(fESDpid->NumberOfSigmasTPC(pos,AliPID::kPion))<sigmaAroundLine){
-//printf("... dEdx 9 \n") ;
         isdEdx=kFALSE;
       }
     }
@@ -1218,18 +1274,21 @@ void AliAnalysisTaskCaloConv::SelectConvPhotons(){
     if(negProbArray[AliPID::kElectron]<fprobCut || posProbArray[AliPID::kElectron]<fprobCut){
       isProb=kFALSE ;
     }
-    if(!isKink && isProb && fToUseCF){
+    if(fToUseCF){
       if(isOnFly)
         fConvCFCont->Fill(a,9) ;
       else
         fConvCFCont->Fill(a,10) ;
     }
 
-    Double_t v0x,v0y,v0z;
+    Double_t v0x=0.,v0y=0.,v0z=0.;
     v0->GetXYZ(v0x,v0y,v0z) ;
     Double_t r=TMath::Sqrt(v0x*v0x + v0y*v0y) ;
+    //Remove Dalitz
+    const Double_t rMin=2.8 ;
+    if(r<rMin)
+      continue ;
     if(r>fmaxR){ // cuts on distance from collision point
-//printf("... maxR \n") ;
       continue;
     }
     Bool_t isStrictR=kFALSE ;
@@ -1244,7 +1303,6 @@ void AliAnalysisTaskCaloConv::SelectConvPhotons(){
 
 
     if((TMath::Abs(v0z)*zrSlope12)-zOffset > r ){ // cuts out regions where we do not reconstruct
-//printf("... ZR slope=%f, offset=%f, z=%f, zs=%f, r=%f \n",zrSlope,zOffset,v0z,TMath::Abs(v0z)*zrSlope-zOffset,r) ;
       continue;
     }
     if(fToUseCF){
@@ -1255,7 +1313,6 @@ void AliAnalysisTaskCaloConv::SelectConvPhotons(){
     }
 
     if(TMath::Abs(v0z) > fmaxZ ){ // cuts out regions where we do not reconstruct
-//printf("... maxZ \n") ;
       continue;
     }
     Bool_t isStrictZ=kFALSE ;
@@ -1270,7 +1327,6 @@ void AliAnalysisTaskCaloConv::SelectConvPhotons(){
     }
  
     if(photKF.GetNDF()<=0){
-//printf("... NDF \n") ;
       continue;
     }
     if(fToUseCF){
@@ -1284,7 +1340,6 @@ void AliAnalysisTaskCaloConv::SelectConvPhotons(){
     FillHistogram("All_chi2_eta_pt",chi2V0,photLV.Eta(),photLV.Pt()) ;
 
     if(chi2V0 > fchi2CutConversion || chi2V0 <=0){
-//printf("... chi2 \n") ;
       continue;
     }
     Bool_t isStrictChi=kFALSE ;
@@ -1301,12 +1356,10 @@ void AliAnalysisTaskCaloConv::SelectConvPhotons(){
 
     const Double_t wideEtaCut=1.2 ;
     if(TMath::Abs(photLV.Eta())> wideEtaCut){
-//printf("... ETA \n") ;
       continue;
     }
     if(TMath::Abs(paramPos->Eta())> wideEtaCut ||  
        TMath::Abs(paramNeg->Eta())> wideEtaCut ){
-//printf("... ETA pls mns \n") ;
       continue ;
     }
 
@@ -1319,7 +1372,6 @@ void AliAnalysisTaskCaloConv::SelectConvPhotons(){
     
 
     if(photLV.Pt()<fptCut){
-//printf("... pt \n") ;
       continue;
     }
     if(fToUseCF){
@@ -1331,21 +1383,24 @@ void AliAnalysisTaskCaloConv::SelectConvPhotons(){
 
 
     //Just QA plot
-/*
     if(photLV.Pt()>0.5){
        Double_t phi=photLV.Phi() ;
        while(phi<0.)phi+=TMath::TwoPi() ;
        while(phi>TMath::TwoPi())phi-=TMath::TwoPi() ;
-       FillHistogram("ConvPhiEta",phi,photLV.Eta()) ; 
+       FillHistogram("hQA_ConvPhiEta",phi,photLV.Eta()) ; 
     }
-*/
     
     Double_t w=PlanarityAngle(paramPos,paramNeg) ;
     Bool_t isPlanarityCut = (0.08-0.22*w > m || 0.15*(w-2.4)>m) ;
     FillHistogram("All_w_vs_m",w,m) ;
 
+    const Double_t armenterosAlphaCut=0.05 ;
+    Double_t armenterosQtAlfa[2]={0.,0.}  ;
+    GetArmenterosQtAlfa(&posKF, &negKF, &photKF, armenterosQtAlfa ) ;
+    Bool_t isArmQt=(armenterosQtAlfa[1]<armenterosAlphaCut) ;
+
     photLV.SetBit(kConvOnFly,isOnFly) ;
-    photLV.SetBit(kConvKink,isKink) ;
+    photLV.SetBit(kConvArmQt,isArmQt) ;
     photLV.SetBit(kConvdEdx,isdEdx) ;
     photLV.SetBit(kConvProb,isProb) ;
     photLV.SetBit(kConvR,isStrictR) ;
@@ -1358,53 +1413,44 @@ void AliAnalysisTaskCaloConv::SelectConvPhotons(){
     fGammaV0s[inConv] = iv0 ;
     inConv++ ;
 
-//    if(isOnFly)
-//      printf("CaloConv: v0(%d): onFly \n",inConv) ;
-//    else
-//      printf("CaloConv: v0(%d): Offline \n",inConv) ;
-
     //Single photon spectrum
     Double_t pt=photLV.Pt() ;
     if(isOnFly){
       //Default
-      if(!isKink && isdEdx && isProb && !isWideEta)
+      if(!isWideEta)
         FillHistogram("Single_conv_OnFly",pt) ;
-      if(isdEdx && isProb && !isWideEta)
-        FillHistogram("Single_conv_On_Kink",pt) ;
-      if(!isKink && isProb && !isWideEta)
+      if(isdEdx && !isWideEta)
         FillHistogram("Single_conv_On_dEdx",pt) ;
-      if(!isKink && isdEdx && !isWideEta)
-        FillHistogram("Single_conv_On_Prob",pt) ;
-      if(!isKink && isdEdx && isProb && !isWideEta && isStrictR)
+      if(!isWideEta && isStrictR)
         FillHistogram("Single_conv_On_R120",pt) ; 
-      if(!isKink && isdEdx && isProb && !isWideEta && isStrictZ)
+      if( !isWideEta && isStrictZ)
         FillHistogram("Single_conv_On_Z",pt) ;
-      if(!isKink && isdEdx && isProb && !isWideEta && isStrictChi)
+      if(!isWideEta && isStrictChi)
         FillHistogram("Single_conv_On_chi",pt) ;
-      if(!isKink && isdEdx && isProb)
+      if(1)
         FillHistogram("Single_conv_On_Eta",pt) ;
-      if(!isKink && isdEdx && isProb && !isWideEta && isPlanarityCut)
+      if(!isWideEta && isPlanarityCut)
         FillHistogram("Single_conv_On_Wcut",pt) ;
+      if(!isWideEta && isArmQt)
+        FillHistogram("Single_conv_On_ArmQt",pt) ;
     }
     else{
-      if(!isKink && isdEdx && isProb && !isWideEta)
+      if(!isWideEta)
         FillHistogram("Single_conv_Offline",pt) ;
-      if(isdEdx && isProb && !isWideEta)
-        FillHistogram("Single_conv_Off_Kink",pt) ;
-      if(!isKink && isProb && !isWideEta)
+      if(isdEdx && !isWideEta)
         FillHistogram("Single_conv_Off_dEdx",pt) ;
-      if(!isKink && isdEdx && !isWideEta)
-        FillHistogram("Single_conv_Off_Prob",pt) ;
-      if(!isKink && isdEdx && isProb && !isWideEta && isStrictR)
+      if(!isWideEta && isStrictR)
         FillHistogram("Single_conv_Off_R120",pt) ; 
-      if(!isKink && isdEdx && isProb && !isWideEta && isStrictZ)
+      if(!isWideEta && isStrictZ)
         FillHistogram("Single_conv_Off_Z",pt) ;
-      if(!isKink && isdEdx && isProb && !isWideEta && isStrictChi)
+      if(!isWideEta && isStrictChi)
         FillHistogram("Single_conv_Off_chi",pt) ;
-      if(!isKink && isdEdx && isProb)
+      if(1)
         FillHistogram("Single_conv_Off_Eta",pt) ;
-      if(!isKink && isdEdx && isProb && !isWideEta && isPlanarityCut)
+      if(!isWideEta && isPlanarityCut)
         FillHistogram("Single_conv_Off_Wcut",pt) ;
+      if(!isWideEta && isArmQt)
+        FillHistogram("Single_conv_Off_ArmQt",pt) ;
     }
 
     //Fill MC information
@@ -1478,14 +1524,13 @@ void AliAnalysisTaskCaloConv::FillRealMixed(){
   Int_t nConvGood=0 ;
   for(Int_t iConv = 0; iConv<nConv; iConv++){
     TLorentzVector * cnv = static_cast<TLorentzVector*>(fConvEvent->At(iConv)) ;
-    if(cnv->TestBit(kConvOnFly) && !cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta)){
+    if(cnv->TestBit(kConvOnFly) && !cnv->TestBit(kConvEta)){
       nConvGood++ ;
     }
   }
   FillHistogram("hRunConvs",run,double(nConvGood)) ;
   FillHistogram("hRunPHOS", run,double(nPHOS)) ;
   FillHistogram("hRunEMCAL",run,double(nEMCAL)) ;
-//printf("CaloConv::FillRe:  nConv=%d \n",nConvGood) ;
 
   //Fill Real distributions
   for(Int_t iPHOS=0; iPHOS<nPHOS;iPHOS++){
@@ -1494,9 +1539,23 @@ void AliAnalysisTaskCaloConv::FillRealMixed(){
       TLorentzVector * cnv = static_cast<TLorentzVector*>(fConvEvent->At(iConv)) ;
       TLorentzVector pi=*cal + *cnv ;
       Double_t alpha=TMath::Abs(cal->Energy()-cnv->Energy())/(cal->Energy()+cnv->Energy()) ;
-      if(cnv->TestBit(kConvOnFly) && !cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta)){
-        //Non-linearity check
+      if(cnv->TestBit(kConvOnFly) && !cnv->TestBit(kConvEta)){
         FillHistogram("PHOS_Re_mvsPt_all",pi.M(),pi.Pt()) ;
+        char keym[55] ;
+        for(Int_t iw=0;iw<10;iw++){ //resolution
+          for(Int_t in=0;in<10;in++){
+            snprintf(keym,55,"hMC_nonlinearity_w%d_n%d",iw,in) ;
+            Double_t mMod=0.,ptMod=0. ;
+            Recalibrate(mMod, ptMod, cal, cnv, iw, in) ;
+            FillHistogram(keym,mMod,ptMod) ;
+            snprintf(keym,55,"hMC_nonlinearity_ConvPHOS_w%d_n%d",iw,in) ;
+            RecalibrateConvPHOS(mMod, ptMod, cal, cnv, iw, in) ;
+            FillHistogram(keym,mMod,ptMod) ;
+          }
+        }
+        if(cal->TestBit(kCaloDistBad))
+          FillHistogram("PHOS_Re_mvsPt_all_dist",pi.M(),pi.Pt()) ;
         FillHistogram("PHOS_Re_mvsPt_E",pi.M(),pi.Pt(),cal->Energy()) ;
         FillHistogram("PHOS_Re_mvsPt_alpha",pi.M(),pi.Pt(),alpha) ;
         if(cal->TestBit(kCaloPIDdisp))
@@ -1511,45 +1570,51 @@ void AliAnalysisTaskCaloConv::FillRealMixed(){
       //Vary Conversion cuts
       if(cnv->TestBit(kConvOnFly)){
         //Default
-        if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta))
+        if(!cnv->TestBit(kConvEta)){
           FillHistogram("PHOS_Re_mvsPt_OnFly",pi.M(),pi.Pt()) ;
-        if(cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta))
-          FillHistogram("PHOS_Re_mvsPt_On_Kink",pi.M(),pi.Pt()) ;
-        if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta))
+          FillHistogram("PHOS_Re_mvsPt_OnFly_mult",pi.M(),pi.Pt(),fCentr) ;
+        }
+        if(cnv->TestBit(kConvdEdx) && !cnv->TestBit(kConvEta))
           FillHistogram("PHOS_Re_mvsPt_On_dEdx",pi.M(),pi.Pt()) ;
-        if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && !cnv->TestBit(kConvEta))
-          FillHistogram("PHOS_Re_mvsPt_On_Prob",pi.M(),pi.Pt()) ;
-        if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvR))
+        if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvR))
           FillHistogram("PHOS_Re_mvsPt_On_R120",pi.M(),pi.Pt()) ;
-        if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvZR))
+        if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvZR))
           FillHistogram("PHOS_Re_mvsPt_On_Z",pi.M(),pi.Pt()) ;
-        if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvNDF)) 
+        if( !cnv->TestBit(kConvEta) && cnv->TestBit(kConvNDF)) 
           FillHistogram("PHOS_Re_mvsPt_On_chi",pi.M(),pi.Pt()) ;
-        if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb))
+        if(1)
           FillHistogram("PHOS_Re_mvsPt_On_Eta",pi.M(),pi.Pt()) ;
-        if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvPlan)) 
+        if( !cnv->TestBit(kConvEta) && cnv->TestBit(kConvPlan)){ 
           FillHistogram("PHOS_Re_mvsPt_On_Wcut",pi.M(),pi.Pt()) ;
+          if(cal->TestBit(kCaloPIDneutral))
+            FillHistogram("PHOS_Re_mvsPt_On_Wcut_Neu",pi.M(),pi.Pt()) ;
+        }
+        if( !cnv->TestBit(kConvEta) && cnv->TestBit(kConvArmQt)) 
+          FillHistogram("PHOS_Re_mvsPt_On_ArmQt",pi.M(),pi.Pt()) ;
       }
       else{
         //Default
-        if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta))
+        if(!cnv->TestBit(kConvEta)){
           FillHistogram("PHOS_Re_mvsPt_Offline",pi.M(),pi.Pt()) ;
-        if(cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta))
-          FillHistogram("PHOS_Re_mvsPt_Off_Kink",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta))
+          FillHistogram("PHOS_Re_mvsPt_Offline_mult",pi.M(),pi.Pt(),fCentr) ;
+        }
+        if(cnv->TestBit(kConvdEdx) && !cnv->TestBit(kConvEta))
           FillHistogram("PHOS_Re_mvsPt_Off_dEdx",pi.M(),pi.Pt()) ;
-        if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && !cnv->TestBit(kConvEta))
-          FillHistogram("PHOS_Re_mvsPt_Off_Prob",pi.M(),pi.Pt()) ;
-        if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvR))
+        if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvR))
           FillHistogram("PHOS_Re_mvsPt_Off_R120",pi.M(),pi.Pt()) ;
-        if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvZR))
+        if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvZR))
           FillHistogram("PHOS_Re_mvsPt_Off_Z",pi.M(),pi.Pt()) ;
-        if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvNDF))
+        if( !cnv->TestBit(kConvEta) && cnv->TestBit(kConvNDF))
           FillHistogram("PHOS_Re_mvsPt_Off_chi",pi.M(),pi.Pt()) ;
-        if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb))
+        if(1)
           FillHistogram("PHOS_Re_mvsPt_Off_Eta",pi.M(),pi.Pt()) ;
-        if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvPlan))
+        if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvPlan)){
           FillHistogram("PHOS_Re_mvsPt_Off_Wcut",pi.M(),pi.Pt()) ;
+          if(cal->TestBit(kCaloPIDneutral))
+            FillHistogram("PHOS_Re_mvsPt_Off_Wcut_Neu",pi.M(),pi.Pt()) ;
+        }
+        if( !cnv->TestBit(kConvEta) && cnv->TestBit(kConvArmQt)) 
+          FillHistogram("PHOS_Re_mvsPt_Off_ArmQt",pi.M(),pi.Pt()) ;
       }
     }
   }
@@ -1557,33 +1622,17 @@ void AliAnalysisTaskCaloConv::FillRealMixed(){
   for(Int_t iPHOS=0; iPHOS<nPHOS;iPHOS++){
     TLorentzVector * cal = static_cast<TLorentzVector*>(fPHOSEvent->At(iPHOS)) ;
     Int_t mod=1;
-    while(!cal->TestBit(BIT(16+mod)) && mod<5)mod++ ;
+    while(!cal->TestBit(BIT(17+mod)) && mod<5)mod++ ;
     TString base("PHOS_Re_mvsPt_mod") ; base+=mod ;
     TString full ;
     for(Int_t iConv = 0; iConv<nConv; iConv++){
       TLorentzVector * cnv = static_cast<TLorentzVector*>(fConvEvent->At(iConv)) ;
       TLorentzVector pi=*cal + *cnv ;
       full=base ; full+="_single" ;
-      if(cnv->TestBit(kConvOnFly) && !cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta)){
+      if(cnv->TestBit(kConvOnFly) && !cnv->TestBit(kConvEta)){
         FillHistogram(full,pi.M(),cal->Pt()) ;
         full=base ; full+="_all" ;
         FillHistogram(full,pi.M(),pi.Pt()) ;
-        if(cal->TestBit(kCaloPIDdisp)){
-          full=base ; full+="_Disp" ;
-          FillHistogram(full,pi.M(),pi.Pt()) ;
-        }
-        if(cal->TestBit(kCaloPIDtof)){
-          full=base ; full+="_TOF" ;
-          FillHistogram(full,pi.M(),pi.Pt()) ;
-        }
-          if(cal->TestBit(kCaloPIDneutral)){
-          full=base ; full+="_Neutral" ;
-          FillHistogram(full,pi.M(),pi.Pt()) ;
-        }
-        if(cal->TestBit(kCaloPIDneutral) && cal->TestBit(kCaloPIDdisp)){
-          full=base ; full+="_DispNeutral" ;
-            FillHistogram(full,pi.M(),pi.Pt()) ;
-        }
       }
     }
   }
@@ -1598,69 +1647,62 @@ void AliAnalysisTaskCaloConv::FillRealMixed(){
       TLorentzVector pi=*cal + *cnv ;
 //      Double_t alpha=TMath::Abs(cal->Energy()-cnv->Energy())/(cal->Energy()+cnv->Energy()) ;
       full=base+"_single" ;
-      if(cnv->TestBit(kConvOnFly) && !cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta)){
+      if(cnv->TestBit(kConvOnFly) && !cnv->TestBit(kConvEta)){
         FillHistogram(full,pi.M(),cal->Pt()) ;
         full=base+"_all" ;
         FillHistogram(full,pi.M(),pi.Pt()) ;
-        if(cal->TestBit(kCaloPIDdisp)){
-          full=base+"_Disp" ;
-          FillHistogram(full,pi.M(),pi.Pt()) ;
-        }
-        if(cal->TestBit(kCaloPIDtof)){
-          full=base+"_TOF" ;
-          FillHistogram(full,pi.M(),pi.Pt()) ;
-        }
-        if(cal->TestBit(kCaloPIDneutral)){
-          full=base+"_Neutral" ;
-          FillHistogram(full,pi.M(),pi.Pt()) ;
-        }
-        if(cal->TestBit(kCaloPIDneutral) && cal->TestBit(kCaloPIDdisp)){
-          full=base+"_DispNeutral" ;
-          FillHistogram(full,pi.M(),pi.Pt()) ;
+        char keym[55] ;
+        for(Int_t iw=0;iw<10;iw++){ //resolution
+          for(Int_t in=0;in<10;in++){
+            snprintf(keym,55,"hMC_nonlinearity_EMCAL_w%d_n%d",iw,in) ;
+            Double_t mMod=0.,ptMod=0. ;
+            RecalibrateEMCAL(mMod, ptMod, cal, cnv, iw, in) ;
+            FillHistogram(keym,mMod,ptMod) ;
+          }
         }
       }
       //Vary Conversion cuts
       if(cnv->TestBit(kConvOnFly)){
         //Default
-        if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta))
+        if(!cnv->TestBit(kConvEta)){
           FillHistogram("EMCAL_Re_mvsPt_OnFly",pi.M(),pi.Pt()) ;
-        if(cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta))
-          FillHistogram("EMCAL_Re_mvsPt_On_Kink",pi.M(),pi.Pt()) ;
-        if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta))
+          FillHistogram("EMCAL_Re_mvsPt_OnFly_mult",pi.M(),pi.Pt(),fCentr) ;
+        }
+        if(cnv->TestBit(kConvdEdx) && !cnv->TestBit(kConvEta))
           FillHistogram("EMCAL_Re_mvsPt_On_dEdx",pi.M(),pi.Pt()) ;
-        if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && !cnv->TestBit(kConvEta))
-          FillHistogram("EMCAL_Re_mvsPt_On_Prob",pi.M(),pi.Pt()) ;
-        if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvR))
+        if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvR))
           FillHistogram("EMCAL_Re_mvsPt_On_R120",pi.M(),pi.Pt()) ;
-        if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvZR))
+        if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvZR))
           FillHistogram("EMCAL_Re_mvsPt_On_Z",pi.M(),pi.Pt()) ;
-        if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvNDF))
+        if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvNDF))
           FillHistogram("EMCAL_Re_mvsPt_On_chi",pi.M(),pi.Pt()) ;
-        if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb))
+        if(1)
           FillHistogram("EMCAL_Re_mvsPt_On_Eta",pi.M(),pi.Pt()) ;
-        if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvPlan))
+        if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvPlan))
           FillHistogram("EMCAL_Re_mvsPt_On_Wcut",pi.M(),pi.Pt()) ;
+        if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvArmQt))
+          FillHistogram("EMCAL_Re_mvsPt_On_ArmQt",pi.M(),pi.Pt()) ;
       }
       else{
         //Default
-        if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta))
+        if(!cnv->TestBit(kConvEta)){
           FillHistogram("EMCAL_Re_mvsPt_Offline",pi.M(),pi.Pt()) ;
-        if(cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta))
-          FillHistogram("EMCAL_Re_mvsPt_Off_Kink",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta))
+          FillHistogram("EMCAL_Re_mvsPt_Offline_mult",pi.M(),pi.Pt(),fCentr) ;
+        }
+        if(cnv->TestBit(kConvdEdx) && !cnv->TestBit(kConvEta))
           FillHistogram("EMCAL_Re_mvsPt_Off_dEdx",pi.M(),pi.Pt()) ;
-        if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && !cnv->TestBit(kConvEta))
-          FillHistogram("EMCAL_Re_mvsPt_Off_Prob",pi.M(),pi.Pt()) ;
-        if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvR))
+        if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvR))
           FillHistogram("EMCAL_Re_mvsPt_Off_R120",pi.M(),pi.Pt()) ;
-        if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvZR))
+        if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvZR))
           FillHistogram("EMCAL_Re_mvsPt_Off_Z",pi.M(),pi.Pt()) ;
-        if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvNDF))
+        if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvNDF))
           FillHistogram("EMCAL_Re_mvsPt_Off_chi",pi.M(),pi.Pt()) ;
-        if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb))
+        if(1)
           FillHistogram("EMCAL_Re_mvsPt_Off_Eta",pi.M(),pi.Pt()) ;
-        if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvPlan))
+        if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvPlan))
           FillHistogram("EMCAL_Re_mvsPt_Off_Wcut",pi.M(),pi.Pt()) ;
+        if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvArmQt))
+          FillHistogram("EMCAL_Re_mvsPt_Off_ArmQt",pi.M(),pi.Pt()) ;
       }
     }
   }
@@ -1677,7 +1719,7 @@ void AliAnalysisTaskCaloConv::FillRealMixed(){
       for(Int_t iConv = 0; iConv<mixConv->GetEntriesFast(); iConv++){
         TLorentzVector * cnv = static_cast<TLorentzVector*>(mixConv->At(iConv)) ;
         TLorentzVector pi=*cal + *cnv ;
-        if(cnv->TestBit(kConvOnFly) && !cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta)){
+        if(cnv->TestBit(kConvOnFly) && !cnv->TestBit(kConvEta)){
           FillHistogram("PHOS_Mi_mvsPt_all",pi.M(),pi.Pt()) ;
           if(cal->TestBit(kCaloPIDdisp))
             FillHistogram("PHOS_Mi_mvsPt_Disp",pi.M(),pi.Pt()) ;
@@ -1691,45 +1733,41 @@ void AliAnalysisTaskCaloConv::FillRealMixed(){
         //Vary Conversion cuts
         if(cnv->TestBit(kConvOnFly)){
           //Default
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta))
+          if(!cnv->TestBit(kConvEta))
             FillHistogram("PHOS_Mi_mvsPt_OnFly",pi.M(),pi.Pt()) ;
-          if(cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta))
-            FillHistogram("PHOS_Mi_mvsPt_On_Kink",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta))
+          if( cnv->TestBit(kConvdEdx) && !cnv->TestBit(kConvEta))
             FillHistogram("PHOS_Mi_mvsPt_On_dEdx",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && !cnv->TestBit(kConvEta))
-            FillHistogram("PHOS_Mi_mvsPt_On_Prob",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvR))
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvR))
             FillHistogram("PHOS_Mi_mvsPt_On_R120",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvZR))
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvZR))
             FillHistogram("PHOS_Mi_mvsPt_On_Z",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvNDF))
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvNDF))
             FillHistogram("PHOS_Mi_mvsPt_On_chi",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb))
+          if(1)
             FillHistogram("PHOS_Mi_mvsPt_On_Eta",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvPlan))
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvPlan))
             FillHistogram("PHOS_Mi_mvsPt_On_Wcut",pi.M(),pi.Pt()) ;
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvArmQt))
+            FillHistogram("PHOS_Mi_mvsPt_On_ArmQt",pi.M(),pi.Pt()) ;
         }
         else{
           //Default
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta))
+          if(!cnv->TestBit(kConvEta))
             FillHistogram("PHOS_Mi_mvsPt_Offline",pi.M(),pi.Pt()) ;
-          if(cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta))
-            FillHistogram("PHOS_Mi_mvsPt_Off_Kink",pi.M(),pi.Pt()) ;
-            if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta))
+          if(cnv->TestBit(kConvdEdx) && !cnv->TestBit(kConvEta))
             FillHistogram("PHOS_Mi_mvsPt_Off_dEdx",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && !cnv->TestBit(kConvEta))
-            FillHistogram("PHOS_Mi_mvsPt_Off_Prob",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvR))
+          if( !cnv->TestBit(kConvEta) && cnv->TestBit(kConvR))
             FillHistogram("PHOS_Mi_mvsPt_Off_R120",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvZR))
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvZR))
             FillHistogram("PHOS_Mi_mvsPt_Off_Z",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvNDF))
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvNDF))
             FillHistogram("PHOS_Mi_mvsPt_Off_chi",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb))
+          if(1)
             FillHistogram("PHOS_Mi_mvsPt_Off_Eta",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvPlan))
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvPlan))
             FillHistogram("PHOS_Mi_mvsPt_Off_Wcut",pi.M(),pi.Pt()) ;
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvArmQt))
+            FillHistogram("PHOS_Mi_mvsPt_Off_ArmQt",pi.M(),pi.Pt()) ;
         }
       }
     }
@@ -1741,7 +1779,7 @@ void AliAnalysisTaskCaloConv::FillRealMixed(){
       for(Int_t iPHOS=0; iPHOS<mixPHOS->GetEntriesFast();iPHOS++){
         TLorentzVector * cal = static_cast<TLorentzVector*>(mixPHOS->At(iPHOS)) ;
         TLorentzVector pi=*cal + *cnv ;
-        if(cnv->TestBit(kConvOnFly) && !cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta)){
+        if(cnv->TestBit(kConvOnFly) && !cnv->TestBit(kConvEta)){
           FillHistogram("PHOS_Mi_mvsPt_all",pi.M(),pi.Pt()) ;
           if(cal->TestBit(kCaloPIDdisp))
             FillHistogram("PHOS_Mi_mvsPt_Disp",pi.M(),pi.Pt()) ;
@@ -1755,55 +1793,52 @@ void AliAnalysisTaskCaloConv::FillRealMixed(){
         //Vary Conversion cuts
         if(cnv->TestBit(kConvOnFly)){
           //Default
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta))
+          if(!cnv->TestBit(kConvEta))
             FillHistogram("PHOS_Mi_mvsPt_OnFly",pi.M(),pi.Pt()) ;
-          if(cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta))
-            FillHistogram("PHOS_Mi_mvsPt_On_Kink",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta))
+          if(cnv->TestBit(kConvdEdx) && !cnv->TestBit(kConvEta))
             FillHistogram("PHOS_Mi_mvsPt_On_dEdx",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && !cnv->TestBit(kConvEta))
-            FillHistogram("PHOS_Mi_mvsPt_On_Prob",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvR))
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvR))
             FillHistogram("PHOS_Mi_mvsPt_On_R120",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvZR))
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvZR))
             FillHistogram("PHOS_Mi_mvsPt_On_Z",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvNDF))
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvNDF))
             FillHistogram("PHOS_Mi_mvsPt_On_chi",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb))
+          if(1)
             FillHistogram("PHOS_Mi_mvsPt_On_Eta",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvPlan))
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvPlan))
             FillHistogram("PHOS_Mi_mvsPt_On_Wcut",pi.M(),pi.Pt()) ;
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvArmQt))
+            FillHistogram("PHOS_Mi_mvsPt_On_ArmQt",pi.M(),pi.Pt()) ;
         }
         else{
           //Default
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta))
+          if(!cnv->TestBit(kConvEta))
             FillHistogram("PHOS_Mi_mvsPt_Offline",pi.M(),pi.Pt()) ;
-          if(cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta))
-            FillHistogram("PHOS_Mi_mvsPt_Off_Kink",pi.M(),pi.Pt()) ;
-            if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta))
+          if(cnv->TestBit(kConvdEdx) && !cnv->TestBit(kConvEta))
             FillHistogram("PHOS_Mi_mvsPt_Off_dEdx",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && !cnv->TestBit(kConvEta))
-            FillHistogram("PHOS_Mi_mvsPt_Off_Prob",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvR))
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvR))
             FillHistogram("PHOS_Mi_mvsPt_Off_R120",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvZR))
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvZR))
             FillHistogram("PHOS_Mi_mvsPt_Off_Z",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvNDF))
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvNDF))
             FillHistogram("PHOS_Mi_mvsPt_Off_chi",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb))
+          if(1)
             FillHistogram("PHOS_Mi_mvsPt_Off_Eta",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvPlan))
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvPlan))
             FillHistogram("PHOS_Mi_mvsPt_Off_Wcut",pi.M(),pi.Pt()) ;
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvArmQt))
+            FillHistogram("PHOS_Mi_mvsPt_Off_ArmQt",pi.M(),pi.Pt()) ;
         }
       }
     }
   }
  
+/*
   //PHOS module dependent
   for(Int_t iPHOS=0; iPHOS<nPHOS;iPHOS++){
     TLorentzVector * cal = static_cast<TLorentzVector*>(fPHOSEvent->At(iPHOS)) ;
     Int_t mod=1;
-    while(!cal->TestBit(BIT(16+mod)) && mod<5)mod++ ;
+    while(!cal->TestBit(BIT(17+mod)) && mod<5)mod++ ;
     TString base("PHOS_Mi_mvsPt_mod") ; base+=mod ;
     TString full ;
     for(Int_t ev=0; ev<prevConv->GetSize();ev++){
@@ -1812,24 +1847,8 @@ void AliAnalysisTaskCaloConv::FillRealMixed(){
         TLorentzVector * cnv = static_cast<TLorentzVector*>(mixConv->At(iConv)) ;
         TLorentzVector pi=*cal + *cnv ;
         full=base+"_all" ;
-        if(cnv->TestBit(kConvOnFly) && !cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta)){
+        if(cnv->TestBit(kConvOnFly) && !cnv->TestBit(kConvEta)){
           FillHistogram(full,pi.M(),pi.Pt()) ;
-          if(cal->TestBit(kCaloPIDdisp)){
-            full=base+"_Disp" ;
-            FillHistogram(full,pi.M(),pi.Pt()) ;
-          }
-          if(cal->TestBit(kCaloPIDtof)){
-            full=base+"_TOF" ;
-            FillHistogram(full,pi.M(),pi.Pt()) ;
-          }
-          if(cal->TestBit(kCaloPIDneutral)){
-            full=base+"_Neutral" ;
-            FillHistogram(full,pi.M(),pi.Pt()) ;
-          }
-          if(cal->TestBit(kCaloPIDneutral) && cal->TestBit(kCaloPIDdisp)){
-            full=base+"_DispNeutral" ;
-            FillHistogram(full,pi.M(),pi.Pt()) ;
-          }
         }
       }
     }
@@ -1841,34 +1860,18 @@ void AliAnalysisTaskCaloConv::FillRealMixed(){
       for(Int_t iPHOS=0; iPHOS<mixPHOS->GetEntriesFast();iPHOS++){
         TLorentzVector * cal = static_cast<TLorentzVector*>(mixPHOS->At(iPHOS)) ;
         Int_t mod=1;
-        while(!cal->TestBit(BIT(16+mod)) && mod<5)mod++ ;
+        while(!cal->TestBit(BIT(17+mod)) && mod<5)mod++ ;
         TString base("PHOS_Mi_mvsPt_mod") ; base+=mod ;
         TString full ;
         TLorentzVector pi=*cal + *cnv ;
         full=base+"_all" ;
-        if(cnv->TestBit(kConvOnFly) && !cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta)){
+        if(cnv->TestBit(kConvOnFly) && !cnv->TestBit(kConvEta)){
           FillHistogram(full,pi.M(),pi.Pt()) ;
-          if(cal->TestBit(kCaloPIDdisp)){
-            full=base+"_Disp" ;
-            FillHistogram(full,pi.M(),pi.Pt()) ;
-          }
-          if(cal->TestBit(kCaloPIDtof)){
-            full=base+"_TOF" ;
-            FillHistogram(full,pi.M(),pi.Pt()) ;
-          }
-          if(cal->TestBit(kCaloPIDneutral)){
-            full=base+"_Neutral" ;
-            FillHistogram(full,pi.M(),pi.Pt()) ;
-          }
-          if(cal->TestBit(kCaloPIDneutral) && cal->TestBit(kCaloPIDdisp)){
-            full=base+"_DispNeutral" ;
-            FillHistogram(full,pi.M(),pi.Pt()) ;
-          }
         }
       }
     }
   }
-
+*/
 
   //EMCAL
   for(Int_t iEMCAL=0; iEMCAL<nEMCAL;iEMCAL++){
@@ -1883,70 +1886,51 @@ void AliAnalysisTaskCaloConv::FillRealMixed(){
         TLorentzVector * cnv = static_cast<TLorentzVector*>(mixConv->At(iConv)) ;
         TLorentzVector pi=*cal + *cnv ;
         full=base+"_all" ;
-        if(cnv->TestBit(kConvOnFly) && !cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta)){
+        if(cnv->TestBit(kConvOnFly) && !cnv->TestBit(kConvEta)){
           FillHistogram(full,pi.M(),pi.Pt()) ;
-          if(cal->TestBit(kCaloPIDdisp)){
-            full=base+"_Disp" ;
-            FillHistogram(full,pi.M(),pi.Pt()) ;
-          }
-          if(cal->TestBit(kCaloPIDtof)){
-            full=base+"_TOF" ;
-            FillHistogram(full,pi.M(),pi.Pt()) ;
-          }
-          if(cal->TestBit(kCaloPIDneutral)){
-            full=base+"_Neutral" ;
-            FillHistogram(full,pi.M(),pi.Pt()) ;
-          }
-          if(cal->TestBit(kCaloPIDneutral) && cal->TestBit(kCaloPIDdisp)){
-            full=base+"_Neutral" ;
-            FillHistogram(full,pi.M(),pi.Pt()) ;
-          }
         } 
         if(cnv->TestBit(kConvOnFly)){
           //Default
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta))
+          if(!cnv->TestBit(kConvEta))
             FillHistogram("EMCAL_Mi_mvsPt_OnFly",pi.M(),pi.Pt()) ;
-          if(cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta))
-            FillHistogram("EMCAL_Mi_mvsPt_On_Kink",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta))
+          if(cnv->TestBit(kConvdEdx) && !cnv->TestBit(kConvEta))
             FillHistogram("EMCAL_Mi_mvsPt_On_dEdx",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && !cnv->TestBit(kConvEta))
-            FillHistogram("EMCAL_Mi_mvsPt_On_Prob",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvR))
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvR))
             FillHistogram("EMCAL_Mi_mvsPt_On_R120",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvZR))
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvZR))
             FillHistogram("EMCAL_Mi_mvsPt_On_Z",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvNDF))
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvNDF))
             FillHistogram("EMCAL_Mi_mvsPt_On_chi",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb))
+          if(1)
             FillHistogram("EMCAL_Mi_mvsPt_On_Eta",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvPlan))
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvPlan))
             FillHistogram("EMCAL_Mi_mvsPt_On_Wcut",pi.M(),pi.Pt()) ;
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvArmQt))
+            FillHistogram("EMCAL_Mi_mvsPt_On_ArmQt",pi.M(),pi.Pt()) ;
         }
         else{
           //Default
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta))
+          if(!cnv->TestBit(kConvEta))
             FillHistogram("EMCAL_Mi_mvsPt_Offline",pi.M(),pi.Pt()) ;
-          if(cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta))
-            FillHistogram("EMCAL_Mi_mvsPt_Off_Kink",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta))
+          if( cnv->TestBit(kConvdEdx) && !cnv->TestBit(kConvEta))
             FillHistogram("EMCAL_Mi_mvsPt_Off_dEdx",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && !cnv->TestBit(kConvEta))
-            FillHistogram("EMCAL_Mi_mvsPt_Off_Prob",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvR))
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvR))
             FillHistogram("EMCAL_Mi_mvsPt_Off_R120",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvZR))
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvZR))
             FillHistogram("EMCAL_Mi_mvsPt_Off_Z",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvNDF))
+          if( !cnv->TestBit(kConvEta) && cnv->TestBit(kConvNDF))
             FillHistogram("EMCAL_Mi_mvsPt_Off_chi",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb))
+          if(1)
             FillHistogram("EMCAL_Mi_mvsPt_Off_Eta",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvPlan))
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvPlan))
             FillHistogram("EMCAL_Mi_mvsPt_Off_Wcut",pi.M(),pi.Pt()) ;
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvArmQt))
+            FillHistogram("EMCAL_Mi_mvsPt_Off_ArmQt",pi.M(),pi.Pt()) ;
         }
       }
     }
   }
+/*
   for(Int_t iConv = 0; iConv<nConv; iConv++){
     TLorentzVector * cnv = static_cast<TLorentzVector*>(fConvEvent->At(iConv)) ;
     for(Int_t ev=0; ev<prevEMCAL->GetSize();ev++){
@@ -1959,7 +1943,7 @@ void AliAnalysisTaskCaloConv::FillRealMixed(){
         TString full ;
         TLorentzVector pi=*cal + *cnv ;
         full=base+"_all" ;
-        if(cnv->TestBit(kConvOnFly) && !cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta)){
+        if(cnv->TestBit(kConvOnFly) && !cnv->TestBit(kConvEta)){
           FillHistogram(full,pi.M(),pi.Pt()) ;
           if(cal->TestBit(kCaloPIDdisp)){
             full=base+"_Disp" ;
@@ -1980,49 +1964,46 @@ void AliAnalysisTaskCaloConv::FillRealMixed(){
         }
         if(cnv->TestBit(kConvOnFly)){
           //Default
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta))
+          if(!cnv->TestBit(kConvEta))
             FillHistogram("EMCAL_Mi_mvsPt_OnFly",pi.M(),pi.Pt()) ;
-          if(cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta))
-            FillHistogram("EMCAL_Mi_mvsPt_On_Kink",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta))
+          if(cnv->TestBit(kConvdEdx) && !cnv->TestBit(kConvEta))
             FillHistogram("EMCAL_Mi_mvsPt_On_dEdx",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && !cnv->TestBit(kConvEta))
-            FillHistogram("EMCAL_Mi_mvsPt_On_Prob",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvR))
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvR))
             FillHistogram("EMCAL_Mi_mvsPt_On_R120",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvZR))
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvZR))
             FillHistogram("EMCAL_Mi_mvsPt_On_Z",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvNDF))
+          if( !cnv->TestBit(kConvEta) && cnv->TestBit(kConvNDF))
             FillHistogram("EMCAL_Mi_mvsPt_On_chi",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb))
+          if(1)
             FillHistogram("EMCAL_Mi_mvsPt_On_Eta",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvPlan)) 
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvPlan)) 
             FillHistogram("EMCAL_Mi_mvsPt_On_Wcut",pi.M(),pi.Pt()) ;
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvArmQt)) 
+            FillHistogram("EMCAL_Mi_mvsPt_On_ArmQt",pi.M(),pi.Pt()) ;
         }
         else{
           //Default
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta))
+          if(!cnv->TestBit(kConvEta))
             FillHistogram("EMCAL_Mi_mvsPt_Offline",pi.M(),pi.Pt()) ;
-          if(cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta))
-            FillHistogram("EMCAL_Mi_mvsPt_Off_Kink",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta))
+          if(cnv->TestBit(kConvdEdx) && !cnv->TestBit(kConvEta))
             FillHistogram("EMCAL_Mi_mvsPt_Off_dEdx",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && !cnv->TestBit(kConvEta))
-            FillHistogram("EMCAL_Mi_mvsPt_Off_Prob",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvR))
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvR))
             FillHistogram("EMCAL_Mi_mvsPt_Off_R120",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvZR)) 
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvZR)) 
             FillHistogram("EMCAL_Mi_mvsPt_Off_Z",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvNDF))
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvNDF))
             FillHistogram("EMCAL_Mi_mvsPt_Off_chi",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb))
+          if(1)
             FillHistogram("EMCAL_Mi_mvsPt_Off_Eta",pi.M(),pi.Pt()) ;
-          if(!cnv->TestBit(kConvKink) && cnv->TestBit(kConvdEdx) && cnv->TestBit(kConvProb) && !cnv->TestBit(kConvEta) && cnv->TestBit(kConvPlan))
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvPlan))
             FillHistogram("EMCAL_Mi_mvsPt_Off_Wcut",pi.M(),pi.Pt()) ;
+          if(!cnv->TestBit(kConvEta) && cnv->TestBit(kConvArmQt)) 
+            FillHistogram("EMCAL_Mi_mvsPt_Off_ArmQt",pi.M(),pi.Pt()) ;
         }
       }
     }
   }
+*/
 
 
       
@@ -2065,11 +2046,22 @@ void AliAnalysisTaskCaloConv::ProcessMC(){
   vtx[1] = fESDEvent->GetPrimaryVertex()->GetY();
   vtx[2] = fESDEvent->GetPrimaryVertex()->GetZ();
 
-  //---------First pi0s-----------------------------
+  Int_t nPHOS=fPHOSEvent->GetEntriesFast() ;
+  Int_t nEMCAL=fEMCALEvent->GetEntriesFast() ;
+  Int_t nConv = fConvEvent->GetEntriesFast() ;
+  //---------First pi0/eta-----------------------------
+  char partName[10] ;
+  char hkey[55] ;
   for (Int_t iTracks = 0; iTracks < fStack->GetNtrack(); iTracks++) {
     TParticle* particle = (TParticle *)fStack->Particle(iTracks);
-    if(particle->GetPdgCode() != 111)
-      continue ;
+    if(particle->GetPdgCode() == 111)
+      snprintf(partName,10,"pi0") ;
+    else
+      if(particle->GetPdgCode() == 221)
+        snprintf(partName,10,"eta") ;
+      else
+        continue ;
      
     //Primary particle
     if(particle->R() >rcut)
@@ -2077,9 +2069,12 @@ void AliAnalysisTaskCaloConv::ProcessMC(){
 
     Double_t pt = particle->Pt() ;
     //Total number of pi0 with creation radius <1 cm
-    FillHistogram("hMC_CaloConv_allPi0",pt) ;
-    if(TMath::Abs(particle->Y())<1.)
-      FillHistogram("hMC_CaloConv_pi0_unitEta",pt) ;
+    snprintf(hkey,55,"hMC_CaloConv_all%s",partName) ;
+    FillHistogram(hkey,pt) ;
+    if(TMath::Abs(particle->Y())<1.){
+      snprintf(hkey,55,"hMC_CaloConv_%s_unitEta",partName) ;
+      FillHistogram(hkey,pt,fCentr) ;
+    }
 
     //Check if one of photons converted
     if(particle->GetNDaughters()!=2)
@@ -2090,20 +2085,22 @@ void AliAnalysisTaskCaloConv::ProcessMC(){
     //Number of pi0s decayed into acceptance
     Bool_t inAcc1 = (TMath::Abs(gamma1->Eta())<0.9) ;
     Bool_t inAcc2 = (TMath::Abs(gamma2->Eta())<0.9) ;
-    Int_t mod ;
-    Double_t x,z ;
-    Bool_t hitPHOS1 = fPHOSgeom->ImpactOnEmc(gamma1, mod, z,x) ;
-    Bool_t hitPHOS2 = fPHOSgeom->ImpactOnEmc(gamma2, mod, z,x) ;
+    Int_t mod1,mod2 ;
+    Double_t x=0.,z=0. ;
+    Bool_t hitPHOS1 = fPHOSgeom->ImpactOnEmc(gamma1, mod1, z,x) ;
+    Bool_t hitPHOS2 = fPHOSgeom->ImpactOnEmc(gamma2, mod2, z,x) ;
     Bool_t hitEMCAL1= fEMCALgeom->Impact(gamma1) ;
     Bool_t hitEMCAL2= fEMCALgeom->Impact(gamma2) ;
  
     Bool_t goodPair=kFALSE ;
     if((inAcc1 && hitPHOS2) || (inAcc2 && hitPHOS1)){
-      FillHistogram("hMC_CaloConv_pi0PHOSacc",pt) ;
+      snprintf(hkey,55,"hMC_CaloConv_%sPHOSacc",partName) ;
+      FillHistogram(hkey,pt) ;
       goodPair=kTRUE ;
     } 
     if((inAcc1 && hitEMCAL2) || (inAcc2 && hitEMCAL1)){
-      FillHistogram("hMC_CaloConv_pi0EMCALacc",pt) ;
+      snprintf(hkey,55,"hMC_CaloConv_%sEMCALacc",partName) ;
+      FillHistogram(hkey,pt) ;
        goodPair=kTRUE ;
     }
     if(!goodPair){
@@ -2130,38 +2127,43 @@ void AliAnalysisTaskCaloConv::ProcessMC(){
     }
   
     //Number of pi0s with one photon converted
-    if((converted1 && !converted2 && hitPHOS2) || (!converted1 && hitPHOS1 && converted2)) 
-       FillHistogram("hMC_CaloConv_pi0_PHOS_conv",pt) ;
+    if((converted1 && !converted2 && hitPHOS2) || (!converted1 && hitPHOS1 && converted2)) {
+      snprintf(hkey,55,"hMC_CaloConv_%s_PHOS_conv",partName) ;
+      FillHistogram(hkey,pt) ;
+    }
  
-    if((converted1 && !converted2 && hitEMCAL2) || (!converted1 && hitEMCAL1 && converted2)) 
-       FillHistogram("hMC_CaloConv_pi0_EMCAL_conv",pt) ;
+    if((converted1 && !converted2 && hitEMCAL2) || (!converted1 && hitEMCAL1 && converted2)) {
+      snprintf(hkey,55,"hMC_CaloConv_%s_EMCAL_conv",partName) ;
+      FillHistogram(hkey,pt) ;
+    }
  
     //Both converted
     if(converted1 && converted2) {
-      FillHistogram("hMC_CaloConv_pi0_bothphot_conv",pt) ;
+      snprintf(hkey,55,"hMC_CaloConv_%s_bothphot_conv",partName) ;
+      FillHistogram(hkey,pt) ;
         continue ;
     }
  
     //photon pointing calorimeter converted
     if((converted1 && hitPHOS1 && !hitEMCAL2) || (converted2 && hitPHOS2 && !hitEMCAL1) || 
        (converted1 && hitEMCAL1 && !hitPHOS2) || (converted2 && hitEMCAL2 && !hitPHOS1)){
-       FillHistogram("hMC_CaloConv_pi0__convPhotInCalo",pt) ;
+      snprintf(hkey,55,"hMC_CaloConv_%s_convPhotInCalo",partName) ;
+      FillHistogram(hkey,pt) ;
        continue ;
     }
    
     //Converted pi0 with v0 and photon PHOS or EMCAL
-    Bool_t foundV01=kFALSE, foundV02=kFALSE ;
-    TLorentzVector pConv ;
+    Bool_t foundV01onfly=kFALSE, foundV01offline=kFALSE, foundV02onfly=kFALSE, foundV02offline=kFALSE ;
+    Bool_t foundV01onflyPID=kFALSE, foundV01offlinePID=kFALSE, foundV02onflyPID=kFALSE, foundV02offlinePID=kFALSE ;
+    TLorentzVector pConvOn,pConvOff ;
     for(Int_t iv0=0; iv0<fESDEvent->GetNumberOfV0s();iv0++){
       AliESDv0 * v0 = fESDEvent->GetV0(iv0) ;
  
       TParticle * negativeMC = fStack->Particle(TMath::Abs(fESDEvent->GetTrack(v0->GetNindex())->GetLabel()));
       TParticle * positiveMC = fStack->Particle(TMath::Abs(fESDEvent->GetTrack(v0->GetPindex())->GetLabel()));
  
-      if(negativeMC && positiveMC){
-        if(negativeMC->GetMother(0) != positiveMC->GetMother(0))
-          continue ;
-      }
+      if(negativeMC->GetMother(0) != positiveMC->GetMother(0))
+        continue ;
  
       if(TMath::Abs(negativeMC->GetPdgCode())!=11 || TMath::Abs(positiveMC->GetPdgCode())!=11){
         continue;
@@ -2178,13 +2180,28 @@ void AliAnalysisTaskCaloConv::ProcessMC(){
        same = (tmp == gamma1) ;
      }
      if(same){
-       foundV01 = kTRUE ;
-       const AliExternalTrackParam * paramPos = v0->GetParamP() ;
-       const AliExternalTrackParam * paramNeg = v0->GetParamN() ;
-       AliKFParticle negKF(*paramNeg,11);
-       AliKFParticle posKF(*paramPos,-11);
-       pConv.SetXYZM(negKF.Px()+posKF.Px(),negKF.Py()+posKF.Py(),negKF.Pz()+negKF.Pz(),0.) ;
-       break ;
+       if(v0->GetOnFlyStatus())
+         foundV01onfly = kTRUE ;
+       else
+         foundV01offline= kTRUE ;
+       for(Int_t iconv=0; iconv<nConv;iconv++){
+         if(fGammaV0s[iconv] == iv0){
+           TLorentzVector * cnv = static_cast<TLorentzVector*>(fConvEvent->At(iconv)) ;
+           //default cuts
+           if(!cnv->TestBit(kConvEta)){
+             if(v0->GetOnFlyStatus()){
+               pConvOn= *cnv ; 
+               foundV01onflyPID = kTRUE ;
+             }
+             else{
+               pConvOff= *cnv ;
+               foundV01offlinePID = kTRUE ;
+             }
+           }
+           break ;
+         }
+       }
+       continue ;
      } 
      same = (v0Gamma == gamma2) ;
      tmp = v0Gamma ;
@@ -2193,23 +2210,49 @@ void AliAnalysisTaskCaloConv::ProcessMC(){
        same = (tmp == gamma2) ;
      }
      if(same){
-       foundV02 = kTRUE ;
-       const AliExternalTrackParam * paramPos = v0->GetParamP() ;
-       const AliExternalTrackParam * paramNeg = v0->GetParamN() ;
-       AliKFParticle negKF(*paramNeg,11);
-       AliKFParticle posKF(*paramPos,-11);
-       pConv.SetXYZM(negKF.Px()+posKF.Px(),negKF.Py()+posKF.Py(),negKF.Pz()+negKF.Pz(),0.) ;
-       break ;
+       if(v0->GetOnFlyStatus())
+         foundV02onfly = kTRUE ;
+       else
+         foundV02offline = kTRUE ;
+       for(Int_t iconv=0; iconv<nConv;iconv++){
+         if(fGammaV0s[iconv] == iv0){
+           TLorentzVector * cnv = static_cast<TLorentzVector*>(fConvEvent->At(iconv)) ;
+           //default cuts
+           if(!cnv->TestBit(kConvEta)){
+             if(v0->GetOnFlyStatus()){
+               pConvOn= *cnv ;
+               foundV02onflyPID = kTRUE ;
+             }
+             else{
+               pConvOff= *cnv ;
+               foundV02offlinePID = kTRUE ;
+             }
+           }
+           break ;
+         }
+       }
      } 
    }
 
    goodPair=kFALSE ;
-   if((foundV01 && hitPHOS2) || (foundV02 && hitPHOS1)){
-     FillHistogram("hMC_CaloConv_pi0_v0_PHOSacc",pt) ;
+   if((foundV01onfly && hitPHOS2) || (foundV02onfly && hitPHOS1)){
+     snprintf(hkey,55,"hMC_CaloConv_%s_v0onfly_PHOSacc",partName) ;
+     FillHistogram(hkey,pt) ;
+     goodPair=kTRUE;
+   }
+   if((foundV01offline && hitPHOS2) || (foundV02offline && hitPHOS1)){
+     snprintf(hkey,55,"hMC_CaloConv_%s_v0offline_PHOSacc",partName) ;
+     FillHistogram(hkey,pt) ;
+     goodPair=kTRUE;
+   }
+   if((foundV01onfly && hitEMCAL2) || (foundV02onfly && hitEMCAL1)){
+     snprintf(hkey,55,"hMC_CaloConv_%s_v0onfly_EMCALacc",partName) ;
+     FillHistogram(hkey,pt) ;
      goodPair=kTRUE;
    }
-   if((foundV01 && hitEMCAL2) || (foundV02 && hitEMCAL1)){
-     FillHistogram("hMC_CaloConv_pi0_v0_EMCALacc",pt) ;
+   if((foundV01offline && hitEMCAL2) || (foundV02offline && hitEMCAL1)){
+     snprintf(hkey,55,"hMC_CaloConv_%s_v0offline_EMCALacc",partName) ;
+     FillHistogram(hkey,pt) ;
      goodPair=kTRUE;
    }
    if(!goodPair){
@@ -2218,6 +2261,8 @@ void AliAnalysisTaskCaloConv::ProcessMC(){
 
    //Converted pi0 with v0 and cluster in PHOS/EMCAL
    Bool_t cluInPHOS = kFALSE,cluInEMCAL=kFALSE ;
+   Bool_t cluInPHOSpid = kFALSE,cluInEMCALpid=kFALSE ;
+   Bool_t closeToBad= kFALSE ;
    TLorentzVector pCalo ;
    for (Int_t i=0; i<fESDEvent->GetNumberOfCaloClusters(); i++) {
      AliESDCaloCluster * clu = fESDEvent->GetCaloCluster(i);
@@ -2236,29 +2281,144 @@ void AliAnalysisTaskCaloConv::ProcessMC(){
        continue ;
      if(clu->IsPHOS() && (hitPHOS1 || hitPHOS2)){
        cluInPHOS=kTRUE ;
+       //Check if cluster passed PID
+       for(Int_t inPHOS=0; inPHOS<nPHOS;inPHOS++){
+         if(fGammaPHOS[inPHOS] == i){
+           cluInPHOSpid=kTRUE ;
+           break ;
+         }
+       }
        clu->GetMomentum(pCalo ,vtx);
+       if(clu->GetDistanceToBadChannel()<fBadDistCutPHOS)
+         closeToBad=kTRUE ;
        break ;
      }
      if(!clu->IsPHOS() && (hitEMCAL1 || hitEMCAL2)){
        cluInEMCAL=kTRUE ;
+       //Check if cluster passed PID
+       for(Int_t inEMCAL=0; inEMCAL<nEMCAL;inEMCAL++){
+         if(fGammaEMCAL[inEMCAL] == i){
+           cluInPHOSpid=kTRUE ;
+           break ;
+         }
+       }
        clu->GetMomentum(pCalo ,vtx);
+       if(clu->GetDistanceToBadChannel()<fBadDistCutEMCAL)
+         closeToBad=kTRUE ;
        break ;
      }
    }
 
    if(cluInPHOS){
-     FillHistogram("hMC_CaloConv_pi0_v0_PHOSclu",pt) ;
-     Double_t m=(pCalo+pConv).M() ;
-     Double_t ptm=(pCalo+pConv).Pt() ;
-     FillHistogram("hMC_CaloConv_pi0_v0_PHOSclu_ptRec",ptm) ;
-     FillHistogram("hMC_CaloConv_pi0_v0_PHOSclu_mvsPt",m,ptm) ;
+     //OnFly
+     if(foundV01onfly ||foundV02onfly){
+       snprintf(hkey,55,"hMC_CaloConv_%s_v0onfly_PHOSclu",partName) ;
+       FillHistogram(hkey,pt) ;
+
+       if((foundV01onflyPID ||foundV02onflyPID) && cluInPHOSpid){
+       snprintf(hkey,55,"hMC_CaloConv_%s_v0onfly_PHOSclu_pid",partName) ;
+         FillHistogram(hkey,pt) ;
+         for(Int_t iw=0;iw<10;iw++){ //resolution
+           for(Int_t in=0;in<10;in++){
+             char keym[55] ;
+             snprintf(keym,55,"hMC_CaloConv_%s_v0onfly_PHOSclu_w%d_n%d",partName,iw,in) ;
+             Double_t mMod=0.,ptMod=0. ;
+             Recalibrate(mMod, ptMod, &pCalo, &pConvOn, iw, in) ;
+             FillHistogram(keym,ptMod) ;
+             snprintf(keym,55,"hMC_CaloConv_%s_v0onfly_ConvPHOSclu_w%d_n%d",partName,iw,in) ;
+             RecalibrateConvPHOS(mMod, ptMod, &pCalo, &pConvOn, iw, in) ;
+             FillHistogram(keym,ptMod) ;
+           }
+         }
+         if(!closeToBad){
+           snprintf(hkey,55,"hMC_CaloConv_%s_v0onfly_PHOSclu_good",partName) ;
+           FillHistogram(hkey,pt) ;
+         }
+         Double_t m=(pCalo+pConvOn).M() ;
+         Double_t ptm=(pCalo+pConvOn).Pt() ;
+         snprintf(hkey,55,"hMC_CaloConv_%s_v0on_PHOSclu_ptRec",partName) ;
+         FillHistogram(hkey,ptm) ;
+         snprintf(hkey,55,"hMC_CaloConv_%s_v0on_PHOSclu_mvsPt",partName) ;
+         FillHistogram(hkey,m,ptm) ;
+       }
+     }
+
+     //Offline
+     if(foundV01offline ||foundV02offline){
+       snprintf(hkey,55,"hMC_CaloConv_%s_v0offline_PHOSclu",partName) ;
+       FillHistogram(hkey,pt) ;
+       if((foundV01offlinePID ||foundV02offlinePID) && cluInPHOSpid){
+         snprintf(hkey,55,"hMC_CaloConv_%s_v0offline_PHOSclu_pid",partName) ;
+         FillHistogram(hkey,pt) ;
+         Double_t m=(pCalo+pConvOff).M() ;
+         Double_t ptm=(pCalo+pConvOff).Pt() ;
+         snprintf(hkey,55,"hMC_CaloConv_%s_v0off_PHOSclu_ptRec",partName) ;
+         FillHistogram(hkey,ptm) ;
+         snprintf(hkey,55,"hMC_CaloConv_%s_v0off_PHOSclu_mvsPt",partName) ;
+         FillHistogram(hkey,m,ptm) ;
+         if(!closeToBad){
+           snprintf(hkey,55,"hMC_CaloConv_%s_v0offline_PHOSclu_good",partName) ;
+           FillHistogram(hkey,pt) ;
+         }
+       }
+     } 
+
+     if((foundV01onflyPID ||foundV02onflyPID) && cluInPHOSpid){
+       TString base("hMC_CaloConv_") ; base+=partName; base+="_v0onfly_PHOSclu_mod" ;
+       if(hitPHOS1)
+         base+=mod1 ;
+       else
+         base+=mod2 ;
+       FillHistogram(base.Data(),pt) ;
+     }
+
+     if((foundV01offlinePID ||foundV02offlinePID) && cluInPHOSpid){
+       TString base("hMC_CaloConv_") ; base+=partName; base+="_v0offline_PHOSclu_mod" ;
+       if(hitPHOS1)
+         base+=mod1 ;
+       else
+         base+=mod2 ;
+       FillHistogram(base.Data(),pt) ;
+     }
    }
-   if(cluInEMCAL){
-     FillHistogram("hMC_CaloConv_pi0_v0_EMCALclu",pt) ;
-     Double_t m=(pCalo+pConv).M() ;
-     Double_t ptm=(pCalo+pConv).Pt() ;
-     FillHistogram("hMC_CaloConv_pi0_v0_EMCALclu_ptRec",ptm) ;
-     FillHistogram("hMC_CaloConv_pi0_v0_EMCALclu_mvsPt",m,ptm) ;
+   if(cluInEMCAL && strcmp(partName,"pi0")==0){
+     //OnFly
+     if(foundV01onfly ||foundV02onfly){
+       FillHistogram("hMC_CaloConv_pi0_v0onfly_EMCALclu",pt) ;
+
+       if((foundV01onflyPID ||foundV02onflyPID) && cluInEMCALpid){
+         FillHistogram("hMC_CaloConv_pi0_v0onfly_EMCALclu_pid",pt) ;
+         for(Int_t iw=0;iw<10;iw++){ //resolution
+           for(Int_t in=0;in<10;in++){
+             char keym[55] ;
+             snprintf(keym,55,"hMC_CaloConv_pi0_v0onfly_EMCALclu_w%d_n%d",iw,in) ;
+             Double_t mMod=0.,ptMod=0. ;
+             RecalibrateEMCAL(mMod, ptMod, &pCalo, &pConvOn, iw, in) ;
+             FillHistogram(keym,ptMod) ;
+           }
+         }
+         if(!closeToBad)
+           FillHistogram("hMC_CaloConv_pi0_v0onfly_EMCALclu_good",pt) ;
+         Double_t m=(pCalo+pConvOn).M() ;
+         Double_t ptm=(pCalo+pConvOn).Pt() ;
+         FillHistogram("hMC_CaloConv_pi0_v0on_EMCALclu_ptRec",ptm) ;
+         FillHistogram("hMC_CaloConv_pi0_v0on_EMCALclu_mvsPt",m,ptm) ;
+       }
+     }
+
+     //Offline
+     if(foundV01offline ||foundV02offline){
+       FillHistogram("hMC_CaloConv_pi0_v0offline_EMCALclu",pt) ;
+       if((foundV01offlinePID ||foundV02offlinePID) && cluInEMCALpid){
+         FillHistogram("hMC_CaloConv_pi0_v0offline_EMCALclu_pid",pt) ;
+         Double_t m=(pCalo+pConvOff).M() ;
+         Double_t ptm=(pCalo+pConvOff).Pt() ;
+         FillHistogram("hMC_CaloConv_pi0_v0off_EMCALclu_ptRec",ptm) ;
+         FillHistogram("hMC_CaloConv_pi0_v0off_EMCALclu_mvsPt",m,ptm) ;
+         if(!closeToBad)
+           FillHistogram("hMC_CaloConv_pi0_v0offline_EMCALclu_good",pt) ;
+       }
+     }
    }
   }
 
@@ -2271,7 +2431,7 @@ void AliAnalysisTaskCaloConv::ProcessMC(){
       Int_t iprimPHOS = clu->GetLabel() ; //# of particle hit PHOS/EMCAL
       for(Int_t iConv = 0; iConv<fConvEvent->GetEntriesFast(); iConv++){
         TLorentzVector * cnv = static_cast<TLorentzVector*>(fConvEvent->At(iConv)) ;
-        if(!cnv->TestBit(kConvOnFly) || cnv->TestBit(kConvKink) || !cnv->TestBit(kConvdEdx) || !cnv->TestBit(kConvProb) || cnv->TestBit(kConvEta)) 
+        if(!cnv->TestBit(kConvOnFly) || cnv->TestBit(kConvEta)) 
           continue;
 
         Int_t iv0=fGammaV0s[iConv] ;
@@ -2366,7 +2526,7 @@ void AliAnalysisTaskCaloConv::ProcessMC(){
       Int_t iprimEMCAL = clu->GetLabel() ; //# of particle hit EMCAL
       for(Int_t iConv = 0; iConv<fConvEvent->GetEntriesFast(); iConv++){
         TLorentzVector * cnv = static_cast<TLorentzVector*>(fConvEvent->At(iConv)) ;
-        if(!cnv->TestBit(kConvOnFly) || cnv->TestBit(kConvKink) || !cnv->TestBit(kConvdEdx) || !cnv->TestBit(kConvProb) || cnv->TestBit(kConvEta)) 
+        if(!cnv->TestBit(kConvOnFly) || cnv->TestBit(kConvEta)) 
           continue;
         Int_t iv0=fGammaV0s[iConv] ;
         AliESDv0 * v0 = fESDEvent->GetV0(iv0) ;
@@ -2470,7 +2630,7 @@ void AliAnalysisTaskCaloConv::ProcessMC(){
      FillHistogram("hMC_CaloConv_phot",pt) ;
 
      Int_t mod ;
-     Double_t x,z ;
+     Double_t x=0.,z=0. ;
      Bool_t hitPHOS = fPHOSgeom->ImpactOnEmc(particle, mod, z,x) ;
      Bool_t hitEMCAL= fEMCALgeom->Impact(particle) ;
 
@@ -2539,6 +2699,7 @@ void AliAnalysisTaskCaloConv::ProcessMC(){
       //Registered in PHOS/EMCAL
      Bool_t cluInPHOS = kFALSE,cluInEMCAL=kFALSE ;
      TLorentzVector pCalo ;
+     Bool_t dist1=kFALSE, dist2=kFALSE ;
      for (Int_t i=0; i<fESDEvent->GetNumberOfCaloClusters(); i++) {
        AliESDCaloCluster * clu = fESDEvent->GetCaloCluster(i);
        Int_t iprim = clu->GetLabel() ; //# of particle hit PHOS/EMCAL
@@ -2557,22 +2718,38 @@ void AliAnalysisTaskCaloConv::ProcessMC(){
        if(clu->IsPHOS() && hitPHOS){
          cluInPHOS=kTRUE ;
          clu->GetMomentum(pCalo ,vtx);
+         if(clu->GetDistanceToBadChannel()<fBadDistCutPHOS)
+           dist1=kTRUE ;
+         if(clu->GetDistanceToBadChannel()<2.*fBadDistCutPHOS)
+           dist2=kTRUE ;
          break ;
        }
        if(!clu->IsPHOS() && hitEMCAL){
          cluInEMCAL=kTRUE ;
          clu->GetMomentum(pCalo ,vtx);
+         if(clu->GetDistanceToBadChannel()<fBadDistCutEMCAL)
+           dist1=kTRUE ;
+         if(clu->GetDistanceToBadChannel()<2.*fBadDistCutEMCAL)
+           dist2=kTRUE ;
          break ;
        }
      }
 
      if(cluInPHOS){
        FillHistogram("hMC_CaloConv_gamma_PHOSclu",pt) ;
+       if(!dist1)
+         FillHistogram("hMC_CaloConv_gamma_PHOSclu_dist1",pt) ;
+       if(!dist2)
+         FillHistogram("hMC_CaloConv_gamma_PHOSclu_dist2",pt) ;
        FillHistogram("hMC_CaloConv_gamma_PHOSclu_recE",pCalo.E()) ;
        FillHistogram("hMC_CaloConv_gamma_PHOSclu_devsE",(particle->Energy()-pCalo.E())/particle->Energy(),particle->Energy()) ;
      }
      if(cluInEMCAL){
        FillHistogram("hMC_CaloConv_gamma_EMCALclu",pt) ;
+       if(!dist1)
+         FillHistogram("hMC_CaloConv_gamma_EMCALclu_dist1",pt) ;
+       if(!dist2)
+         FillHistogram("hMC_CaloConv_gamma_EMCALclu_dist2",pt) ;
        FillHistogram("hMC_CaloConv_gamma_EMCALclu_recE",pCalo.E()) ;
        FillHistogram("hMC_CaloConv_gamma_EMCALclu_devsE",(particle->Energy()-pCalo.E())/particle->Energy(),particle->Energy()) ;
      }
@@ -2582,16 +2759,20 @@ void AliAnalysisTaskCaloConv::ProcessMC(){
 void AliAnalysisTaskCaloConv::FillHistogram(const char * key,Double_t x)const{
   //FillHistogram
   TH1F * tmp = dynamic_cast<TH1F*>(fOutputContainer->FindObject(key)) ;
-  if(!tmp)
-    AliError(Form("can not find histogram <%s> ",key)) ;
+  if(!tmp){
+    AliInfo(Form("can not find histogram <%s> ",key)) ;
+    return ;
+  }
   tmp->Fill(x) ;
 }
 //_____________________________________________________________________________
 void AliAnalysisTaskCaloConv::FillHistogram(const char * key,Double_t x,Double_t y)const{
   //FillHistogram
   TObject * tmp = fOutputContainer->FindObject(key) ;
-  if(!tmp)
-    AliError(Form("can not find histogram <%s> ",key)) ;
+  if(!tmp){
+    AliInfo(Form("can not find histogram <%s> ",key)) ;
+    return ;
+  }
   if(tmp->IsA() == TClass::GetClass("TH1F")){
     ((TH1F*)tmp)->Fill(x,y) ;
     return ;
@@ -2603,13 +2784,14 @@ void AliAnalysisTaskCaloConv::FillHistogram(const char * key,Double_t x,Double_t
   AliError(Form("Calling FillHistogram with 2 parameters for histo <%s> of type %s",key,tmp->IsA()->GetName())) ;
 }
 
-
 //_____________________________________________________________________________
 void AliAnalysisTaskCaloConv::FillHistogram(const char * key,Double_t x,Double_t y, Double_t z) const{
   //Fills 1D histograms with key
   TObject * tmp = fOutputContainer->FindObject(key) ;
-  if(!tmp)
-    AliError(Form("can not find histogram <%s> ",key)) ;
+  if(!tmp){
+    AliInfo(Form("can not find histogram <%s> ",key)) ;
+    return ;
+  }
   if(tmp->IsA() == TClass::GetClass("TH2F")){
     ((TH2F*)tmp)->Fill(x,y,z) ;
     return ;
@@ -2680,6 +2862,103 @@ Bool_t AliAnalysisTaskCaloConv::IsGoodChannel(const char * det, Int_t mod, Int_t
    
   return kTRUE ;
 }
+//______________________________________________________________________________
+void AliAnalysisTaskCaloConv::Recalibrate(Double_t &m, Double_t &pt, const TLorentzVector *calo, const TLorentzVector * conv, Int_t iw, Int_t in) {
+  //Apply decalibration and non-linearity
+  TLorentzVector calo2(*calo) ;
+  Double_t en=calo2.E() ;
+
+  Double_t sigma=0.06+0.005*iw ; //additional smearing
+  //Nonlinearity
+  Double_t a=0.02*(in%6-2.5) ;
+  Double_t b=0.5+1.*((Int_t)in/6) ;
+  Double_t enNew=1.-a*TMath::Exp(-en/b) ;
+  Double_t corr=gRandom->Gaus(enNew,sigma) ;
+  calo2*=corr ;
+
+  m=(calo2+ *conv).M() ;
+  pt=(calo2+ *conv).Pt() ;
+
+}
+//______________________________________________________________________________
+void AliAnalysisTaskCaloConv::RecalibrateEMCAL(Double_t &m, Double_t &pt, const TLorentzVector *calo, const TLorentzVector * conv, Int_t iw, Int_t in) {
+  //Apply decalibration and non-linearity
+  TLorentzVector calo2(*calo) ;
+  Double_t en=calo2.E() ;
+
+  Double_t sigma=0.04+0.005*iw ; //additional smearing
+  //Nonlinearity
+  Double_t a=0.02*(in%6-2.5) ;
+  Double_t b=0.25+0.5*((Int_t)in/6) ;
+  Double_t enNew=1.-a*TMath::Exp(-en/b) ;
+  Double_t corr=gRandom->Gaus(enNew,sigma) ;
+  calo2*=corr ;
+
+  m=(calo2+ *conv).M() ;
+  pt=(calo2+ *conv).Pt() ;
+
+}
+//______________________________________________________________________________
+void AliAnalysisTaskCaloConv::RecalibrateConvPHOS(Double_t &m, Double_t &pt, const TLorentzVector *calo, const TLorentzVector * conv, Int_t iw, Int_t in) {
+  //Apply decalibration and non-linearity
+
+  //First default PHOS smearing
+  TLorentzVector calo2(*calo) ;
+  Double_t en=calo2.E() ;
+
+  Double_t sigma=0.065 ; //additional smearing
+  //Nonlinearity
+  Double_t a=0.15 ;
+  Double_t b=0.45 ;
+  Double_t enNew=1.+a*TMath::Exp(-en/b) ;
+  Double_t corr=gRandom->Gaus(enNew,sigma) ;
+  calo2*=corr ;
+
+  //Now conversion photon
+  TLorentzVector conv2(*conv) ;
+  //linear offset in z:
+  Double_t eta=conv2.Eta() ;
+  Double_t c=1.e-3*iw ;
+  eta+= c *TMath::Sign(0.9-TMath::Abs(eta),eta) ;
+
+  //Smear energy and add nonlinearity
+  //Nonlinearity
+  Double_t enConv=conv2.E() ;
+  Double_t ac=0.02*(in%5) ;
+  Double_t bc=0.25+0.5*((Int_t)in/5) ;
+  Double_t enNewc=1.+ac*TMath::Exp(-enConv/bc) ;
+  corr=gRandom->Gaus(enNewc,0.01) ;
+  Double_t ptc=conv2.Pt()*corr ;
+  conv2.SetPtEtaPhiM(ptc,eta,conv2.Phi(),0.) ;
+
+  m =(calo2 + conv2).M() ;
+  pt=(calo2 + conv2).Pt() ;
+
+}
+//______________________________________________________________________________
+void AliAnalysisTaskCaloConv::GetArmenterosQtAlfa(AliKFParticle* positiveKFParticle, AliKFParticle * negativeKFParticle, AliKFParticle * gammaKFCandidate, Double_t armenterosQtAlfa[2] ){
+  //see header file for documentation
+
+  TVector3 momentumVectorPositiveKF(positiveKFParticle->GetPx(),positiveKFParticle->GetPy(),positiveKFParticle->GetPz());
+  TVector3 momentumVectorNegativeKF(negativeKFParticle->GetPx(),negativeKFParticle->GetPy(),negativeKFParticle->GetPz());
+  TVector3 vecV0(gammaKFCandidate->GetPx(),gammaKFCandidate->GetPy(),gammaKFCandidate->GetPz());
+
+  Float_t thetaV0pos=TMath::ACos(( momentumVectorPositiveKF* vecV0)/(momentumVectorPositiveKF.Mag() * vecV0.Mag()));
+  Float_t thetaV0neg=TMath::ACos(( momentumVectorNegativeKF* vecV0)/(momentumVectorNegativeKF.Mag() * vecV0.Mag()));
+
+  Float_t alfa =((momentumVectorPositiveKF.Mag())*TMath::Cos(thetaV0pos)-(momentumVectorNegativeKF.Mag())*TMath::Cos(thetaV0neg))/
+    ((momentumVectorPositiveKF.Mag())*TMath::Cos(thetaV0pos)+(momentumVectorNegativeKF.Mag())*TMath::Cos(thetaV0neg)) ;
+
+
+  Float_t qt = momentumVectorPositiveKF.Mag()*TMath::Sin(thetaV0pos);
+
+  armenterosQtAlfa[0]=qt;
+  armenterosQtAlfa[1]=alfa;
+
+}
+
+
+
 
  
 
index 354f62a..3ece2df 100644 (file)
@@ -19,12 +19,15 @@ class AliESDEvent;
 class AliAODEvent;
 class AliMCEvent;
 class TList;
+class TLorentzVector;
 class AliCFContainer ;
 class AliStack;
 class AliESDpid ;
+class AliESDtrackCuts ;
 class AliEMCALGeoUtils ;
 class AliPHOSGeoUtils ;
 class AliExternalTrackParam ;
+class AliKFParticle ;
 
 class AliAnalysisTaskCaloConv : public AliAnalysisTaskSE
 {
@@ -76,19 +79,26 @@ class AliAnalysisTaskCaloConv : public AliAnalysisTaskSE
    void FillHistogram(const char * key,Double_t x, Double_t y, Double_t z) const ; //Fill 3D histogram witn name key
    Double_t PlanarityAngle(const AliExternalTrackParam * pos, const AliExternalTrackParam * neg)const ;
    Bool_t IsGoodChannel(const char * det="PHOS", Int_t mod=1, Int_t ix=1,Int_t iz=1) ; //Checks bad map
+   void Recalibrate(Double_t &m, Double_t &pt, const TLorentzVector *calo, const TLorentzVector * conv, Int_t iw, Int_t in) ;
+   void RecalibrateConvPHOS(Double_t &m, Double_t &pt, const TLorentzVector *calo, const TLorentzVector * conv, Int_t iw, Int_t in) ;
+   void RecalibrateEMCAL(Double_t &m, Double_t &pt, const TLorentzVector *calo, const TLorentzVector * conv, Int_t iw, Int_t in) ;
+   void GetArmenterosQtAlfa(AliKFParticle* positiveKFParticle, AliKFParticle * negativeKFParticle, 
+                            AliKFParticle * gammaKFCandidate, Double_t armenterosQtAlfa[2] ) ;
 
  private:
   AliAnalysisTaskCaloConv(const AliAnalysisTaskCaloConv&); // Not implemented
   AliAnalysisTaskCaloConv& operator=(const AliAnalysisTaskCaloConv&); // Not implemented
                
+ protected:
   enum{
     kCaloPIDdisp = BIT(14),
     kCaloPIDtof  = BIT(15),
-    kCaloPIDneutral= BIT(16)
+    kCaloPIDneutral= BIT(16),
+    kCaloDistBad = BIT(17)
   };
   enum{
     kConvOnFly= BIT(14),
-    kConvKink = BIT(15),
+    kConvArmQt= BIT(15),
     kConvdEdx = BIT(16),
     kConvProb = BIT(17),
     kConvR    = BIT(18),
@@ -101,6 +111,7 @@ class AliAnalysisTaskCaloConv : public AliAnalysisTaskSE
                
   AliESDEvent* fESDEvent; //!pointer to the ESDEvent
   AliESDpid * fESDpid ;   //class for Track PID calculation
+  AliESDtrackCuts * fESDtrackCuts; //class for charged multiplicity estimation
   AliStack * fStack;      //! pointer to the MC particle stack
   TList * fOutputContainer; //final histogram container
   TList * fCFOutputContainer; //Correction Fremework conntainer
@@ -109,6 +120,8 @@ class AliAnalysisTaskCaloConv : public AliAnalysisTaskSE
   AliCFContainer * fPHOSCFCont ;  //Container for Conv. photons correction calculation
   AliCFContainer * fEMCALCFCont ; //Container for Conv. photons correction calculation
   AliCFContainer * fPi0CFCont ;   //Container for Conv. photons correction calculation
+
+  Double_t fCentr ;
                
   Bool_t fTriggerCINT1B; //Flag to select trigger CINT1B
   Bool_t fToUseCF ;      //Switch on/off CF histogram filling
@@ -119,6 +132,8 @@ class AliAnalysisTaskCaloConv : public AliAnalysisTaskSE
   AliEMCALGeoUtils *fEMCALgeom;     //!EMCAL geometry
   Double_t fPi0Thresh1 ;    //Threshold 1 for pi0 calibration
   Double_t fPi0Thresh2 ;    //Threshold 2 for pi0 calibration
+  Double_t fBadDistCutPHOS ; //Cut on distance to bad channel
+  Double_t fBadDistCutEMCAL ; //Cut on distance to bad channel
   TH2I * fPHOSBadMap[6] ;   //Container for PHOS bad channels map
   TH2I * fEMCALBadMap[10] ; //Container for EMCAL Bad channels map
 
@@ -146,7 +161,7 @@ class AliAnalysisTaskCaloConv : public AliAnalysisTaskSE
   Double_t fptCut ;                  //fptCut
   Double_t fchi2CutConversion ;      //fchi2CutConversion
 
-  ClassDef(AliAnalysisTaskCaloConv, 1); // Analysis task for conversion + calorimeters
+  ClassDef(AliAnalysisTaskCaloConv, 2); // Analysis task for conversion + calorimeters
 };
 
 #endif //ALIANALYSISTASKCALOCO_H