Adding UE corrections task, Updating UE classes with new vertex cut
authorkleinb <kleinb@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 15 Jul 2010 08:06:00 +0000 (08:06 +0000)
committerkleinb <kleinb@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 15 Jul 2010 08:06:00 +0000 (08:06 +0000)
PWG4/JetTasks/AliAnalyseUE.cxx
PWG4/JetTasks/AliAnalyseUE.h
PWG4/JetTasks/AliAnalysisTaskCorrectionsUE.cxx [new file with mode: 0644]
PWG4/JetTasks/AliAnalysisTaskCorrectionsUE.h [new file with mode: 0644]
PWG4/JetTasks/AliAnalysisTaskUE.cxx
PWG4/JetTasks/AliAnalysisTaskUE.h
PWG4/JetTasks/AliHistogramsUE.cxx
PWG4/JetTasks/AliHistogramsUE.h
PWG4/PWG4JetTasksLinkDef.h
PWG4/libPWG4JetTasks.pkg
PWG4/macros/AddTaskCorrectionsUE.C [new file with mode: 0644]

index 822ff620a5da69d5a4e2d59c7394833a990e0fad..1abd74d3b6e37ea59057aa3b4470af33f445fc06 100644 (file)
 
 #include "AliAnalysisManager.h"
 #include "AliAODEvent.h"
+#include "AliESDEvent.h"
 #include "AliAODHandler.h"
 #include "AliAODInputHandler.h"
 #include "AliAODJet.h"
 #include "AliAODMCParticle.h"
 #include "AliAODTrack.h"
+#include "AliESDtrack.h"
 #include "AliKFVertex.h"
 #include "AliMCEvent.h"
 #include "AliMCEventHandler.h"
@@ -69,8 +71,11 @@ AliAnalyseUE::AliAnalyseUE() :
   TObject(),
   //fTaskUE(0),
   fkAOD(0x0),            
+  fkMC(0x0), 
+  fkESD(0x0),
   fDebug(0),
   fSimulateChJetPt(kFALSE),
+  fStack(0x0), 
   fAnaType(1),         
   fAreaReg(1.5393), // Pi*0.7*0.7
   fConeRadius(0.7),
@@ -97,8 +102,9 @@ AliAnalyseUE::AliAnalyseUE() :
   fNTrackRegionNegat(0),
   fNTrackRegionForward(0),
   fNTrackRegionBackward(0),
-  fSettingsTree(0x0)
-
+  fSettingsTree(0x0),
+  fLtLabel(-999),
+  fLtMCLabel(-999)
 {
   // constructor
 }
@@ -109,8 +115,11 @@ AliAnalyseUE::AliAnalyseUE(const AliAnalyseUE & original) :
   TObject(original),
   //fTaskUE(original.fTaskUE),
   fkAOD(original.fkAOD),            
+  fkMC(original.fkMC),            
+  fkESD(original.fkESD),            
   fDebug(original.fDebug),
   fSimulateChJetPt(original.fSimulateChJetPt),
+  fStack(original.fStack),
   fAnaType(original.fAnaType),
   fAreaReg(original.fAreaReg),
   fConeRadius(original.fConeRadius),
@@ -137,7 +146,9 @@ AliAnalyseUE::AliAnalyseUE(const AliAnalyseUE & original) :
   fNTrackRegionNegat(original.fNTrackRegionNegat),
   fNTrackRegionForward(original.fNTrackRegionForward),
   fNTrackRegionBackward(original.fNTrackRegionBackward),
-  fSettingsTree(original.fSettingsTree)
+  fSettingsTree(original.fSettingsTree),
+  fLtLabel(original.fLtLabel),
+  fLtMCLabel(original.fLtMCLabel)
 {
   //copy constructor   
 }
@@ -480,8 +491,11 @@ void AliAnalyseUE::FillRegions(Bool_t isNorm2Area,  TVector3 *jetVect){
 
 
 //-------------------------------------------------------------------
-void AliAnalyseUE::FindMaxMinRegions(TVector3 *jetVect, Int_t conePosition){
-  
+void AliAnalyseUE::FindMaxMinRegions(TVector3 *jetVect, Int_t conePosition, Int_t mctrue=0, Int_t eff=0){
+  // If mctrue = 1 consider branch AliAODMCParticles  
+  // If    eff = 1 track cuts for efficiency studies 
+
   // Identify the different topological zones
   fSumPtRegionPosit = 0.;
   fSumPtRegionNegat = 0.;
@@ -497,56 +511,191 @@ void AliAnalyseUE::FindMaxMinRegions(TVector3 *jetVect, Int_t conePosition){
   static Double_t const  k270rad = 270.*kPI/180.;
   Double_t const kMyTolerance = 0.0000001;
 
-    Int_t nTracks = fkAOD->GetNTracks();
-    if (fDebug > 1) AliInfo(Form(" ==== AOD tracks = %d \n ",nTracks));
+    Int_t nTracks=0;
+    TClonesArray *tca = 0;
+    if (!mctrue) {
+       nTracks = fkAOD->GetNTracks();
+       if (fDebug > 1) AliInfo(Form(" ==== AOD tracks = %d \n ",nTracks));
+    }else{
+       tca = dynamic_cast<TClonesArray*>(fkAOD->FindListObject(AliAODMCParticle::StdBranchName())); 
+       if(!tca){
+               Printf("No branch!!!");
+               return;
+               }
+       nTracks = tca->GetEntriesFast();
+       if (fDebug > 1) AliInfo(Form(" ==== AOD MC particles = %d \n ",nTracks));
+       }
     
+    //If UE task d0 distribution is not filled
+    Int_t flag_tmp=0;
+    if (fHistos->GetHistograms()->FindObject("hDCAxy")) flag_tmp = 1;
+
     for (Int_t ipart=0; ipart<nTracks; ++ipart) {
+    AliVParticle *part; 
+    AliAODTrack *partRECO=0;
+    AliAODMCParticle *partMC=0;
+    Double_t charge=-999.;
+    Double_t pt=-999.;
+    Double_t eta=-999.;
+    Int_t pdgcode=-999; 
+    TString suffix("");
+
+    // get track reco or true
+    if (!mctrue){
+        partRECO = dynamic_cast<AliAODTrack*>(fkAOD->GetTrack(ipart));
+        part = partRECO;
+        }
+    else {
+       partMC = dynamic_cast<AliAODMCParticle*>(tca->At(ipart)); 
+        part = partMC;
+        charge = partMC->Charge();
+       pt = partMC->Pt();
+        eta = partMC->Eta();
+       pdgcode = partMC->GetPdgCode();
+        suffix.Append("MC"); 
+       } 
+
       
-    AliAODTrack* part = fkAOD->GetTrack( ipart );
     if (fDebug > 1) AliInfo(Form(" ==== AOD track = %d pt = %f charge = %d \n ",ipart,part->Pt(),part->Charge()));
+    
     // track selection
-    if (! TrackSelected(part)) continue;
-      
+    if (!mctrue && !eff ){
+       if( !TrackSelected(partRECO)) continue; //track selection for data and MC reconstructed
+        if (flag_tmp){
+               if (fkESD && fkESD->GetNumberOfTracks() ){
+                       AliInfo("READING ESD *************************************************");
+                       Int_t id = partRECO->GetID();
+                       AliESDtrack *trackESD;
+                       trackESD = (AliESDtrack*)fkESD->GetTrack(id);
+                       Float_t d0;
+                       Float_t z;
+                       trackESD->GetImpactParameters(d0,z);
+                       fHistos->FillHistogram("hDCAxy", d0, jetVect[0].Pt());
+                       }else AliInfo("NO TRACKS ************************************************") 
+               }
+       }
+    
+    if (!mctrue && eff){
+       if (!TrackSelectedEfficiency(partRECO )) continue; //track selection for MC reconstructed for efficiency studies
+               if(fkESD && fkESD->GetNumberOfTracks()){
+                       Int_t id = partRECO->GetID();
+                       AliESDtrack * trackESD = (AliESDtrack*) fkESD->GetTrack(id);
+                       Float_t d0;
+                       Float_t z;
+                       trackESD->GetImpactParameters(d0,z);
+                       fHistos->FillHistogram("hDCAxyPrimary", d0, jetVect[0].Pt()); 
+                       }
+       }
+
+    if (mctrue){
+        if ( !(TrackMCSelected(charge, pt, eta, pdgcode) && partMC->IsPhysicalPrimary())) continue; //track selection for MC true
+      }
       
     TVector3 partVect(part->Px(), part->Py(), part->Pz());
     Bool_t isFlagPart = kTRUE;
     Double_t deltaPhi = jetVect[0].DeltaPhi(partVect)+k270rad;
     if( deltaPhi > kTWOPI )  deltaPhi-= kTWOPI;
-    if (fAnaType != 4 ) fHistos->FillHistogram("hdNdEtaPhiDist",deltaPhi, jetVect[0].Pt());
+    if (fAnaType != 4 ) fHistos->FillHistogram(Form("hdNdEtaPhiDist%s",suffix.Data()),deltaPhi, jetVect[0].Pt());
     else if (TMath::Abs(deltaPhi-k270rad) >= kMyTolerance && TMath::Abs(jetVect[0].Eta()-partVect.Eta()) >= kMyTolerance){
-       fHistos->FillHistogram("hdNdEtaPhiDist",deltaPhi, jetVect[0].Pt());
+       fHistos->FillHistogram(Form("hdNdEtaPhiDist%s",suffix.Data()),deltaPhi, jetVect[0].Pt());
        isFlagPart = kFALSE;
        }
       
-    fHistos->FillHistogram("hFullRegPartPtDistVsEt", part->Pt(), jetVect[0].Pt());  
+    fHistos->FillHistogram(Form("hFullRegPartPtDistVsEt%s",suffix.Data()), part->Pt(), jetVect[0].Pt());  
     
     Int_t region = IsTrackInsideRegion( jetVect, &partVect, conePosition );  
     if (region == 1) {
        if( fMaxPartPtRegion < part->Pt() ) fMaxPartPtRegion = part->Pt();
         fSumPtRegionPosit += part->Pt();
         fNTrackRegionPosit++;
-       fHistos->FillHistogram("hTransRegPartPtDistVsEt",part->Pt(), jetVect[0].Pt());
+       fHistos->FillHistogram(Form("hTransRegPartPtDistVsEt%s",suffix.Data()),part->Pt(), jetVect[0].Pt());
        }
     if (region == -1) {
        if( fMaxPartPtRegion < part->Pt() ) fMaxPartPtRegion = part->Pt();
         fSumPtRegionNegat += part->Pt();
         fNTrackRegionNegat++;
-       fHistos->FillHistogram("hTransRegPartPtDistVsEt",part->Pt(), jetVect[0].Pt());
+       fHistos->FillHistogram(Form("hTransRegPartPtDistVsEt%s",suffix.Data()),part->Pt(), jetVect[0].Pt());
        }
     if (region == 2){ //forward
        fSumPtRegionForward += part->Pt();
         fNTrackRegionForward++;
-       fHistos->FillHistogram("hRegForwardPartPtDistVsEt",part->Pt(), jetVect[0].Pt());
+       fHistos->FillHistogram(Form("hRegForwardPartPtDistVsEt%s",suffix.Data()),part->Pt(), jetVect[0].Pt());
        }
     if (region == -2){ //backward
        fSumPtRegionBackward += part->Pt();
         fNTrackRegionBackward++;
-       fHistos->FillHistogram("hRegBackwardPartPtDistVsEt",part->Pt(), jetVect[0].Pt());
+       fHistos->FillHistogram(Form("hRegBackwardPartPtDistVsEt%s",suffix.Data()),part->Pt(), jetVect[0].Pt());
        }
     }//end loop AOD tracks
 
 }
 
+//-------------------------------------------------------------------
+/*TVector3 AliAnalyseUE::GetLeadingTracksMC(AliMCEvent *mcEvent){
+   
+  fkMC = mcEvent; 
+
+  Double_t maxPtJet1 = 0.; 
+  Int_t    index1 = -1;
+  
+  TVector3 jetVect[3];
+  
+  jetVect[0].SetPtEtaPhi(-1.,-1.,-1.);
+  jetVect[1].SetPtEtaPhi(-1.,-1.,-1.);
+  jetVect[2].SetPtEtaPhi(-1.,-1.,-1.);
+  
+  Int_t nJets = 0;
+  
+  TObjArray* tracks = SortChargedParticlesMC();
+    if( tracks ) {
+       nJets = tracks->GetEntriesFast();
+       if( nJets > 0 ) {
+               index1 = 0;
+               TParticle* jet = (TParticle*)tracks->At(0);
+               maxPtJet1 = jet->Pt();
+               jetVect[0].SetXYZ(jet->Px(), jet->Py(), jet->Pz());
+               }
+       tracks->Clear();
+       delete tracks; 
+  }
+  return *jetVect;
+
+}
+*/
+
+//-------------------------------------------------------------------
+TVector3 AliAnalyseUE::GetLeadingTracksMC(AliMCEvent *mcEvent){
+   
+  fkMC = mcEvent; 
+
+  Double_t maxPtJet1 = 0.; 
+  Int_t    index1 = -1;
+  
+  TVector3 jetVect[3];
+  
+  jetVect[0].SetPtEtaPhi(-1.,-1.,-1.);
+  jetVect[1].SetPtEtaPhi(-1.,-1.,-1.);
+  jetVect[2].SetPtEtaPhi(-1.,-1.,-1.);
+  
+  Int_t nJets = 0;
+  
+  TObjArray* tracks = SortChargedParticlesMC();
+    if( tracks ) {
+       nJets = tracks->GetEntriesFast();
+       if( nJets > 0 ) {
+               index1 = 0;
+               AliAODMCParticle* jet = (AliAODMCParticle*)tracks->At(0);
+               fLtMCLabel = jet->GetLabel();
+               maxPtJet1 = jet->Pt();
+               jetVect[0].SetXYZ(jet->Px(), jet->Py(), jet->Pz());
+               }
+       tracks->Clear();
+       delete tracks; 
+  }
+  return *jetVect;
+
+}
+
 //-------------------------------------------------------------------
 TVector3 AliAnalyseUE::GetOrderedClusters(TString aodBranch, Bool_t chargedJets, Double_t chJetPtMin){ 
 
@@ -649,7 +798,8 @@ TVector3 AliAnalyseUE::GetOrderedClusters(TString aodBranch, Bool_t chargedJets,
                if( nJets > 0 ) {
                        index1 = 0;
                        AliAODTrack* jet = (AliAODTrack*)tracks->At(0);
-                       maxPtJet1 = jet->Pt();
+                       fLtLabel = jet->GetLabel();     
+                       maxPtJet1 = jet->Pt();
                        jetVect[0].SetXYZ(jet->Px(), jet->Py(), jet->Pz());
                        }
                tracks->Clear();
@@ -666,7 +816,15 @@ TVector3 AliAnalyseUE::GetOrderedClusters(TString aodBranch, Bool_t chargedJets,
 
 //-------------------------------------------------------------------
 void AliAnalyseUE::Initialize(AliAnalysisTaskUE& taskUE){
-   
+/*void AliAnalyseUE::Initialize(AliAnalysisTask& task){// when correction task is in trunk
+   if (task->InheritsFrom("AliAnalysisTaskUE")){
+        AliAnalysisTaskUE *taskUE = dynamic_cast<AliAnalysisTaskUE*> task; 
+       }
+   else if (task->InheritsFrom("AliAnalysisTaskCorrectionsUE")){
+        AliAnalysisTaskCorrectionsUE *taskUE = dynamic_cast<AliAnalysisTaskCorrectionsUE*> task; 
+       }
+
+*/     
   //Get principal settings from current instance of UE analysis-task
   fAnaType = taskUE.GetAnaTopology();         
   fkAOD = taskUE.GetAOD();           
@@ -690,6 +848,49 @@ void AliAnalyseUE::Initialize(AliAnalysisTaskUE& taskUE){
   
 }
 
+//-------------------------------------------------------------------
+void  AliAnalyseUE::Initialize(Int_t anaType, AliAODEvent* aod,Double_t coneRadius, Int_t debug, Int_t filterBit, Double_t jet1EtaCut, Double_t jet2DeltaPhiCut, Double_t jet2RatioPtCut, Double_t jet3PtCut, Int_t ordering, Int_t regionType,Bool_t simulateChJetPt, Double_t trackEtaCut, Double_t trackPtCut, Bool_t useChargeHadrons, Bool_t useChPartJet, Bool_t usePositiveCharge, Bool_t useSingleCharge, AliHistogramsUE* histos){
+   
+   fAnaType = anaType;
+   fkAOD = aod;
+   fConeRadius = coneRadius;
+   fDebug = debug;
+   fFilterBit = filterBit;
+   fJet1EtaCut = jet1EtaCut;
+   fJet2DeltaPhiCut = jet2DeltaPhiCut;
+   fJet2RatioPtCut = jet2RatioPtCut;
+   fJet3PtCut = jet3PtCut;
+   fOrdering = ordering;
+   fRegionType = regionType;
+   fSimulateChJetPt = simulateChJetPt;
+   fTrackEtaCut = trackEtaCut;
+   fTrackPtCut = trackPtCut;
+   fUseChargeHadrons = useChargeHadrons;
+   fUseChPartJet = useChPartJet;
+   fUsePositiveCharge = usePositiveCharge;
+   fUseSingleCharge = useSingleCharge; 
+   fHistos = histos; 
+}
+
+
+//-------------------------------------------------------------------
+Bool_t  AliAnalyseUE::TriggerSelection(AliInputEventHandler* inputHandler){
+
+  //Use AliPhysicsSelection to select good events
+  if( !inputHandler->InheritsFrom("AliAODInputHandler") ) { // input AOD
+       if (inputHandler->IsEventSelected()) {
+               if (fDebug > 1) AliInfo(" Trigger Selection: event ACCEPTED ... ");
+       } else {
+               if (fDebug > 1) AliInfo(" Trigger Selection: event REJECTED ... ");
+               return kFALSE;
+               }
+        }                                
+
+  return kTRUE;
+
+}
+
+
 //-------------------------------------------------------------------
 Bool_t  AliAnalyseUE::VertexSelection(AliAODEvent *aod, Int_t tracks, Double_t zed ){
 
@@ -992,6 +1193,49 @@ void  AliAnalyseUE::QSortTracks(TObjArray &a, Int_t first, Int_t last)
 }
 
 
+//-------------------------------------------------------------------
+void  AliAnalyseUE::QSortTracksMC(TObjArray &a, Int_t first, Int_t last)
+{
+  // Sort array of TObjArray of tracks by Pt using a quicksort algorithm.
+  
+  static TObject *tmp;
+  static int i;           // "static" to save stack space
+  int j;
+  
+  while (last - first > 1) {
+    i = first;
+    j = last;
+    for (;;) {
+      while (++i < last && ((AliAODMCParticle*)a[i])->Pt() > ((AliAODMCParticle*)a[first])->Pt() )
+        ;
+      while (--j > first && ((AliAODMCParticle*)a[j])->Pt() < ((AliAODMCParticle*)a[first])->Pt() )
+        ;
+      if (i >= j)
+        break;
+      
+      tmp  = a[i];
+      a[i] = a[j];
+      a[j] = tmp;
+    }
+    if (j == first) {
+      ++first;
+      continue;
+    }
+    tmp = a[first];
+    a[first] = a[j];
+    a[j] = tmp;
+    if (j - first < last - (j + 1)) {
+      QSortTracksMC(a, first, j);
+      first = j + 1;   // QSortTracks(j + 1, last);
+    } else {
+      QSortTracksMC(a, j + 1, last);
+      last = j;        // QSortTracks(first, j);
+    }
+  }
+}
+
+
+
 
 
 //-------------------------------------------------------------------
@@ -1037,6 +1281,60 @@ TObjArray*  AliAnalyseUE::SortChargedParticles()
   return tracks;
   }
 
+//____________________________________________________________________
+/*TObjArray*  AliAnalyseUE::SortChargedParticlesMC()
+{
+  //  return an array with all charged particles ordered according to their pT .
+  AliStack *mcStack = fkMC->Stack();
+  Int_t nTracks = mcStack->GetNtrack();
+  if( !nTracks ) return 0;
+  TObjArray* tracks = new TObjArray(nTracks);
+
+  for (Int_t ipart=0; ipart<nTracks; ++ipart) {
+       if (!(mcStack->IsPhysicalPrimary(ipart))) continue;
+       TParticle *part = mcStack->Particle(ipart);
+       
+       if( !part->GetPDG()->Charge() ) continue;
+       if( part->Pt() < fTrackPtCut ) continue;
+       tracks->AddLast( part );
+       }
+  QSortTracksMC( *tracks, 0, tracks->GetEntriesFast() );
+
+  nTracks = tracks->GetEntriesFast();
+  if( !nTracks ) return 0;
+
+  return tracks;
+  }
+*/
+
+//____________________________________________________________________
+TObjArray*  AliAnalyseUE::SortChargedParticlesMC()
+{
+  //  return an array with all charged particles ordered according to their pT .
+  TClonesArray *tca = dynamic_cast<TClonesArray*>(fkAOD->FindListObject(AliAODMCParticle::StdBranchName())); 
+  if(!tca){
+       Printf("No branch!!!");
+       return 0;
+  } 
+  Int_t nTracks = tca->GetEntriesFast();
+  if( !nTracks ) return 0;
+  TObjArray* tracks = new TObjArray(nTracks);
+
+  for (Int_t ipart=0; ipart<nTracks; ++ipart) {
+        AliAODMCParticle *part = dynamic_cast<AliAODMCParticle*>(tca->At(ipart));      
+       if(!part->IsPhysicalPrimary())continue;
+        if( part->Pt() < fTrackPtCut ) continue;
+       if(!part->Charge()) continue;
+        tracks->AddLast( part );
+       }
+  QSortTracksMC( *tracks, 0, tracks->GetEntriesFast() );
+
+  nTracks = tracks->GetEntriesFast();
+  if( !nTracks ) return 0;
+
+  return tracks;
+  }
+
 
 //____________________________________________________________________
 Bool_t AliAnalyseUE::TrackMCSelected(Double_t charge, Double_t pT, Double_t eta, Int_t pdgCode)const{
@@ -1088,4 +1386,48 @@ Bool_t AliAnalyseUE::TrackSelected(AliAODTrack* part)const{
   return kTRUE;
 }
 
+//____________________________________________________________________
+Bool_t AliAnalyseUE::TrackSelectedEfficiency(AliAODTrack* part)const{
+  
+  if (!fStack) AliWarning("Attention: stack not set from mother task");  
+  // Real track selection
+  if ( !part->TestFilterBit(fFilterBit) ) return kFALSE; // track cut selection
+  if ( !part->IsPrimaryCandidate()) return kFALSE; // reject whatever is not linked to collision point
+  // PID Selection: Reject everything but hadrons
+  Bool_t isHadron = part->GetMostProbablePID()==AliAODTrack::kPion || 
+       part->GetMostProbablePID()==AliAODTrack::kKaon || 
+       part->GetMostProbablePID()==AliAODTrack::kProton;
+  if ( fUseChargeHadrons && !isHadron ) return kFALSE;
+      
+  if ( !part->Charge() ) return kFALSE; //Only charged
+  if ( fUseSingleCharge ) { // Charge selection
+       if ( fUsePositiveCharge && part->Charge() < 0.) return kFALSE; // keep Positives
+       if ( !fUsePositiveCharge && part->Charge() > 0.) return kFALSE; // keep Negatives
+       } 
+    
+  /*if ( part->Pt() < fTrackPtCut ) return kFALSE;
+  if( TMath::Abs(part->Eta()) > fTrackEtaCut ) return kFALSE;*/
+
+  //Check if there was a primary fulfilling the required cuts 
+  Double_t charge=-999.;
+  Double_t pt=-999.;
+  Double_t eta=-999.;
+  Int_t pdgcode=-999; 
+  
+  Int_t label = part->GetLabel();
+  TClonesArray *tca=0;
+  tca = dynamic_cast<TClonesArray*>(fkAOD->FindListObject(AliAODMCParticle::StdBranchName()));
+  //TParticle *partMC = fStack->ParticleFromTreeK(label);
+  AliAODMCParticle *partMC=dynamic_cast<AliAODMCParticle*>(tca->At(TMath::Abs(label)));
+  if (!partMC->IsPhysicalPrimary())return kFALSE;
+  //charge = ((TParticlePDG*)partMC->GetPDG())->Charge();
+  charge = partMC->Charge();  
+  pt = partMC->Pt();
+  eta = partMC->Eta();
+  pdgcode = partMC->GetPdgCode();
+  
+  if (!TrackMCSelected(charge, pt, eta, pdgcode)) return kFALSE;
+  return kTRUE;
+}
+
 
index b8fcf380e924e3257c52e51a808abfee6f7c69a7..f9e5d07d63e7a5a1e8887fe770881ae977d6b79b 100644 (file)
 
 class AliAnalysisTaskUE;
 class AliAODEvent;
+class AliESDEvent;
 class AliAODTrack;
 class AliGenPythiaEventHeader;
 class AliHistogramsUE;
+class AliInputEventHandler;
 class AliMCEvent;
+class AliStack;
 class TVector3;
 
 class AliAnalyseUE : public TObject {
@@ -35,11 +38,21 @@ class AliAnalyseUE : public TObject {
  
   void          FillRegions(Bool_t isNorm2Area, TVector3 *jetVect);
 
-  void                 FindMaxMinRegions(TVector3 *jetVect, Int_t conePosition);
+  void                 FindMaxMinRegions(TVector3 *jetVect, Int_t conePosition, Int_t mctrue, Int_t eff);
   
   TVector3     GetOrderedClusters(TString aodBranch, Bool_t chargedJets, Double_t chJetPtMin);
 
+  TVector3      GetLeadingTracksMC(AliMCEvent *mcEvent);
+  //leading track label
+  virtual Int_t      GetLtLabel()      const         { return fLtLabel;   }    
+  virtual Int_t      GetLtMCLabel()    const         { return fLtMCLabel; }
+
   void          Initialize(AliAnalysisTaskUE& tmp);
+  //void          Initialize(AliAnalysisTask& tmp);
+  
+  void          Initialize(Int_t anaType, AliAODEvent* aod,Double_t coneRadius, Int_t debug, Int_t filterBit, Double_t jet1EtaCut, Double_t jet2DeltaPhiCut, Double_t jet2RatioPtCut, Double_t jet3PtCut, Int_t ordering, Int_t regionType,Bool_t simulateChJetPt, Double_t trackEtaCut, Double_t trackPtCut, Bool_t useChargeHadrons, Bool_t useChPartJet, Bool_t usePositiveCharge, Bool_t useSingleCharge, AliHistogramsUE* histos);
+
+  Bool_t       TriggerSelection(AliInputEventHandler* input);
 
   Bool_t        VertexSelection(AliAODEvent *value, Int_t tracks, Double_t zed);
 
@@ -52,6 +65,7 @@ class AliAnalyseUE : public TObject {
   void          SetAOD(AliAODEvent *value)             { fkAOD = value; }
   void          SetConeRadius(Double_t value)          { fConeRadius = value; }
   void          SetDebug(Int_t value)                  { fDebug = value; }
+  void          SetESDEvent(AliESDEvent *value)         { fkESD = value;  }
   void          SetFilterBit(Int_t value)              { fFilterBit = value; }
   void          SetJet1EtaCut(Double_t value)          { fJet1EtaCut = value; }
   void          SetJet2DeltaPhiCut(Double_t value)     { fJet2DeltaPhiCut = value; }
@@ -66,7 +80,8 @@ class AliAnalyseUE : public TObject {
   void          SetUseChPartJet(Bool_t value)          { fUseChPartJet = value; }
   void          SetUsePositiveCharge(Bool_t value)     { fUsePositiveCharge = value; }
   void          SetUseSingleCharge(Bool_t value)       { fUseSingleCharge = value; }
-
+  
+  void          SetStack(AliStack* value)              { fStack = value; }
  private:
 
   void          FillAvePartPtRegion( Double_t leadingE, Double_t ptMax, Double_t ptMin );
@@ -75,20 +90,26 @@ class AliAnalyseUE : public TObject {
   TObjArray*   FindChargedParticleJets( Double_t chJetPtMin);
   Int_t        IsTrackInsideRegion(TVector3 *jetVect, TVector3 *partVect, Int_t conePosition);
   void         QSortTracks(TObjArray &a, Int_t first, Int_t last);
+  void         QSortTracksMC(TObjArray &a, Int_t first, Int_t last);
   void         SetRegionArea(TVector3 *jetVect);
   TObjArray*    SortChargedParticles();     
-  virtual Bool_t   TrackSelected(AliAODTrack* part) const;
-  virtual Bool_t   TrackMCSelected(Double_t charge, Double_t pT, Double_t eta, Int_t pdgCode) const;
+  TObjArray*    SortChargedParticlesMC();     
+  virtual Bool_t TrackSelected(AliAODTrack* part) const;
+  virtual Bool_t TrackSelectedEfficiency(AliAODTrack* part) const;
+  virtual Bool_t TrackMCSelected(Double_t charge, Double_t pT, Double_t eta, Int_t pdgCode) const;
 
   
     //AliAnalysisTaskUE    fTaskUE;        //  current instance of the analysis-task
     const AliAODEvent*   fkAOD;             //! AOD Event 
-    Int_t          fDebug;           //  Debug flag
+    AliMCEvent*    fkMC;              //! MC  Event
+    AliESDEvent*   fkESD;             //! ESD Event (only needed to get track DCA) 
+    Int_t          fDebug;            //  Debug flag
 
     
     // For MC
     Bool_t         fSimulateChJetPt;      // Naive simulation of charged jet Pt from original Jet in MC Header
-    
+    AliStack*      fStack;                // Instance of MC Particle Stack
+
     // Cuts UE analysis
     Int_t          fAnaType;              // Analysis type on jet topology: 
     Double_t       fAreaReg;              // Area of the region To be used as normalization factor when filling histograms
@@ -113,7 +134,6 @@ class AliAnalyseUE : public TObject {
     // track cuts
     Double_t      fTrackEtaCut;      // Eta cut on tracks in the regions (fRegionType=1)
     Double_t      fTrackPtCut;       // Pt cut of tracks in the regions
-  
     AliHistogramsUE* fHistos;       // Pointer to histogram class      
 
     //to fill the different regions
@@ -130,6 +150,11 @@ class AliAnalyseUE : public TObject {
     //Store analysis settings
     TTree*       fSettingsTree;        // To store analysis settings
     
+    //Leading track labels             
+    Int_t         fLtLabel;              // Label of reconstructed leading track
+    Int_t         fLtMCLabel;            // Label of true leading track
+    
+    
     ClassDef(AliAnalyseUE,0)
 };
 #endif
diff --git a/PWG4/JetTasks/AliAnalysisTaskCorrectionsUE.cxx b/PWG4/JetTasks/AliAnalysisTaskCorrectionsUE.cxx
new file mode 100644 (file)
index 0000000..c52e29a
--- /dev/null
@@ -0,0 +1,565 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/* $Id:$ */
+
+////////////////////////////////////////////////////////////////////////
+//
+// Analysis class to Correct Underlying Event studies
+// (requires input AOD)
+//
+// Different analysis are performed according to input.
+//
+// Run on MC:
+// - fraction of diffractive events after different cuts
+// - tracking efficiency and contamination
+// 
+// Run on DATA:
+// - fraction of events after different cuts
+// - vertex reconstruction efficiency
+//
+// vallero@physi.uni-heidelberg.de
+// 
+////////////////////////////////////////////////////////////////////////
+
+#include <TROOT.h>
+#include <TChain.h>
+#include <TCanvas.h>
+#include <TFile.h>
+#include <TList.h>
+#include <TMath.h>
+#include <TProfile.h>
+#include <TTree.h>
+#include <TVector3.h>
+
+#include "AliAnalyseUE.h"
+#include "AliAnalysisHelperJetTasks.h"
+#include "AliAnalysisManager.h"
+#include "AliAnalysisTaskCorrectionsUE.h"
+#include "AliAODHandler.h"
+#include "AliESDHandler.h"
+#include "AliESDtrack.h"
+#include "AliESDEvent.h"
+#include "AliAODInputHandler.h"
+#include "AliESDInputHandler.h"
+#include "AliCFContainer.h"
+#include "AliCFManager.h"
+#include "AliGenDPMjetEventHeader.h"
+#include "AliGenPythiaEventHeader.h"
+#include "AliHistogramsUE.h"
+#include "AliInputEventHandler.h"
+#include "AliLog.h"
+#include "AliMCEventHandler.h"
+#include "AliAnalysisHelperJetTasks.h"
+
+ClassImp( AliAnalysisTaskCorrectionsUE)
+
+// Define global pointer
+AliAnalysisTaskCorrectionsUE* AliAnalysisTaskCorrectionsUE::fgTaskCorrectionsUE=NULL;
+
+//____________________________________________________________________
+AliAnalysisTaskCorrectionsUE:: AliAnalysisTaskCorrectionsUE(const char* name):
+AliAnalysisTask(name,""),
+fAnaUE(0x0),
+fAOD(0x0), 
+fESDHandler(0x0),
+fAODBranch("jets"),
+fCFManager(0x0),
+fDebug(0),
+fHistosUE(0x0),
+fInputHandler(0x0),
+fListOfHistos(0x0),  
+fMcHandler(0x0),
+fMcEvent(0x0),
+fBinsPtInHist(30),     
+fIsNorm2Area(kTRUE),
+fMaxJetPtInHist(300.), 
+fMinJetPtInHist(0.),
+fConstrainDistance(kTRUE),
+fMinDistance(0.2),
+fSimulateChJetPt(kFALSE),
+fUseAliStack(kTRUE),
+fUseMCParticleBranch(kFALSE),
+fnTracksVertex(3),  // QA tracks pointing to principal vertex (= 3 default) 
+fZVertex(5.),
+fAnaType(1),         
+fConePosition(1),
+fConeRadius(0.7),
+fFilterBit(0xFF),
+fJetsOnFly(kFALSE),
+fRegionType(1),
+fUseChargeHadrons(kFALSE),
+fUseChPartJet(kFALSE),
+fUsePositiveCharge(kTRUE),
+fUseSingleCharge(kFALSE),
+fOrdering(1),
+fChJetPtMin(5.0),
+fJet1EtaCut(0.2),
+fJet2DeltaPhiCut(2.616),    // 150 degrees
+fJet2RatioPtCut(0.8),
+fJet3PtCut(15.),
+fTrackEtaCut(0.9),
+fTrackPtCut(0.),
+fAvgTrials(1)
+{
+  // Default constructor
+  // Define input and output slots here
+  // Input slot #0 works with a TChain
+  DefineInput(0, TChain::Class());
+  // Output slot #0 writes into a TList container
+  DefineOutput(0, TList::Class());
+  DefineOutput(1, AliCFContainer::Class());
+
+}
+
+//____________________________________________________________________
+AliAnalysisTaskCorrectionsUE:: AliAnalysisTaskCorrectionsUE(const AliAnalysisTaskCorrectionsUE & original):
+AliAnalysisTask(),
+fAnaUE(original.fAnaUE),
+fAOD(original.fAOD),            
+fESDHandler(original.fESDHandler),            
+fAODBranch(original.fAODBranch),
+fCFManager(original.fCFManager),
+fDebug(original.fDebug),
+fHistosUE(original.fHistosUE),
+fInputHandler(original.fInputHandler),
+fListOfHistos(original.fListOfHistos),  
+fMcHandler(original.fMcHandler),
+fMcEvent(original.fMcEvent),
+fBinsPtInHist(original.fBinsPtInHist),     
+fIsNorm2Area(original.fIsNorm2Area),
+fMaxJetPtInHist(original.fMaxJetPtInHist), 
+fMinJetPtInHist(original.fMinJetPtInHist),
+fConstrainDistance(original.fConstrainDistance),
+fMinDistance(original.fMinDistance),
+fSimulateChJetPt(original.fSimulateChJetPt),
+fUseAliStack(original.fUseAliStack),
+fUseMCParticleBranch(original.fUseMCParticleBranch),
+fnTracksVertex(original.fnTracksVertex),  // QA tracks pointing to principal vertex (= 3 default) 
+fZVertex(original.fZVertex),
+fAnaType(original.fAnaType),         
+fConePosition(original.fConePosition),
+fConeRadius(original.fConeRadius),
+fFilterBit(original.fFilterBit),
+fJetsOnFly(original.fJetsOnFly),
+fRegionType(original.fRegionType),
+fUseChargeHadrons(original.fUseChargeHadrons),
+fUseChPartJet(original.fUseChPartJet),
+fUsePositiveCharge(original.fUsePositiveCharge),
+fUseSingleCharge(original.fUseSingleCharge),
+fOrdering(original.fOrdering),
+fChJetPtMin(original.fChJetPtMin),
+fJet1EtaCut(original.fJet1EtaCut),
+fJet2DeltaPhiCut(original.fJet2DeltaPhiCut),    // 150 degrees
+fJet2RatioPtCut(original.fJet2RatioPtCut),
+fJet3PtCut(original.fJet3PtCut),
+fTrackEtaCut(original.fTrackEtaCut),
+fTrackPtCut(original.fTrackPtCut),
+fAvgTrials(original.fAvgTrials)
+{
+  // Copy constructor
+}
+
+
+//______________________________________________________________
+AliAnalysisTaskCorrectionsUE & AliAnalysisTaskCorrectionsUE::operator = (const AliAnalysisTaskCorrectionsUE & /*source*/)
+{
+  // assignment operator
+  return *this;
+}
+
+//______________________________________________________________
+Bool_t AliAnalysisTaskCorrectionsUE::Notify()
+{
+  //
+  // Implemented Notify() to read the cross sections
+  // and number of trials from pyxsec.root
+  // Copy from AliAnalysisTaskJFSystematics
+  fAvgTrials = 1;
+  TTree *tree = AliAnalysisManager::GetAnalysisManager()->GetTree();
+  Float_t xsection = 0;
+  Float_t trials  = 1;
+  if(tree){
+       TFile *curfile = tree->GetCurrentFile();
+       if (!curfile) {
+               Error("Notify","No current file");
+               return kFALSE;
+               }
+       
+       AliAnalysisHelperJetTasks::PythiaInfoFromFile(curfile->GetName(),xsection,trials); 
+        fHistosUE->GetXsec()->Fill("<#sigma>",xsection);
+
+       // construct average trials
+       Float_t nEntries = (Float_t)tree->GetTree()->GetEntries();
+       if(trials>=nEntries && nEntries>0.)fAvgTrials = trials/nEntries;
+       }
+  
+  return kTRUE;
+
+}
+
+//____________________________________________________________________
+void AliAnalysisTaskCorrectionsUE::ConnectInputData(Option_t* /*option*/)
+{
+  // Connect the input data  
+  
+  // We need AODs with tracks and jets.
+  // Since AODs can either be connected to the InputEventHandler 
+  // or to the OutputEventHandler ( the AOD is created by a previous task in the train )
+  // we need to check where it is and get the pointer to AODEvent in the right way
+  
+  // Delta AODs are also accepted
+  
+  if (fDebug > 1) AliInfo("ConnectInputData() ");
+  
+  //Get the input handler
+  TObject* handler = AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler();
+
+  if( handler && handler->InheritsFrom("AliAODInputHandler") ) { // input AOD
+       fAOD = ((AliAODInputHandler*)handler)->GetEvent();
+       if(!fJetsOnFly){
+               if (fDebug > 1) AliInfo(" ==== Tracks and Jets from AliAODInputHandler");
+               }else{
+               if (fDebug > 1) AliInfo(" ==== Tracks from AliAODInputHandler / Jets on-the-fly");
+               }
+       } else {  //output AOD
+       handler = AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler();
+       if( handler && handler->InheritsFrom("AliAODHandler") ) {
+               fAOD = ((AliAODHandler*)handler)->GetAOD();
+               if (!fJetsOnFly){
+                       if (fDebug > 1) AliInfo(" ==== Tracks and Jets from AliAODHandler");
+                       } else {
+                       if (fDebug > 1) AliInfo(" ==== Tracks from AliAODHandler / Jets on-the-fly");
+                       }
+               }else {
+               AliFatal("I can't get any AOD Event Handler");
+               return;
+               }
+       }
+
+  //Get ESD input handler
+  AliInputEventHandler *inputHandler = dynamic_cast<AliInputEventHandler*>(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
+   AliESDEvent *esdEvent = (AliESDEvent*)inputHandler->GetEvent();
+   if (!esdEvent && fDebug > 1) {
+       AliInfo("********************** No ESD event: cannot retrive DCA values from AOD !!! ");
+  }else fAnaUE->SetESDEvent(esdEvent);
+
+  //Get MC handler 
+  fMcHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
+  //Initialize AliAnalysisUE class
+  fAnaUE->Initialize(fAnaType, fAOD, fConeRadius, fDebug, fFilterBit, fJet1EtaCut, fJet2DeltaPhiCut, fJet2RatioPtCut, fJet3PtCut, fOrdering, fRegionType, fSimulateChJetPt, fTrackEtaCut, fTrackPtCut, fUseChargeHadrons, fUseChPartJet, fUsePositiveCharge, fUseSingleCharge, fHistosUE);
+}
+
+//____________________________________________________________________
+void  AliAnalysisTaskCorrectionsUE::CreateOutputObjects()
+{
+  // Create the output container
+  
+  if (fDebug > 1) AliInfo("CreateOutPutData()");
+   
+  // Create pointer to AliAnalysisUE, a class implementing the main analysis algorithms
+  fAnaUE = new AliAnalyseUE();
+  if (!fAnaUE){
+     AliError("UE analysis class not initialized!!!");
+     return;
+  }
+  // Create pointer to AliHistogramsUE, a class handling histogram creation/filling
+  fHistosUE = new AliHistogramsUE();
+  if (!fHistosUE){
+     AliError("UE histograms class not initialized!!!");
+     return;
+  }
+
+  // Create list of output histograms
+  if (fListOfHistos != NULL){
+       delete fListOfHistos;
+        fListOfHistos = NULL;
+       }
+  if (!fListOfHistos){
+       fListOfHistos = new TList();
+       fListOfHistos->SetOwner(kTRUE); 
+       }
+  
+  
+  //Initialize output histograms
+  fHistosUE->CreateHistogramsCorrections(fListOfHistos,fBinsPtInHist, fMinJetPtInHist, fMaxJetPtInHist, fTrackEtaCut);
+  AddSettingsTree();
+
+  //Configure the CF manager
+  if (fCFManager != NULL){
+       delete fCFManager;
+        fCFManager = NULL;
+       }
+  if (!fCFManager){
+        fCFManager = new AliCFManager();
+       }
+  fHistosUE->CreateCorrectionsContainer(fCFManager,fBinsPtInHist, fMinJetPtInHist, fMaxJetPtInHist, fTrackEtaCut,fJet1EtaCut);
+
+  //Post outputs
+  PostData(0,fListOfHistos);
+  PostData(1,fCFManager->GetEventContainer());
+
+}
+
+//____________________________________________________________________
+void  AliAnalysisTaskCorrectionsUE::Exec(Option_t */*option*/)
+{
+
+  Bool_t flag=kTRUE;
+
+  //Determine the corrections
+  if (fMcHandler){
+       fMcEvent = fMcHandler->MCEvent();
+               if ( fDebug > 3 ) AliInfo( " Processing MC event..." );
+  }else{
+               if ( fDebug > 3 ) AliInfo( " Processing DATA event..." );
+       }
+  
+
+  flag = EvaluateCorrections(); 
+
+  
+  if (flag){ //executed if event passes trigger+vertex selection
+       //Fetch the pythia header info and get the trials
+       Float_t nTrials = 1;
+       if (fMcHandler && fMcEvent) {
+               AliGenPythiaEventHeader*  pythiaGenHeader = AliAnalysisHelperJetTasks::GetPythiaEventHeader(fMcEvent);
+               if(pythiaGenHeader) nTrials = pythiaGenHeader->Trials();
+               }
+       fHistosUE->GetTrials()->Fill("#sum{ntrials}",fAvgTrials);
+       PostData(0,fListOfHistos);
+       PostData(1,fCFManager->GetEventContainer());
+       }
+}
+
+//____________________________________________________________________
+void  AliAnalysisTaskCorrectionsUE::AddSettingsTree()
+{
+  //Write settings to output list
+  TTree *settingsTree   = new TTree("UECorrectionsSettings","Analysis Settings in UE corrections");
+  settingsTree->Branch("fFilterBit", &fFilterBit,"FilterBit/I");
+  settingsTree->Branch("fConeRadius", &fConeRadius,"Rad/D");
+  settingsTree->Branch("fJet1EtaCut", &fJet1EtaCut, "LeadJetEtaCut/D");
+  settingsTree->Branch("fJet2DeltaPhiCut", &fJet2DeltaPhiCut, "DeltaPhi/D");
+  settingsTree->Branch("fJet2RatioPtCut", &fJet2RatioPtCut, "Jet2Ratio/D");
+  settingsTree->Branch("fJet3PtCut", &fJet3PtCut, "Jet3PtCut/D");
+  settingsTree->Branch("fTrackPtCut", &fTrackPtCut, "TrackPtCut/D");
+  settingsTree->Branch("fTrackEtaCut", &fTrackEtaCut, "TrackEtaCut/D");
+  settingsTree->Branch("fAnaType", &fAnaType, "Ana/I");        
+  settingsTree->Branch("fRegionType", &fRegionType,"Reg/I");
+  settingsTree->Branch("fOrdering", &fOrdering,"OrderMeth/I");
+  settingsTree->Branch("fUseChPartJet", &fUseChPartJet,"UseChPart/O");
+  settingsTree->Branch("fUseChargeHadrons", &fUseChargeHadrons,"UseChHadrons/O");
+  settingsTree->Branch("fUseSingleCharge", &fUseSingleCharge,"UseSingleCh/O");
+  settingsTree->Branch("fUsePositiveCharge", &fUsePositiveCharge,"UsePositiveCh/O");
+  settingsTree->Fill();
+  fListOfHistos->Add(settingsTree);
+} 
+
+
+//____________________________________________________________________
+Bool_t  AliAnalysisTaskCorrectionsUE::EvaluateCorrections()
+{
+  
+  /////////////////////////////////////////////////////////////////////////
+  // 
+  // EVENT SELECTION:
+  // CF containers are filled to get the number of entries after every cut.
+  // *** Cuts: ***
+  // 0 - triggered
+  // 1 - physics selection
+  // 2 - vertex selection
+  // 3 - event topology
+  // 4 - leading track pT cut
+  // 5 - leading track correctly identified
+  // *** Variables: ***
+  // 0 - leading track pT (reco)
+  // 1 - leading track eta (reco)
+  // 2 - process type:
+  //   1: non diffractive
+  //   2: double diffractive
+  //   4: single diffractive
+  // 3 - leading track pT (true)
+  // 4 - leading track eta (true)
+  // 5 - delta eta (reco-true)
+  // 6 - delta phi (reco-true)
+  // 7 - radius (reco-true)
+  //
+  // TRACK-LEVEL CORRECTIONS:
+  // Fill histograms similar to AliAnalysisTaskUE.
+  //
+  /////////////////////////////////////////////////////////////////////////
+
+  Double_t containerInput[8];// relevant variables (see above)  
+  
+  //PROCESS TYPE (ND,SD,DD)
+  AliAnalysisHelperJetTasks::MCProcessType eventId = AliAnalysisHelperJetTasks::kInvalidProcess;
+  if (fMcHandler && fMcEvent) {
+               AliGenEventHeader* genHeader = fMcEvent->GenEventHeader();
+               eventId = AliAnalysisHelperJetTasks::GetPythiaEventProcessType(genHeader,kFALSE);
+               if (eventId<0){
+               eventId = AliAnalysisHelperJetTasks::GetDPMjetEventProcessType(genHeader,kFALSE);
+               }
+               if (eventId<0 && fDebug>1)AliInfo("No Pythia or Phojet Header retrived!"); 
+  }else if (fDebug>1) AliInfo("No MC handler or Event!"); 
+
+  //Initialize container inputs 
+  for (Int_t i =0; i<8; i++){  
+       containerInput[i]=-999.;
+       }
+  
+  //Assign process type
+  if (eventId == 1 ) containerInput[2]=1.; //Non diffractive
+  if (eventId == 2 ) containerInput[2]=2.; //Double diffractive
+  if (eventId == 4 ) containerInput[2]=4.; //Single diffractive
+  
+  // Execute analysis for current event ******************************
+  
+  // Get jets and order by pT
+  TVector3 jetVect[3];
+  *jetVect = fAnaUE->GetOrderedClusters(fAODBranch, fUseChPartJet, fChJetPtMin );
+  
+  //now define leading track pT and eta
+  containerInput[0]=jetVect[0].Pt();
+  containerInput[1]=jetVect[0].Eta();
+
+  fCFManager->GetEventContainer()->Fill(containerInput,kCFStepTriggered);  //fill CF container 
+  
+  // Physics selection ************************************************
+  fInputHandler = (AliInputEventHandler*)AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler();
+  if (!fAnaUE->TriggerSelection(fInputHandler)) return kFALSE;
+  
+  fCFManager->GetEventContainer()->Fill(containerInput, kCFStepPhysSelect); //fill CF container
+  
+  // Event selection (vertex) *****************************************
+  
+  if(!fAnaUE->VertexSelection(fAOD,fnTracksVertex,fZVertex)) return kFALSE;
+  //if(!fAnaUE->VertexSelectionOld(fAOD)) return kFALSE; // temporary to compare with old task and to have same cuts for MC !!!
+
+  fCFManager->GetEventContainer()->Fill(containerInput, kCFStepVertexSelect); //fill CF container
+   
+   // Select events according to analysis type *************************
+   // (in the leading track analysis it should not happen that there are no "jets")
+   if( jetVect[0].Pt() < 0. ) {
+       if( fDebug > 1 ) AliInfo("\n   Skipping Event, not jet found...");
+       return kTRUE;
+    } else {
+       if (fDebug >1 ) AliInfo(Form("\n   Pt Leading Jet = %6.1f eta=%5.3f ",  jetVect[0].Pt(), jetVect[0].Eta() ));
+       }
+  
+  
+  if ( ! (fAnaUE->AnaTypeSelection(jetVect))) return kTRUE;
+   
+   
+   // For the events selected check the real MC leading particle
+   // (only when running on MC)
+   TVector3 jetVectMC[3];
+   if (fMcEvent){
+       *jetVectMC = fAnaUE->GetLeadingTracksMC(fMcEvent); 
+       if (fAnaUE->AnaTypeSelection(jetVectMC) ){
+               //now define leading track pT and eta
+               containerInput[3]=jetVectMC[0].Pt();
+               containerInput[4]=jetVectMC[0].Eta();
+               //Check distance between real and reco leading-particle
+               containerInput[5] = jetVect[0].Eta()-jetVectMC[0].Eta();
+               containerInput[6] = TMath::Abs(jetVect[0].Phi()-jetVectMC[0].Phi());
+               if (containerInput[6] >= 2.*TMath::Pi())containerInput[6] -= 2.*TMath::Pi(); 
+               containerInput[7] = sqrt(TMath::Power(containerInput[5],2.) + TMath::Power(containerInput[6],2.));
+               } 
+       }  
+   
+   fCFManager->GetEventContainer()->Fill(containerInput, kCFStepAnaTopology); //fill CF container
+   
+   //Cut on the leading track pT 
+   if (!(jetVect[0].Pt() >= 1.)) return kTRUE;
+   // (only when running on MC)   
+   if (fMcEvent){ 
+       if (!(jetVectMC[0].Pt()>= 1.)){
+               containerInput[3]=containerInput[4]=-999.;
+               containerInput[5]=containerInput[6]=containerInput[7]=-999.;
+               }
+       }       
+   
+   fCFManager->GetEventContainer()->Fill(containerInput, kCFStepLtPtCut1); //fill CF container
+
+   // Check if leading track is correctly identified
+   // (only when running on MC)
+   if (fMcEvent){
+       Int_t labelLt = fAnaUE->GetLtLabel();
+       Int_t labelLtMC = fAnaUE->GetLtMCLabel();
+       if (labelLt == labelLtMC){
+               fCFManager->GetEventContainer()->Fill(containerInput, kCFStepLtCorrect); //fill CF container
+               } 
+       }
+
+   // For track efficiency and contamination
+   // (only when running on MC)
+   if (fMcEvent){
+       //Run once on reco...
+       fAnaUE->FindMaxMinRegions( jetVect,  fConePosition, 0, 0 );//normal track cut 
+       fAnaUE->FindMaxMinRegions( jetVect,  fConePosition, 0, 1 );//for efficiency: cut on pT and eta are set on MC true  
+       //and once on MC true
+        fAnaUE->FindMaxMinRegions( jetVect,  fConePosition, 1, 0 );
+  }else{
+       // For d0 distribution, runs only on real data
+       fAnaUE->FindMaxMinRegions( jetVect,  fConePosition, 0, 0 );//run on real data 
+       }
+
+
+   return kTRUE;
+}
+
+//____________________________________________________________________
+AliAnalysisTaskCorrectionsUE* AliAnalysisTaskCorrectionsUE::Instance()
+{ 
+  
+  //Create instance
+  if (fgTaskCorrectionsUE) {
+       return fgTaskCorrectionsUE;
+  } else {
+       fgTaskCorrectionsUE = new AliAnalysisTaskCorrectionsUE();
+       return fgTaskCorrectionsUE;
+       }
+}
+
+//____________________________________________________________________
+void  AliAnalysisTaskCorrectionsUE::Terminate(Option_t */*option*/)
+{
+  // Terminate analysis
+  
+  if (fDebug >1) AliAnalysisHelperJetTasks::PrintDirectorySize("PWG4_JetTasksOutput.root");
+  
+  if (!gROOT->IsBatch()){
+       fListOfHistos = dynamic_cast<TList*> (GetOutputData(0));
+       if (!fListOfHistos){
+               AliError("Histogram List is not available");
+               return;
+               }
+
+  } else {
+        AliInfo(" Batch mode, not histograms will be shown...");
+  }
+
+  
+}
+
+//____________________________________________________________________
+void  AliAnalysisTaskCorrectionsUE::WriteSettings()
+{ 
+
+}
diff --git a/PWG4/JetTasks/AliAnalysisTaskCorrectionsUE.h b/PWG4/JetTasks/AliAnalysisTaskCorrectionsUE.h
new file mode 100644 (file)
index 0000000..7b0876b
--- /dev/null
@@ -0,0 +1,279 @@
+#ifndef ALIANALYSISTASKCORRECTIONSUE_H
+#define ALIANALYSISTASKCORRECTIONSUE_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+////////////////////////////////////////////////////////////////////////
+//
+// Analysis class to Correct Underlying Event studies
+//
+// This class needs as input AOD with track and Jets.
+// The output is a list of histograms
+//
+// AOD can be either connected to the InputEventHandler  
+// for a chain of AOD files 
+// or 
+// to the OutputEventHandler
+// for a chain of ESD files, so this case class should be 
+// in the train after the Jet finder
+//
+// 
+// vallero@physi.uni-heidelberg.de
+////////////////////////////////////////////////////////////////////////
+
+#include "AliAnalysisTask.h"
+
+class AliAnalyseUE;
+class AliCFManager;
+class AliHistogramsUE;
+class AliInputEventHandler;
+class AliAODEvent;
+class AliESDEvent;
+class AliAODInputHandler;
+class AliESDEventHandler;
+class AliMCEventHandler;
+class AliMCEvent;
+class TH1F;
+class TH2F;
+class TH1I;
+class TProfile;
+class TTree;
+class TVector3;
+
+class  AliAnalysisTaskCorrectionsUE : public AliAnalysisTask
+  {
+  public:
+    
+    enum {
+       kCFStepTriggered     = 0,
+       kCFStepPhysSelect    = 1, 
+       kCFStepVertexSelect  = 2,
+       kCFStepAnaTopology   = 3,
+       kCFStepLtPtCut1      = 4,
+       kCFStepLtCorrect     = 5
+    };
+
+
+
+    AliAnalysisTaskCorrectionsUE(const char* name="AliAnalysisTaskCorrectionsUE");
+    virtual           ~AliAnalysisTaskCorrectionsUE() {if ( fListOfHistos ) delete fListOfHistos; }
+    AliAnalysisTaskCorrectionsUE(const  AliAnalysisTaskCorrectionsUE &det);
+    AliAnalysisTaskCorrectionsUE&   operator=(const  AliAnalysisTaskCorrectionsUE &det);
+       
+    // return instance of the singleton
+    static  AliAnalysisTaskCorrectionsUE* Instance();
+      
+    // Implementation of interace methods
+    virtual     Bool_t Notify();
+    virtual     void   ConnectInputData(Option_t *);
+    virtual     void   CreateOutputObjects();
+    virtual     void   Exec(Option_t *option);
+    virtual     void   Terminate(Option_t *);
+
+    //  Setters/Getters
+    virtual     void         SetDebugLevel( Int_t level )  { fDebug = level; }
+    virtual    Int_t         GetDebugLevel() const { return fDebug; }
+    
+    void       SetPtRangeInHist( Int_t bin, Double_t min, Double_t max ) {
+                       fBinsPtInHist = bin; 
+                       fMinJetPtInHist = min; 
+                       fMaxJetPtInHist = max; 
+                       }
+
+    // Read AODs
+    void         SelectAODBranch(const char* val)     { fAODBranch = val;   }
+    virtual       TString               GetAODBranch() const { return fAODBranch;   }
+    virtual       AliAODEvent*   GetAOD() const               { return fAOD; } 
+
+    // Setters/Getters for MC
+    void       SetConstrainDistance(Bool_t val1, Double_t val2){ fMinDistance = val2; fConstrainDistance = val1;}
+    void       SetSimulateChJetPt(){fSimulateChJetPt = kTRUE;}
+    void       SetUseAODMCParticle(){fUseAliStack = kFALSE;}
+    void       SetUseMCBranch(){fUseMCParticleBranch = kTRUE;}
+
+    virtual  Bool_t    GetConstrainDistance() const {return fConstrainDistance;}
+    virtual  Double_t  GetMinDistance()       const {return fMinDistance;}
+    virtual  Bool_t    GetSimulateChJetPt()   const {return fSimulateChJetPt;}
+    virtual  Bool_t    GetUseAODMCParticle()  const {return fUseAliStack;}
+    virtual  Bool_t    GetUseMCParticleBranch() const {return fUseMCParticleBranch;}
+
+    //Event QA
+    void  SetZVertex( Double_t val ) { fZVertex = val; }
+    void  SetTracksInVertex( Int_t val ){ fnTracksVertex = val; }
+    void  SetCFManager(AliCFManager* cfm){ fCFManager = cfm; }
+    AliCFManager* GetCFManager() const {return fCFManager;}
+
+    // Setters/Getters for UE Analysis
+    void   SetAnaTopology( Int_t val )       { fAnaType = val;    }
+    void   SetConePosition(Int_t val)        { fConePosition= val; }
+    void   SetConeRadius( Double_t val )     { fConeRadius = val; }
+    void   SetDoNotNormalizeQuantities()     { fIsNorm2Area = kFALSE; }
+    void   SetFilterBit( UInt_t val )        { fFilterBit = val;  }
+    void   SetJetsOnFly( Bool_t val )        { fJetsOnFly = val;  }
+    void   SetPtSumOrdering( Int_t val )     { fOrdering = val;   }
+    void   SetRegionType( Int_t val )        { fRegionType = val; }
+    void   SetUseChargeHadrons( Bool_t val ) { fUseChargeHadrons = val; }
+    void   SetUseChPartJet( Int_t val )      { fUseChPartJet = val; }
+    void   SetUseNegativeChargeType()        { fUsePositiveCharge = kFALSE; }
+    void   SetUseSingleCharge()              { fUseSingleCharge = kTRUE; } 
+    
+    virtual Int_t     GetAnaTopology()  const                    { return fAnaType; }
+    virtual Int_t     GetConePosition() const             { return fConePosition; }
+    virtual Double_t  GetConeRadius()          const             { return fConeRadius; }
+    virtual Bool_t    GetDoNotNormalizeQuantities() const { return fIsNorm2Area; }
+    virtual UInt_t    GetFilterBit()    const            { return fFilterBit;  }
+    virtual Bool_t    GetJetsOnFly()    const            { return fJetsOnFly;  }
+    virtual Int_t     GetPtSumOrdering() const            { return fOrdering;   }
+    virtual Int_t     GetRegionType()    const            { return fRegionType; }
+    virtual Bool_t    GetUseChargeHadrons() const         { return fUseChargeHadrons; }
+    virtual Int_t     GetUseChPartJet() const             { return fUseChPartJet; }
+    virtual Bool_t    GetUseNegativeChargeType()    const { return fUsePositiveCharge; }
+    virtual Bool_t    GetUseSingleCharge()  const         { return fUseSingleCharge; } 
+    
+    // Jet cuts
+    void   SetJet1EtaCut( Double_t val )      { fJet1EtaCut = val; }
+    void   SetJet2DeltaPhiCut( Double_t val ) { fJet2DeltaPhiCut = val; }
+    void   SetJet2RatioPtCut( Double_t val )  { fJet2RatioPtCut = val; }
+    void   SetJet3PtCut( Double_t val )       { fJet3PtCut = val; }
+    void   SetPtMinChPartJet( Double_t val )  { fChJetPtMin = val; }
+    
+    virtual Double_t   GetJet1EtaCut()       const         { return fJet1EtaCut; }
+    virtual Double_t   GetJet2DeltaPhiCut()  const        { return fJet2DeltaPhiCut; }
+    virtual Double_t   GetJet2RatioPtCut()   const         { return fJet2RatioPtCut; }
+    virtual Double_t   GetJet3PtCut()        const         { return fJet3PtCut; }
+    virtual Double_t   GetPtMinChPartJet()   const         { return fChJetPtMin; }
+    
+    // track cuts
+    void   SetTrackEtaCut( Double_t val ) { fTrackEtaCut = val; }
+    void   SetTrackPtCut( Double_t val )  { fTrackPtCut = val; }
+
+    virtual Double_t   GetTrackEtaCut()  const         { return fTrackEtaCut; }
+    virtual Double_t   GetTrackPtCut()   const         { return fTrackPtCut; }
+    
+       
+  protected:
+    static AliAnalysisTaskCorrectionsUE*     fgTaskCorrectionsUE;        // Pointer to single instance
+  private:
+    void         AddSettingsTree();
+    Bool_t       EvaluateCorrections();
+    void         FillAvePartPtRegion( Double_t leadingE, Double_t ptMax, Double_t ptMin );
+    void         FillMultRegion( Double_t leadingE, Double_t nTrackPtmax, Double_t nTrackPtmin, Double_t ptMin );
+    void         FillSumPtRegion( Double_t leadingE, Double_t ptMax, Double_t ptMin );
+    TObjArray*   FindChargedParticleJets();
+    Int_t        IsTrackInsideRegion(TVector3 *jetVect, TVector3 *partVect);
+    void         WriteSettings();
+    
+    AliAnalyseUE*  fAnaUE;           //! points to AliAnalyseUE class
+    AliAODEvent*   fAOD;             //! AOD Event 
+    AliESDEventHandler*   fESDHandler;        //! ESD Event
+    TString        fAODBranch;       //  Jet branch name from standard AOD
+    AliCFManager*  fCFManager;       //  pointer to CORRECTION FRAMEWORK manager
+    Int_t          fDebug;           //  Debug flag
+    AliHistogramsUE* fHistosUE;      //  Points to UE histograms class
+    AliInputEventHandler* fInputHandler; // Input event handler
+    TList*         fListOfHistos;    //  Output list of histograms
+    AliMCEventHandler* fMcHandler;   //  pointer to MC handler
+    AliMCEvent*        fMcEvent;     //  pointer to MC event
+    
+    // Config
+    Int_t          fBinsPtInHist;     //  # bins for Pt histos range
+    Bool_t         fIsNorm2Area;      // Apply Area Normalization to collected observables
+    Double_t       fMaxJetPtInHist;   //  max Jet Pt value for histo range
+    Double_t       fMinJetPtInHist;   //  min Jet Pt value for histo range
+    
+    // For MC
+    Bool_t        fConstrainDistance;    // Constrain Distance between rec jet and pyth
+    Double_t       fMinDistance;          // Minimum distance between rec jet and pyth
+    Bool_t         fSimulateChJetPt;      // Naive simulation of charged jet Pt from original Jet in MC Header
+    Bool_t         fUseAliStack;          // Use AliSatck for particle info otherwise "mcparticles" branch in AOD
+    Bool_t         fUseMCParticleBranch;  // Run Over mcparticles branch in AOD
+    
+    // Cuts Events type
+    Int_t          fnTracksVertex;        // QA tracks pointing to principal vertex (= 3 default) 
+    Double_t       fZVertex;              // Position of Vertex in Z direction
+    
+    // Cuts UE analysis
+    Int_t          fAnaType;              // Analysis type on jet topology: 
+                                               //     1=inclusive  (default) 
+                                               //     2=back to back inclusive
+                                               //     3=back to back exclusive
+                                               //     4=Pt max (max Pt track in region)
+                                               //     5=gama jet (back to back) ???
+                                               //  Minimum bias
+                                               //     31 = Semi jet (charged leading particle jets)
+                                               //     32 = Random jetcone  ?
+                                               //     33 = Swiss chees   ?
+    
+    
+    Int_t          fConePosition;         // This parameter set how will cone center in transversal zone will be set
+                                          //    1 : To be used in any jet topology (default value)
+                                          //        eta_cone = eta_leadingjet
+                                          //        phi_cone = phi_leadingjet + - 90
+                                          //    2 : To be used in multiple jet topology (code will cry otherwise)
+                                          //        eta_cone = (eta_leadingjet + eta_subleadingjet)/2
+                                          //        phi_cone = phi_leadingjet + - 90
+    
+    Double_t       fConeRadius;           // if selected Cone-like region type, set Radius (=0.7 default)
+    
+    UInt_t         fFilterBit;            // Select tracks from an specific track cut (default 0xFF all track selected)
+    
+    Bool_t         fJetsOnFly;            // if jets are reconstructed on the fly from AOD tracks (see ConnectInputData() )
+    
+    // UE analysis is conducted in different type of regions
+    // Transverse are those like defined in: R. Field Acta Physica Polonica B. Vol 36 No. 2 pg 167 (2005) 
+    // Cone regions like defined in: Phys. Rev. D 70, 072002 (2004)
+    Int_t         fRegionType;           // 1 = transverse regions (default)
+                                          // 2 = cone regions   
+    
+
+
+    Bool_t         fUseChargeHadrons;     // Only use charge hadrons
+    Bool_t         fUseChPartJet;         // Use "Charged Particle Jet" instead of jets from AOD see FindChargedParticleJets()
+    
+    // Theoreticians ask for tools charge-aware
+    // especially those which are related to multiplicity and MC-tunings
+    // see arXiv:hep-ph/0507008v3
+    Bool_t         fUsePositiveCharge;    //If Single type of charge used then set which one (=kTRUE default positive)
+    Bool_t         fUseSingleCharge;      //Make analysis for a single type of charge (=kFALSE default)
+    
+    Int_t          fOrdering;             //  Pt and multiplicity summation ordering:
+                   //     1=CDF-like -independent sorting according quantity to be scored: Double sorting- (default)
+                   //        if Pt summation will be scored take Pt minimum between both zones and 
+                   //        fill Pt Max. and Min. histog. accordingly
+                   //        if Multiplicity summation will be scored take Mult. minimum between both zones and 
+                   //        fill Mult Max and Min histog. accordingly
+                   //       Bib:
+                   //     2=Marchesini-like (Only Pt sorting: Single sorting)
+                   //        sort only according Pt summation scored, find minimum between both zones and
+                   //        fill Pt and Multiplicity Max and Min summation histog. following only this criterium
+                   //        Bib: Phys. Rev. D 38, 3419 (1988)
+                   //     3=Nameless pt per track single sorting
+                   //        sort according to pt per track scored in each transverse zone 
+                   //        lowest values indicates minimum zone.   
+                   //     4=User Selection sorting (NOTE: USER must implement it within cxx)
+   
+    
+    // Jet cuts 
+    Double_t      fChJetPtMin;       // Min Pt for charged Particle Jet
+    Double_t      fJet1EtaCut;       // |jet1 eta| < fJet1EtaCut   (fAnaType = 1,2,3)
+    Double_t      fJet2DeltaPhiCut;  // |Jet1.Phi - Jet2.Phi| < fJet2DeltaPhiCut (fAnaType = 2,3)
+    Double_t      fJet2RatioPtCut;   // Jet2.Pt/Jet1Pt > fJet2RatioPtCut  (fAnaType = 2,3)
+    Double_t      fJet3PtCut;        // Jet3.Pt < fJet3PtCut  (fAnaType = 3)
+
+    // track cuts
+    Double_t      fTrackEtaCut;      // Eta cut on tracks in the regions (fRegionType=1)
+    Double_t      fTrackPtCut;       // Pt cut of tracks in the regions
+   
+    // MC cross-section 
+    Double_t      fAvgTrials;        // average trials used to fill the fh1Trials histogram in case we do not have trials on a event by event basis
+    //TProfile*     fh1Xsec;           //!
+    //TH1F*         fh1Trials;         //!
+   
+
+    ClassDef( AliAnalysisTaskCorrectionsUE, 5); // Analysis task for Underlying Event analysis
+  };
+
+#endif
+
+    
index a469338197be74dbd9cb807c29aba39d9bca3646..893cb0acdc82f8937acaffef565228c43936853b 100644 (file)
 
 /* $Id:$ */
 
-//class AliAODInputHandler;
-//class AliAODHandler;
-//class AliLog;
-//class TROOT;
-
 #include <TROOT.h>
 #include <TChain.h>
 #include <TFile.h>
@@ -115,42 +110,6 @@ fTrackEtaCut(0.9),
 fTrackPtCut(0.),
 //For MC
 fAvgTrials(1)
-/*//Histograms
-fhNJets(0x0),
-fhEleadingPt(0x0),
-fhMinRegPtDist(0x0),
-fhRegionMultMin(0x0),
-fhMinRegAvePt(0x0),
-fhMinRegSumPt(0x0),
-fhMinRegMaxPtPart(0x0),
-fhMinRegSumPtvsMult(0x0),
-fhdNdEtaPhiDist(0x0),
-fhFullRegPartPtDistVsEt(0x0),
-fhTransRegPartPtDistVsEt(0x0),
-fhRegionSumPtMaxVsEt(0x0),
-fhRegionMultMax(0x0),
-fhRegionMultMaxVsEt(0x0),
-fhRegionSumPtMinVsEt(0x0),
-fhRegionMultMinVsEt(0x0),
-fhRegionAveSumPtVsEt(0x0),
-fhRegionDiffSumPtVsEt(0x0),
-fhRegionAvePartPtMaxVsEt(0x0),
-fhRegionAvePartPtMinVsEt(0x0),
-fhRegionMaxPartPtMaxVsEt(0x0),    
-fhRegForwardMult(0x0),
-fhRegForwardSumPtvsMult(0x0),
-fhRegBackwardMult(0x0),
-fhRegBackwardSumPtvsMult(0x0),
-fhRegForwardPartPtDistVsEt(0x0),
-fhRegBackwardPartPtDistVsEt(0x0),
-fhRegTransMult(0x0),
-fhRegTransSumPtVsMult(0x0),
-fhMinRegSumPtJetPtBin(0x0),
-fhMaxRegSumPtJetPtBin(0x0),
-fhVertexMult(0x0),
-fh1Xsec(0x0),  
-fh1Trials(0x0)
-*/
 {
   // Default constructor
   // Define input and output slots here
@@ -202,42 +161,6 @@ fTrackEtaCut(original.fTrackEtaCut),
 fTrackPtCut(original.fTrackPtCut),
 //For MC
 fAvgTrials(original.fAvgTrials)
-/*//Histograms
-fhNJets(original.fhNJets),
-fhEleadingPt(original.fhEleadingPt),
-fhMinRegPtDist(original.fhMinRegPtDist),
-fhRegionMultMin(original.fhRegionMultMin),
-fhMinRegAvePt(original.fhMinRegAvePt),
-fhMinRegSumPt(original.fhMinRegSumPt),
-fhMinRegMaxPtPart(original.fhMinRegMaxPtPart),
-fhMinRegSumPtvsMult(original.fhMinRegSumPtvsMult),
-fhdNdEtaPhiDist(original.fhdNdEtaPhiDist),
-fhFullRegPartPtDistVsEt(original.fhFullRegPartPtDistVsEt),
-fhTransRegPartPtDistVsEt(original.fhTransRegPartPtDistVsEt),
-fhRegionSumPtMaxVsEt(original.fhRegionSumPtMaxVsEt),
-fhRegionMultMax(original.fhRegionMultMax),
-fhRegionMultMaxVsEt(original.fhRegionMultMaxVsEt),
-fhRegionSumPtMinVsEt(original.fhRegionSumPtMinVsEt),
-fhRegionMultMinVsEt(original.fhRegionMultMinVsEt),
-fhRegionAveSumPtVsEt(original.fhRegionAveSumPtVsEt),
-fhRegionDiffSumPtVsEt(original.fhRegionDiffSumPtVsEt),
-fhRegionAvePartPtMaxVsEt(original.fhRegionAvePartPtMaxVsEt),
-fhRegionAvePartPtMinVsEt(original.fhRegionAvePartPtMinVsEt),
-fhRegionMaxPartPtMaxVsEt(original.fhRegionMaxPartPtMaxVsEt),
-fhRegForwardMult(original.fhRegForwardMult),
-fhRegForwardSumPtvsMult(original.fhRegForwardSumPtvsMult),
-fhRegBackwardMult(original.fhRegBackwardMult),
-fhRegBackwardSumPtvsMult(original.fhRegBackwardSumPtvsMult),
-fhRegForwardPartPtDistVsEt(original.fhRegForwardPartPtDistVsEt),
-fhRegBackwardPartPtDistVsEt(original.fhRegBackwardPartPtDistVsEt),
-fhRegTransMult(original.fhRegTransMult),
-fhRegTransSumPtVsMult(original.fhRegTransSumPtVsMult),
-fhMinRegSumPtJetPtBin(original.fhMinRegSumPtJetPtBin),
-fhMaxRegSumPtJetPtBin(original.fhMaxRegSumPtJetPtBin),
-fhVertexMult(original.fhVertexMult),
-fh1Xsec(original.fh1Xsec),     
-fh1Trials(original.fh1Trials)
-*/
 {
   // Copy constructor
 }
@@ -285,9 +208,9 @@ void AliAnalysisTaskUE::ConnectInputData(Option_t* /*option*/)
 {
   // Connect the input data  
   
-  // We need AOD with tracks and jets.
-  // Since AOD can be either connected to the InputEventHandler (input chain fron AOD files)
-  // or to the OutputEventHandler ( AOD is create by a previus task in the train )
+  // We need AODs with tracks and jets.
+  // Since AODs can either be connected to the InputEventHandler
+  // or to the OutputEventHandler ( the AOD is created by a previus task in the train )
   // we need to check where it is and get the pointer to AODEvent in the right way
   
   // Delta AODs are also accepted
@@ -356,18 +279,11 @@ void  AliAnalysisTaskUE::Exec(Option_t */*option*/)
   // Trigger selection ************************************************
   AliInputEventHandler* inputHandler = (AliInputEventHandler*)
          ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
-  if( !inputHandler->InheritsFrom("AliAODInputHandler") ) { // input AOD
-       if (inputHandler->IsEventSelected()) {
-               if (fDebug > 1) AliInfo(" Trigger Selection: event ACCEPTED ... ");
-       } else {
-               if (fDebug > 1) AliInfo(" Trigger Selection: event REJECTED ... ");
-               return;
-               }
-        }                                
-  // Event selection (vertex) *****************************************
-   
-  //if(!fAnaUE->VertexSelection(fAOD,fnTracksVertex,fZVertex)) return;
-  if(!fAnaUE->VertexSelectionOld(fAOD)) return; // temporary to compare with old task and to have same cuts for MC !!!
+  if (!fAnaUE->TriggerSelection(inputHandler)) return;
+  
+  // Vertex selection *************************************************
+  if(!fAnaUE->VertexSelection(fAOD,fnTracksVertex,fZVertex)) return;
+  //if(!fAnaUE->VertexSelectionOld(fAOD)) return; // temporary to compare with old task and to have same cuts for MC !!!
   
   // Execute analysis for current event ******************************
   
@@ -433,7 +349,7 @@ void  AliAnalysisTaskUE::AnalyseUE()
                if (fDebug >1 ) AliInfo(Form("\n   Pt Leading Jet = %6.1f eta=%5.3f ",  jetVect[0].Pt(), jetVect[0].Eta() ));
                }
 
-   // Select events according to analysis type
+   // Select events according to analysis type ***********************************
    if ( ! (fAnaUE->AnaTypeSelection(jetVect))) return;
 
   // Find max and min regions with real tracks
@@ -445,7 +361,7 @@ void  AliAnalysisTaskUE::AnalyseUE()
        // Fill leading "jet" histogram
        fHistosUE->FillHistogram("hEleadingPt",jetVect[0].Pt());
 
-       fAnaUE->FindMaxMinRegions( jetVect,  fConePosition );
+       fAnaUE->FindMaxMinRegions( jetVect,  fConePosition, 0, 0 );
 
   }else { 
     
@@ -499,12 +415,12 @@ void  AliAnalysisTaskUE::Terminate(Option_t */*option*/)
   
   // Terminate analysis
 
+  if (!gROOT->IsBatch()){
   fListOfHistos = dynamic_cast<TList*> (GetOutputData(0));
   if (!fListOfHistos){
        AliError("Histogram List is not available");
        return;
-  }
-  if (!gROOT->IsBatch()){
+       }
   //call class AliHistogramsUE
   AliHistogramsUE *histos=new AliHistogramsUE(fListOfHistos);
   histos->DrawUE(0);
index d1db8aee1c64babfe917bc05aa7c490eee40b99e..59c43ef9f9a007a9a13e54eab89a2c3a6cae31fa 100644 (file)
@@ -61,7 +61,7 @@ class  AliAnalysisTaskUE : public AliAnalysisTask
 
     //  Setters/Getters
     virtual     void         SetDebugLevel( Int_t level )  { fDebug = level; }
-    virtual     Int_t        GetDebugLevel() const { return fDebug; }
+    virtual     Int_t        GetDebugLevel() const  { return fDebug; }
     
     void       SetPtRangeInHist( Int_t bin, Double_t min, Double_t max ) {
                        fBinsPtInHist = bin; 
@@ -70,9 +70,9 @@ class  AliAnalysisTaskUE : public AliAnalysisTask
                        }
 
     // Read AODs
-    void         SelectAODBranch(const char* val)     { fAODBranch = val;   }
-    virtual       TString       GetAODBranch() const  { return fAODBranch;   }
-    virtual       AliAODEvent*   GetAOD()       const  { return fAOD; } 
+    void         SelectAODBranch(const char* val)      { fAODBranch = val;   }
+    virtual       TString       GetAODBranch() const   { return fAODBranch;   }
+    virtual       AliAODEvent*   GetAOD() const         { return fAOD; } 
 
     // Setters/Getters for MC
     void       SetConstrainDistance(Bool_t val1, Double_t val2){ fMinDistance = val2; fConstrainDistance = val1;}
@@ -80,11 +80,11 @@ class  AliAnalysisTaskUE : public AliAnalysisTask
     void       SetUseAODMCParticle(){fUseAliStack = kFALSE;}
     void       SetUseMCBranch(){fUseMCParticleBranch = kTRUE;}
 
-    virtual  Bool_t    GetConstrainDistance() const  {return fConstrainDistance;}
-    virtual  Double_t  GetMinDistance() const {return fMinDistance;}
-    virtual  Bool_t    GetSimulateChJetPt() const {return fSimulateChJetPt;}
-    virtual  Bool_t    GetUseAODMCParticle() const {return fUseAliStack;}
-    virtual  Bool_t    GetUseMCParticleBranch() const {return fUseMCParticleBranch;}
+    virtual Bool_t     GetConstrainDistance()   const  {return fConstrainDistance;}
+    virtual Double_t   GetMinDistance()         const  {return fMinDistance;}
+    virtual Bool_t     GetSimulateChJetPt()     const  {return fSimulateChJetPt;}
+    virtual Bool_t     GetUseAODMCParticle()    const  {return fUseAliStack;}
+    virtual Bool_t     GetUseMCParticleBranch() const  {return fUseMCParticleBranch;}
 
     //Setters for Events QA
     void  SetZVertex( Double_t val ) { fZVertex = val; }
@@ -104,18 +104,18 @@ class  AliAnalysisTaskUE : public AliAnalysisTask
     void   SetUseNegativeChargeType()        { fUsePositiveCharge = kFALSE; }
     void   SetUseSingleCharge()              { fUseSingleCharge = kTRUE; } 
     
-    virtual Int_t     GetAnaTopology()   const               { return fAnaType; }
-    virtual Int_t     GetConePosition()  const               { return fConePosition; }
-    virtual Double_t  GetConeRadius()           const               { return fConeRadius; }
-    virtual Bool_t    GetDoNotNormalizeQuantities()   const  { return fIsNorm2Area; }
-    virtual UInt_t    GetFilterBit()     const                      { return fFilterBit;  }
-    virtual Bool_t    GetJetsOnFly()     const              { return fJetsOnFly;  }
-    virtual Int_t     GetPtSumOrdering() const               { return fOrdering;   }
-    virtual Int_t     GetRegionType()    const               { return fRegionType; }
-    virtual Bool_t    GetUseChargeHadrons() const            { return fUseChargeHadrons; }
-    virtual Int_t     GetUseChPartJet()  const               { return fUseChPartJet; }
-    virtual Bool_t    GetUseNegativeChargeType() const       { return fUsePositiveCharge; }
-    virtual Bool_t    GetUseSingleCharge()       const       { return fUseSingleCharge; } 
+    virtual Int_t     GetAnaTopology()             const     { return fAnaType; }
+    virtual Int_t     GetConePosition()             const     { return fConePosition; }
+    virtual Double_t  GetConeRadius()                      const     { return fConeRadius; }
+    virtual Bool_t    GetDoNotNormalizeQuantities() const     { return fIsNorm2Area; }
+    virtual UInt_t    GetFilterBit()               const     { return fFilterBit;  }
+    virtual Bool_t    GetJetsOnFly()               const     { return fJetsOnFly;  }
+    virtual Int_t     GetPtSumOrdering()            const     { return fOrdering;   }
+    virtual Int_t     GetRegionType()               const     { return fRegionType; }
+    virtual Bool_t    GetUseChargeHadrons()         const     { return fUseChargeHadrons; }
+    virtual Int_t     GetUseChPartJet()             const     { return fUseChPartJet; }
+    virtual Bool_t    GetUseNegativeChargeType()    const     { return fUsePositiveCharge; }
+    virtual Bool_t    GetUseSingleCharge()          const     { return fUseSingleCharge; } 
     
     // Jet cuts
     void   SetJet1EtaCut( Double_t val )      { fJet1EtaCut = val; }
@@ -124,18 +124,18 @@ class  AliAnalysisTaskUE : public AliAnalysisTask
     void   SetJet3PtCut( Double_t val )       { fJet3PtCut = val; }
     void   SetPtMinChPartJet( Double_t val )  { fChJetPtMin = val; }
     
-    virtual Double_t   GetJet1EtaCut()     const           { return fJet1EtaCut; }
-    virtual Double_t   GetJet2DeltaPhiCut() const         { return fJet2DeltaPhiCut; }
-    virtual Double_t   GetJet2RatioPtCut() const           { return fJet2RatioPtCut; }
-    virtual Double_t   GetJet3PtCut()      const           { return fJet3PtCut; }
-    virtual Double_t   GetPtMinChPartJet() const           { return fChJetPtMin; }
+    virtual Double_t   GetJet1EtaCut()       const      { return fJet1EtaCut; }
+    virtual Double_t   GetJet2DeltaPhiCut()  const     { return fJet2DeltaPhiCut; }
+    virtual Double_t   GetJet2RatioPtCut()   const      { return fJet2RatioPtCut; }
+    virtual Double_t   GetJet3PtCut()        const      { return fJet3PtCut; }
+    virtual Double_t   GetPtMinChPartJet()   const      { return fChJetPtMin; }
     
     // track cuts
     void   SetTrackEtaCut( Double_t val ) { fTrackEtaCut = val; }
     void   SetTrackPtCut( Double_t val )  { fTrackPtCut = val; }
 
-    virtual Double_t   GetTrackEtaCut()  const         { return fTrackEtaCut; }
-    virtual Double_t   GetTrackPtCut()   const         { return fTrackPtCut; }
+    virtual Double_t   GetTrackEtaCut() const     { return fTrackEtaCut; }
+    virtual Double_t   GetTrackPtCut()  const     { return fTrackPtCut; }
     
 
     AliHistogramsUE*    fHistosUE;        //! points to AliHistogramsUE class   
index 841a4e742d1fb4eff7f94fc8dd526b68db13311e..5b4083bac645bdd4c8943eb312cfb05edba0976b 100644 (file)
@@ -41,6 +41,8 @@
 #include "AliHistogramsUE.h"
 #include "AliAnalysisTaskUE.h"
 #include "AliAnalyseUE.h"
+#include "AliCFContainer.h"
+#include "AliCFManager.h"
 #include "AliLog.h"
 
 ClassImp( AliHistogramsUE)
@@ -52,6 +54,7 @@ fBinsPtInHist(0),
 fMinJetPtInHist(0.),
 fMaxJetPtInHist(0.),
 fTrackEtaCut(0.),
+fJet1EtaCut(0.),
 fListOfHistos(0x0),  
 fhNJets(0x0),
 fhEleadingPt(0x0),
@@ -62,8 +65,11 @@ fhMinRegSumPt(0x0),
 fhMinRegMaxPtPart(0x0),
 fhMinRegSumPtvsMult(0x0),
 fhdNdEtaPhiDist(0x0),        
+fhdNdEtaPhiDistMC(0x0),        
 fhFullRegPartPtDistVsEt(0x0), 
+fhFullRegPartPtDistVsEtMC(0x0), 
 fhTransRegPartPtDistVsEt(0x0),
+fhTransRegPartPtDistVsEtMC(0x0),
 fhRegionSumPtMaxVsEt(0x0),
 fhRegionMultMax(0x0),         
 fhRegionMultMaxVsEt(0x0),     
@@ -79,14 +85,19 @@ fhRegForwardSumPtvsMult(0x0),
 fhRegBackwardMult(0x0),
 fhRegBackwardSumPtvsMult(0x0),
 fhRegForwardPartPtDistVsEt(0x0),
+fhRegForwardPartPtDistVsEtMC(0x0),
 fhRegBackwardPartPtDistVsEt(0x0),
+fhRegBackwardPartPtDistVsEtMC(0x0),
 fhRegTransMult(0x0),
 fhRegTransSumPtVsMult(0x0),
 fhMinRegSumPtJetPtBin(0x0),
 fhMaxRegSumPtJetPtBin(0x0),
 fhVertexMult(0x0),
 fh1Xsec(0x0),
-fh1Trials(0x0)
+fh1Trials(0x0),
+fhDCAxy(0x0),
+fhDCAxyPrimary(0x0)
+//For Corrections
 {
   // Default constructor
 
@@ -99,6 +110,7 @@ fBinsPtInHist(0),
 fMinJetPtInHist(0.),
 fMaxJetPtInHist(0.),
 fTrackEtaCut(0.),
+fJet1EtaCut(0.),
 fListOfHistos(0x0),  
 fhNJets(0x0),
 fhEleadingPt(0x0),
@@ -109,8 +121,11 @@ fhMinRegSumPt(0x0),
 fhMinRegMaxPtPart(0x0),
 fhMinRegSumPtvsMult(0x0),
 fhdNdEtaPhiDist(0x0),        
+fhdNdEtaPhiDistMC(0x0),        
 fhFullRegPartPtDistVsEt(0x0), 
+fhFullRegPartPtDistVsEtMC(0x0), 
 fhTransRegPartPtDistVsEt(0x0),
+fhTransRegPartPtDistVsEtMC(0x0),
 fhRegionSumPtMaxVsEt(0x0),
 fhRegionMultMax(0x0),         
 fhRegionMultMaxVsEt(0x0),     
@@ -126,14 +141,19 @@ fhRegForwardSumPtvsMult(0x0),
 fhRegBackwardMult(0x0),
 fhRegBackwardSumPtvsMult(0x0),
 fhRegForwardPartPtDistVsEt(0x0),
+fhRegForwardPartPtDistVsEtMC(0x0),
 fhRegBackwardPartPtDistVsEt(0x0),
+fhRegBackwardPartPtDistVsEtMC(0x0),
 fhRegTransMult(0x0),
 fhRegTransSumPtVsMult(0x0),
 fhMinRegSumPtJetPtBin(0x0),
 fhMaxRegSumPtJetPtBin(0x0),
 fhVertexMult(0x0),
 fh1Xsec(0x0),
-fh1Trials(0x0)
+fh1Trials(0x0),
+fhDCAxy(0x0),
+fhDCAxyPrimary(0x0)
+//For Corrections
 {
   // Constructor, initialize members from list
        fhNJets = (TH1F*)list->FindObject("hNJets"); 
@@ -145,8 +165,11 @@ fh1Trials(0x0)
        fhMinRegMaxPtPart = (TH1F*)list->FindObject("hMinRegMaxPtPart");
        fhMinRegSumPtvsMult = (TH1F*)list->FindObject("hMinRegSumPtvsMult");
        fhdNdEtaPhiDist = (TH2F*)list->FindObject("hdNdEtaPhiDist");  
+       fhdNdEtaPhiDistMC = (TH2F*)list->FindObject("hdNdEtaPhiDistMC");  
        fhFullRegPartPtDistVsEt = (TH2F*)list->FindObject("hFullRegPartPtDistVsEt");
+       fhFullRegPartPtDistVsEtMC = (TH2F*)list->FindObject("hFullRegPartPtDistVsEtMC");
        fhTransRegPartPtDistVsEt = (TH2F*)list->FindObject("hTransRegPartPtDistVsEt");
+       fhTransRegPartPtDistVsEtMC = (TH2F*)list->FindObject("hTransRegPartPtDistVsEtMC");
        fhRegionSumPtMaxVsEt = (TH1F*)list->FindObject("hRegionSumPtMaxVsEt"); 
        fhRegionMultMax = (TH1I*)list->FindObject("hRegionMultMax");
        fhRegionMultMaxVsEt = (TH1F*)list->FindObject("hRegionMultMaxVsEt");
@@ -162,7 +185,9 @@ fh1Trials(0x0)
        fhRegBackwardMult = (TH2F*)list->FindObject("hRegBackwardMult");
        fhRegBackwardSumPtvsMult = (TH2F*)list->FindObject("hRegBackwardSumPtvsMult");
        fhRegForwardPartPtDistVsEt = (TH2F*)list->FindObject("hRegForwardPartPtDistVsEt");
+       fhRegForwardPartPtDistVsEtMC = (TH2F*)list->FindObject("hRegForwardPartPtDistVsEtMC");
        fhRegBackwardPartPtDistVsEt = (TH2F*)list->FindObject("hRegBackwardPartPtDistVsEt");
+       fhRegBackwardPartPtDistVsEtMC = (TH2F*)list->FindObject("hRegBackwardPartPtDistVsEtMC");
        fhRegTransMult = (TH2F*)list->FindObject("hRegTransMult");
        fhRegTransSumPtVsMult = (TH2F*)list->FindObject("hRegTransSumPtVsMult");
        fhMinRegSumPtJetPtBin = (TH2F*)list->FindObject("hMinRegSumPtJetPtBin");
@@ -170,7 +195,8 @@ fh1Trials(0x0)
        fhVertexMult = (TH1F*)list->FindObject("hVertexMult");
        fh1Xsec = (TProfile*)list->FindObject("h1Xsec");
        fh1Trials = (TH1F*)list->FindObject("h1Trials"); 
-
+       fhDCAxy = (TH2F*)list->FindObject("hDCAxy");
+       fhDCAxyPrimary = (TH2F*)list->FindObject("hDCAxyPrimary");
 }
 //____________________________________________________________________
 AliHistogramsUE:: AliHistogramsUE(const AliHistogramsUE & original):
@@ -179,6 +205,7 @@ fBinsPtInHist(original.fBinsPtInHist),
 fMinJetPtInHist(original.fMinJetPtInHist),
 fMaxJetPtInHist(original.fMaxJetPtInHist),
 fTrackEtaCut(original.fTrackEtaCut),
+fJet1EtaCut(original.fJet1EtaCut),
 fListOfHistos(original.fListOfHistos),  
 fhNJets(original.fhNJets),
 fhEleadingPt(original.fhEleadingPt),
@@ -189,8 +216,11 @@ fhMinRegSumPt(original.fhMinRegSumPt),
 fhMinRegMaxPtPart(original.fhMinRegMaxPtPart),
 fhMinRegSumPtvsMult(original.fhMinRegSumPtvsMult),
 fhdNdEtaPhiDist(original.fhdNdEtaPhiDist),        
+fhdNdEtaPhiDistMC(original.fhdNdEtaPhiDistMC),        
 fhFullRegPartPtDistVsEt(original.fhFullRegPartPtDistVsEt), 
+fhFullRegPartPtDistVsEtMC(original.fhFullRegPartPtDistVsEtMC), 
 fhTransRegPartPtDistVsEt(original.fhTransRegPartPtDistVsEt),
+fhTransRegPartPtDistVsEtMC(original.fhTransRegPartPtDistVsEtMC),
 fhRegionSumPtMaxVsEt(original.fhRegionSumPtMaxVsEt),
 fhRegionMultMax(original.fhRegionMultMax),         
 fhRegionMultMaxVsEt(original.fhRegionMultMaxVsEt),     
@@ -206,14 +236,19 @@ fhRegForwardSumPtvsMult(original.fhRegForwardSumPtvsMult),
 fhRegBackwardMult(original.fhRegBackwardMult),
 fhRegBackwardSumPtvsMult(original.fhRegBackwardSumPtvsMult),
 fhRegForwardPartPtDistVsEt(original.fhRegForwardPartPtDistVsEt),
+fhRegForwardPartPtDistVsEtMC(original.fhRegForwardPartPtDistVsEtMC),
 fhRegBackwardPartPtDistVsEt(original.fhRegBackwardPartPtDistVsEt),
+fhRegBackwardPartPtDistVsEtMC(original.fhRegBackwardPartPtDistVsEtMC),
 fhRegTransMult(original.fhRegTransMult),
 fhRegTransSumPtVsMult(original.fhRegTransSumPtVsMult),
 fhMinRegSumPtJetPtBin(original.fhMinRegSumPtJetPtBin),
 fhMaxRegSumPtJetPtBin(original.fhMaxRegSumPtJetPtBin),
 fhVertexMult(original.fhVertexMult),
 fh1Xsec(original.fh1Xsec),
-fh1Trials(original.fh1Trials)
+fh1Trials(original.fh1Trials),
+fhDCAxy(original.fhDCAxy),
+fhDCAxyPrimary(original.fhDCAxyPrimary)
+//For Corrections
 {
 
   // Copy constructor
@@ -245,7 +280,9 @@ TObjArray* AliHistogramsUE::CreateCanvas(const Int_t ncanv){
        gStyle->SetOptTitle(0);
        arr->Add(c);
         }
+
 return arr;
+
 }
 
 //____________________________________________________________________
@@ -479,6 +516,232 @@ void  AliHistogramsUE::CreateHistograms(TList *list,Int_t bins, Double_t min, Do
   fListOfHistos=list; 
 }
 
+//____________________________________________________________________
+void AliHistogramsUE::CreateCorrectionsContainer(AliCFManager* cfman,Int_t bins, Double_t min, Double_t max, Double_t etacut, Double_t jetetacut){
+  
+  fBinsPtInHist = bins;
+  fMinJetPtInHist = min;
+  fMaxJetPtInHist = max;
+  fTrackEtaCut= etacut;
+  fJet1EtaCut = jetetacut;
+  //Define some constant
+  const Double_t minpT=fMinJetPtInHist; 
+  const Double_t maxpT=fMaxJetPtInHist;
+
+  const Double_t mineta=(-1.*fJet1EtaCut);
+  const Double_t maxeta=fJet1EtaCut;
+       
+  const Double_t minprocess=-0.5; 
+  const Double_t maxprocess=9.5;
+
+  const Double_t mindeltaeta=-5.; 
+  const Double_t maxdeltaeta=5.;
+
+  const Double_t mindeltaphi=0.;
+  const Double_t maxdeltaphi=7.;
+  
+  const Double_t  minradius=0.; 
+  const Double_t  maxradius=10.;
+
+  //Define sensitive variables
+  UInt_t ipT       = 0;     //leading track pT
+  UInt_t ieta      = 1;     //leading track eta 
+  UInt_t iprocess  = 2;     //process type (ND,DD,SD)  
+  UInt_t ipTMC     = 3;     //MC leading track pT  
+  UInt_t ietaMC    = 4;     //MC leading track eta 
+  UInt_t ideltaeta = 5;     //leading track eta  reco-MC
+  UInt_t ideltaphi = 6;     //leading track phi  reco-MC 
+  UInt_t iradius   = 7;     //leading track radius reco-MC 
+  
+  //Set-up grid
+  UInt_t nstep = 6;
+  const Int_t nvar = 8;
+  const Int_t nbinspT = fBinsPtInHist;
+  const Int_t nbinseta = 10;
+  const Int_t nbinsprocess = 10;
+  const Int_t nbinsdeltaeta = 20;
+  const Int_t nbinsdeltaphi = 20; 
+  const Int_t nbinsradius = 20; 
+
+  Int_t iBin[nvar];
+  iBin[0] = nbinspT;
+  iBin[1] = nbinseta;
+  iBin[2] = nbinsprocess;
+  iBin[3] = nbinspT;
+  iBin[4] = nbinseta;
+  iBin[5] = nbinsdeltaeta;
+  iBin[6] = nbinsdeltaphi;
+  iBin[7] = nbinsradius;
+  
+  //lower bounds
+  Double_t *binLimpT=new Double_t[nbinspT+1];
+  for (Int_t i=0; i<=nbinspT; i++) binLimpT[i]=(Double_t)minpT + (maxpT-minpT)/nbinspT*(Double_t)i ;
+  
+  Double_t *binLimeta=new Double_t[nbinseta+1];
+  for (Int_t i=0; i<=nbinseta; i++) binLimeta[i]=(Double_t)mineta + (maxeta-mineta)/nbinseta*(Double_t)i ;
+  
+  Double_t *binLimprocess=new Double_t[nbinsprocess+1];
+  for (Int_t i=0; i<=nbinsprocess; i++) binLimprocess[i]=(Double_t)minprocess + (maxprocess-minprocess)/nbinsprocess*(Double_t)i ;
+  
+  Double_t *binLimdeltaeta=new Double_t[nbinsdeltaeta+1];
+  for (Int_t i=0; i<=nbinsdeltaeta; i++) binLimdeltaeta[i]=(Double_t)mindeltaeta + (maxdeltaeta-mindeltaeta)/nbinsdeltaeta*(Double_t)i ;
+  
+  Double_t *binLimdeltaphi=new Double_t[nbinsdeltaphi+1];
+  for (Int_t i=0; i<=nbinsdeltaphi; i++) binLimdeltaphi[i]=(Double_t)mindeltaphi + (maxdeltaphi-mindeltaphi)/nbinsdeltaphi*(Double_t)i ;
+  
+  Double_t *binLimradius=new Double_t[nbinsradius+1];
+  for (Int_t i=0; i<=nbinsradius; i++) binLimradius[i]=(Double_t)minradius + (maxradius-minradius)/nbinsradius*(Double_t)i ;
+  
+
+  //Container
+  AliCFContainer * container = new AliCFContainer("container1", "EventSelection",nstep,nvar,iBin);
+  container->SetBinLimits(ipT,binLimpT);
+  container->SetBinLimits(ieta,binLimeta);
+  container->SetBinLimits(iprocess,binLimprocess);
+  container->SetBinLimits(ipTMC,binLimpT);
+  container->SetBinLimits(ietaMC,binLimeta);
+  container->SetBinLimits(ideltaeta,binLimdeltaeta);
+  container->SetBinLimits(ideltaphi,binLimdeltaphi);
+  container->SetBinLimits(iradius,binLimradius);
+
+  container->SetVarTitle(ipT,"Leading track p_{T} (reco.)");
+  container->SetVarTitle(ieta,"Leading track #eta (reco.)");
+  container->SetVarTitle(iprocess,"Process");
+  container->SetVarTitle(ipTMC,"Leading track p_{T} (true)");
+  container->SetVarTitle(ietaMC,"Leading track #eta (true)");
+  container->SetVarTitle(ideltaeta,"Leading track #Delta #eta (reco.-true)");
+  container->SetVarTitle(ideltaphi,"Leading track #Delta #phi (reco.-true)");
+  container->SetVarTitle(iradius,"Leading track R (reco.-true)");
+
+  //set steps
+  container->SetStepTitle(0,"Triggered");
+  container->SetStepTitle(1,"Pass physics selection");
+  container->SetStepTitle(2,"Pass primary vertex cuts");
+  container->SetStepTitle(3,"Required analysis topology ");
+  container->SetStepTitle(4,"Leading track p_{T} > 1 GeV/c");
+  container->SetStepTitle(5,"Leading track correctly identified");
+  
+  cfman->SetEventContainer(container);
+  
+}
+
+
+
+//____________________________________________________________________
+void  AliHistogramsUE::CreateHistogramsCorrections(TList *list,Int_t bins, Double_t min, Double_t max, Double_t etacut)
+{
+
+  // Create all histograms necessary for UE corrections
+  fBinsPtInHist = bins;
+  fMinJetPtInHist = min;
+  fMaxJetPtInHist = max;
+  fTrackEtaCut= etacut;
+
+  //Number of reconstructed clusters  
+  fhNJets = new TH1F("hNJets", "Number of clusters",  20, 0, 20);
+  fhNJets->SetXTitle("Number of reconstructed clusters");
+  fhNJets->SetYTitle("#");
+  fhNJets->Sumw2();
+  list->Add( fhNJets );                  
+  
+  //Cross-section from MC
+  fh1Xsec = new TProfile("h1Xsec","xsec from pyxsec.root",1,0,1); 
+  fh1Xsec->GetXaxis()->SetBinLabel(1,"<#sigma>");
+  fh1Xsec->Sumw2();
+  list->Add( fh1Xsec );   
+
+  //Number of trials from MC
+  fh1Trials = new TH1F("h1Trials","trials from pyxsec.root",1,0,1);
+  fh1Trials->GetXaxis()->SetBinLabel(1,"#sum{ntrials}");
+  fh1Trials->Sumw2();
+  list->Add( fh1Trials ); 
+
+  //FOR TRACK EFFICIENCY 
+  //Phi correlation track-cluster vs. leading cluster pT 
+  fhdNdEtaPhiDist  = new TH2F("hdNdEtaPhiDist", Form("Charge particle density |#eta|<%3.1f vs #Delta#phi", fTrackEtaCut),62, 0.,   2.*TMath::Pi(), bins, min, max);
+  fhdNdEtaPhiDist->SetXTitle("#Delta#phi");
+  fhdNdEtaPhiDist->SetYTitle("Leading cluster p_{T}");
+  fhdNdEtaPhiDist->Sumw2();
+  list->Add( fhdNdEtaPhiDist );        
+  //idem for MC true 
+  fhdNdEtaPhiDistMC  = new TH2F("hdNdEtaPhiDistMC", Form("Charge particle density |#eta|<%3.1f vs #Delta#phi", fTrackEtaCut),62, 0.,   2.*TMath::Pi(), bins, min, max);
+  fhdNdEtaPhiDistMC->SetXTitle("#Delta#phi");
+  fhdNdEtaPhiDistMC->SetYTitle("Leading cluster p_{T}");
+  fhdNdEtaPhiDistMC->Sumw2();
+  list->Add( fhdNdEtaPhiDistMC );      
+  
+
+  //Can be used to get track pT distribution for different cluster pT bins (full region)
+  fhFullRegPartPtDistVsEt = new TH2F("hFullRegPartPtDistVsEt", Form( "dN/dp_{T} |#eta|<%3.1f vs Leading cluster p_{T}", fTrackEtaCut),100,0.,50., bins, min, max);
+  fhFullRegPartPtDistVsEt->SetYTitle("Leading cluster p_{T}");
+  fhFullRegPartPtDistVsEt->SetXTitle("p_{T}");
+  fhFullRegPartPtDistVsEt->Sumw2();
+  list->Add( fhFullRegPartPtDistVsEt );   
+  //idem for MC true
+  fhFullRegPartPtDistVsEtMC = new TH2F("hFullRegPartPtDistVsEtMC", Form( "dN/dp_{T} |#eta|<%3.1f vs Leading cluster p_{T}", fTrackEtaCut),100,0.,50., bins, min, max);
+  fhFullRegPartPtDistVsEtMC->SetYTitle("Leading cluster p_{T}");
+  fhFullRegPartPtDistVsEtMC->SetXTitle("p_{T}");
+  fhFullRegPartPtDistVsEtMC->Sumw2();
+  list->Add( fhFullRegPartPtDistVsEtMC );   
+
+
+  //Can be used to get part pT distribution for different cluster pT bins (transverse region)
+  fhTransRegPartPtDistVsEt = new TH2F("hTransRegPartPtDistVsEt", Form( "dN/dp_{T} in tranvese regions |#eta|<%3.1f vs Leading cluster p_{T}", fTrackEtaCut),100,0.,50., bins, min,   max);
+  fhTransRegPartPtDistVsEt->SetYTitle("Leading cluster p_{T}");
+  fhTransRegPartPtDistVsEt->SetXTitle("p_{T}");
+  fhTransRegPartPtDistVsEt->Sumw2();
+  list->Add( fhTransRegPartPtDistVsEt );  
+  //idem for MC true
+  fhTransRegPartPtDistVsEtMC = new TH2F("hTransRegPartPtDistVsEtMC", Form( "dN/dp_{T} in tranvese regions |#eta|<%3.1f vs Leading cluster p_{T}", fTrackEtaCut),100,0.,50., bins, min,   max);
+  fhTransRegPartPtDistVsEtMC->SetYTitle("Leading cluster p_{T}");
+  fhTransRegPartPtDistVsEtMC->SetXTitle("p_{T}");
+  fhTransRegPartPtDistVsEtMC->Sumw2();
+  list->Add( fhTransRegPartPtDistVsEtMC ); 
+
+
+  //Track pT distribution in FORWARD region vs. leading-cluster pT 
+  fhRegForwardPartPtDistVsEt = new TH2F("hRegForwardPartPtDistVsEt", Form( "dN/dP_{T} |#eta|<%3.1f vs Leading cluster p_{T}", fTrackEtaCut), 100,0.,50., bins, min, max);
+  fhRegForwardPartPtDistVsEt->SetYTitle("Leading cluster p_{T}");
+  fhRegForwardPartPtDistVsEt->SetXTitle("p_{T} (GeV/c)");
+  fhRegForwardPartPtDistVsEt->Sumw2();
+  list->Add( fhRegForwardPartPtDistVsEt );   
+  //idem for MC true 
+  fhRegForwardPartPtDistVsEtMC = new TH2F("hRegForwardPartPtDistVsEtMC", Form( "dN/dP_{T} |#eta|<%3.1f vs Leading cluster p_{T}", fTrackEtaCut), 100,0.,50., bins, min, max);
+  fhRegForwardPartPtDistVsEtMC->SetYTitle("Leading cluster p_{T}");
+  fhRegForwardPartPtDistVsEtMC->SetXTitle("p_{T} (GeV/c)");
+  fhRegForwardPartPtDistVsEtMC->Sumw2();
+  list->Add( fhRegForwardPartPtDistVsEtMC );   
+  
+  //Track pT distribution in BACKWARD region vs. leading-cluster pT 
+  fhRegBackwardPartPtDistVsEt = new TH2F("hRegBackwardPartPtDistVsEt", Form( "dN/dP_{T} |#eta|<%3.1f vs Leading cluster p_{T}", fTrackEtaCut), 100,0.,50., bins, min, max);
+  fhRegBackwardPartPtDistVsEt->SetYTitle("Leading cluster p_{T}");
+  fhRegBackwardPartPtDistVsEt->SetXTitle("p_{T}");
+  fhRegBackwardPartPtDistVsEt->Sumw2();
+  list->Add( fhRegBackwardPartPtDistVsEt );   
+  //idem for MC true 
+  fhRegBackwardPartPtDistVsEtMC = new TH2F("hRegBackwardPartPtDistVsEtMC", Form( "dN/dP_{T} |#eta|<%3.1f vs Leading cluster p_{T}", fTrackEtaCut), 100,0.,50., bins, min, max);
+  fhRegBackwardPartPtDistVsEtMC->SetYTitle("Leading cluster p_{T}");
+  fhRegBackwardPartPtDistVsEtMC->SetXTitle("p_{T}");
+  fhRegBackwardPartPtDistVsEtMC->Sumw2();
+  list->Add( fhRegBackwardPartPtDistVsEtMC );  
+
+  //FOR DCA DISTRIBUTION 
+  fhDCAxy = new TH2F("hDCAxy","Transverse DCA vs. leading track p_{T} ",50,-5.,5.,bins,min,max); 
+  fhDCAxy->SetYTitle("Leading cluster p_{T}");
+  fhDCAxy->SetXTitle("d_{0}");
+  fhDCAxy->Sumw2();
+  list->Add( fhDCAxy );
+  
+  //Fill only if reconstructed points back to a true primary  
+  fhDCAxyPrimary = new TH2F("hDCAxyPrimary","Transverse DCA vs. leading track p_{T} (primaries)",50,-5.,5.,bins,min,max);
+  fhDCAxyPrimary->SetYTitle("Leading cluster p_{T}");
+  fhDCAxyPrimary->SetXTitle("d_{0}");
+  fhDCAxyPrimary->Sumw2();
+  list->Add( fhDCAxyPrimary );  
+  fListOfHistos=list; 
+}
 
 //____________________________________________________________________
 void AliHistogramsUE::DrawUE(Int_t debug){
index 50e1865fc37e194b0519c973cb83c4f18a1f78d2..9913eab40ebe2b2cbdc2d79481136fac70f693bc 100644 (file)
@@ -18,6 +18,7 @@ class TProfile;
 class TTree;
 class TVector3;
 class AliAnalysisTaskUE;
+class AliCFManager;
 
 class  AliHistogramsUE : public TObject
   {
@@ -31,6 +32,8 @@ class  AliHistogramsUE : public TObject
     TObjArray*     CreateCanvas(const Int_t ncanv);
     TObjArray*     GetHistosForPlotting(TString file, TString branches);
     void          CreateHistograms(TList* list,Int_t bins, Double_t min, Double_t max, Double_t etacut);
+    void          CreateHistogramsCorrections(TList* list,Int_t bins, Double_t min, Double_t max, Double_t etacut);
+    void           CreateCorrectionsContainer(AliCFManager* cfman,Int_t bins, Double_t min, Double_t max, Double_t etacut, Double_t jetetacut);
     void           DrawUE(Int_t debug);  //to draw final plots (normalized)
     void           FillHistogram(const char* name,Double_t fillX); //One dimensional
     void           FillHistogram(const char* name,Int_t fillX); //One dimensional
@@ -50,51 +53,61 @@ class  AliHistogramsUE : public TObject
     Double_t       fMinJetPtInHist;  // Minimum jet pT in histograms
     Double_t       fMaxJetPtInHist;  // Maximum jet pT in histograms
     Double_t       fTrackEtaCut;     // Track eta cut  
+    Double_t       fJet1EtaCut;      // Jet eta cut 
     TList*         fListOfHistos;    //  Output list of histograms
     
    
     // Histograms
-    TH1F*  fhNJets;                  //!
-    TH1F*  fhEleadingPt;             //!
+    TH1F*  fhNJets;                    //!
+    TH1F*  fhEleadingPt;               //!
     
-    TH1F*  fhMinRegPtDist;           //!
-    TH1F*  fhRegionMultMin;          //!
-    TH1F*  fhMinRegAvePt;            //!
-    TH1F*  fhMinRegSumPt;            //!
-    TH1F*  fhMinRegMaxPtPart;        //!
-    TH1F*  fhMinRegSumPtvsMult;      //!
+    TH1F*  fhMinRegPtDist;             //!
+    TH1F*  fhRegionMultMin;            //!
+    TH1F*  fhMinRegAvePt;              //!
+    TH1F*  fhMinRegSumPt;              //!
+    TH1F*  fhMinRegMaxPtPart;          //!
+    TH1F*  fhMinRegSumPtvsMult;        //!
     
-    TH2F*  fhdNdEtaPhiDist;          //!
-    TH2F*  fhFullRegPartPtDistVsEt;  //!
-    TH2F*  fhTransRegPartPtDistVsEt; //!
+    TH2F*  fhdNdEtaPhiDist;            //!
+    TH2F*  fhdNdEtaPhiDistMC;          //!
+    TH2F*  fhFullRegPartPtDistVsEt;    //!
+    TH2F*  fhFullRegPartPtDistVsEtMC;  //!
+    TH2F*  fhTransRegPartPtDistVsEt;   //!
+    TH2F*  fhTransRegPartPtDistVsEtMC; //!
     
-    TH1F*  fhRegionSumPtMaxVsEt;     //!
-    TH1I*  fhRegionMultMax;          //!
-    TH1F*  fhRegionMultMaxVsEt;      //!
-    TH1F*  fhRegionSumPtMinVsEt;     //!
-    TH1F*  fhRegionMultMinVsEt;      //!
-    TH1F*  fhRegionAveSumPtVsEt;     //!
-    TH1F*  fhRegionDiffSumPtVsEt;    //!
+    TH1F*  fhRegionSumPtMaxVsEt;       //!
+    TH1I*  fhRegionMultMax;            //!
+    TH1F*  fhRegionMultMaxVsEt;        //!
+    TH1F*  fhRegionSumPtMinVsEt;       //!
+    TH1F*  fhRegionMultMinVsEt;        //!
+    TH1F*  fhRegionAveSumPtVsEt;       //!
+    TH1F*  fhRegionDiffSumPtVsEt;      //!
     
-    TH1F*  fhRegionAvePartPtMaxVsEt; //!
-    TH1F*  fhRegionAvePartPtMinVsEt; //!
-    TH1F*  fhRegionMaxPartPtMaxVsEt; //!
+    TH1F*  fhRegionAvePartPtMaxVsEt;   //!
+    TH1F*  fhRegionAvePartPtMinVsEt;   //!
+    TH1F*  fhRegionMaxPartPtMaxVsEt;   //!
     
-    TH2F*  fhRegForwardMult;         //!
-    TH2F*  fhRegForwardSumPtvsMult;  //!
-    TH2F*  fhRegBackwardMult;        //!
-    TH2F*  fhRegBackwardSumPtvsMult; //!
-    TH2F*  fhRegForwardPartPtDistVsEt; //!
-    TH2F*  fhRegBackwardPartPtDistVsEt; //!
-    TH2F*  fhRegTransMult;         //!
-    TH2F*  fhRegTransSumPtVsMult;    //!
-    TH2F*  fhMinRegSumPtJetPtBin;    //!
-    TH2F*  fhMaxRegSumPtJetPtBin;    //!
-    TH1F*  fhVertexMult;             //!
+    TH2F*  fhRegForwardMult;              //!
+    TH2F*  fhRegForwardSumPtvsMult;       //!
+    TH2F*  fhRegBackwardMult;             //!
+    TH2F*  fhRegBackwardSumPtvsMult;      //!
+    TH2F*  fhRegForwardPartPtDistVsEt;    //!
+    TH2F*  fhRegForwardPartPtDistVsEtMC;  //!
+    TH2F*  fhRegBackwardPartPtDistVsEt;   //!
+    TH2F*  fhRegBackwardPartPtDistVsEtMC; //!
+    TH2F*  fhRegTransMult;                //!
+    TH2F*  fhRegTransSumPtVsMult;         //!
+    TH2F*  fhMinRegSumPtJetPtBin;         //!
+    TH2F*  fhMaxRegSumPtJetPtBin;         //!
+    TH1F*  fhVertexMult;                  //!
  
     TProfile*  fh1Xsec;                    //!         
     TH1F*  fh1Trials;               //!
 
+    //For corrections
+    TH2F   *fhDCAxy;               //! 
+    TH2F   *fhDCAxyPrimary;        //!
+       
     ClassDef( AliHistogramsUE, 0 ); // Class to manage histograms in UE analysis
   };
 
index eda33c308d20d615d395c6877277e45f42f1760b..438d2b73e7d517e4b8935d99f868ff89a534e75b 100644 (file)
@@ -7,6 +7,7 @@
 #pragma link C++ class AliAnalysisTaskUE+;
 #pragma link C++ class AliAnalyseUE+;
 #pragma link C++ class AliHistogramsUE+;
+#pragma link C++ class AliAnalysisTaskCorrectionsUE+;
 #pragma link C++ class AliAnalysisTaskJetServices+;
 #pragma link C++ class AliAnalysisTaskJetSpectrum+;
 #pragma link C++ class AliAnalysisTaskJetSpectrum2+;
index 88d14d9caa914aaaa9653bd7320be6dc16d47fcb..680b962701ca95561dbd6e5c8c43dae6e1407a62 100644 (file)
@@ -1,6 +1,6 @@
 #-*- Mode: Makefile -*-
 
-SRCS = JetTasks/AliAnalysisTaskUE.cxx JetTasks/AliHistogramsUE.cxx JetTasks/AliAnalyseUE.cxx JetTasks/AliAnalysisTaskJetSpectrum.cxx JetTasks/AliAnalysisTaskJetSpectrum2.cxx JetTasks/AliAnalysisHelperJetTasks.cxx JetTasks/AliAnalysisTaskJetServices.cxx JetTasks/AliAnalysisTaskPWG4PidDetEx.cxx JetTasks/AliJetSpectrumUnfolding.cxx JetTasks/AliAnalysisTaskJFSystematics.cxx JetTasks/AliAnalysisTaskJetCorrections.cxx JetTasks/AliAnalysisTaskThreeJets.cxx JetTasks/AliPWG4HighPtQATPConly.cxx JetTasks/AliPWG4HighPtQAMC.cxx JetTasks/AliPWG4HighPtSpectra.cxx JetTasks/AliPWG4CosmicCandidates.cxx JetTasks/AliAnalysisTaskJetChem.cxx 
+SRCS = JetTasks/AliAnalysisTaskUE.cxx JetTasks/AliHistogramsUE.cxx JetTasks/AliAnalyseUE.cxx  JetTasks/AliAnalysisTaskCorrectionsUE.cxx JetTasks/AliAnalysisTaskJetSpectrum.cxx JetTasks/AliAnalysisTaskJetSpectrum2.cxx JetTasks/AliAnalysisHelperJetTasks.cxx JetTasks/AliAnalysisTaskJetServices.cxx JetTasks/AliAnalysisTaskPWG4PidDetEx.cxx JetTasks/AliJetSpectrumUnfolding.cxx JetTasks/AliAnalysisTaskJFSystematics.cxx JetTasks/AliAnalysisTaskJetCorrections.cxx JetTasks/AliAnalysisTaskThreeJets.cxx JetTasks/AliPWG4HighPtQATPConly.cxx JetTasks/AliPWG4HighPtQAMC.cxx JetTasks/AliPWG4HighPtSpectra.cxx JetTasks/AliPWG4CosmicCandidates.cxx JetTasks/AliAnalysisTaskJetChem.cxx 
 
 HDRS:= $(SRCS:.cxx=.h) 
 
diff --git a/PWG4/macros/AddTaskCorrectionsUE.C b/PWG4/macros/AddTaskCorrectionsUE.C
new file mode 100644 (file)
index 0000000..6cb329f
--- /dev/null
@@ -0,0 +1,208 @@
+void ConfigTaskCorrectionsUE(AliAnalysisTaskCorrectionsUE * uecorr );          // common config, extend with different cases\r
+void SetTrackCuts(AliAnalysisTaskCorrectionsUE * uecorr, Char_t *ct);      //can be extended\r
+void SetAnaTopology(AliAnalysisTaskCorrectionsUE * uecorr, Char_t *at);    //can be extended                  \r
+void SetRegionType(AliAnalysisTaskCorrectionsUE * uecorr, Char_t *rt);     //can be extended        \r
+void SetSorting(AliAnalysisTaskCorrectionsUE * uecorr, Char_t *sort);\r
+\r
+AliAnalysisTaskCorrectionsUE *AddTaskCorrectionsUE(Char_t *jetBranch = "jets",Char_t *cuts = "ALICE", Char_t *anaTopology="LJ", Char_t *regionType="TRANSV", Char_t *sortBy="MSP", Bool_t proof=0)\r
+{\r
+\r
+   gSystem->SetIncludePath("-I. -I$ROOTSYS/include -I$ALICE_ROOT/include -I$ALICE_ROOT/lib/tgt_linux -I$ALICE_ROOT/ANALYSIS -I$ALICE_ROOT/JETAN  -I$ALICE_ROOT/JETAN/fastjet -I$ALICE_ROOT/PWG4 -I$ALICE_ROOT/PYTHIA6 -I$ALICE_ROOT/CORRFW");\r
+  \r
+  // Get the pointer to the existing analysis manager via the static access method.\r
+   //==============================================================================\r
+   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();\r
+   if (!mgr) {\r
+      ::Error("AddTaskCorrectionsUE", "No analysis manager to connect to.");\r
+      return NULL;\r
+   }  \r
+   \r
+   // Check the analysis type using the event handlers connected to the analysis manager.\r
+   //==============================================================================\r
+   if (!mgr->GetInputEventHandler()) {\r
+      ::Error("AddTaskCorrectionsUE", "This task requires an input event handler");\r
+      return NULL;\r
+   }\r
+\r
+   // Create the task and configure it.\r
+   //===========================================================================\r
+   \r
+   TString jb(jetBranch);\r
+   TString ct(cuts);\r
+   TString at(anaTopology);\r
+   TString rt(regionType);\r
+   TString sort(sortBy);\r
+   TString name(Form("%s_%s_%s_%s_%s",jb.Data(),ct.Data(),at.Data(),rt.Data(),sort.Data()));\r
+   \r
+   AliAnalysisTaskCorrectionsUE* uecorr = new  AliAnalysisTaskCorrectionsUE(Form("UECorrections_%s",name.Data()));\r
+   uecorr->SelectAODBranch(jb.Data());\r
+   ConfigTaskCorrectionsUE(uecorr);\r
+   SetTrackCuts(uecorr,cuts);\r
+   SetAnaTopology(uecorr,anaTopology);\r
+   SetRegionType(uecorr,regionType);\r
+   SetSorting(uecorr,sortBy);\r
+\r
+   if( jb.Contains("ICDF") ) { // Use internal "Charged Particle Jet CDF" instead of jets from AOD\r
+      uecorr->SetUseChPartJet( kTRUE );\r
+      uecorr->SetPtMinChPartJet(0.5);\r
+   }\r
+\r
+   //  ***** to be fixed *******\r
+   /*\r
+   if(jb.Length()>0){\r
+     ueana->ReadDeltaAOD(kTRUE);\r
+     ueana->SelectDeltaAODBranch(jb.Data());\r
+   }\r
+   */\r
+\r
+   mgr->AddTask(uecorr);\r
+   \r
+   // Create ONLY the output containers for the data produced by the task.\r
+   // Get and connect other common input/output containers via the manager as below\r
+   //==============================================================================\r
+   AliAnalysisDataContainer *coutput1_UE = 0;\r
+   AliAnalysisDataContainer *coutput2_UE = 0;\r
+\r
+   if (!proof){\r
+       if(jb.Length()==0)coutput1_UE = mgr->CreateContainer("histosCorrectionsUE", TList::Class(),AliAnalysisManager::kOutputContainer,Form("%s:PWG4_CorrectionsUE",AliAnalysisManager::GetCommonFileName()));\r
+       else coutput1_UE = mgr->CreateContainer(Form("histosCorrectionsUE_%s",name.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,Form("%s:PWG4_CorrectionsUE_%s",AliAnalysisManager::GetCommonFileName(),name.Data()));\r
+   \r
+       if(jb.Length()==0)coutput2_UE = mgr->CreateContainer("containersCorrectionsUE", AliCFContainer::Class(),AliAnalysisManager::kOutputContainer,Form("%s:PWG4_CorrectionsUE",AliAnalysisManager::GetCommonFileName()));\r
+       else coutput2_UE = mgr->CreateContainer(Form("containersCorrectionsUE_%s",name.Data()), AliCFContainer::Class(),AliAnalysisManager::kOutputContainer,Form("%s:PWG4_CorrectionsUE_%s",AliAnalysisManager::GetCommonFileName(),name.Data()));\r
+  } else {//simplify output structure in case of PROOF or it crashes while transferring files from master)\r
+       if(jb.Length()==0)coutput1_UE = mgr->CreateContainer("histosCorrectionsUE", TList::Class(),AliAnalysisManager::kOutputContainer,Form("%s",AliAnalysisManager::GetCommonFileName()));\r
+       else coutput1_UE = mgr->CreateContainer(Form("histosCorrectionsUE_%s",name.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,Form("%s",AliAnalysisManager::GetCommonFileName()));\r
+   \r
+       if(jb.Length()==0)coutput2_UE = mgr->CreateContainer("containersCorrectionsUE", AliCFContainer::Class(),AliAnalysisManager::kOutputContainer,Form("%s",AliAnalysisManager::GetCommonFileName()));\r
+       else coutput2_UE = mgr->CreateContainer(Form("containersCorrectionsUE_%s",name.Data()), AliCFContainer::Class(),AliAnalysisManager::kOutputContainer,Form("%s",AliAnalysisManager::GetCommonFileName()));\r
+\r
+\r
+\r
+  }\r
+\r
+   mgr->ConnectInput  (uecorr, 0, mgr->GetCommonInputContainer());\r
+   mgr->ConnectOutput (uecorr,     0, coutput1_UE );\r
+   mgr->ConnectOutput (uecorr,     1, coutput2_UE );\r
+   \r
+   return uecorr;\r
+}\r
+\r
+//------------------------------------------------------------------------\r
+void ConfigTaskCorrectionsUE(AliAnalysisTaskCorrectionsUE * uecorr){\r
+  // common config,\r
+  uecorr->SetDebugLevel(10); \r
+  uecorr->SetPtRangeInHist(100, 0., 100.);\r
+}\r
+\r
+//------------------------------------------------------------------------\r
+SetTrackCuts(AliAnalysisTaskCorrectionsUE * uecorr, Char_t *ct){\r
+  \r
+  uecorr->SetFilterBit(16); // Standard TPC+ITS cuts 2009\r
+\r
+  switch (ct) {\r
+       case "ALICE":\r
+       uecorr->SetTrackPtCut(0.1);\r
+       uecorr->SetTrackEtaCut(0.9);\r
+       break;\r
+  \r
+       case "CDF":\r
+       uecorr->SetTrackPtCut(0.5);\r
+       uecorr->SetTrackEtaCut(0.9); \r
+       break;\r
+\r
+       default:\r
+       Printf("\n >>>>>>> AddTaskCorrectionsUE Error Wrong Set of Track Cuts selected\n");\r
+       break;\r
+  }\r
+}\r
+\r
+//------------------------------------------------------------------------\r
+SetAnaTopology(AliAnalysisTaskCorrectionsUE * uecorr, Char_t *at){\r
+\r
+  switch (at) {\r
+       case "LJ":  // leading jet\r
+        uecorr->SetAnaTopology(1);\r
+        uecorr->SetJet1EtaCut(0.5);\r
+       break;\r
+\r
+       case "LJCC":  // leading jet with charged cluster\r
+        uecorr->SetAnaTopology(1);\r
+        uecorr->SetJet1EtaCut(0.9);  // CDF allow jet radius extend ouside |eta|<1\r
+       break;\r
+  \r
+       case "BB":  // back-to-back\r
+        uecorr->SetAnaTopology(2);\r
+        uecorr->SetJet1EtaCut(0.5);\r
+        uecorr->SetJet2DeltaPhiCut(2.616);\r
+       break;\r
+\r
+       case "BE":  // back-to-back exclusive\r
+        uecorr->SetAnaTopology(3);\r
+        uecorr->SetJet1EtaCut(0.5);\r
+        uecorr->SetJet2DeltaPhiCut(2.616);\r
+        uecorr->SetJet3PtCut(10.);\r
+       break;\r
+\r
+       case "MP_eta05":\r
+        uecorr->SetAnaTopology(4);\r
+        uecorr->SetJet1EtaCut(0.9);\r
+       break;\r
+\r
+       case "MP_eta09":  // max Pt charged particle\r
+         uecorr->SetAnaTopology(4);\r
+         uecorr->SetJet1EtaCut(0.9);\r
+       break;\r
+\r
+\r
+       default:\r
+       Printf("\n >>>>>>> AddTaskCorrectionsUE Error Wrong Analysis Topology selected\n");\r
+       break;\r
+  }\r
+\r
+}\r
+\r
+//------------------------------------------------------------------------\r
+SetRegionType(AliAnalysisTaskCorrectionsUE * uecorr, Char_t *rt){\r
+\r
+  switch (rt) {\r
+       case "TRANSV":  \r
+        uecorr->SetRegionType(1);        \r
+       break;\r
+  \r
+       case "CONE":\r
+        uecorr->SetRegionType(2);        \r
+        uecorr->SetConeRadius(0.4);   \r
+       break;\r
+\r
+       default:\r
+       Printf("\n >>>>>>> AddTaskCorrectionsUE Error Wrong Region Type selected\n");\r
+       break;\r
+  }\r
+}  \r
+\r
+//------------------------------------------------------------------------\r
+SetSorting(AliAnalysisTaskCorrectionsUE * uecorr, Char_t *sort){\r
+   \r
+   switch (sort){\r
+      // Minimum zone is selected per quantity type\r
+      case "MQA":\r
+       uecorr->SetPtSumOrdering(1);             \r
+      break;\r
+      \r
+      // Minimum Zone is selected at the region having lowest pt summation of all tracks \r
+      case "MSP":\r
+       uecorr->SetPtSumOrdering(2);\r
+      break;\r
+      \r
+      // Minimum Zone is selected at the region having lowest average pt per track\r
+      case "MAP":\r
+       uecorr->SetPtSumOrdering(3);\r
+      break;\r
+      \r
+      default:\r
+       Printf("\n >>>>>>> AddTaskCorrectionsUE Error Wrong Sorting selected\n");     \r
+       Printf("\n >>>>>>> AddTaskCorrectionsUE Sort by Set to MSP \n");\r
+       uecorr->SetPtSumOrdering(2);\r
+      break;\r
+   }\r
+}\r