]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
New analysis for electron identification
authorgconesab <gconesab@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 3 Jul 2009 06:38:17 +0000 (06:38 +0000)
committergconesab <gconesab@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 3 Jul 2009 06:38:17 +0000 (06:38 +0000)
16 files changed:
PWG4/CMake_libPWG4PartCorrDep.txt
PWG4/PWG4PartCorrDepLinkDef.h
PWG4/PartCorrBase/AliMCAnalysisUtils.cxx
PWG4/PartCorrBase/AliMCAnalysisUtils.h
PWG4/PartCorrDep/AliAnaElectron.cxx [new file with mode: 0755]
PWG4/PartCorrDep/AliAnaElectron.h [new file with mode: 0755]
PWG4/libPWG4PartCorrDep.pkg
PWG4/macros/electrons/ConfigAnalysisElectron.C [new file with mode: 0644]
PWG4/macros/electrons/GetProofLogs.C [new file with mode: 0644]
PWG4/macros/electrons/README [new file with mode: 0644]
PWG4/macros/electrons/anaElectron.C [new file with mode: 0644]
PWG4/macros/electrons/anaElectron.jdl [new file with mode: 0644]
PWG4/macros/electrons/anaElectron.sh [new file with mode: 0644]
PWG4/macros/electrons/mergeElectron.jdl [new file with mode: 0644]
PWG4/macros/electrons/mylauncher.C [new file with mode: 0644]
PWG4/macros/electrons/parmaker [new file with mode: 0755]

index 88722b3b84cb1007767eb483f2e34963ab00e0bf..68eea3a9618099176c53d1e546914b774c4de6e8 100755 (executable)
@@ -7,7 +7,8 @@ set(SRCS
        PartCorrDep/AliAnaParticleIsolation.cxx PartCorrDep/AliAnaParticlePartonCorrelation.cxx 
        PartCorrDep/AliAnaParticleHadronCorrelation.cxx PartCorrDep/AliAnaParticleJetFinderCorrelation.cxx
        PartCorrDep/AliAnaParticleJetLeadingConeCorrelation.cxx PartCorrDep/AliAnaChargedParticles.cxx
        PartCorrDep/AliAnaParticleIsolation.cxx PartCorrDep/AliAnaParticlePartonCorrelation.cxx 
        PartCorrDep/AliAnaParticleHadronCorrelation.cxx PartCorrDep/AliAnaParticleJetFinderCorrelation.cxx
        PartCorrDep/AliAnaParticleJetLeadingConeCorrelation.cxx PartCorrDep/AliAnaChargedParticles.cxx
-       PartCorrDep/AliAnaCalorimeterQA.cxx PartCorrDep/AliAnaNeutralMeson.cxx      
+       PartCorrDep/AliAnaCalorimeterQA.cxx PartCorrDep/AliAnaNeutralMeson.cxx  
+       PartCorrDep/AliAnaElectron.cxx    
 )
 
 # fill list of header files from list of source files
 )
 
 # fill list of header files from list of source files
index 27d79c49ac95a930c6933539bc567417e53d5399..9c2737dfdaae35803d7438ef84ff430c61ed6004 100755 (executable)
@@ -18,5 +18,6 @@
 #pragma link C++ class AliAnaParticleJetLeadingConeCorrelation+;
 #pragma link C++ class AliAnaCalorimeterQA+;
 #pragma link C++ class AliAnaNeutralMeson+;
 #pragma link C++ class AliAnaParticleJetLeadingConeCorrelation+;
 #pragma link C++ class AliAnaCalorimeterQA+;
 #pragma link C++ class AliAnaNeutralMeson+;
+#pragma link C++ class AliAnaElectron+;
 
 #endif
 
 #endif
index c02dbfd9bd95fbe13d80194b6b569187a08a46bf..b1a567e2a9e07c036765c23324965ed3c2a3f020 100755 (executable)
-/**************************************************************************
- * 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: AliMCAnalysisUtils.cxx 21839 2007-10-29 13:49:42Z gustavo $ */
-
-//_________________________________________________________________________
-// Class for analysis utils for MC data
-// stored in stack or event header.
-// Contains:
-//  - method to check the origin of a given track/cluster
-//  - method to obtain the generated jets
-//                
-//*-- Author: Gustavo Conesa (LNF-INFN) 
-//////////////////////////////////////////////////////////////////////////////
-  
-
-// --- ROOT system ---
-#include <TMath.h>
-#include <TList.h>
-
-//---- ANALYSIS system ----
-#include "AliMCAnalysisUtils.h"
-#include "AliStack.h"
-#include "TParticle.h"
-#include "AliGenPythiaEventHeader.h"
-
-  ClassImp(AliMCAnalysisUtils)
-
- //________________________________________________
-  AliMCAnalysisUtils::AliMCAnalysisUtils() : 
-    TObject(), fCurrentEvent(-1), fDebug(-1), 
-    fJetsList(new TList), fMCGenerator("PYTHIA")
-{
-  //Ctor
-}
-
-//____________________________________________________________________________
-AliMCAnalysisUtils::AliMCAnalysisUtils(const AliMCAnalysisUtils & mcutils) :   
-  TObject(mcutils), fCurrentEvent(mcutils.fCurrentEvent), fDebug(mcutils.fDebug),
-  fJetsList(mcutils.fJetsList), fMCGenerator(mcutils.fMCGenerator)
-{
-  // cpy ctor
-  
-}
-
-//_________________________________________________________________________
-AliMCAnalysisUtils & AliMCAnalysisUtils::operator = (const AliMCAnalysisUtils & mcutils)
-{
-  // assignment operator
-  
-  if(&mcutils == this) return *this;
-  fCurrentEvent = mcutils.fCurrentEvent ;
-  fDebug        = mcutils.fDebug;
-  fJetsList     = mcutils.fJetsList;
-  fMCGenerator  = mcutils.fMCGenerator;
-  
-  return *this; 
-}
-
-//____________________________________________________________________________
-AliMCAnalysisUtils::~AliMCAnalysisUtils() 
-{
-  // Remove all pointers.
-  
-  if (fJetsList) {
-    fJetsList->Clear();
-    delete fJetsList ;
-  }     
-}
-
-//_________________________________________________________________________
-Int_t AliMCAnalysisUtils::CheckOrigin(const Int_t label, AliStack * stack) const {
-  //Play with the MC stack if available
-  //Check origin of the candidates, good for PYTHIA
-  
-  if(!stack) {
-    printf("AliMCAnalysisUtils::CheckOrigin() - Stack is not available, check analysis settings in configuration file, STOP!!\n");
-    abort();
-  }
-  //  printf("label %d, ntrack %d, nprim %d\n",label, stack->GetNtrack(), stack->GetNprimary());
-  //   for(Int_t i = 0; i< stack->GetNprimary(); i++){
-  //      TParticle *particle =   stack->Particle(i);
-  //                   //particle->Print();
-  //   }
-  if(label >= 0 && label <  stack->GetNtrack()){
-    //Mother
-    TParticle * mom = stack->Particle(label);
-    Int_t mPdg = TMath::Abs(mom->GetPdgCode());
-    Int_t mStatus =  mom->GetStatusCode() ;
-    Int_t iParent =  mom->GetFirstMother() ;
-    if(fDebug > 0 && label < 8 ) printf("AliMCAnalysisUtils::CheckOrigin: Mother is parton %d\n",iParent);
-    
-    //GrandParent
-    TParticle * parent = new TParticle ;
-    Int_t pPdg = -1;
-    Int_t pStatus =-1;
-    if(iParent > 0){
-      parent = stack->Particle(iParent);
-      pPdg = TMath::Abs(parent->GetPdgCode());
-      pStatus = parent->GetStatusCode();  
-    }
-    else if(fDebug > 0 ) printf("AliMCAnalysisUtils::CheckOrigin: Parent with label %d\n",iParent);
-    
-    //return tag
-    if(mPdg == 22){
-      if(mStatus == 1){
-       if(fMCGenerator == "PYTHIA"){
-         if(iParent < 8 && iParent > 5) {//outgoing partons
-           if(pPdg == 22) return kMCPrompt;
-           else  return kMCFragmentation;
-         }//Outgoing partons
-         else if(pStatus == 11){//Decay
-           if(pPdg == 111) return kMCPi0Decay ;
-           else if (pPdg == 221)  return kMCEtaDecay ;
-           else  return kMCOtherDecay ;
-         }//Decay
-         else return kMCISR; //Initial state radiation
-       }//PYTHIA
-
-       else if(fMCGenerator == "HERWIG"){        
-         if(pStatus < 197){//Not decay
-           while(1){
-             if(parent->GetFirstMother()<=5) break;
-             iParent = parent->GetFirstMother();
-             parent=stack->Particle(iParent);
-             pStatus= parent->GetStatusCode();
-             pPdg = parent->GetPdgCode();
-           }//Look for the parton
-           
-           if(iParent < 8 && iParent > 5) {
-             if(pPdg == 22) return kMCPrompt;
-             else  return kMCFragmentation;
-           }
-           return kMCISR;//Initial state radiation
-         }//Not decay
-         else{//Decay
-           if(pPdg == 111) return kMCPi0Decay ;
-           else if (pPdg == 221)  return kMCEtaDecay ;
-           else  return kMCOtherDecay ;
-         }//Decay
-       }//HERWIG
-       else return  kMCUnknown;
-      }//Status 1 : Pythia generated
-      else if(mStatus == 0){
-       if(pPdg ==22 || pPdg ==11|| pPdg == 2112 ||  pPdg == 211 ||  
-          pPdg == 321 ||  pPdg == 2212  ||  pPdg == 130  ||  pPdg == 13 ) 
-         return kMCConversion ;
-       if(pPdg == 111) return kMCPi0Decay ;
-       else if (pPdg == 221)  return kMCEtaDecay ;
-       else  return kMCOtherDecay ;
-      }//status 0 : geant generated
-    }//Mother Photon
-    else if(mPdg == 111)  return kMCPi0 ;
-    else if(mPdg == 221)  return kMCEta ;
-    else if(mPdg ==11){
-//       if(pPdg !=22 &&mStatus == 0) {
-//     printf("Origin electron, pT %f, status %d, parent %s, pstatus %d, vx %f, vy %f, vz %f\n",
-//            mom->Pt(),mStatus, parent->GetName(),pStatus,mom->Vx(),mom->Vy(), mom->Vz());
-
-//       }
-
-      if(mStatus == 0) {
-       if(pPdg ==22) return kMCConversion ;
-       else if (pStatus == 0) return kMCConversion;
-       else return kMCElectron ;
-      }
-      else return kMCElectron ;
-    }
-    else return kMCUnknown;
-  }//Good label value
-  else{
-    if(label < 0 ) printf("AliMCAnalysisUtils::CheckOrigin: *** bad label or no stack ***:  label %d \n", label);
-    if(label >=  stack->GetNtrack()) printf("AliMCAnalysisUtils::CheckOrigin: *** large label ***:  label %d, n tracks %d \n", label, stack->GetNtrack());
-    return kMCUnknown;
-  }//Bad label
-       
-  return kMCUnknown;
-  
-}
-
-//_________________________________________________________________________
-TList * AliMCAnalysisUtils::GetJets(Int_t iEvent, AliStack * stack, AliGenEventHeader * geh) {
- //Return list of jets (TParticles) and index of most likely parton that originated it.
-       
-  if(fCurrentEvent!=iEvent){
-    fCurrentEvent = iEvent;
-    fJetsList = new TList;
-    Int_t nTriggerJets = 0;
-    Float_t tmpjet[]={0,0,0,0};
-               
-    //printf("Event %d %d\n",fCurrentEvent,iEvent);
-    //Get outgoing partons
-    if(stack->GetNtrack() < 8) return fJetsList;
-    TParticle * parton1 =  stack->Particle(6);
-    TParticle * parton2 =  stack->Particle(7);
-    if(fDebug > 2){
-      printf("AliMCAnalysisUtils::GetJets() - parton 6 : %s, pt %2.2f,E %2.2f, phi %2.2f, eta %2.2f \n",
-            parton1->GetName(),parton1->Pt(),parton1->Energy(),parton1->Phi()*TMath::RadToDeg(),parton1->Eta());
-      printf("AliMCAnalysisUtils::GetJets() - parton 7 : %s, pt %2.2f,E %2.2f, phi %2.2f, eta %2.2f \n",
-            parton2->GetName(),parton2->Pt(),parton2->Energy(),parton2->Phi()*TMath::RadToDeg(),parton2->Eta());
-               }
-//             //Trace the jet from the mother parton
-//             Float_t pt  = 0;
-//             Float_t pt1 = 0;
-//             Float_t pt2 = 0;
-//             Float_t e   = 0;
-//             Float_t e1  = 0;
-//             Float_t e2  = 0;
-//             TParticle * tmptmp = new TParticle;
-//             for(Int_t i = 0; i< stack->GetNprimary(); i++){
-//                     tmptmp = stack->Particle(i);
-               
-//                     if(tmptmp->GetStatusCode() == 1){
-//                             pt = tmptmp->Pt();
-//                             e =  tmptmp->Energy();                  
-//                             Int_t imom = tmptmp->GetFirstMother();
-//                             Int_t imom1 = 0;
-//                             //printf("1st imom %d\n",imom);
-//                             while(imom > 5){
-//                                     imom1=imom;
-//                                     tmptmp = stack->Particle(imom);
-//                                     imom = tmptmp->GetFirstMother();
-//                                     //printf("imom %d       \n",imom);
-//                             }
-//                             //printf("Last imom %d %d\n",imom1, imom);
-//                             if(imom1 == 6) {
-//                                     pt1+=pt;
-//                                     e1+=e;                          
-//                             }
-//                             else if (imom1 == 7){
-//                                     pt2+=pt;
-//                                     e2+=e;                                  }
-//                     }// status 1
-                               
-//             }// for
-               
-//             printf("JET 1, pt %2.2f, e %2.2f; JET 2, pt %2.2f, e %2.2f \n",pt1,e1,pt2,e2);
-               
-               //Get the jet, different way for different generator
-               //PYTHIA
-    if(fMCGenerator == "PYTHIA"){
-      TParticle * jet =  new TParticle;
-      AliGenPythiaEventHeader* pygeh= (AliGenPythiaEventHeader*) geh;
-      nTriggerJets =  pygeh->NTriggerJets();
-      if(fDebug > 1)
-         printf("AliMCAnalysisUtils::GetJets() - PythiaEventHeader: Njets: %d\n",nTriggerJets);
-               
-      Int_t iparton = -1;
-      for(Int_t i = 0; i< nTriggerJets; i++){
-       iparton=-1;
-       pygeh->TriggerJet(i, tmpjet);
-       jet = new TParticle(94, 21, -1, -1, -1, -1, tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3], 0,0,0,0);
-       //Assign an outgoing parton as mother
-       Float_t phidiff1 = TMath::Abs(jet->Phi()-parton1->Phi());               
-       Float_t phidiff2 = TMath::Abs(jet->Phi()-parton2->Phi());
-       if(phidiff1 > phidiff2) jet->SetFirstMother(7);
-       else  jet->SetFirstMother(6);
-       //jet->Print();
-       if(fDebug > 1)
-         printf("AliMCAnalysisUtils::GetJets() - PYTHIA Jet %d: mother %d, pt %2.2f,E %2.2f, phi %2.2f, eta %2.2f \n",
-                i, jet->GetFirstMother(),jet->Pt(),jet->Energy(),jet->Phi()*TMath::RadToDeg(),jet->Eta());
-       fJetsList->Add(jet);                    
-      }
-    }//Pythia triggered jets
-    //HERWIG
-    else if (fMCGenerator=="HERWIG"){
-      Int_t pdg = -1;          
-      //Check parton 1
-      TParticle * tmp = parton1;
-      if(parton1->GetPdgCode()!=22){
-       while(pdg != 94){
-         if(tmp->GetFirstDaughter()==-1) return fJetsList;
-         tmp = stack->Particle(tmp->GetFirstDaughter());
-         pdg = tmp->GetPdgCode();
-       }//while
-       
-       //Add found jet to list
-       TParticle *jet1 = new TParticle(*tmp);
-       jet1->SetFirstMother(6);
-       fJetsList->Add(jet1);
-       //printf("jet 1:  first daughter %d, last daughter %d\n", tmp->GetFirstDaughter(), tmp->GetLastDaughter());
-       //tmp = stack->Particle(tmp->GetFirstDaughter());
-       //tmp->Print();
-       //jet1->Print();
-       if(fDebug > 1)                  
-         printf("AliMCAnalysisUtils::GetJets() - HERWIG Jet 1: mother %d, status %d, pt %2.2f,E %2.2f, phi %2.2f, eta %2.2f \n",
-                jet1->GetFirstMother(),jet1->GetStatusCode(),jet1->Pt(),jet1->Energy(),jet1->Phi()*TMath::RadToDeg(),jet1->Eta());
-      }//not photon
-      
-      //Check parton 2
-      pdg = -1;
-      tmp = parton2;
-      Int_t i = -1;
-      if(parton2->GetPdgCode()!=22){
-       while(pdg != 94){
-         if(tmp->GetFirstDaughter()==-1) return fJetsList;
-         i = tmp->GetFirstDaughter();
-         tmp = stack->Particle(tmp->GetFirstDaughter());
-         pdg = tmp->GetPdgCode();
-       }//while
-       //Add found jet to list
-       TParticle *jet2 = new TParticle(*tmp);
-       jet2->SetFirstMother(7);
-       fJetsList->Add(jet2);
-       //jet2->Print();
-       if(fDebug > 1)
-         printf("AliMCAnalysisUtils::GetJets() - HERWIG Jet 2: mother %d, status %d, pt %2.2f,E %2.2f, phi %2.2f, eta %2.2f \n",
-                jet2->GetFirstMother(),jet2->GetStatusCode(),jet2->Pt(),jet2->Energy(),jet2->Phi()*TMath::RadToDeg(),jet2->Eta());
-       //Int_t first =  tmp->GetFirstDaughter();
-       //Int_t last  =  tmp->GetLastDaughter();
-       //printf("jet 2:  first daughter %d, last daughter %d, pdg %d\n",first, last, tmp->GetPdgCode());
-                               //      for(Int_t d = first ; d < last+1; d++){
-//                                             tmp = stack->Particle(d);
-//                                             if(i == tmp->GetFirstMother())
-//                                                     printf("Daughter n %d, Mother %d, name %s, status %d, pT %2.2f,E %2.2f, phi %2.2f, eta %2.2f \n",
-//                                                     d,tmp->GetFirstMother(), tmp->GetName(), tmp->GetStatusCode(),tmp->Pt(),tmp->Energy(),tmp->Phi()*TMath::RadToDeg(),tmp->Eta());                    
-//                        }
-                                                  //tmp->Print();
-      }//not photon
-    }//Herwig generated jets
-  }
-  
-  return fJetsList;
-}
-
-//________________________________________________________________
-void AliMCAnalysisUtils::Print(const Option_t * opt) const
-{
-  //Print some relevant parameters set for the analysis
- if(! opt)
-   return;
- printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
- printf("Debug level    = %d\n",fDebug);
- printf("MC Generator   = %s\n",fMCGenerator.Data());
- printf(" \n");
-} 
-
-
+/**************************************************************************\r
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
+ *                                                                        *\r
+ * Author: The ALICE Off-line Project.                                    *\r
+ * Contributors are mentioned in the code where appropriate.              *\r
+ *                                                                        *\r
+ * Permission to use, copy, modify and distribute this software and its   *\r
+ * documentation strictly for non-commercial purposes is hereby granted   *\r
+ * without fee, provided that the above copyright notice appears in all   *\r
+ * copies and that both the copyright notice and this permission notice   *\r
+ * appear in the supporting documentation. The authors make no claims     *\r
+ * about the suitability of this software for any purpose. It is          *\r
+ * provided "as is" without express or implied warranty.                  *\r
+ **************************************************************************/\r
+/* $Id: AliMCAnalysisUtils.cxx 21839 2007-10-29 13:49:42Z gustavo $ */\r
+\r
+//_________________________________________________________________________\r
+// Class for analysis utils for MC data\r
+// stored in stack or event header.\r
+// Contains:\r
+//  - method to check the origin of a given track/cluster\r
+//  - method to obtain the generated jets\r
+//                \r
+//*-- Author: Gustavo Conesa (LNF-INFN) \r
+//////////////////////////////////////////////////////////////////////////////\r
+  \r
+\r
+// --- ROOT system ---\r
+#include <TMath.h>\r
+#include <TList.h>\r
+\r
+//---- ANALYSIS system ----\r
+#include "AliMCAnalysisUtils.h"\r
+#include "AliStack.h"\r
+#include "TParticle.h"\r
+#include "AliGenPythiaEventHeader.h"\r
+\r
+  ClassImp(AliMCAnalysisUtils)\r
+\r
+ //________________________________________________\r
+  AliMCAnalysisUtils::AliMCAnalysisUtils() : \r
+    TObject(), fCurrentEvent(-1), fDebug(-1), \r
+    fJetsList(new TList), fMCGenerator("PYTHIA")\r
+{\r
+  //Ctor\r
+}\r
+\r
+//____________________________________________________________________________\r
+AliMCAnalysisUtils::AliMCAnalysisUtils(const AliMCAnalysisUtils & mcutils) :   \r
+  TObject(mcutils), fCurrentEvent(mcutils.fCurrentEvent), fDebug(mcutils.fDebug),\r
+  fJetsList(mcutils.fJetsList), fMCGenerator(mcutils.fMCGenerator)\r
+{\r
+  // cpy ctor\r
+  \r
+}\r
+\r
+//_________________________________________________________________________\r
+AliMCAnalysisUtils & AliMCAnalysisUtils::operator = (const AliMCAnalysisUtils & mcutils)\r
+{\r
+  // assignment operator\r
+  \r
+  if(&mcutils == this) return *this;\r
+  fCurrentEvent = mcutils.fCurrentEvent ;\r
+  fDebug        = mcutils.fDebug;\r
+  fJetsList     = mcutils.fJetsList;\r
+  fMCGenerator  = mcutils.fMCGenerator;\r
+  \r
+  return *this; \r
+}\r
+\r
+//____________________________________________________________________________\r
+AliMCAnalysisUtils::~AliMCAnalysisUtils() \r
+{\r
+  // Remove all pointers.\r
+  \r
+  if (fJetsList) {\r
+    fJetsList->Clear();\r
+    delete fJetsList ;\r
+  }     \r
+}\r
+\r
+//_________________________________________________________________________\r
+Int_t AliMCAnalysisUtils::CheckOrigin(const Int_t label, AliStack * stack) const {\r
+  //Play with the MC stack if available\r
+  //Check origin of the candidates, good for PYTHIA\r
+  \r
+  if(!stack) {\r
+    printf("AliMCAnalysisUtils::CheckOrigin() - Stack is not available, check analysis settings in configuration file, STOP!!\n");\r
+    abort();\r
+  }\r
+  //  printf("label %d, ntrack %d, nprim %d\n",label, stack->GetNtrack(), stack->GetNprimary());\r
+  //   for(Int_t i = 0; i< stack->GetNprimary(); i++){\r
+  //      TParticle *particle =   stack->Particle(i);\r
+  //                   //particle->Print();\r
+  //   }\r
+  if(label >= 0 && label <  stack->GetNtrack()){\r
+    //Mother\r
+    TParticle * mom = stack->Particle(label);\r
+    Int_t mPdg = TMath::Abs(mom->GetPdgCode());\r
+    Int_t mStatus =  mom->GetStatusCode() ;\r
+    Int_t iParent =  mom->GetFirstMother() ;\r
+    if(fDebug > 0 && label < 8 ) printf("AliMCAnalysisUtils::CheckOrigin: Mother is parton %d\n",iParent);\r
+    \r
+    //GrandParent\r
+    TParticle * parent = new TParticle ;\r
+    Int_t pPdg = -1;\r
+    Int_t pStatus =-1;\r
+    if(iParent > 0){\r
+      parent = stack->Particle(iParent);\r
+      pPdg = TMath::Abs(parent->GetPdgCode());\r
+      pStatus = parent->GetStatusCode();  \r
+    }\r
+    else if(fDebug > 0 ) printf("AliMCAnalysisUtils::CheckOrigin: Parent with label %d\n",iParent);\r
+    \r
+    //return tag\r
+    if(mPdg == 22){ //photon\r
+      if(mStatus == 1){ //undecayed particle\r
+       if(fMCGenerator == "PYTHIA"){\r
+         if(iParent < 8 && iParent > 5) {//outgoing partons\r
+           if(pPdg == 22) return kMCPrompt;\r
+           else  return kMCFragmentation;\r
+         }//Outgoing partons\r
+         else if(pStatus == 11){//Decay\r
+           if(pPdg == 111) return kMCPi0Decay ;\r
+           else if (pPdg == 221)  return kMCEtaDecay ;\r
+           else  return kMCOtherDecay ;\r
+         }//Decay\r
+         else return kMCISR; //Initial state radiation\r
+       }//PYTHIA\r
+\r
+       else if(fMCGenerator == "HERWIG"){        \r
+         if(pStatus < 197){//Not decay\r
+           while(1){\r
+             if(parent->GetFirstMother()<=5) break;\r
+             iParent = parent->GetFirstMother();\r
+             parent=stack->Particle(iParent);\r
+             pStatus= parent->GetStatusCode();\r
+             pPdg = parent->GetPdgCode();\r
+           }//Look for the parton\r
+           \r
+           if(iParent < 8 && iParent > 5) {\r
+             if(pPdg == 22) return kMCPrompt;\r
+             else  return kMCFragmentation;\r
+           }\r
+           return kMCISR;//Initial state radiation\r
+         }//Not decay\r
+         else{//Decay\r
+           if(pPdg == 111) return kMCPi0Decay ;\r
+           else if (pPdg == 221)  return kMCEtaDecay ;\r
+           else  return kMCOtherDecay ;\r
+         }//Decay\r
+       }//HERWIG\r
+       else return  kMCUnknown;\r
+      }//Status 1 : Pythia generated\r
+      else if(mStatus == 0){\r
+       if(pPdg ==22 || pPdg ==11|| pPdg == 2112 ||  pPdg == 211 ||  \r
+          pPdg == 321 ||  pPdg == 2212  ||  pPdg == 130  ||  pPdg == 13 ) \r
+         return kMCConversion ;\r
+       if(pPdg == 111) return kMCPi0Decay ;\r
+       else if (pPdg == 221)  return kMCEtaDecay ;\r
+       else  return kMCOtherDecay ;\r
+      }//status 0 : geant generated\r
+    }//Mother Photon\r
+    else if(mPdg == 111)  return kMCPi0 ;\r
+    else if(mPdg == 221)  return kMCEta ;\r
+\r
+    //cluster's mother is an electron.  Where did that electron come from?\r
+    else if(mPdg == 11){ //electron\r
+\r
+      if(fDebug > 0) printf("AliMCAnalysisUtils::CheckOrigin: Checking ancestors of electrons");\r
+\r
+      //check first for B and C ancestry, then other possibilities.\r
+      //An electron from a photon parent could have other particles in\r
+      //its history and we would want to know that, right?\r
+\r
+      if(mStatus == 1) { //electron from event generator\r
+       if      (pPdg == -1) return kMCElectron; //no parent\r
+       else if (pPdg == 23) return kMCZDecay;   //parent is Z-boson\r
+       else if (pPdg == 24) return kMCWDecay;   //parent is W-boson\r
+       else { //check the electron's ancestors for B/C contribution\r
+         Bool_t BAncestor = kFALSE;\r
+         Bool_t CAncestor = kFALSE;\r
+         TParticle * ancestors = stack->Particle(label);\r
+         Int_t aPdg = TMath::Abs(ancestors->GetPdgCode());\r
+         //Int_t aStatus = ancestors->GetStatusCode();\r
+         Int_t iAncestors = ancestors->GetFirstMother();\r
+         if(fDebug > 0) printf("AliMCAnalysisUtils::CheckOrigin: Scaning the decay chain for bottom/charm generated electron");\r
+         while(ancestors->IsPrimary()){//searching for ancestors \r
+           if((499 < aPdg && aPdg < 600)||(4999 < aPdg && aPdg < 6000)) BAncestor = kTRUE;\r
+           if((399 < aPdg && aPdg < 500)||(3999 < aPdg && aPdg < 5000)) CAncestor = kTRUE;\r
+           if(BAncestor && CAncestor) break;\r
+           iAncestors = ancestors->GetFirstMother();\r
+           ancestors = stack->Particle(iAncestors);\r
+           aPdg = ancestors->GetPdgCode();\r
+         }//searching for ancestors\r
+         if(BAncestor && CAncestor) return kMCEFromCFromB;//Decay chain has both B and C\r
+         else if(BAncestor && !CAncestor) return kMCEFromB;//Decay chain has only B\r
+         else if(!BAncestor && CAncestor) return kMCEFromC;//Decay chain has only C \r
+       }\r
+       //if it is not from W,Z or B/C ancestor, where is it from?\r
+       if     (pPdg == 111) return kMCPi0Decay;//Pi0 Dalitz decay\r
+       else if(pPdg == 221) return kMCEtaDecay;//Eta Dalitz decay\r
+       else                 return kMCOtherDecay;\r
+\r
+      } else if (mStatus == 0) { //electron from GEANT\r
+\r
+       //Rewind ancestry and check for electron with status == 1\r
+       //if we find one, we'll assume that this object is from an\r
+       //electron but that it may have gone through some showering in\r
+       //material before the detector\r
+\r
+       //Not a double-counting problem because we are only accessing\r
+       //these histories for MC labels connected to a reco object.\r
+       //If you wanted to use this to sort through the kine stack\r
+       //directly, might it be a problem?\r
+       Bool_t EleFromEvGen = kFALSE;\r
+       Bool_t BAncestor = kFALSE;\r
+        Bool_t CAncestor = kFALSE;\r
+\r
+       TParticle * ancestors = stack->Particle(label);\r
+        Int_t aPdg = TMath::Abs(ancestors->GetPdgCode());\r
+        Int_t aStatus = ancestors->GetStatusCode();\r
+        Int_t iAncestors = ancestors->GetFirstMother();\r
+        if(fDebug > 0) printf("AliMCAnalysisUtils::CheckOrigin: Scaning the decay chain for bottom/charm electrons");\r
+       while(ancestors->IsPrimary()){//searching for ancestors\r
+         if(aStatus == 1 && aPdg == 11) EleFromEvGen = kTRUE;\r
+         if(EleFromEvGen && aPdg == 23) return kMCZDecay;\r
+         if(EleFromEvGen && aPdg == 24) return kMCWDecay;\r
+         if(EleFromEvGen && ((499 < aPdg && aPdg < 600)||(4999 < aPdg && aPdg < 6000))) BAncestor = kTRUE;\r
+         if(EleFromEvGen && ((399 < aPdg && aPdg < 500)||(3999 < aPdg && aPdg < 5000))) CAncestor = kTRUE;\r
+         if(BAncestor && CAncestor) break;\r
+         iAncestors = ancestors->GetFirstMother();\r
+          ancestors = stack->Particle(iAncestors);\r
+          aPdg = ancestors->GetPdgCode();\r
+        }//searching for ancestors\r
+       if(BAncestor && CAncestor) return kMCEFromCFromB;//Decay chain has both B and C\r
+       else if(BAncestor && !CAncestor) return kMCEFromB;//Decay chain has only B\r
+       else if(!BAncestor && CAncestor) return kMCEFromC;//Decay chain has only C\r
+       if(pPdg ==22 || pPdg ==11|| pPdg == 2112 ||  pPdg == 211 ||  \r
+          pPdg == 321 ||  pPdg == 2212  ||  pPdg == 130  ||  pPdg == 13 ) \r
+         return kMCConversion ;\r
+       if(pPdg == 111) return kMCPi0Decay ;\r
+       else if (pPdg == 221)  return kMCEtaDecay ;\r
+       else  return kMCOtherDecay ;\r
+      } //GEANT check\r
+    }//electron check\r
+    else return kMCUnknown;\r
+  }//Good label value\r
+  else{\r
+    if(label < 0 ) printf("AliMCAnalysisUtils::CheckOrigin: *** bad label or no stack ***:  label %d \n", label);\r
+    if(label >=  stack->GetNtrack()) printf("AliMCAnalysisUtils::CheckOrigin: *** large label ***:  label %d, n tracks %d \n", label, stack->GetNtrack());\r
+    return kMCUnknown;\r
+  }//Bad label\r
+       \r
+  return kMCUnknown;\r
+  \r
+}\r
+\r
+//_________________________________________________________________________\r
+TList * AliMCAnalysisUtils::GetJets(Int_t iEvent, AliStack * stack, AliGenEventHeader * geh) {\r
+ //Return list of jets (TParticles) and index of most likely parton that originated it.\r
+       \r
+  if(fCurrentEvent!=iEvent){\r
+    fCurrentEvent = iEvent;\r
+    fJetsList = new TList;\r
+    Int_t nTriggerJets = 0;\r
+    Float_t tmpjet[]={0,0,0,0};\r
+               \r
+    //printf("Event %d %d\n",fCurrentEvent,iEvent);\r
+    //Get outgoing partons\r
+    if(stack->GetNtrack() < 8) return fJetsList;\r
+    TParticle * parton1 =  stack->Particle(6);\r
+    TParticle * parton2 =  stack->Particle(7);\r
+    if(fDebug > 2){\r
+      printf("AliMCAnalysisUtils::GetJets() - parton 6 : %s, pt %2.2f,E %2.2f, phi %2.2f, eta %2.2f \n",\r
+            parton1->GetName(),parton1->Pt(),parton1->Energy(),parton1->Phi()*TMath::RadToDeg(),parton1->Eta());\r
+      printf("AliMCAnalysisUtils::GetJets() - parton 7 : %s, pt %2.2f,E %2.2f, phi %2.2f, eta %2.2f \n",\r
+            parton2->GetName(),parton2->Pt(),parton2->Energy(),parton2->Phi()*TMath::RadToDeg(),parton2->Eta());\r
+               }\r
+//             //Trace the jet from the mother parton\r
+//             Float_t pt  = 0;\r
+//             Float_t pt1 = 0;\r
+//             Float_t pt2 = 0;\r
+//             Float_t e   = 0;\r
+//             Float_t e1  = 0;\r
+//             Float_t e2  = 0;\r
+//             TParticle * tmptmp = new TParticle;\r
+//             for(Int_t i = 0; i< stack->GetNprimary(); i++){\r
+//                     tmptmp = stack->Particle(i);\r
+               \r
+//                     if(tmptmp->GetStatusCode() == 1){\r
+//                             pt = tmptmp->Pt();\r
+//                             e =  tmptmp->Energy();                  \r
+//                             Int_t imom = tmptmp->GetFirstMother();\r
+//                             Int_t imom1 = 0;\r
+//                             //printf("1st imom %d\n",imom);\r
+//                             while(imom > 5){\r
+//                                     imom1=imom;\r
+//                                     tmptmp = stack->Particle(imom);\r
+//                                     imom = tmptmp->GetFirstMother();\r
+//                                     //printf("imom %d       \n",imom);\r
+//                             }\r
+//                             //printf("Last imom %d %d\n",imom1, imom);\r
+//                             if(imom1 == 6) {\r
+//                                     pt1+=pt;\r
+//                                     e1+=e;                          \r
+//                             }\r
+//                             else if (imom1 == 7){\r
+//                                     pt2+=pt;\r
+//                                     e2+=e;                                  }\r
+//                     }// status 1\r
+                               \r
+//             }// for\r
+               \r
+//             printf("JET 1, pt %2.2f, e %2.2f; JET 2, pt %2.2f, e %2.2f \n",pt1,e1,pt2,e2);\r
+               \r
+               //Get the jet, different way for different generator\r
+               //PYTHIA\r
+    if(fMCGenerator == "PYTHIA"){\r
+      TParticle * jet =  new TParticle;\r
+      AliGenPythiaEventHeader* pygeh= (AliGenPythiaEventHeader*) geh;\r
+      nTriggerJets =  pygeh->NTriggerJets();\r
+      if(fDebug > 1)\r
+         printf("AliMCAnalysisUtils::GetJets() - PythiaEventHeader: Njets: %d\n",nTriggerJets);\r
+               \r
+      Int_t iparton = -1;\r
+      for(Int_t i = 0; i< nTriggerJets; i++){\r
+       iparton=-1;\r
+       pygeh->TriggerJet(i, tmpjet);\r
+       jet = new TParticle(94, 21, -1, -1, -1, -1, tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3], 0,0,0,0);\r
+       //Assign an outgoing parton as mother\r
+       Float_t phidiff1 = TMath::Abs(jet->Phi()-parton1->Phi());               \r
+       Float_t phidiff2 = TMath::Abs(jet->Phi()-parton2->Phi());\r
+       if(phidiff1 > phidiff2) jet->SetFirstMother(7);\r
+       else  jet->SetFirstMother(6);\r
+       //jet->Print();\r
+       if(fDebug > 1)\r
+         printf("AliMCAnalysisUtils::GetJets() - PYTHIA Jet %d: mother %d, pt %2.2f,E %2.2f, phi %2.2f, eta %2.2f \n",\r
+                i, jet->GetFirstMother(),jet->Pt(),jet->Energy(),jet->Phi()*TMath::RadToDeg(),jet->Eta());\r
+       fJetsList->Add(jet);                    \r
+      }\r
+    }//Pythia triggered jets\r
+    //HERWIG\r
+    else if (fMCGenerator=="HERWIG"){\r
+      Int_t pdg = -1;          \r
+      //Check parton 1\r
+      TParticle * tmp = parton1;\r
+      if(parton1->GetPdgCode()!=22){\r
+       while(pdg != 94){\r
+         if(tmp->GetFirstDaughter()==-1) return fJetsList;\r
+         tmp = stack->Particle(tmp->GetFirstDaughter());\r
+         pdg = tmp->GetPdgCode();\r
+       }//while\r
+       \r
+       //Add found jet to list\r
+       TParticle *jet1 = new TParticle(*tmp);\r
+       jet1->SetFirstMother(6);\r
+       fJetsList->Add(jet1);\r
+       //printf("jet 1:  first daughter %d, last daughter %d\n", tmp->GetFirstDaughter(), tmp->GetLastDaughter());\r
+       //tmp = stack->Particle(tmp->GetFirstDaughter());\r
+       //tmp->Print();\r
+       //jet1->Print();\r
+       if(fDebug > 1)                  \r
+         printf("AliMCAnalysisUtils::GetJets() - HERWIG Jet 1: mother %d, status %d, pt %2.2f,E %2.2f, phi %2.2f, eta %2.2f \n",\r
+                jet1->GetFirstMother(),jet1->GetStatusCode(),jet1->Pt(),jet1->Energy(),jet1->Phi()*TMath::RadToDeg(),jet1->Eta());\r
+      }//not photon\r
+      \r
+      //Check parton 2\r
+      pdg = -1;\r
+      tmp = parton2;\r
+      Int_t i = -1;\r
+      if(parton2->GetPdgCode()!=22){\r
+       while(pdg != 94){\r
+         if(tmp->GetFirstDaughter()==-1) return fJetsList;\r
+         i = tmp->GetFirstDaughter();\r
+         tmp = stack->Particle(tmp->GetFirstDaughter());\r
+         pdg = tmp->GetPdgCode();\r
+       }//while\r
+       //Add found jet to list\r
+       TParticle *jet2 = new TParticle(*tmp);\r
+       jet2->SetFirstMother(7);\r
+       fJetsList->Add(jet2);\r
+       //jet2->Print();\r
+       if(fDebug > 1)\r
+         printf("AliMCAnalysisUtils::GetJets() - HERWIG Jet 2: mother %d, status %d, pt %2.2f,E %2.2f, phi %2.2f, eta %2.2f \n",\r
+                jet2->GetFirstMother(),jet2->GetStatusCode(),jet2->Pt(),jet2->Energy(),jet2->Phi()*TMath::RadToDeg(),jet2->Eta());\r
+       //Int_t first =  tmp->GetFirstDaughter();\r
+       //Int_t last  =  tmp->GetLastDaughter();\r
+       //printf("jet 2:  first daughter %d, last daughter %d, pdg %d\n",first, last, tmp->GetPdgCode());\r
+                               //      for(Int_t d = first ; d < last+1; d++){\r
+//                                             tmp = stack->Particle(d);\r
+//                                             if(i == tmp->GetFirstMother())\r
+//                                                     printf("Daughter n %d, Mother %d, name %s, status %d, pT %2.2f,E %2.2f, phi %2.2f, eta %2.2f \n",\r
+//                                                     d,tmp->GetFirstMother(), tmp->GetName(), tmp->GetStatusCode(),tmp->Pt(),tmp->Energy(),tmp->Phi()*TMath::RadToDeg(),tmp->Eta());                    \r
+//                        }\r
+                                                  //tmp->Print();\r
+      }//not photon\r
+    }//Herwig generated jets\r
+  }\r
+  \r
+  return fJetsList;\r
+}\r
+\r
+//________________________________________________________________\r
+void AliMCAnalysisUtils::Print(const Option_t * opt) const\r
+{\r
+  //Print some relevant parameters set for the analysis\r
\r
+ if(! opt)\r
+   return;\r
\r
+ printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;\r
\r
+ printf("Debug level    = %d\n",fDebug);\r
+ printf("MC Generator   = %s\n",fMCGenerator.Data());\r
\r
+ printf(" \n");\r
\r
+} \r
+\r
+\r
index 22f0bbbd653fbe53ebafd7a6258f31e0067b5e37..a0f5fc1d79eb35b81b6f338c1212d736eb73c62f 100755 (executable)
@@ -1,60 +1,60 @@
-#ifndef ALIMCANALYSISUTILS_H
-#define ALIMCANALYSISUTILS_H
-/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
- * See cxx source for full Copyright notice     */
-/* $Id:  $ */
-
-//_________________________________________________________________________
-// Class for analysis utils for MC data
-// stored in stack or event header.
-// Contains:
-//  - method to check the origin of a given track/cluster
-//  - method to obtain the generated jets
-//
-//*-- Author: Gustavo Conesa (INFN-LNF)
-
-// --- ROOT system ---
-#include <TObject.h> 
-class TString ;
-class TList ;
-
-//--- AliRoot system ---
-class AliStack ;
-class AliGenEventHeader ;
-
-class AliMCAnalysisUtils : public TObject {
-       
-public: 
-       
-       AliMCAnalysisUtils() ; // ctor
-       AliMCAnalysisUtils(const AliMCAnalysisUtils & g) ; // cpy ctor
-       AliMCAnalysisUtils & operator = (const AliMCAnalysisUtils & g) ;//cpy assignment
-       virtual ~AliMCAnalysisUtils() ;//virtual dtor
-       
-       enum mcTypes {kMCPrompt, kMCFragmentation, kMCISR, kMCPi0Decay, kMCEtaDecay, kMCOtherDecay, kMCPi0, kMCEta, kMCElectron, kMCConversion, kMCUnknown};
-       
-       Int_t CheckOrigin(const Int_t label, AliStack *  stack) const ;
-       TList * GetJets(Int_t iEvent, AliStack *  stack, AliGenEventHeader * geh) ;
-       
-       void Print(const Option_t * opt)const;
-       
-       void SetDebug(Int_t deb) {fDebug=deb;}
-       Int_t GetDebug() const {return fDebug;} 
-       
-       void SetMCGenerator(TString mcgen) {fMCGenerator=mcgen;}
-       TString GetMCGenerator() const {return fMCGenerator;}   
-
-private:
-       Int_t   fCurrentEvent; // Current Event
-       Int_t   fDebug;        // Debug level
-       TList * fJetsList;      // List of jets
-       TString fMCGenerator;  // MC geneator used to generate data in simulation
-
-       ClassDef(AliMCAnalysisUtils,1)
-} ;
-
-
-#endif //ALIMCANALYSISUTILS_H
-
-
-
+#ifndef ALIMCANALYSISUTILS_H\r
+#define ALIMCANALYSISUTILS_H\r
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
+ * See cxx source for full Copyright notice     */\r
+/* $Id:  $ */\r
+\r
+//_________________________________________________________________________\r
+// Class for analysis utils for MC data\r
+// stored in stack or event header.\r
+// Contains:\r
+//  - method to check the origin of a given track/cluster\r
+//  - method to obtain the generated jets\r
+//\r
+//*-- Author: Gustavo Conesa (INFN-LNF)\r
+\r
+// --- ROOT system ---\r
+#include <TObject.h> \r
+class TString ;\r
+class TList ;\r
+\r
+//--- AliRoot system ---\r
+class AliStack ;\r
+class AliGenEventHeader ;\r
+\r
+class AliMCAnalysisUtils : public TObject {\r
+       \r
+public: \r
+       \r
+       AliMCAnalysisUtils() ; // ctor\r
+       AliMCAnalysisUtils(const AliMCAnalysisUtils & g) ; // cpy ctor\r
+       AliMCAnalysisUtils & operator = (const AliMCAnalysisUtils & g) ;//cpy assignment\r
+       virtual ~AliMCAnalysisUtils() ;//virtual dtor\r
+       \r
+  enum mcTypes {kMCPrompt, kMCFragmentation, kMCISR, kMCPi0Decay, kMCEtaDecay, kMCOtherDecay, kMCPi0, kMCEta, kMCElectron, kMCConversion, kMCUnknown, kMCEFromCFromB, kMCEFromC, kMCEFromB,kMCZDecay,kMCWDecay};\r
+       \r
+       Int_t CheckOrigin(const Int_t label, AliStack *  stack) const ;\r
+       TList * GetJets(Int_t iEvent, AliStack *  stack, AliGenEventHeader * geh) ;\r
+       \r
+       void Print(const Option_t * opt)const;\r
+       \r
+       void SetDebug(Int_t deb) {fDebug=deb;}\r
+       Int_t GetDebug() const {return fDebug;} \r
+       \r
+       void SetMCGenerator(TString mcgen) {fMCGenerator=mcgen;}\r
+       TString GetMCGenerator() const {return fMCGenerator;}   \r
+\r
+private:\r
+       Int_t   fCurrentEvent; // Current Event\r
+       Int_t   fDebug;        // Debug level\r
+       TList * fJetsList;      // List of jets\r
+       TString fMCGenerator;  // MC geneator used to generate data in simulation\r
+\r
+       ClassDef(AliMCAnalysisUtils,1)\r
+} ;\r
+\r
+\r
+#endif //ALIMCANALYSISUTILS_H\r
+\r
+\r
+\r
diff --git a/PWG4/PartCorrDep/AliAnaElectron.cxx b/PWG4/PartCorrDep/AliAnaElectron.cxx
new file mode 100755 (executable)
index 0000000..6e00ca2
--- /dev/null
@@ -0,0 +1,726 @@
+ /**************************************************************************\r
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
+ *                                                                        *\r
+ * Author: The ALICE Off-line Project.                                    *\r
+ * Contributors are mentioned in the code where appropriate.              *\r
+ *                                                                        *\r
+ * Permission to use, copy, modify and distribute this software and its   *\r
+ * documentation strictly for non-commercial purposes hereby granted      *\r
+ * without fee, provided that the above copyright notice appears in all   *\r
+ * copies and that both the copyright notice and this permission notice   *\r
+ * appear in the supporting documentation. The authors make no claims     *\r
+ * about the suitability of this software for any purpose. It is          *\r
+ * provided "as is" without express or implied warranty.                  *\r
+ **************************************************************************/\r
+/* $Id: $ */\r
+\r
+//_________________________________________________________________________\r
+//\r
+// Class for the electron identification.\r
+// Clusters from EMCAL matched to tracks\r
+// and kept in the AOD. Few histograms produced.\r
+//\r
+// -- Author: J.L. Klay (Cal Poly)\r
+//////////////////////////////////////////////////////////////////////////////\r
+  \r
+  \r
+// --- ROOT system --- \r
+#include <TH2F.h>\r
+#include <TClonesArray.h>\r
+#include <TObjString.h>\r
+#include <Riostream.h>\r
+\r
+// --- Analysis system --- \r
+#include "AliAnaElectron.h" \r
+#include "AliCaloTrackReader.h"\r
+#include "AliMCAnalysisUtils.h"\r
+#include "AliFidutialCut.h"\r
+#include "AliESDCaloCluster.h"\r
+//#include "AliESDCaloCells.h"\r
+#include "AliESDtrack.h"\r
+#include "AliESDEvent.h"\r
+#include "AliCaloPID.h"\r
+#include "AliVEvent.h"\r
+\r
+ClassImp(AliAnaElectron)\r
+  \r
+//____________________________________________________________________________\r
+AliAnaElectron::AliAnaElectron() \r
+ : AliAnaPartCorrBaseClass(), fCalorimeter(""),\r
+  fpOverEmin(0.),fpOverEmax(0.),fResidualCut(0.),\r
+  //matching checks\r
+  fh1pOverE(0),fh1dR(0),fh2EledEdx(0),fh2MatchdEdx(0),fh2dEtadPhi(0),\r
+  fh2dEtadPhiMatched(0),fh2dEtadPhiUnmatched(0),\r
+  fh2OuterPtVsExtrapPt(0),fh2OuterPhiVsExtrapPhi(0),fh2OuterEtaVsExtrapEta(0),\r
+  fh2TrackPVsClusterE(0),fh2TrackPtVsClusterE(0),fh2TrackPhiVsClusterPhi(0),fh2TrackEtaVsClusterEta(0),\r
+  //reco\r
+  fhPtElectron(0),fhPhiElectron(0),fhEtaElectron(0),\r
+  //MC\r
+  fhPtConversion(0),fhPhiConversion(0),fhEtaConversion(0),\r
+  fhPtBottom(0),fhPhiBottom(0),fhEtaBottom(0),\r
+  fhPtCharm(0),fhPhiCharm(0),fhEtaCharm(0),\r
+  fhPtCFromB(0),fhPhiCFromB(0),fhEtaCFromB(0),\r
+  fhPtDalitz(0),fhPhiDalitz(0),fhEtaDalitz(0),\r
+  fhPtWDecay(0),fhPhiWDecay(0),fhEtaWDecay(0),\r
+  fhPtZDecay(0),fhPhiZDecay(0),fhEtaZDecay(0),\r
+  fhPtPrompt(0),fhPhiPrompt(0),fhEtaPrompt(0),\r
+  fhPtUnknown(0),fhPhiUnknown(0),fhEtaUnknown(0)\r
+//  fhMCElePt(0),fhMCElePhi(0),fhMCEleEta(0)\r
+{\r
+  //default ctor\r
+  \r
+  //Initialize parameters\r
+  InitParameters();\r
+\r
+}\r
+\r
+//____________________________________________________________________________\r
+AliAnaElectron::AliAnaElectron(const AliAnaElectron & g) \r
+ : AliAnaPartCorrBaseClass(g), fCalorimeter(g.fCalorimeter),\r
+   fpOverEmin(g.fpOverEmin),fpOverEmax(g.fpOverEmax),fResidualCut(g.fResidualCut),\r
+   //matching checks\r
+   fh1pOverE(g.fh1pOverE),fh1dR(g.fh1dR),\r
+   fh2EledEdx(g.fh2EledEdx),fh2MatchdEdx(g.fh2MatchdEdx),fh2dEtadPhi(g.fh2dEtadPhi),\r
+   fh2dEtadPhiMatched(g.fh2dEtadPhiMatched),fh2dEtadPhiUnmatched(g.fh2dEtadPhiUnmatched),\r
+   fh2OuterPtVsExtrapPt(g.fh2OuterPtVsExtrapPt),fh2OuterPhiVsExtrapPhi(g.fh2OuterPhiVsExtrapPhi),\r
+   fh2OuterEtaVsExtrapEta(g.fh2OuterEtaVsExtrapEta),\r
+   fh2TrackPVsClusterE(g.fh2TrackPVsClusterE),fh2TrackPtVsClusterE(g.fh2TrackPtVsClusterE),\r
+   fh2TrackPhiVsClusterPhi(g.fh2TrackPhiVsClusterPhi),fh2TrackEtaVsClusterEta(g.fh2TrackEtaVsClusterEta),   \r
+   //reco\r
+   fhPtElectron(g.fhPtElectron),fhPhiElectron(g.fhPhiElectron),fhEtaElectron(g.fhEtaElectron),\r
+   //MC\r
+   fhPtConversion(g.fhPtConversion),fhPhiConversion(g.fhPhiConversion),fhEtaConversion(g.fhEtaConversion),\r
+   fhPtBottom(g.fhPtBottom),fhPhiBottom(g.fhPhiBottom),fhEtaBottom(g.fhEtaBottom),\r
+   fhPtCharm(g.fhPtCharm),fhPhiCharm(g.fhPhiCharm),fhEtaCharm(g.fhEtaCharm),\r
+   fhPtCFromB(g.fhPtCFromB),fhPhiCFromB(g.fhPhiCFromB),fhEtaCFromB(g.fhEtaCFromB),\r
+   fhPtDalitz(g.fhPtDalitz),fhPhiDalitz(g.fhPhiDalitz),fhEtaDalitz(g.fhEtaDalitz),\r
+   fhPtWDecay(g.fhPtWDecay),fhPhiWDecay(g.fhPhiWDecay),fhEtaWDecay(g.fhEtaWDecay),\r
+   fhPtZDecay(g.fhPtZDecay),fhPhiZDecay(g.fhPhiZDecay),fhEtaZDecay(g.fhEtaZDecay),\r
+   fhPtPrompt(g.fhPtPrompt),fhPhiPrompt(g.fhPhiPrompt),fhEtaPrompt(g.fhEtaPrompt),\r
+   fhPtUnknown(g.fhPtUnknown),fhPhiUnknown(g.fhPhiUnknown),fhEtaUnknown(g.fhEtaUnknown)\r
+   //   fhMCElePt(g.fhMCElePt),fhMCElePhi(g.fhMCElePhi),fhMCEleEta(g.fhMCEleEta)\r
+{\r
+  // cpy ctor\r
+  \r
+}\r
+\r
+//_________________________________________________________________________\r
+AliAnaElectron & AliAnaElectron::operator = (const AliAnaElectron & g)\r
+{\r
+  // assignment operator\r
+  \r
+  if(&g == this) return *this;\r
+  fCalorimeter = g.fCalorimeter;\r
+  fpOverEmin = g.fpOverEmin;\r
+  fpOverEmax = g.fpOverEmax;\r
+  fResidualCut = g.fResidualCut;\r
+  //fhEnergy = g.fhEnergy;\r
+  //fhClusMult = g.fhClusMult;\r
+  //fhClusters = g.fhClusters;\r
+  //fhDigitsEvent = g.fhDigitsEvent;\r
+  fh1pOverE = g.fh1pOverE;\r
+  fh1dR = g.fh1dR;\r
+  fh2EledEdx = g.fh2EledEdx;\r
+  fh2MatchdEdx = g.fh2MatchdEdx;\r
+  fh2dEtadPhi = g.fh2dEtadPhi;\r
+  fh2dEtadPhiMatched = g.fh2dEtadPhiMatched;\r
+  fh2dEtadPhiUnmatched = g.fh2dEtadPhiUnmatched;\r
+  fh2OuterPtVsExtrapPt = g.fh2OuterPtVsExtrapPt;\r
+  fh2OuterPhiVsExtrapPhi = g.fh2OuterPhiVsExtrapPhi;\r
+  fh2OuterEtaVsExtrapEta = g.fh2OuterEtaVsExtrapEta;\r
+  fh2TrackPVsClusterE = g.fh2TrackPVsClusterE;\r
+  fh2TrackPtVsClusterE = g.fh2TrackPtVsClusterE;\r
+  fh2TrackPhiVsClusterPhi = g.fh2TrackPhiVsClusterPhi;\r
+  fh2TrackEtaVsClusterEta = g.fh2TrackEtaVsClusterEta;   \r
+  fhPtElectron = g.fhPtElectron;\r
+  fhPhiElectron = g.fhPhiElectron;\r
+  fhEtaElectron = g.fhEtaElectron;\r
+  fhPtConversion = g.fhPtConversion;\r
+  fhPhiConversion = g.fhPhiConversion;\r
+  fhEtaConversion = g.fhEtaConversion;\r
+  fhPtBottom = g.fhPtBottom;\r
+  fhPhiBottom = g.fhPhiBottom;\r
+  fhEtaBottom = g.fhEtaBottom;\r
+  fhPtCharm = g.fhPtCharm;\r
+  fhPhiCharm = g.fhPhiCharm;\r
+  fhEtaCharm = g.fhEtaCharm;\r
+  fhPtCFromB = g.fhPtCFromB;\r
+  fhPhiCFromB = g.fhPhiCFromB;\r
+  fhEtaCFromB = g.fhEtaCFromB;\r
+  fhPtDalitz = g.fhPtDalitz;\r
+  fhPhiDalitz = g.fhPhiDalitz;\r
+  fhEtaDalitz = g.fhEtaDalitz;\r
+  fhPtWDecay = g.fhPtWDecay;\r
+  fhPhiWDecay = g.fhPhiWDecay;\r
+  fhEtaWDecay = g.fhEtaWDecay;\r
+  fhPtZDecay = g.fhPtZDecay;\r
+  fhPhiZDecay = g.fhPhiZDecay;\r
+  fhEtaZDecay = g.fhEtaZDecay;\r
+  fhPtPrompt = g.fhPtPrompt;\r
+  fhPhiPrompt = g.fhPhiPrompt;\r
+  fhEtaPrompt = g.fhEtaPrompt;\r
+  fhPtUnknown = g.fhPtUnknown;\r
+  fhPhiUnknown = g.fhPhiUnknown;\r
+  fhEtaUnknown = g.fhEtaUnknown;\r
+\r
+  /*\r
+  fhMCElePt = g.fhMCElePt;\r
+  fhMCElePhi = g.fhMCElePhi;\r
+  fhMCEleEta = g.fhMCEleEta;\r
+  */\r
+\r
+  return *this;\r
+  \r
+}\r
+\r
+//____________________________________________________________________________\r
+AliAnaElectron::~AliAnaElectron() \r
+{\r
+  //dtor\r
+\r
+}\r
+\r
+\r
+//________________________________________________________________________\r
+TList *  AliAnaElectron::GetCreateOutputObjects()\r
+{  \r
+  // Create histograms to be saved in output file and \r
+  // store them in outputContainer\r
+  TList * outputContainer = new TList() ; \r
+  outputContainer->SetName("ElectronHistos") ; \r
+  \r
+  Int_t nptbins  = GetHistoNPtBins();\r
+  Int_t nphibins = GetHistoNPhiBins();\r
+  Int_t netabins = GetHistoNEtaBins();\r
+  Float_t ptmax  = GetHistoPtMax();\r
+  Float_t phimax = GetHistoPhiMax();\r
+  Float_t etamax = GetHistoEtaMax();\r
+  Float_t ptmin  = GetHistoPtMin();\r
+  Float_t phimin = GetHistoPhiMin();\r
+  Float_t etamin = GetHistoEtaMin();   \r
+\r
+  fh1pOverE = new TH1F("h1pOverE","EMCAL-TRACK matches p/E",100,0.,10.);\r
+  fh1dR = new TH1F("h1dR","EMCAL-TRACK matches dR",300, 0.,TMath::Pi());\r
+  fh2EledEdx = new TH2F("h2EledEdx","dE/dx vs. p for electrons",200,0.,50.,200,0.,400.);\r
+  fh2MatchdEdx = new TH2F("h2MatchdEdx","dE/dx vs. p for all matches",200,0.,50.,200,0.,400.);\r
+  fh2dEtadPhi = new TH2F("h2dEtadPhi","#Delta#eta vs. #Delta#phi for all track-cluster pairs",200,0.,1.4,300,0.,TMath::Pi());\r
+  fh2dEtadPhiMatched = new TH2F("h2dEtadPhiMatched","#Delta#eta vs. #Delta#phi for matched track-cluster pairs",200,0.,1.4,300,0.,TMath::Pi());\r
+  fh2dEtadPhiUnmatched = new TH2F("h2dEtadPhiUnmatched","#Delta#eta vs. #Delta#phi for unmatched track-cluster pairs",200,0.,1.4,300,0.,TMath::Pi());\r
+  fh2OuterPtVsExtrapPt = new TH2F("h2OuterPtVsExtrapPt","h2OuterPtVsExtrapPt",nptbins,ptmin,ptmax,nptbins,ptmin,ptmax);\r
+  fh2OuterPhiVsExtrapPhi = new TH2F("h2OuterPhiVsExtrapPhi","h2OuterPhiVsExtrapPhi",nphibins,phimin,phimax,nphibins,phimin,phimax);\r
+  fh2OuterEtaVsExtrapEta = new TH2F("h2OuterEtaVsExtrapEta","h2OuterEtaVsExtrapEta",netabins,etamin,etamax,netabins,etamin,etamax);\r
+\r
+  fh2TrackPVsClusterE = new TH2F("h2TrackPVsClusterE","h2TrackPVsClusterE",nptbins,ptmin,ptmax,nptbins,ptmin,ptmax);\r
+  fh2TrackPtVsClusterE = new TH2F("h2TrackPtVsClusterE","h2TrackPtVsClusterE",nptbins,ptmin,ptmax,nptbins,ptmin,ptmax);\r
+  fh2TrackPhiVsClusterPhi = new TH2F("h2TrackPhiVsClusterPhi","h2TrackPhiVsClusterPhi",nphibins,phimin,phimax,nphibins,phimin,phimax);\r
+  fh2TrackEtaVsClusterEta = new TH2F("h2TrackEtaVsClusterEta","h2TrackEtaVsClusterEta",netabins,etamin,etamax,netabins,etamin,etamax);\r
+\r
+  outputContainer->Add(fh1pOverE) ; \r
+  outputContainer->Add(fh1dR) ; \r
+  outputContainer->Add(fh2EledEdx) ;\r
+  outputContainer->Add(fh2MatchdEdx) ;\r
+  outputContainer->Add(fh2dEtadPhi) ;\r
+  outputContainer->Add(fh2dEtadPhiMatched) ;\r
+  outputContainer->Add(fh2dEtadPhiUnmatched) ;\r
+  outputContainer->Add(fh2OuterPtVsExtrapPt) ;\r
+  outputContainer->Add(fh2OuterPhiVsExtrapPhi) ;\r
+  outputContainer->Add(fh2OuterEtaVsExtrapEta) ;\r
+  outputContainer->Add(fh2TrackPVsClusterE) ;\r
+  outputContainer->Add(fh2TrackPtVsClusterE) ;\r
+  outputContainer->Add(fh2TrackPhiVsClusterPhi) ;\r
+  outputContainer->Add(fh2TrackEtaVsClusterEta) ;\r
+  \r
+  fhPtElectron = new TH1F("hPtElectron","Electron pT",nptbins,ptmin,ptmax);\r
+  fhPhiElectron = new TH2F("hPhiElectron","Electron phi vs pT",nptbins,ptmin,ptmax,nphibins,phimin,phimax);\r
+  fhEtaElectron = new TH2F("hEtaElectron","Electron eta vs. eta",nptbins,ptmin,ptmax,netabins,etamin,etamax);\r
+\r
+  outputContainer->Add(fhPtElectron) ; \r
+  outputContainer->Add(fhPhiElectron) ; \r
+  outputContainer->Add(fhEtaElectron) ;\r
+  \r
+  if(IsDataMC()){\r
+    \r
+    fhPtConversion = new TH1F("hPtConversion","Conversion electron pT",nptbins,ptmin,ptmax);\r
+    fhPhiConversion = new TH2F("hPhiConversion","Conversion Electron phi vs pT",nptbins,ptmin,ptmax,nphibins,phimin,phimax);\r
+    fhEtaConversion = new TH2F("hEtaConversion","Conversion Electron eta vs. eta",nptbins,ptmin,ptmax,netabins,etamin,etamax);\r
+    fhPtBottom = new TH1F("hPtBottom","Bottom electron pT",nptbins,ptmin,ptmax);\r
+    fhPhiBottom = new TH2F("hPhiBottom","Bottom Electron phi vs pT",nptbins,ptmin,ptmax,nphibins,phimin,phimax);\r
+    fhEtaBottom = new TH2F("hEtaBottom","Bottom Electron eta vs. eta",nptbins,ptmin,ptmax,netabins,etamin,etamax);\r
+    fhPtCharm = new TH1F("hPtCharm","Charm electron pT",nptbins,ptmin,ptmax);\r
+    fhPhiCharm = new TH2F("hPhiCharm","Charm Electron phi vs pT",nptbins,ptmin,ptmax,nphibins,phimin,phimax);\r
+    fhEtaCharm = new TH2F("hEtaCharm","Charm Electron eta vs. eta",nptbins,ptmin,ptmax,netabins,etamin,etamax);\r
+    fhPtCFromB = new TH1F("hPtCFromB","Charm from Bottom electron pT",nptbins,ptmin,ptmax);\r
+    fhPhiCFromB = new TH2F("hPhiCFromB","Charm from Bottom Electron phi vs pT",nptbins,ptmin,ptmax,nphibins,phimin,phimax);\r
+    fhEtaCFromB = new TH2F("hEtaCFromB","Charm from Bottom Electron eta vs. eta",nptbins,ptmin,ptmax,netabins,etamin,etamax);\r
+    fhPtDalitz = new TH1F("hPtDalitz","Dalitz electron pT",nptbins,ptmin,ptmax);\r
+    fhPhiDalitz = new TH2F("hPhiDalitz","Dalitz Electron phi vs pT",nptbins,ptmin,ptmax,nphibins,phimin,phimax);\r
+    fhEtaDalitz = new TH2F("hEtaDalitz","Dalitz Electron eta vs. eta",nptbins,ptmin,ptmax,netabins,etamin,etamax);\r
+    fhPtWDecay = new TH1F("hPtWDecay","W-boson Electron pT",nptbins,ptmin,ptmax);\r
+    fhPhiWDecay = new TH2F("hPhiWDecay","W-boson electron phi vs pT",nptbins,ptmin,ptmax,nphibins,phimin,phimax);\r
+    fhEtaWDecay = new TH2F("hEtaWDecay","W-boson Electron eta vs. eta",nptbins,ptmin,ptmax,netabins,etamin,etamax);\r
+    fhPtZDecay = new TH1F("hPtZDecay","Z-boson electron pT",nptbins,ptmin,ptmax);\r
+    fhPhiZDecay = new TH2F("hPhiZDecay","Z-boson Electron phi vs pT",nptbins,ptmin,ptmax,nphibins,phimin,phimax);\r
+    fhEtaZDecay = new TH2F("hEtaZDecay","Z-boson Electron eta vs. eta",nptbins,ptmin,ptmax,netabins,etamin,etamax);\r
+    fhPtPrompt = new TH1F("hPtPrompt","Prompt electron pT",nptbins,ptmin,ptmax);\r
+    fhPhiPrompt = new TH2F("hPhiPrompt","Prompt Electron phi vs pT",nptbins,ptmin,ptmax,nphibins,phimin,phimax);\r
+    fhEtaPrompt = new TH2F("hEtaPrompt","Prompt Electron eta vs. eta",nptbins,ptmin,ptmax,netabins,etamin,etamax);\r
+    fhPtUnknown = new TH1F("hPtUnknown","Unknown electron pT",nptbins,ptmin,ptmax);\r
+    fhPhiUnknown = new TH2F("hPhiUnknown","Unknown Electron phi vs pT",nptbins,ptmin,ptmax,nphibins,phimin,phimax);\r
+    fhEtaUnknown = new TH2F("hEtaUnknown","Unknown Electron eta vs. eta",nptbins,ptmin,ptmax,netabins,etamin,etamax);\r
+\r
+    outputContainer->Add(fhPtConversion);\r
+    outputContainer->Add(fhPhiConversion);\r
+    outputContainer->Add(fhEtaConversion);\r
+    outputContainer->Add(fhPtBottom);\r
+    outputContainer->Add(fhPhiBottom);\r
+    outputContainer->Add(fhEtaBottom);\r
+    outputContainer->Add(fhPtCharm);\r
+    outputContainer->Add(fhPhiCharm);\r
+    outputContainer->Add(fhEtaCharm);\r
+    outputContainer->Add(fhPtCFromB);\r
+    outputContainer->Add(fhPhiCFromB);\r
+    outputContainer->Add(fhEtaCFromB);\r
+    outputContainer->Add(fhPtDalitz);\r
+    outputContainer->Add(fhPhiDalitz);\r
+    outputContainer->Add(fhEtaDalitz);\r
+    outputContainer->Add(fhPtWDecay);\r
+    outputContainer->Add(fhPhiWDecay);\r
+    outputContainer->Add(fhEtaWDecay);\r
+    outputContainer->Add(fhPtZDecay);\r
+    outputContainer->Add(fhPhiZDecay);\r
+    outputContainer->Add(fhEtaZDecay);\r
+    outputContainer->Add(fhPtPrompt);\r
+    outputContainer->Add(fhPhiPrompt);\r
+    outputContainer->Add(fhEtaPrompt);\r
+    outputContainer->Add(fhPtUnknown);\r
+    outputContainer->Add(fhPhiUnknown);\r
+    outputContainer->Add(fhEtaUnknown);\r
+\r
+  /*\r
+    fhMCElePt = new TH1F("hMCElePt","MC Electron pT",nptbins,ptmin,ptmax);\r
+    fhMCElePhi = new TH2F("hMCElePhi","MC Electron phi",nptbins,ptmin,ptmax,nphibins,phimin,phimax);\r
+    fhMCEleEta = new TH2F("hMCEleEta","MC Electron eta",nptbins,ptmin,ptmax,netabins,etamin,etamax);\r
+    \r
+    outputContainer->Add(fhMCElePt) ; \r
+    outputContainer->Add(fhMCElePhi) ; \r
+    outputContainer->Add(fhMCEleEta) ;\r
+  */\r
+\r
+  }//Histos with MC\r
+  \r
+  //Save parameters used for analysis\r
+  TString parList ; //this will be list of parameters used for this analysis.\r
+  char onePar[255] ;\r
+  \r
+  sprintf(onePar,"--- AliAnaElectron ---\n") ;\r
+  parList+=onePar ;    \r
+  sprintf(onePar,"fCalorimeter: %s\n",fCalorimeter.Data()) ;\r
+  parList+=onePar ;  \r
+  sprintf(onePar,"fpOverEmin: %f\n",fpOverEmin) ;\r
+  parList+=onePar ;  \r
+  sprintf(onePar,"fpOverEmax: %f\n",fpOverEmax) ;\r
+  parList+=onePar ;  \r
+  sprintf(onePar,"fResidualCut: %f\n",fResidualCut) ;\r
+  parList+=onePar ;  \r
+  \r
+  //Get parameters set in base class.\r
+  parList += GetBaseParametersList() ;\r
+  \r
+  //Get parameters set in FidutialCut class (not available yet)\r
+  //parlist += GetFidCut()->GetFidCutParametersList() \r
+  \r
+  TObjString *oString= new TObjString(parList) ;\r
+  outputContainer->Add(oString);\r
+  \r
+  return outputContainer ;\r
+  \r
+}\r
+\r
+//____________________________________________________________________________\r
+void AliAnaElectron::Init()\r
+{\r
+  \r
+  //Init\r
+  //Do some checks\r
+//  if(fCalorimeter == "PHOS" && !GetReader()->IsPHOSSwitchedOn()){\r
+//    printf("AliAnaElectron::Init() - !!ABORT: You want to use PHOS in analysis but it is not read!! \n!!Check the configuration file!!\n");\r
+//    abort();\r
+//  }\r
+//  else  if(fCalorimeter == "EMCAL" && !GetReader()->IsEMCALSwitchedOn()){\r
+//    printf("AliAnaElectron::Init() - !!ABORT: You want to use EMCAL in analysis but it is not read!! \n!!Check the configuration file!!\n");\r
+//    abort();\r
+//  }\r
+  \r
+}\r
+\r
+\r
+//____________________________________________________________________________\r
+void AliAnaElectron::InitParameters()\r
+{\r
+  \r
+  //Initialize the parameters of the analysis.\r
+  SetOutputAODClassName("AliAODPWG4Particle");\r
+  SetOutputAODName("PWG4Particle");\r
+\r
+  AddToHistogramsName("AnaElectron_");\r
+\r
+  fCalorimeter = "EMCAL" ;\r
+  fpOverEmin = 0.5;\r
+  fpOverEmax = 1.5;\r
+  fResidualCut = 0.02;\r
+\r
+}\r
+\r
+//__________________________________________________________________\r
+void  AliAnaElectron::MakeAnalysisFillAOD() \r
+{\r
+  //\r
+  // Do analysis and fill aods with electron candidates\r
+  // These AODs will be used to do subsequent histogram filling\r
+  //\r
+  // Also fill some QA histograms\r
+  //\r
+\r
+  //Search for electrons in fCalorimeter \r
+  //TRefArray * caloData = new TRefArray(); \r
+  //TRefArray * ctsData = new TRefArray();\r
+       cout<<"Event type "<<GetReader()->GetInputEvent()->GetName()<<endl;\r
+       if((strcmp(GetReader()->GetInputEvent()->GetName(),"AliESDEvent"))) {\r
+               printf("AliAnaElectron::MakeAnalysisFillAOD() - !!ABORT: Analysis working only with ESDs!!\n");\r
+               abort();\r
+       }\r
+\r
+  //Get vertex for cluster momentum calculation\r
+  Double_t vertex[]={0,0,0} ; //vertex ;\r
+  if(GetReader()->GetDataType() != AliCaloTrackReader::kMC) GetReader()->GetVertex(vertex);\r
+  //Get bfield for track extrapolation to Calorimeter\r
+  Double_t bfield = GetReader()->GetInputEvent()->GetMagneticField();  //from V0 finder\r
+  Double_t radius = 0.;\r
+\r
+  //Get the CTS tracks\r
+  //ctsData = GetAODCTS();\r
+  //Select the Calorimeter of the electron\r
+  if(fCalorimeter == "PHOS") {\r
+    //caloData = GetAODPHOS();\r
+    radius = 425.0;  //FIXME\r
+  } else if (fCalorimeter == "EMCAL") {\r
+    //caloData = GetAODEMCAL();\r
+    radius = 441.0;  //[cm] EMCAL radius +13cm FIXME\r
+  }\r
+\r
+  //if(!(ctsData && caloData) || (ctsData->GetEntriesFast() == 0 || caloData->GetEntriesFast() == 0)) return;\r
+  //if(!caloData ||  caloData->GetEntriesFast() == 0) return;\r
+\r
+  ////////////////////////////////////////////////\r
+  //Start from tracks and get associated clusters \r
+  //\r
+  //Note: an alternative method would be to start from clusters and get associated tracks -\r
+  //which is better?  For electrons, probably tracks-->clusters\r
+  ////////////////////////////////////////////////\r
+//  for(Int_t itrk = 0; itrk < ctsData->GetEntriesFast(); itrk++){\r
+//    AliAODTrack *track = (AliAODTrack*)ctsData->At(itrk);\r
+\r
+    AliESDEvent *esd = (AliESDEvent*) GetReader()->GetInputEvent();\r
+    Int_t nTracks   = esd->GetNumberOfTracks() ;\r
+    for (Int_t itrk =  0; itrk <  nTracks; itrk++) {////////////// track loop\r
+      AliESDtrack * track = (AliESDtrack*) esd->GetTrack(itrk) ;\r
+      //extrapolate track to Calorimeter\r
+      Double_t emcmom[3] = {0.,0.,0.};\r
+      Double_t emcpos[3] = {0.,0.,0.};\r
+      AliExternalTrackParam *outerparam = (AliExternalTrackParam*)track->GetOuterParam();\r
+      if(!outerparam) continue;\r
+      \r
+      Bool_t okpos = outerparam->GetXYZAt(radius,bfield,emcpos);\r
+      Bool_t okmom = outerparam->GetPxPyPzAt(radius,bfield,emcmom);\r
+      if(!(okpos && okmom)) continue;\r
+      \r
+      TVector3 pos(emcpos[0],emcpos[1],emcpos[2]);\r
+      TVector3 mom(emcmom[0],emcmom[1],emcmom[2]);\r
+      Double_t tphi = pos.Phi();\r
+      Double_t teta = pos.Eta();\r
+      Double_t tmom = mom.Mag();\r
+      \r
+      TLorentzVector mom2(mom,0.);\r
+      Bool_t in =  GetFidutialCut()->IsInFidutialCut(mom2,fCalorimeter) ;\r
+      if(GetDebug() > 1) printf("AliAnaElectron::MakeAnalysisFillAOD() - Track pt %2.2f, phi %2.2f, eta %2.2f in fidutial cut %d\n",track->Pt(), track->Phi(), track->Eta(), in);\r
+      if(mom.Pt() > GetMinPt() && in) {\r
+\r
+        printf("\tExtrapolated pt %2.2f, phi %2.2f, eta %2.2f \n",mom.Pt(),mom.Phi(),mom.Eta());\r
+       fh2OuterPtVsExtrapPt->Fill(mom.Pt(),track->Pt());\r
+       fh2OuterPhiVsExtrapPhi->Fill(mom.Phi(),track->Phi());\r
+       fh2OuterEtaVsExtrapEta->Fill(mom.Eta(),track->Eta());\r
+\r
+       Int_t ntot = esd->GetNumberOfCaloClusters();//caloData->GetEntriesFast();\r
+       Double_t res = 999.;\r
+       Double_t pOverE = -999.;\r
+       \r
+       //For tracks in EMCAL acceptance, pair them with all clusters\r
+       //and fill the dEta vs dPhi for these pairs:\r
+       for(Int_t iclus = 0; iclus < esd->GetNumberOfCaloClusters(); iclus++) {\r
+         AliESDCaloCluster * clus = (AliESDCaloCluster*) esd->GetCaloCluster(iclus);\r
+         if(!clus) continue;\r
+         if(fCalorimeter == "PHOS"  && !clus->IsPHOS())  continue;\r
+         if(fCalorimeter == "EMCAL" && !clus->IsEMCAL()) continue;\r
+         \r
+         Float_t x[3];\r
+         clus->GetPosition(x);\r
+         TVector3 cluspos(x[0],x[1],x[2]);\r
+         Double_t deta = teta - cluspos.Eta();\r
+         Double_t dphi = tphi - cluspos.Phi();\r
+         if(dphi > TMath::Pi()) dphi -= 2*TMath::Pi();\r
+         if(dphi < -TMath::Pi()) dphi += 2*TMath::Pi();\r
+         if(track->GetEMCALcluster() < -9000) fh2dEtadPhiUnmatched->Fill(deta,dphi);\r
+         fh2dEtadPhi->Fill(deta,dphi);\r
+         fh2TrackPVsClusterE->Fill(clus->E(),track->P());\r
+         fh2TrackPtVsClusterE->Fill(clus->E(),track->Pt());\r
+         fh2TrackPhiVsClusterPhi->Fill(cluspos.Phi(),mom.Phi());\r
+         fh2TrackEtaVsClusterEta->Fill(cluspos.Eta(),mom.Eta());\r
+       }\r
+       \r
+       /////////////////////////////////\r
+       //Perform electron cut analysis//\r
+       /////////////////////////////////\r
+       Bool_t isElectron = kFALSE;\r
+       \r
+       Int_t iCluster = track->GetEMCALcluster();\r
+       if(iCluster < -9000) {printf("NOT MATCHED"); continue; }//no match\r
+       if(iCluster > ntot) continue; //index out of range; shouldn't happen\r
+       if(iCluster < 0 && iCluster > -9000) { //this should only happen in MC events\r
+         printf("AliAnaElectron::MakeAnalysisFillAOD() - Track has a fake match: %d\n",iCluster);\r
+         continue;\r
+       }\r
+       AliESDCaloCluster * clus = (AliESDCaloCluster*) esd->GetCaloCluster(iCluster);\r
+       if(!clus) continue;\r
+       if(fCalorimeter == "PHOS"  && !clus->IsPHOS())  continue;\r
+       if(fCalorimeter == "EMCAL" && !clus->IsEMCAL()) continue;\r
+       \r
+       Float_t x[3];\r
+       clus->GetPosition(x);\r
+       TVector3 cluspos(x[0],x[1],x[2]);\r
+       Double_t deta = teta - cluspos.Eta();\r
+       Double_t dphi = tphi - cluspos.Phi();\r
+       if(dphi > TMath::Pi()) dphi -= 2*TMath::Pi();\r
+       if(dphi < -TMath::Pi()) dphi += 2*TMath::Pi();\r
+       res = sqrt(dphi*dphi + deta*deta);\r
+       fh1dR->Fill(res);\r
+       fh2dEtadPhiMatched->Fill(deta,dphi);\r
+       \r
+       if(res < fResidualCut) {\r
+         //Good match\r
+         fh2MatchdEdx->Fill(track->P(),track->GetTPCsignal());\r
+         \r
+         Double_t energy = clus->E(); \r
+         if(energy > 0) pOverE = tmom/energy;\r
+         fh1pOverE->Fill(pOverE);\r
+         \r
+         Int_t mult = clus->GetNumberOfDigits();\r
+         //    Int_t mcClus = clus->GetLabel();\r
+         AliESDCaloCluster * esdcalo = (AliESDCaloCluster*) esd->GetCaloCluster(clus->GetID());\r
+         Int_t matchIndex = esdcalo->GetTrackMatched();\r
+         \r
+         if(matchIndex != itrk) printf("Track and cluster don't agree! track %d, cluster %d",itrk,matchIndex);\r
+         if(mult < 2) printf("Single digit cluster.");\r
+         \r
+         //////////////////////////////\r
+         //Electron cuts happen here!//\r
+         //////////////////////////////\r
+         if(pOverE > fpOverEmin && pOverE < fpOverEmax) isElectron = kTRUE;\r
+         \r
+       } //good matching residual\r
+       \r
+       ///////////////////////////\r
+       //Fill AOD with electrons//\r
+       ///////////////////////////\r
+       if(isElectron) {\r
+         \r
+         fh2EledEdx->Fill(track->P(),track->GetTPCsignal());\r
+\r
+       Double_t eMass = 0.511/1000; //mass in GeV\r
+       Double_t eleE = sqrt(track->P()*track->P() + eMass*eMass);\r
+       AliAODPWG4Particle tr = AliAODPWG4Particle(track->Px(),track->Py(),track->Pz(),eleE);\r
+       tr.SetLabel(tr.GetLabel());\r
+       tr.SetCaloLabel(clus->GetID(),-1); //sets the indices of the original caloclusters\r
+       tr.SetDetector(fCalorimeter);\r
+       tr.SetPdg(11);\r
+       \r
+       //Play with the MC stack if available\r
+       //Check origin of the candidates\r
+       if(IsDataMC()){\r
+         \r
+         //FIXME:  Need to re-think this for track-oriented analysis\r
+         tr.SetTag(GetMCAnalysisUtils()->CheckOrigin(clus->GetLabel(),GetMCStack()));\r
+         \r
+         if(GetDebug() > 0) printf("AliAnaElectron::MakeAnalysisFillAOD() - Origin of candidate %d\n",tr.GetTag());\r
+       }//Work with stack also   \r
+\r
+       AddAODParticle(tr);\r
+\r
+       if(GetDebug() > 1) printf("AliAnaElectron::MakeAnalysisFillAOD() - Electron selection cuts passed: pT %3.2f, pdg %d\n",tr.Pt(),tr.GetPdg());    \r
+      }//electron\r
+    }//pt, fiducial selection                                                                                  \r
+  }//track loop                         \r
+  \r
+  //FIXME:  Should we also check from the calocluster side, just in\r
+  //case?\r
+\r
+  if(GetDebug() > 1) printf("AliAnaElectron::MakeAnalysisFillAOD()  End fill AODs \n");  \r
+\r
+}\r
+\r
+//__________________________________________________________________\r
+void  AliAnaElectron::MakeAnalysisFillHistograms() \r
+{\r
+  //Do analysis and fill histograms\r
+  \r
+  //Loop on stored AOD electrons\r
+  Int_t naod = GetOutputAODBranch()->GetEntriesFast();\r
+  if(GetDebug() > 0) printf("AliAnaElectron::MakeAnalysisFillHistograms() - aod branch entries %d\n", naod);\r
+  \r
+  for(Int_t iaod = 0; iaod < naod ; iaod++){\r
+    AliAODPWG4Particle* ele =  (AliAODPWG4Particle*) (GetOutputAODBranch()->At(iaod));\r
+    Int_t pdg = ele->GetPdg();\r
+    \r
+    if(GetDebug() > 3) \r
+      printf("AliAnaElectron::MakeAnalysisFillHistograms() - PDG %d, MC TAG %d, Calorimeter %s\n", ele->GetPdg(),ele->GetTag(), (ele->GetDetector()).Data()) ;\r
+    \r
+    if(pdg != AliCaloPID::kElectron) continue; \r
+    if(ele->GetDetector() != fCalorimeter) continue;\r
+    \r
+    if(GetDebug() > 1) \r
+      printf("AliAnaElectron::MakeAnalysisFillHistograms() - ID Electron: pt %f, phi %f, eta %f\n", ele->Pt(),ele->Phi(),ele->Eta()) ;\r
+    \r
+    //Fill electron histograms \r
+    Float_t ptele = ele->Pt();\r
+    Float_t phiele = ele->Phi();\r
+    Float_t etaele = ele->Eta();\r
+    \r
+    fhPtElectron  ->Fill(ptele);\r
+    fhPhiElectron ->Fill(ptele,phiele);\r
+    fhEtaElectron ->Fill(ptele,etaele);\r
+    \r
+    if(IsDataMC()){\r
+      Int_t tag = ele->GetTag();\r
+      if(tag == AliMCAnalysisUtils::kMCConversion){\r
+       fhPtConversion  ->Fill(ptele);\r
+       fhPhiConversion ->Fill(ptele,phiele);\r
+       fhEtaConversion ->Fill(ptele,etaele);\r
+      }\r
+      else if(tag==AliMCAnalysisUtils::kMCEFromB)\r
+       {\r
+         fhPtBottom  ->Fill(ptele);\r
+         fhPhiBottom ->Fill(ptele,phiele);\r
+         fhEtaBottom ->Fill(ptele,etaele);\r
+       }\r
+      else if(tag==AliMCAnalysisUtils::kMCEFromC)\r
+       {\r
+         fhPtCharm  ->Fill(ptele);\r
+         fhPhiCharm ->Fill(ptele,phiele);\r
+         fhEtaCharm ->Fill(ptele,etaele);\r
+       }\r
+      else if(tag==AliMCAnalysisUtils::kMCEFromCFromB)\r
+       {\r
+         fhPtCFromB  ->Fill(ptele);\r
+         fhPhiCFromB ->Fill(ptele,phiele);\r
+         fhEtaCFromB ->Fill(ptele,etaele);\r
+       }\r
+      else if(tag==AliMCAnalysisUtils::kMCPi0Decay || tag==AliMCAnalysisUtils::kMCEtaDecay || tag==AliMCAnalysisUtils::kMCOtherDecay)\r
+       {\r
+         fhPtDalitz  ->Fill(ptele);\r
+         fhPhiDalitz ->Fill(ptele,phiele);\r
+         fhEtaDalitz ->Fill(ptele,etaele);\r
+       }\r
+      else if(tag==AliMCAnalysisUtils::kMCWDecay)\r
+       {\r
+         fhPtWDecay  ->Fill(ptele);\r
+         fhPhiWDecay ->Fill(ptele,phiele);\r
+         fhEtaWDecay ->Fill(ptele,etaele);\r
+       }\r
+      else if(tag==AliMCAnalysisUtils::kMCZDecay)\r
+       {\r
+         fhPtZDecay  ->Fill(ptele);\r
+         fhPhiZDecay ->Fill(ptele,phiele);\r
+         fhEtaZDecay ->Fill(ptele,etaele);\r
+       }\r
+      else if(tag==AliMCAnalysisUtils::kMCElectron)\r
+       {\r
+         fhPtPrompt  ->Fill(ptele);\r
+         fhPhiPrompt ->Fill(ptele,phiele);\r
+         fhEtaPrompt ->Fill(ptele,etaele);       \r
+       }\r
+      else{\r
+       fhPtUnknown  ->Fill(ptele);\r
+       fhPhiUnknown ->Fill(ptele,phiele);\r
+       fhEtaUnknown ->Fill(ptele,etaele);\r
+      }\r
+    }//Histograms with MC\r
+    \r
+  }// aod loop\r
+\r
+  ////////////////////////////////////////////////////////\r
+  //Fill histograms of pure MC kinematics from the stack//\r
+  ////////////////////////////////////////////////////////\r
+  if(IsDataMC()) {\r
+    AliStack * stack =  GetMCStack() ;\r
+\r
+    if(!stack)\r
+      printf("AliAnaElectron::MakeAnalysisFillHistograms() *** no stack ***: \n");\r
+\r
+    //FIXME:  Fill pure kine histograms here\r
+\r
+  }\r
+\r
+}\r
+\r
+\r
+//__________________________________________________________________\r
+void AliAnaElectron::Print(const Option_t * opt) const\r
+{\r
+  //Print some relevant parameters set for the analysis\r
+  \r
+  if(! opt)\r
+    return;\r
+  \r
+  printf("**** Print %s %s ****\n", GetName(), GetTitle() ) ;\r
+  AliAnaPartCorrBaseClass::Print(" ");\r
+\r
+  printf("Calorimeter            =     %s\n", fCalorimeter.Data()) ;\r
+  printf("pOverE range           =     %f - %f\n",fpOverEmin,fpOverEmax);\r
+  printf("residual cut           =     %f\n",fResidualCut);\r
+  printf("    \n") ;\r
+       \r
+} \r
+\r
+//________________________________________________________________________                          \r
+void AliAnaElectron::ReadHistograms(TList* outputList)\r
+{\r
+  // Needed when Terminate is executed in distributed environment                             \r
+  // Refill analysis histograms of this class with corresponding\r
+  // histograms in output list.   \r
+\r
+  // Histograms of this analsys are kept in the same list as other\r
+  // analysis, recover the position of\r
+  // the first one and then add the next                                                      \r
+  Int_t index = outputList->IndexOf(outputList->FindObject(GetAddedHistogramsStringToName()+"fh1pOverE"));\r
+\r
+  //Read histograms, must be in the same order as in\r
+  //GetCreateOutputObject.                   \r
+  fh1pOverE     = (TH1F *) outputList->At(index);\r
+  fh1dR         = (TH1F *) outputList->At(index++);\r
+  fh2EledEdx    = (TH2F *) outputList->At(index++);\r
+  fh2MatchdEdx  = (TH2F *) outputList->At(index++);\r
+  \r
+}\r
+\r
+//__________________________________________________________________                                \r
+void  AliAnaElectron::Terminate(TList* outputList)\r
+{\r
+\r
+  //Do some plots to end\r
+  //Recover histograms from output histograms list, needed for\r
+  //distributed analysis.                \r
+  //  ReadHistograms(outputList);\r
+\r
+  printf(" AliAnaElectron::Terminate()  *** %s Report:", GetName()) ;\r
+\r
+}\r
+\r
diff --git a/PWG4/PartCorrDep/AliAnaElectron.h b/PWG4/PartCorrDep/AliAnaElectron.h
new file mode 100755 (executable)
index 0000000..393b533
--- /dev/null
@@ -0,0 +1,177 @@
+#ifndef ALIANAELECTRON_H\r
+#define ALIANAELECTRON_H\r
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
+ * See cxx source for full Copyright notice     */\r
+/* $Id:  $ */\r
+\r
+//_________________________________________________________________________\r
+//\r
+// Class for the electron identification.\r
+// Clusters from EMCAL matched to tracks are selected \r
+// and kept in the AOD. Few histograms produced.\r
+//\r
+\r
+//-- Author: J.L. Klay (Cal Poly)\r
+\r
+// --- ROOT system ---\r
+class TH2F ;\r
+class TString ;\r
+\r
+// --- ANALYSIS system ---\r
+#include "AliAnaPartCorrBaseClass.h"\r
+\r
+class TList ;\r
+\r
+class AliAnaElectron : public AliAnaPartCorrBaseClass {\r
+\r
+public: \r
+\r
+  AliAnaElectron() ; // default ctor\r
+  AliAnaElectron(const AliAnaElectron & g) ; // cpy ctor\r
+  AliAnaElectron & operator = (const AliAnaElectron & g) ;//cpy assignment\r
+  virtual ~AliAnaElectron() ; //virtual dtor\r
+  \r
+  TList *  GetCreateOutputObjects();\r
+\r
+  void Init();\r
+\r
+  void MakeAnalysisFillAOD()  ;\r
+  \r
+  void MakeAnalysisFillHistograms() ; \r
+  \r
+  void Print(const Option_t * opt)const;\r
+  \r
+  TString GetCalorimeter()   const {return fCalorimeter ; }\r
+  Double_t GetpOverEmin()   const {return fpOverEmin ; }\r
+  Double_t GetpOverEmax()   const {return fpOverEmax ; }\r
+\r
+  void SetCalorimeter(TString det)    {fCalorimeter = det ; }\r
+  void SetpOverEmin(Double_t min)     {fpOverEmin = min ; }\r
+  void SetpOverEmax(Double_t max)     {fpOverEmax = max ; }\r
+  void SetResidualCut(Double_t cut)     {fResidualCut = cut ; }\r
+\r
+  void InitParameters();\r
+\r
+  void Terminate(TList * outputList);\r
+  void ReadHistograms(TList * outputList); //Fill histograms with\r
+                                          //histograms in ouput list,\r
+                                          //needed in Terminate.            \r
+\r
+  private:\r
+  TString  fCalorimeter;  //! Which detector? EMCAL or PHOS\r
+  Double_t fpOverEmin;    //! Minimum p/E value for Electrons\r
+  Double_t fpOverEmax;    //! Maximum p/E value for Electrons\r
+  Double_t fResidualCut;  //! Track-cluster matching distance\r
+\r
+  //matching checks   \r
+  TH1F *fh1pOverE;     //! p/E for track-cluster matches\r
+  TH1F *fh1dR;         //! distance between projected track and cluster\r
+  TH2F *fh2EledEdx;    //! dE/dx vs. momentum for electron candidates\r
+  TH2F *fh2MatchdEdx;  //! dE/dx vs. momentum for all matches\r
+  TH2F *fh2dEtadPhi;   //! DeltaEta vs. DeltaPhi of all track/cluster\r
+                      //! pairs\r
+  TH2F *fh2dEtadPhiMatched;   //! DeltaEta vs. DeltaPhi of matched\r
+                               //! track/cluster pairs\r
+  TH2F *fh2dEtadPhiUnmatched;   //! DeltaEta vs. DeltaPhi of unmatched track/cluster pairs\r
+  TH2F *fh2OuterPtVsExtrapPt;\r
+  TH2F *fh2OuterPhiVsExtrapPhi;\r
+  TH2F *fh2OuterEtaVsExtrapEta;\r
+\r
+  TH2F* fh2TrackPVsClusterE;\r
+  TH2F* fh2TrackPtVsClusterE;\r
+  TH2F* fh2TrackPhiVsClusterPhi;\r
+  TH2F* fh2TrackEtaVsClusterEta;\r
+\r
+  //Reconstructed\r
+  TH1F * fhPtElectron;  //! Number of identified electron vs transverse momentum \r
+  TH2F * fhPhiElectron; //! Azimuthal angle of identified  electron vs transverse momentum \r
+  TH2F * fhEtaElectron; //! Pseudorapidity of identified  electron vs tranvserse momentum \r
+\r
+  TH1F * fhPtConversion;  //! Number of conversion electron vs transverse momentum \r
+  TH2F * fhPhiConversion; //! Azimuthal angle of conversion  electron vs transverse momentum \r
+  TH2F * fhEtaConversion; //! Pseudorapidity of conversion electron vs tranvserse momentum \r
+\r
+  TH1F * fhPtBottom;  //! Number of bottom electron vs transverse momentum \r
+  TH2F * fhPhiBottom; //! Azimuthal angle of bottom  electron vs transverse momentum \r
+  TH2F * fhEtaBottom; //! Pseudorapidity of bottom electron vs tranvserse momentum \r
+\r
+  TH1F * fhPtCharm;  //! Number of charm electron vs transverse momentum \r
+  TH2F * fhPhiCharm; //! Azimuthal angle of charm  electron vs transverse momentum \r
+  TH2F * fhEtaCharm; //! Pseudorapidity of charm electron vs tranvserse momentum \r
+\r
+  TH1F * fhPtCFromB;  //! Number of charm from bottom electron vs transverse momentum \r
+  TH2F * fhPhiCFromB; //! Azimuthal angle of charm from bottom electron vs transverse momentum \r
+  TH2F * fhEtaCFromB; //! Pseudorapidity of charm from bottom electron vs tranvserse momentum \r
+\r
+  TH1F * fhPtDalitz;  //! Number of dalitz electron vs transverse momentum \r
+  TH2F * fhPhiDalitz; //! Azimuthal angle of dalitz  electron vs transverse momentum \r
+  TH2F * fhEtaDalitz; //! Pseudorapidity of dalitz electron vs tranvserse momentum \r
+\r
+  TH1F * fhPtWDecay;  //! Number of W-boson electron vs transverse momentum \r
+  TH2F * fhPhiWDecay; //! Azimuthal angle of W-boson  electron vs transverse momentum \r
+  TH2F * fhEtaWDecay; //! Pseudorapidity of W-boson electron vs tranvserse momentum \r
+               \r
+  TH1F * fhPtZDecay;  //! Number of Z-boson electron vs transverse momentum \r
+  TH2F * fhPhiZDecay; //! Azimuthal angle of Z-boson  electron vs transverse momentum \r
+  TH2F * fhEtaZDecay; //! Pseudorapidity of Z-boson electron vs tranvserse momentum \r
+\r
+  TH1F * fhPtPrompt;  //! Number of prompt electron vs transverse momentum \r
+  TH2F * fhPhiPrompt; //! Azimuthal angle of prompt  electron vs transverse momentum \r
+  TH2F * fhEtaPrompt; //! Pseudorapidity of prompt electron vs tranvserse momentum \r
+\r
+  TH1F * fhPtUnknown;  //! Number of unknown electron vs transverse momentum \r
+  TH2F * fhPhiUnknown; //! Azimuthal angle of unknown  electron vs transverse momentum \r
+  TH2F * fhEtaUnknown; //! Pseudorapidity of unknown electron vs tranvserse momentum \r
+\r
+  /*\r
+  //MC\r
+  TH1F * fhMCPtElectron;   //! pT of MC electrons \r
+  TH2F * fhMCPhiElectron;  //! Phi of MC electrons\r
+  TH2F * fhMCEtaElectron;  //! eta of MC electrons\r
+\r
+  TH1F * fhMCPtConversion;  //! Number of TRACKABLE MC conversion electron vs transverse momentum \r
+  TH2F * fhMCPhiConversion; //! Azimuthal angle of TRACKABLE MC conversion  electron vs transverse momentum \r
+  TH2F * fhMCEtaConversion; //! Pseudorapidity of TRACKABLE MC conversion electron vs tranvserse momentum \r
+\r
+  TH1F * fhMCPtBottom;  //! Number of MC bottom electron vs transverse momentum \r
+  TH2F * fhMCPhiBottom; //! Azimuthal angle of MC bottom  electron vs transverse momentum \r
+  TH2F * fhMCEtaBottom; //! Pseudorapidity of MC bottom electron vs tranvserse momentum \r
+\r
+  TH1F * fhMCPtCharm;  //! Number of MC charm electron vs transverse momentum \r
+  TH2F * fhMCPhiCharm; //! Azimuthal angle of MC charm  electron vs transverse momentum \r
+  TH2F * fhMCEtaCharm; //! Pseudorapidity of MC charm electron vs tranvserse momentum \r
+\r
+  TH1F * fhMCPtCFromB;  //! Number of MC charm from bottom electron vs transverse momentum \r
+  TH2F * fhMCPhiCFromB; //! Azimuthal angle of MC charm from bottom electron vs transverse momentum\r
+  TH2F * fhMCEtaCFromB; //! Pseudorapidity of MC charm from bottom electron vs tranvserse momentum \r
+\r
+  TH1F * fhMCPtDalitz;  //! Number of MC dalitz electron vs transverse momentum \r
+  TH2F * fhMCPhiDalitz; //! Azimuthal angle of MC dalitz  electron vs transverse momentum \r
+  TH2F * fhMCEtaDalitz; //! Pseudorapidity of MC dalitz electron vs tranvserse momentum \r
+\r
+  TH1F * fhMCPtWDecay;  //! Number of MC W-boson electron vs transverse momentum \r
+  TH2F * fhMCPhiWDecay; //! Azimuthal angle of MC W-boson  electron vs transverse momentum \r
+  TH2F * fhMCEtaWDecay; //! Pseudorapidity of MC W-boson electron vs tranvserse momentum \r
+               \r
+  TH1F * fhMCPtZDecay;  //! Number of MC Z-boson electron vs transverse momentum \r
+  TH2F * fhMCPhiZDecay; //! Azimuthal angle of MC Z-boson  electron vs transverse momentum \r
+  TH2F * fhMCEtaZDecay; //! Pseudorapidity of MC Z-boson electron vs tranvserse momentum \r
+\r
+  TH1F * fhMCPtPrompt;  //! Number of prompt MC electron vs transverse momentum \r
+  TH2F * fhMCPhiPrompt; //! Azimuthal angle of prompt MC electron vs transverse momentum \r
+  TH2F * fhMCEtaPrompt; //! Pseudorapidity of prompt MC electron vs tranvserse momentum \r
+\r
+  TH1F * fhMCPtUnknown;  //! Number of unknown MC electron vs transverse momentum \r
+  TH2F * fhMCPhiUnknown; //! Azimuthal angle of unknown MC electron vs transverse momentum \r
+  TH2F * fhMCEtaUnknown; //! Pseudorapidity of unknown MC electron vs tranvserse momentum \r
+  */\r
+\r
+  ClassDef(AliAnaElectron,1)\r
+\r
+} ;\r
\r
+\r
+#endif//ALIANAELECTRON_H\r
+\r
+\r
+\r
index 97ca656939c537edf086651a0e7a828f4953153f..615b984982b14d83ae7387dbf38ac645bb3630b7 100755 (executable)
@@ -9,7 +9,8 @@ SRCS = PartCorrDep/AliAnaCaloTrigger.cxx \
        PartCorrDep/AliAnaParticleJetLeadingConeCorrelation.cxx \
        PartCorrDep/AliAnaPhoton.cxx PartCorrDep/AliAnaPi0.cxx  \
        PartCorrDep/AliAnaPi0EbE.cxx PartCorrDep/AliAnaChargedParticles.cxx \
        PartCorrDep/AliAnaParticleJetLeadingConeCorrelation.cxx \
        PartCorrDep/AliAnaPhoton.cxx PartCorrDep/AliAnaPi0.cxx  \
        PartCorrDep/AliAnaPi0EbE.cxx PartCorrDep/AliAnaChargedParticles.cxx \
-       PartCorrDep/AliAnaCalorimeterQA.cxx PartCorrDep/AliAnaNeutralMeson.cxx
+       PartCorrDep/AliAnaCalorimeterQA.cxx PartCorrDep/AliAnaNeutralMeson.cxx \
+       PartCorrDep/AliAnaElectron.cxx
 
 HDRS:= $(SRCS:.cxx=.h) 
 
 
 HDRS:= $(SRCS:.cxx=.h) 
 
diff --git a/PWG4/macros/electrons/ConfigAnalysisElectron.C b/PWG4/macros/electrons/ConfigAnalysisElectron.C
new file mode 100644 (file)
index 0000000..832e292
--- /dev/null
@@ -0,0 +1,89 @@
+/* $Id: $ */\r
+/* $Log$ */\r
+\r
+//------------------------------------\r
+// Configuration macro example:\r
+//\r
+// Do EMCal electron analysis with ESDs\r
+//\r
+//------------------------------------\r
+\r
+AliAnaPartCorrMaker*  ConfigAnalysis()\r
+{\r
+       //\r
+       // Configuration goes here\r
+       // \r
+       printf("======================== \n");\r
+       printf("ConfigAnalysisElectron() \n");\r
+       printf("======================== \n");\r
+       \r
+       \r
+       //Detector Fidutial Cuts\r
+       //AliFidutialCut * fidCut = new AliFidutialCut();\r
+       //fidCut->DoEMCALFidutialCut(kTRUE) ;\r
+       \r
+       //fidCut->SetSimpleEMCALFidutialCut(0.7,80.,190.);\r
+       \r
+       //fidCut->Print("");\r
+       \r
+       \r
+       //-----------------------------------------------------------  \r
+       // Reader\r
+       //-----------------------------------------------------------\r
+       AliCaloTrackESDReader *reader = new AliCaloTrackESDReader();\r
+       reader->SetDebug(10);//10 for lots of messages\r
+       \r
+       //Switch on or off the detectors information that you want\r
+       reader->SwitchOffCTS();\r
+       reader->SwitchOffEMCAL();\r
+       reader->SwitchOffEMCALCells();  \r
+       reader->SwitchOffPHOS();\r
+       reader->SwitchOffPHOSCells();   \r
+       //Min particle pT\r
+       //reader->SetEMCALPtMin(1.); \r
+       \r
+       //reader->SetFidutialCut(fidCut);\r
+       reader->Print("");\r
+       \r
+       \r
+       //---------------------------------------------------------------------\r
+       // Analysis algorithm\r
+       //---------------------------------------------------------------------\r
+       \r
+       AliAnaElectron *anaelectron = new AliAnaElectron();\r
+       anaelectron->SetDebug(10); //10 for lots of messages\r
+       anaelectron->SetCalorimeter("EMCAL");\r
+       anaelectron->SetpOverEmin(0.8);\r
+       anaelectron->SetpOverEmax(1.2);\r
+       anaelectron->SetResidualCut(0.05);\r
+       anaelectron->SwitchOnDataMC();\r
+       anaelectron->SetMinPt(1.);\r
+       //Set Histrograms bins and ranges\r
+       anaelectron->SetHistoPtRangeAndNBins(0, 50, 100) ;\r
+       anaelectron->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;\r
+       anaelectron->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ; anaelectron->Print("");\r
+       \r
+       //Detector Fidutial Cuts\r
+       AliFidutialCut * fidCut2 = new AliFidutialCut();\r
+       fidCut2->DoEMCALFidutialCut(kTRUE) ;\r
+       fidCut2->SetSimpleEMCALFidutialCut(0.7,80.,190.);\r
+       fidCut2->Print("");\r
+               \r
+       \r
+       //---------------------------------------------------------------------\r
+       // Set  analysis algorithm and reader\r
+       //---------------------------------------------------------------------\r
+       maker = new AliAnaPartCorrMaker();\r
+       maker->SetReader(reader);//pointer to reader\r
+       maker->AddAnalysis(anaelectron,0);\r
+       maker->SetAnaDebug(10)  ;\r
+       maker->SwitchOnHistogramsMaker()  ;\r
+       //maker->SwitchOnAODsMaker()  ;\r
+       \r
+       maker->Print("");\r
+       //\r
+       printf("======================== \n");\r
+       printf("END ConfigAnalysisElectron() \n");\r
+       printf("======================== \n");\r
+       return maker ;\r
+}\r
diff --git a/PWG4/macros/electrons/GetProofLogs.C b/PWG4/macros/electrons/GetProofLogs.C
new file mode 100644 (file)
index 0000000..dc4d431
--- /dev/null
@@ -0,0 +1,7 @@
+{
+ gEnv->SetValue("XSec.GSI.DelegProxy","2");
+ logs=TProof::Mgr("kread@localhost")->GetSessionLogs(0);
+ logs->Display();
+ //logs->Grep("segmentation violation");
+ logs->Save("*","logs.txt");
+}
diff --git a/PWG4/macros/electrons/README b/PWG4/macros/electrons/README
new file mode 100644 (file)
index 0000000..1516630
--- /dev/null
@@ -0,0 +1,538 @@
+29 May 2009
+
+This is a grand unified example of the ALICE Analysis Framework for
+EMCal analysis on Local, Local CAF, PROOF, GRID interactive, GRID
+batch, and AliEn PLUGIN.
+
+Notice: Everything is working today. Really!
+
+
+---------------------------------------------------------------------
+
+PAR files
+
+You can skip this PAR section for your first use of the example if you
+just want to see how things work. The PAR files in the example were
+built with ROOT v5-23-04 and AliRoot v4-16-Rev-11. See VM20090529.pdf
+file with updated build instructions for ROOT v5-23-04 and AliROOT
+v4-16-Rev-11. If you have write access to $ALICE_ROOT, you can install
+AliAnalysisTaskElectron.cxx and make a new PAR file as follows:
+
+edit $ALICE_ROOT/PWG4/PWG4PartCorrLinkDef.h to include AliAnalysisTaskElectron
+edit $ALICE_ROOT/PWG4/libPWG4PartCorr.pkg to include AliAnalysisTaskElectron
+edit $ALICE_ROOT/PWG4/CMake_libPWG4PartCorr.txt to include AliAnalysisTaskElectron
+cp <yourlocalarea>/AliAnalysisTaskElectron.cxx $ALICE_ROOT/PWG4/PartCorr
+cp <yourlocalarea>/AliAnalysisTaskElectron.h   $ALICE_ROOT/PWG4/PartCorr
+
+cd $ALICE_ROOT
+make
+make PWG4PartCorr.par
+mv PWG4PartCorr.par <your workarea>
+
+
+---------------------------------------------------------------------
+
+local usage (your laptop, workstation, PDSF account, etc.):
+
+For PDSF:
+ssh -X <username>@pdsf.nersc.gov
+cp ~kread/.chos $HOME/.chos (to invoke SciLinux 4.4)
+logout and log back in
+source /project/projectdirs/alice/alisetup.csh
+
+All of the files at /afs/cern.ch/user/k/kread/public/all/v416 need to be
+copied to your local workarea (except for README and PDF files).
+
+If not at PDSF, need a valid local matching ROOT and AliROOT installation. 
+(See /afs/cern.ch/user/k/kread/public/all/v416/VM20090529.pdf)
+
+cd <yourworkarea>
+
+Change this line in anaElectron.C to point to your local AliESDs.root
+data files:
+char * kInDir = "/afs/cern.ch/user/k/kread/PWG4/data/"
+
+root -b
+.L anaElectron.C
+anaElectron(0,"ConfigAnalysisElectron")
+.q
+
+
+---------------------------------------------------------------------
+
+CAF local usage (including for files on GRID):
+
+All of the files at /afs/cern.ch/user/k/kread/public/all/v416 need to be
+copied to your local workarea.
+
+Your valid public and private keys need to be properly located in
+/afs/cern.ch/user/<username>/.globus.
+
+ssh -X <username>@lxplus.cern.sh
+cd <yourworkarea>
+bash
+source /afs/cern.ch/alice/caf/caf-lxplus.sh -alien v4-16-Release 
+enter GRID password
+
+Edit ESDlist.txt to point to the location of your AliESDs.root files
+(including those on the GRID).
+
+root -b
+.L anaElectron.C
+anaElectron(1,"ConfigAnalysisElectron")
+.q
+
+
+---------------------------------------------------------------------
+
+PROOF usage within CERN:
+
+All of the files at /afs/cern.ch/user/k/kread/public/all/v416 need to be
+copied to your local workarea.
+
+The lines in anaElectron.C to need to look like this (which is the default):
+    char* myproofname = "alicecaf";
+    //char* myproofname = "kread@localhost";
+
+
+Your valid public and private keys need to be properly located in
+$HOME/.globus.
+
+ssh -X <username>@lxplus.cern.sh (or other computer at CERN)
+cd <yourworkarea>
+bash
+
+You need a valid matching local ROOT and AliROOT installation with ROOT
+v5-23-04 or higher.  (See
+/afs/cern.ch/user/k/kread/public/all/v416/VM20090529.pdf if necessary.)
+For instance:
+source /afs/cern.ch/alice/caf/caf-lxplus.sh -alien v4-16-Release
+enter GRID password
+
+Edit this line in anaElectron.C to point to the appropriate CAF
+dataset:
+char * kmydataset = "/COMMON/COMMON/LHC09a4_run8101X"
+
+To access files in AliEN, first type
+root -b
+gEnv->SetValue("XSec.GSI.DelegProxy","2")
+
+root -b
+.L anaElectron.C
+anaElectron(2,"ConfigAnalysisElectron")
+.q
+
+For instructions concerning how to stage data files to CAF and how
+to inspect what data is already staged, see:
+http://aliceinfo.cern.ch/Offline/Activities/Analysis/CAF/index.html
+
+If you do not use the provided PAR files, then you will need to add
+the following lines at the beginning of
+AliAnalysisTaskElectron::Terminate in AliAnalysisTaskElectron.cxx,
+
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (mgr->GetAnalysisType()==AliAnalysisManager::kProofAnalysis) return;
+
+These lines work for all modes of anaElectron.cxx. So, you can install
+a revised version of AliAnalysisTaskElectron.cxx at $ALICE_ROOT/PWG4/PartCorr .
+
+---------------------------------------------------------------------
+
+remote PROOF usage (not at CERN):
+
+This is a GREAT feature, but you will need a local installation with
+ROOT v5-23-04 built with --globus, AliROOT v4-16-Rev-nn, and probably
+write-access to $ALICE_ROOT. 
+(See /afs/cern.ch/user/k/kread/public/all/v416/VM20090529.pdf. Remote
+PROOF access is not possible without at least ROOT v5-23-02b.)  This
+requires some understanding of PAR file manipulation.  If you have
+already been using the example, first type this and be sure not to do it
+in the $ALICE_ROOT area:
+
+cd <your workarea>
+/bin/rm -rf ANALYSIS ANALYSISalice AOD ESD STEERBase PWG4PartCorr
+
+All of the files at /afs/cern.ch/user/k/kread/public/all/v416 need to
+be copied to your local workarea.  You should only have the (provided)
+PAR file versions (not untarred versions) of the AliRoot
+subdirectories present in your workarea.
+
+Modify these lines in anaElectron.C to look like this, replacing
+"kread" with your lxplus.cern.ch username:
+    //char* myproofname = "alicecaf";
+    char* myproofname = "kread@localhost";
+
+Your valid public and private keys need to be properly located in
+$HOME/.globus.
+
+ssh -L 1093:alicecaf.cern.ch:1093 -fN <username>@lxplus.cern.ch
+bash
+alien-token-init
+
+enter GRID password
+source /tmp/gclient_env_$UID
+export alien_CLOSE_SE="ALICE::CNAF::SE"
+export XrdSecGSISRVNAMES="lxfsrd0506.cern.ch"
+
+Edit this line in anaElectron.C to point to the appropriate CAF
+dataset:
+char * kmydataset = "/COMMON/COMMON/LHC09a4_run8101X"
+
+root -b
+.L anaElectron.C
+anaElectron(2,"ConfigAnalysisElectron")
+.q
+
+For instructions concerning how to stage data files to CAF and how
+to inspect what data is already staged, see:
+http://aliceinfo.cern.ch/Offline/Activities/Analysis/CAF/index.html .
+
+The macro will create PAR files in $HOME/.proof/packages.  If you have
+trouble you can look at what is there and also uncomment appropriate
+lines in anaElectron.C to ClearPackages.
+
+You can see PROOF slave log files by creating a file GetProofLogs.C with these
+lines:
+{
+ gEnv->SetValue("XSec.GSI.DelegProxy","2");
+ logs=TProof::Mgr("kread@localhost")->GetSessionLogs(0);
+ logs->Display();
+ //logs->Grep("segmentation violation");
+ logs->Save("*","logs.txt");
+}
+
+and then relaunching root and typing:
+
+root -b
+.x GetProofLogs.C
+
+
+If you do not use the provided PAR files, then you will need to add
+the following lines at the beginning of
+AliAnalysisTaskElectron::Terminate in AliAnalysisTaskElectron.cxx,
+
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (mgr->GetAnalysisType()==AliAnalysisManager::kProofAnalysis) return;
+
+These lines work for all modes of anaElectron.cxx. So, you can install
+a revised version of AliAnalysisTaskElectron.cxx at $ALICE_ROOT/PWG4/PartCorr .
+
+---------------------------------------------------------------------
+
+GRID usage:
+
+Copy all of the files at /afs/cern.ch/user/k/kread/public/all/v416 to your
+local workarea.
+
+Change all instances of username "kread" and to your username in
+anaElectron.jdl and mergeElectron.jdl.  Change email address in
+mergeElectron.jdl.  There is no need to change the jobid number inside
+mergeElectron.jdl.
+
+Need a valid local ROOT installation built with --enable-globus.
+Need a valid local alien grid shell installed.
+(If running locally and not at PDSF or lxplus, see
+/afs/cern.ch/user/k/kread/public/all/v416/VM20090529.pdf.)
+
+Your valid public and private keys need to be properly located in
+$HOME/.globus.
+
+bash
+alien-token-init
+enter GRID password
+source /tmp/gclient_env_$UID
+export alien_CLOSE_SE="ALICE::CNAF::SE"
+
+cd <local workarea>
+aliensh (to get to GRID home directory)
+
+Make the following directories (if not done already):
+cd $HOME
+mkdir bin
+mkdir work3
+mkdir work3/output
+mkdir work3/output/merge
+
+Need to upload files (including par and jdl files) to GRID.
+
+Can use:
+cp file:yourlocalfile.ext gridfile.ext (being sure to spell out the GRID
+file name.)
+Do not try:
+cp file:yourlocalfile.ext .
+
+Or, exit from aliensh and type locally:
+alien_cp localfile.ext alien://alice/cern.ch/user/<first-initial>/<username>/work3/gridfile.ext
+
+Do not try to skip the complete GRID file name like this:
+alien_cp localfile.ext alien://alice/cern.ch/user/<first-initial>/<username>/work3/
+
+anaElectron.sh needs to be uploaded to the GRID to $HOME/bin.
+anaElectron.sh sets the mode to GRID.
+
+To launch job:
+aliensh
+cd $HOME/work3
+submit anaElectron.jdl
+
+To change input data.
+aliensh
+cd $HOME/work3
+rm mycollect.xml (need to remove before uploading new version)
+Use the desired run number and pattern in the find command, perhaps using the -l switch:
+find -x mycollect /alice/sim/PDC_08b/LHC08d8/30009/0* AliESDs.root > mycollect.xml
+or
+find -x mycollect -l 200 /alice/sim/PDC_08b/LHC08d9/40010/* AliESDs.root > mycollect.xml
+exit
+alien_cp mycollect.xml alien://alice/cern.ch/user/<first-initial>/<username>/work3/mycollect.xml
+
+Then, relaunch.
+
+To monitor grid job:
+aliensh
+ps
+ps -trace <jobid>
+spy <jobid> stdout
+spy <jobid> stderr
+spy <jobid> anaElectron.log
+
+If job fails with status E or EV, then to obtain stdout and other output type:
+registerOutput <jobid>
+
+Available GRID productions monitored via MonaLisa are listed here:
+http://pcalimonitor.cern.ch/job_details.jsp
+
+The choice of $alien_CLOSE_SE is very important.  You can see the status of ALICE grid
+storage elements here:
+
+http://pcalimonitor.cern.ch/stats?page=SE/table
+
+
+---------------------------------------------------------------------
+
+Plugin usage:
+
+Copy all of the files at /afs/cern.ch/user/k/kread/public/all/v416 to your
+local workarea.
+
+Change all instances of username "kread" to your username in
+anaElectron.jdl and mergeElectron.jdl.  Change email address in
+mergeElectron.jdl.  There is no need to change the jobid number inside
+mergeElectron.jdl.
+
+Need a valid local ROOT installation built with --enable-globus.
+Need a valid local alien grid shell installed.
+(If running locally and not at PDSF or lxplus, see
+/afs/cern.ch/user/k/kread/public/all/v416/VM20090529.pdf.)
+
+Your valid public and private keys need to be properly located in
+$HOME/.globus.
+
+bash
+alien-token-init
+enter GRID password
+source /tmp/gclient_env_$UID
+export alien_CLOSE_SE="ALICE::CNAF::SE"
+
+Copy new xml file manually to AliEn (after deleting any existing copy in $HOME/work3) by typing
+alien_cp mycollect.xml alien://alice/cern.ch/user/<first-initial>/<username>/work3/mycollect.xml
+
+
+cd <local workarea>
+root -b
+.L anaElectron.C
+anaElectron(4,"ConfigAnalysisElectron")
+.q
+
+Ignore warning messages from plugin about missing myAnalysis.C and
+analysis.root which are not needed here.
+
+Files should be automatically uploaded to grid and job launched.
+aliensh is launched in order to monitor job.  Exiting aliensh after
+jobs are done will automatically invoke merge and copy merged output
+histograms to local workarea.
+
+Note that above we interactively submit the plugin job using mode=4.
+However, do not change the mode to 4 inside the file anaElectron.sh
+which is executed on each GRID compute node.  That needs to remain
+mode=3 (GRID).
+
+See GRID usage section above for more about copying to/from GRID and
+monitoring jobs.
+Make directories on the GRID (if not done already) as follows:
+
+aliensh
+cd $HOME
+mkdir bin
+mkdir work3
+mkdir work3/output
+mkdir work3/output/merge
+exit
+
+
+---------------------------------------------------------------------
+
+GRID via AliEn plugin for simpler macro
+
+An earlier, simpler, separate stand-alone example of EMCal analysis
+with the AliEn plugin is presently available at
+/afs/cern.ch/user/k/kread/public/plugin.
+
+Copy the tar file to your local workarea.
+Untar the file.
+tar -xvf plugin-example.tar
+
+Need a valid local ROOT installation built with --enable-globus.
+Need a valid local alien grid shell installed.
+(If running locally and not at PDSF or lxplus, see
+/afs/cern.ch/user/k/kread/public/all/v416/VM20090529.pdf.)
+
+Your valid public and private keys need to be properly located in
+$HOME/.globus.
+
+bash
+alien-token-init
+enter GRID password
+source /tmp/gclient_env_$UID
+export alien_CLOSE_SE="ALICE::CNAF::SE"
+
+cd <local workarea>
+root -b
+.x runGrid.C
+.q
+
+Edit CreateAlienHandler.C to select different input data available on GRID.
+See GRID section above for more about copying to/from GRID and monitoring jobs.
+1 June 2009
+
+These are the instructions for the anaElctron helper macro when used
+with AliRoot v4-17. All of the v416 files and instructions (located at
+/afs/cern.ch/user/k/kread/public/all/v416) are appropriate for use
+with AliRoot v4-17 except for the following which are different:
+
+anaElectron.C, anaElectron.jdl, and all of the *.par files.
+
+The PAR files in this subdirectory were built using ROOT v5-23-04 and
+AliRoot v4-17-03.
+
+The warnings about input and output containers being automatically created are
+normal.
+
+For remote PROOF, follow the usual instructions but set up two tunnels:
+ssh -L 1093:alicecaf.cern.ch:1093 -fN <username>@lxplus.cern.ch
+ssh -L 11094:alicecaf.cern.ch:11094 -fN <username>@lxplus.cern.ch
+
+As usual, for PROOF, if you don't use these PAR files, then you will need
+to add these lines at the beginning of AliAnalysisTaskElectron::Terminate in
+AliAnalysisTaskElectron.cxx:
+
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (mgr->GetAnalysisType()==AliAnalysisManager::kProofAnalysis) return;
+
+To build PWG4PartCorrDep.par:
+
+copy AliAnalysisTaskElectron.cxx and AliAnalysisTaskElectron.h to $ALICE_ROOT/PWG4/PartCorrDep
+edit $ALICE_ROOT/PWG4/PWG4PartCorrDepLinkDef.h to include AliAnalysisTaskElectron
+edit $ALICE_ROOT/PWG4/libPWG4PartCorrDep.pkg to include AliAnalysisTaskElectron
+edit $ALICE_ROOT/PWG4/CMake_libPWG4PartCorrDep.txt to include AliAnalysisTaskElectron
+
+For PLUGIN mode, we have to work around a new small bug in the AliEn
+plugin for v4-17-03.  Please, ignore the fact that an irrelevant xml
+file (30010.xml) is generated for PLUGIN mode and uploaded to the
+grid.  This satisfies some (uneccesary) requirements in the plugin for
+this release and will be fixed in the future.
+June 2009
+
+mylauncher.C is a robust file upload and grid submit helper.  Just
+edit the first few lines (after, of course, defining alien_CLOSE_SE
+and doing alien-token-init).  Adjust it as needed and you may
+prefer it to the plugin.  Even for manual grid submitters, it
+can really simplify uploading and make it more robust.
+
+The environment variable alien_CLOSE_SE needs to be defined locally,
+and be defined BEFORE you do alien-token-init.  (I will change the
+other READMEs to reflect this.) Then, and only then, you will find
+that it is listed in /tmp/gclient_env_$UID.  It needs to be there in
+order to be defined later within aliensh.  Within aliensh you can see if
+things are OK by typing echo $alien_CLOSE_SE.  And, of course, outside
+of aliensh, you can type echo $alien_CLOSE_SE.
+
+My recommendation to enforce this is either to put 
+export alien_CLOSE_SE="ALICE::CNAF::SE"
+
+in your login profile or initial setup script or to make the following local alias:
+
+alias myaliti='export alien_CLOSE_SE="ALICE::CNAF::SE";alien-token-init'
+
+For tcsh/csh, that would of course be
+
+alias myaliti 'setenv alien_CLOSE_SE "ALICE::CNAF::SE";alien-token-init'
+
+Then, by just typing "myaliti" (which means my alien token init),
+everything will be OK concerning alien_CLOSE_SE and you will never forget
+to set it.
+
+Next, people who use bash will continue to type "source
+/tmp/glient_env_$uid" after typing myaliti.
+
+However, they can to this in their login files 
+
+alias myalige='source /tmp/gclient_env_$UID'
+
+(That stands for my alien globus environment.)
+
+Then, they just always type
+
+myaliti
+myalige
+
+Tcsh/csh users never even need to type "bash" (since they can't source
+that bash file in the /tmp area) if they do the following.
+
+1. Prepare a new file in your util subdirectory and call it
+$HOME/util/gclient_env.csh.  It should be just like
+/tmp/gclient_env_$uid, except remove all the equal signs and change
+the word export to setenv everywhere. You only need to do that once.
+And you need to make two changes in the new file:
+
+a. Comment out one line and let the myaliti alias do it:
+#setenv alien_CLOSE_SE "ALICE::CNAF::SE"
+
+b. Replace the corresponding line about the volatile GBBOX_ENVFILE with this sed magic:
+
+setenv GBBOX_ENVFILE `grep ENVFILE /tmp/gclient_env_$uid | sed s/"export GBBOX_ENVFILE="/""/`
+
+
+2. Then, define:
+
+alias myalige 'source $HOME/util/gclient_env.csh'
+
+So, these users never need to type "bash", but also just always type
+
+myaliti 
+myalige
+
+
+The symmetry of myaliti, myalige is why I didn't put alien_CLOSE_SE
+in my login script.  By defining myaliti1, myaliti2, ... myaliti5
+with different, favored SE's in advance, then based on varying storage
+element health you can type
+
+myaliti3  (or 4 or 5 or whatever is best, and avoid mis-typing)
+myalige
+
+I like that.
+
+Next, note that interactive copying to your alien space does not allow
+graceful overwriting.  You need to delete any existing copy of a
+desired file before you copy a new one to the grid with that name.
+(mylauncher.C detects this and does it automatically.)
+
+
+
+--------------------------------------------------
+
+Note that mylauncher.C opens the way to arbitrary file upload,
+download, and copy, and multiple simultaneous, coordinated submits.
+That could be useful for systematic analyses involving scores or
+hundreds of jobs.
diff --git a/PWG4/macros/electrons/anaElectron.C b/PWG4/macros/electrons/anaElectron.C
new file mode 100644 (file)
index 0000000..9dfc290
--- /dev/null
@@ -0,0 +1,535 @@
+/* $Id:  $ */\r
+//--------------------------------------------------\r
+// Example macro to do analysis with the \r
+// analysis classes in PWG4PartCorr\r
+// Can be executed with Root and AliRoot\r
+//\r
+// Pay attention to the options and definitions\r
+// set in the lines below\r
+//\r
+//  Author : Gustavo Conesa Balbastre (INFN-LNF)\r
+//  Modifications by K. Read\r
+//\r
+//-------------------------------------------------\r
+enum anaModes {mLocal, mLocalCAF, mPROOF, mGRID, mPLUGIN};\r
+//mLocal    = 0: Analyze locally files in your computer\r
+//mLocalCAF = 1: Analyze locally CAF files\r
+//mPROOF    = 2: Analyze CAF files with PROOF\r
+//mGRID     = 3: Analyze files on GRID\r
+//mPLUGIN   = 4: Analyze files on GRID with AliEn plugin\r
+\r
+//---------------------------------------------------------------------------\r
+//Settings to read locally several files, only for "mLocal" mode\r
+//The different values are default, they can be set with environmental \r
+//variables: INDIR, PATTERN, NEVENT, respectively\r
+//NOTE:  Must be absolute path.  Relative paths don't seem to work\r
+char * kInDir = "/Users/jklay/Projects/LHC/alice/work/ppr/PWG4/v417/data"; \r
+//char * kInDir = "/work/jobs/public/data/"; \r
+char * kPattern = ""; // Data are in files kInDir/kPattern+i \r
+Int_t kFile = 4; // Number of files\r
+//---------------------------------------------------------------------------\r
+//Collection file for grid analysis\r
+char * kXML = "collection.xml";\r
+//---------------------------------------------------------------------------\r
+//Data directory for PROOF analysis\r
+char * kmydataset = "/PWG4/mcosenti/LHC08d10_ppElectronB_Jets#esdTree";\r
+//char * kmydataset = "/COMMON/COMMON/LHC09a4_run8101X";\r
+//---------------------------------------------------------------------------\r
+//Scale histograms from file. Change to kTRUE when xsection file exists\r
+//Put name of file containing xsection \r
+//Put number of events per ESD file\r
+//This is an specific case for normalization of Pythia files.\r
+const Bool_t kGetXSectionFromFileAndScale = kFALSE ;\r
+const char * kXSFileName = "pyxsec.root";\r
+const Int_t kNumberOfEventsPerFile = 100; \r
+//---------------------------------------------------------------------------\r
+\r
+const Bool_t kMC = kTRUE; //With real data kMC = kFALSE\r
+const TString kInputData = "ESD";//ESD, AOD, MC\r
+TString kTreeName = "esdTree";\r
+\r
+void anaElectron(Int_t mode=mLocal, TString configName = "ConfigAnalysisElectron")\r
+{\r
+  // Main\r
+\r
+  //--------------------------------------------------------------------\r
+  // Load analysis libraries\r
+  // Look at the method below, \r
+  // change whatever you need for your analysis case\r
+  // ------------------------------------------------------------------\r
+  LoadLibraries(mode) ;\r
+  \r
+  //-------------------------------------------------------------------------------------------------\r
+  //Create chain from ESD and from cross sections files, look below for options.\r
+  //------------------------------------------------------------------------------------------------- \r
+  if(kInputData == "ESD") kTreeName = "esdTree" ;\r
+  else if(kInputData == "AOD") kTreeName = "aodTree" ;\r
+  else if (kInputData == "MC") kTreeName = "TE" ;\r
+  else {\r
+    cout<<"Wrong  data type "<<kInputData<<endl;\r
+    break;\r
+  }\r
+\r
+  TChain *chain   = new TChain(kTreeName) ;\r
+  TChain * chainxs = new TChain("Xsection") ;\r
+\r
+  if (mode==mLocal || mode==mLocalCAF || mode == mGRID) {\r
+    CreateChain(mode, chain, chainxs);  \r
+  }\r
+\r
+  if( chain || mode==mPROOF || mode==mPLUGIN ){\r
+    //AliLog::SetGlobalLogLevel(AliLog::kError);//Minimum prints on screen\r
+    \r
+    //--------------------------------------\r
+    // Make the analysis manager\r
+    //-------------------------------------\r
+    AliAnalysisManager *mgr  = new AliAnalysisManager("Manager", "Manager");\r
+\r
+    if( mode == mPLUGIN ){\r
+      // Create and configure the alien handler plugin\r
+      if (!AliAnalysisGrid::CreateToken()) return NULL;\r
+      AliAnalysisAlien *plugin = new AliAnalysisAlien();\r
+      plugin->SetRunMode("submit");\r
+      //Uncomment the following 3 lines to permit auto xml creation\r
+      //plugin->SetGridDataDir("/alice/sim/PDC_08b/LHC08d10/"); //dummy\r
+      //plugin->SetDataPattern("AliESDs.root"); //dummy\r
+      //plugin->AddRunNumber(30010); //dummy\r
+      plugin->AddDataFile("mycollect.xml");\r
+      plugin->SetGridWorkingDir("work3");\r
+      plugin->SetAdditionalLibs("anaElectron.C ConfigAnalysisElectron.C ANALYSIS.par ANALYSISalice.par AOD.par ESD.par PWG4PartCorrBase.par PWG4PartCorrDep.par STEERBase.par");\r
+      plugin->SetJDLName("anaElectron.jdl");\r
+      plugin->SetExecutable("anaElectron.sh");\r
+      plugin->SetOutputFiles("histos.root");\r
+      AliAnalysisGrid *alienHandler = plugin;\r
+      if (!alienHandler) return;\r
+\r
+      // Connect plug-in to the analysis manager\r
+      mgr->SetGridHandler(alienHandler);\r
+    }\r
+\r
+    // MC handler\r
+    if(kMC || kInputData == "MC"){\r
+      AliMCEventHandler* mcHandler = new AliMCEventHandler();\r
+      mcHandler->SetReadTR(kFALSE);//Do not search TrackRef file\r
+      mgr->SetMCtruthEventHandler(mcHandler);\r
+      if( kInputData == "MC") mgr->SetInputEventHandler(NULL);\r
+    }\r
+\r
+    // AOD output handler\r
+    AliAODHandler* aodoutHandler   = new AliAODHandler();\r
+    aodoutHandler->SetOutputFileName("aod.root");\r
+    //aodoutHandler->SetCreateNonStandardAOD();\r
+    mgr->SetOutputEventHandler(aodoutHandler);\r
+    \r
+    //input\r
+    if(kInputData == "ESD"){\r
+      // ESD handler\r
+      AliESDInputHandler *esdHandler = new AliESDInputHandler();\r
+      mgr->SetInputEventHandler(esdHandler);\r
+    }\r
+    if(kInputData == "AOD"){\r
+      // AOD handler\r
+      AliAODInputHandler *aodHandler = new AliAODInputHandler();\r
+      mgr->SetInputEventHandler(aodHandler);\r
+    }\r
+\r
+    mgr->SetDebugLevel(10); // For debugging, do not uncomment if you want no messages.\r
+\r
+    //-------------------------------------------------------------------------\r
+    //Define task, put here any other task that you want to use.\r
+    //-------------------------------------------------------------------------\r
+    //AliAnaElectron * taskpwg4 = new AliAnaElectron();\r
+    AliAnalysisTaskParticleCorrelation * taskpwg4 = new AliAnalysisTaskParticleCorrelation ("Particle");\r
+    taskpwg4->SetConfigFileName(configName); //Default name is ConfigAnalysisElectron\r
+\r
+    mgr->AddTask(taskpwg4);\r
+    \r
+    // Create containers for input/output\r
+    AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();\r
+    AliAnalysisDataContainer *coutput1 = mgr->GetCommonOutputContainer();\r
+    AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("histos", TList::Class(),\r
+                                                             AliAnalysisManager::kOutputContainer, "histos.root");\r
+\r
+    mgr->ConnectInput  (taskpwg4,     0, cinput1);\r
+    mgr->ConnectOutput (taskpwg4,     0, coutput1 );\r
+    mgr->ConnectOutput (taskpwg4,     1, coutput2 );\r
+  \r
+    //------------------------  \r
+    //Scaling task\r
+    //-----------------------\r
+    Int_t nfiles = chainxs->GetEntries();\r
+    //cout<<"Get? "<<kGetXSectionFromFileAndScale<<" nfiles "<<nfiles<<endl;\r
+    if(kGetXSectionFromFileAndScale && nfiles > 0){\r
+      //cout<<"Init AnaScale"<<endl;\r
+      //Get the cross section\r
+      Double_t xsection=0; \r
+      Float_t ntrials = 0;\r
+      GetAverageXsection(chainxs, xsection, ntrials);\r
+      \r
+      AliAnaScale * scale = new AliAnaScale("scale") ;\r
+      scale->Set(xsection/ntrials/kNumberOfEventsPerFile/nfiles) ;\r
+      scale->MakeSumw2(kFALSE);//If you want histograms with error bars set to kTRUE\r
+      //scale->SetDebugLevel(2);\r
+      mgr->AddTask(scale);\r
+      \r
+      AliAnalysisDataContainer *coutput3 = mgr->CreateContainer("histosscaled", TList::Class(),\r
+                                                               AliAnalysisManager::kOutputContainer, "histosscaled.root");\r
+      mgr->ConnectInput  (scale,     0, coutput2);\r
+      mgr->ConnectOutput (scale,     0, coutput3 );\r
+    }\r
+    \r
+    //-----------------------\r
+    // Run the analysis\r
+    //-----------------------    \r
+    TString smode = "";\r
+    if (mode==mLocal || mode == mLocalCAF) \r
+      smode = "local";\r
+    else if (mode==mPROOF) \r
+      smode = "proof";\r
+    else if (mode==mGRID) \r
+      smode = "local";\r
+    else if (mode==mPLUGIN) \r
+      smode = "grid";\r
+    \r
+    //mgr->ResetAnalysis();\r
+    mgr->InitAnalysis();\r
+    mgr->PrintStatus();\r
+    if (mode==mPROOF)\r
+      mgr->StartAnalysis(smode.Data(),kmydataset,1500,0);\r
+    else if (mode==mPLUGIN)\r
+      mgr->StartAnalysis(smode.Data());\r
+    else\r
+      mgr->StartAnalysis(smode.Data(),chain);\r
+\r
+    cout <<" Analysis ended sucessfully "<< endl ;\r
+\r
+  }\r
+  else cout << "Chain was not produced ! "<<endl;\r
+  \r
+}\r
+\r
+void  LoadLibraries(const anaModes mode) {\r
+  \r
+  \r
+  //----------------------------------------------------------\r
+  // >>>>>>>>>>> Local mode <<<<<<<<<<<<<< \r
+  //----------------------------------------------------------\r
+  if (mode==mLocal || mode == mLocalCAF || mode == mGRID || mode == mPLUGIN) {\r
+\r
+    //--------------------------------------\r
+    // Load the needed libraries most of them already loaded by aliroot\r
+    //--------------------------------------\r
+    gSystem->Load("libTree.so");\r
+    gSystem->Load("libGeom.so");\r
+    gSystem->Load("libVMC.so");\r
+    gSystem->Load("libXMLIO.so");\r
+    //--------------------------------------------------------\r
+    // If you want to use already compiled libraries \r
+    // in the aliroot distribution\r
+    //--------------------------------------------------------\r
+    //gSystem->Load("libSTEERBase");\r
+    //gSystem->Load("libESD");\r
+    //gSystem->Load("libAOD");\r
+    //gSystem->Load("libANALYSIS");\r
+    //gSystem->Load("libANALYSISalice");\r
+    //gSystem->Load("libPWG4PartCorrBase");\r
+    //gSystem->Load("libPWG4PartCorrDep");\r
+       \r
+    //--------------------------------------------------------\r
+    //If you want to use root and par files from aliroot\r
+    //--------------------------------------------------------  \r
+    SetupPar("STEERBase");\r
+    SetupPar("ESD");\r
+    SetupPar("AOD");\r
+    SetupPar("ANALYSIS");\r
+    SetupPar("ANALYSISalice");\r
+    SetupPar("PWG4PartCorrBase");\r
+    SetupPar("PWG4PartCorrDep");\r
+  }\r
+\r
+  //---------------------------------------------------------\r
+  // <<<<<<<<<< PROOF mode >>>>>>>>>>>>\r
+  //---------------------------------------------------------\r
+  else if (mode==mPROOF) {\r
+    //\r
+    // Connect to proof\r
+    // Put appropriate username here\r
+    //char* myproofname = "alicecaf";\r
+    char* myproofname = "jklay@localhost";\r
+\r
+    //TProof::Reset("proof://kread@lxb6046.cern.ch");\r
+    //JLK 28-Jun-2009: Only need to do this occasionally?\r
+    //TProof::Reset("jklay@localhost",kTRUE);\r
+\r
+    gEnv->SetValue("XSec.GSI.DelegProxy","2");   \r
+    //TProof::Mgr(myproofname)->ShowROOTVersions();\r
+    //TProof::Mgr(myproofname)->SetROOTVersion("v5-23-04");\r
+    TProof::Open(myproofname);\r
+\r
+    // gProof->ClearPackages();\r
+    // gProof->SetLogLevel(5);\r
+    // gProof->ClearPackage("STEERBase");\r
+    // gProof->ClearPackage("ESD");\r
+    // gProof->ClearPackage("AOD");\r
+    // gProof->ClearPackage("ANALYSIS");\r
+    // gProof->ClearPackage("ANALYSISalice");\r
+    // gProof->ClearPackage("PWG4PartCorrBase");\r
+    // gProof->ClearPackage("PWG4PartCorrDep");\r
+    // gProof->ShowEnabledPackages();\r
+\r
+    // Enable the STEERBase Package\r
+    gProof->UploadPackage("STEERBase.par");\r
+    gProof->EnablePackage("STEERBase");\r
+    // Enable the ESD Package\r
+    gProof->UploadPackage("ESD.par");\r
+    gProof->EnablePackage("ESD");\r
+    // Enable the AOD Package\r
+    gProof->UploadPackage("AOD.par");\r
+    gProof->EnablePackage("AOD");\r
+    // Enable the Analysis Package\r
+    gProof->UploadPackage("ANALYSIS.par");\r
+    gProof->EnablePackage("ANALYSIS");\r
+    // Enable the Analysis Package\r
+    gProof->UploadPackage("ANALYSISalice.par");\r
+    gProof->EnablePackage("ANALYSISalice");\r
+    // Enable PartCorr analysis\r
+    gProof->UploadPackage("PWG4PartCorrBase.par");\r
+    gProof->EnablePackage("PWG4PartCorrBase");\r
+    // Enable PartCorr analysis\r
+    gProof->UploadPackage("PWG4PartCorrDep.par");\r
+    gProof->EnablePackage("PWG4PartCorrDep");\r
+\r
+    gProof->ShowEnabledPackages();\r
+  }  \r
+  \r
+}\r
+\r
+void SetupPar(char* pararchivename)\r
+{\r
+  //Load par files, create analysis libraries\r
+  //For testing, if par file already decompressed and modified\r
+  //classes then do not decompress.\r
\r
+  TString cdir(Form("%s", gSystem->WorkingDirectory() )) ; \r
+  TString parpar(Form("%s.par", pararchivename)) ; \r
+  //if ( gSystem->AccessPathName(parpar.Data()) ) {\r
+  //The lines in this if block are forbidden on GRID.\r
+  //  gSystem->ChangeDirectory(gSystem->Getenv("ALICE_ROOT")) ;\r
+  //  TString processline(Form(".! make %s", parpar.Data())) ; \r
+  //  gROOT->ProcessLine(processline.Data()) ;\r
+  //  gSystem->ChangeDirectory(cdir) ; \r
+  //  processline = Form(".! mv $ALICE_ROOT/%s .", parpar.Data()) ;\r
+  //  gROOT->ProcessLine(processline.Data()) ;\r
+  //} \r
+  if ( gSystem->AccessPathName(pararchivename) ) {  \r
+    TString processline = Form(".! tar xvzf %s",parpar.Data()) ;\r
+    gROOT->ProcessLine(processline.Data());\r
+  }\r
+  \r
+  TString ocwd = gSystem->WorkingDirectory();\r
+  gSystem->ChangeDirectory(pararchivename);\r
+  \r
+  // check for BUILD.sh and execute\r
+  if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {\r
+    printf("*******************************\n");\r
+    printf("*** Building PAR archive    ***\n");\r
+    cout<<pararchivename<<endl;\r
+    printf("*******************************\n");\r
+    \r
+    if (gSystem->Exec("PROOF-INF/BUILD.sh")) {\r
+      Error("runProcess","Cannot Build the PAR Archive! - Abort!");\r
+      return -1;\r
+    }\r
+  }\r
+  // check for SETUP.C and execute\r
+  if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {\r
+    printf("*******************************\n");\r
+    printf("*** Setup PAR archive       ***\n");\r
+    cout<<pararchivename<<endl;\r
+    printf("*******************************\n");\r
+    gROOT->Macro("PROOF-INF/SETUP.C");\r
+  }\r
+  \r
+  gSystem->ChangeDirectory(ocwd.Data());\r
+  printf("Current dir: %s\n", ocwd.Data());\r
+}\r
+\r
+\r
+\r
+void CreateChain(const anaModes mode, TChain * chain, TChain * chainxs){\r
+  //Fills chain with data\r
+  TString ocwd = gSystem->WorkingDirectory();\r
+  \r
+  //-----------------------------------------------------------\r
+  //Analysis of CAF data locally\r
+  //-----------------------------------------------------------\r
+  if(mode == mLocalCAF){\r
+    // Read the input list of files and add them to the chain\r
+    TString line;\r
+    ifstream in;\r
+    in.open("ESDlist.txt");\r
+    while (in.good()) {\r
+      in >> line;\r
+      if (line.Length() == 0) continue;\r
+      // cout << " line = " << line << endl;\r
+      chain->Add(line);\r
+    }\r
+  }\r
+  \r
+  //---------------------------------------\r
+  //Local files analysis\r
+  //---------------------------------------\r
+  else if(mode == mLocal){\r
+    //If you want to add several ESD files sitting in a common directory INDIR\r
+    //Specify as environmental variables the directory (INDIR), the number of files \r
+    //to analyze (NEVENT) and the pattern name of the directories with files (PATTERN)\r
+\r
+    if(gSystem->Getenv("INDIR"))  \r
+      kInDir = gSystem->Getenv("INDIR") ; \r
+    else cout<<"INDIR not set, use default: "<<kInDir<<endl;   \r
+    \r
+    if(gSystem->Getenv("PATTERN"))   \r
+      kPattern = gSystem->Getenv("PATTERN") ; \r
+    else  cout<<"PATTERN not set, use default: "<<kPattern<<endl;\r
+    \r
+    //This is bad - we really mean NFILE here, should this env\r
+    //variable be changed?  JLK\r
+    if(gSystem->Getenv("NEVENT"))\r
+      kFile = atoi(gSystem->Getenv("NEVENT")) ;\r
+    else cout<<"NEVENT not set, use default: "<<kFile<<endl;\r
+    \r
+    //Check if env variables are set and are correct\r
+    if ( kInDir  && kFile) {\r
+      printf("Get %d files from directory %s\n",kFile,kInDir);\r
+      if ( ! gSystem->cd(kInDir) ) {//check if ESDs directory exist\r
+       printf("%s does not exist\n", kInDir) ;\r
+       return ;\r
+      }\r
+      cout<<"INDIR : "<<kInDir<<endl;\r
+      cout<<"NEVENT : "<<kFile<<endl;\r
+      cout<<"PATTERN: " <<kPattern<<endl;\r
+      \r
+      TString datafile="";\r
+      if(kInputData == "ESD") datafile = "AliESDs.root" ;\r
+      else if(kInputData == "AOD") datafile = "aod.root" ;\r
+      else if(kInputData == "MC")  datafile = "galice.root" ;\r
+      \r
+      //Loop on ESD files, add them to chain\r
+      Int_t event =0;\r
+      Int_t skipped=0 ; \r
+      char file[120] ;\r
+      char filexs[120] ;\r
+      \r
+      for (event = 0 ; event < kFile ; event++) {\r
+       sprintf(file, "%s/%s%d/%s", kInDir,kPattern,event,datafile.Data()) ; \r
+       sprintf(filexs, "%s/%s%d/%s", kInDir,kPattern,event,kXSFileName) ; \r
+       TFile * fESD = 0 ; \r
+       //Check if file exists and add it, if not skip it\r
+       if ( fESD = TFile::Open(file)) {\r
+         if ( fESD->Get(kTreeName) ) { \r
+           printf("++++ Adding %s\n", file) ;\r
+           chain->AddFile(file);\r
+           chainxs->Add(filexs) ; \r
+         }\r
+       }\r
+       else { \r
+         printf("---- Skipping %s\n", file) ;\r
+         skipped++ ;\r
+       }\r
+      }\r
+      printf("number of entries # %lld, skipped %d\n", chain->GetEntries(), skipped*100) ;     \r
+    }\r
+    else {\r
+      TString input = "AliESDs.root" ;\r
+      cout<<">>>>>> No list added, take a single file <<<<<<<<< "<<input<<endl;\r
+      chain->AddFile(input);\r
+    }\r
+    \r
+  }// local files analysis\r
+  \r
+  //------------------------------\r
+  //GRID xml files\r
+  //-----------------------------\r
+  else if(mode == mGRID){\r
+    //Get colection file. It is specified by the environmental\r
+    //variable XML\r
+\r
+    if(gSystem->Getenv("XML") )\r
+      kXML = gSystem->Getenv("XML");\r
+    else\r
+      sprintf(kXML, "collection.xml") ; \r
+    \r
+    if (!TFile::Open(kXML)) {\r
+      printf("No collection file with name -- %s -- was found\n",kXML);\r
+      return ;\r
+    }\r
+    else cout<<"XML file "<<kXML<<endl;\r
+\r
+    //Load necessary libraries and connect to the GRID\r
+    gSystem->Load("libNetx.so") ; \r
+    gSystem->Load("libRAliEn.so"); \r
+    TGrid::Connect("alien://") ;\r
+\r
+    //Feed Grid with collection file\r
+    //TGridCollection * collection =  (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\", 0)", kXML));\r
+    TGridCollection * collection = (TGridCollection*) TAlienCollection::Open(kXML);\r
+    if (! collection) {\r
+      AliError(Form("%s not found", kXML)) ; \r
+      return kFALSE ; \r
+    }\r
+    TGridResult* result = collection->GetGridResult("",0 ,0);\r
+   \r
+    // Makes the ESD chain \r
+    printf("*** Getting the Chain       ***\n");\r
+    for (Int_t index = 0; index < result->GetEntries(); index++) {\r
+      TString alienURL = result->GetKey(index, "turl") ; \r
+      cout << "================== " << alienURL << endl ; \r
+      chain->Add(alienURL) ; \r
+      alienURL.ReplaceAll("AliESDs.root",kXSFileName);\r
+      chainxs->Add(alienURL) ; \r
+    }\r
+  }// xml analysis\r
+\r
+  gSystem->ChangeDirectory(ocwd.Data());\r
+}\r
+\r
+//________________________________________________\r
+void GetAverageXsection(TTree * tree, Double_t & xs, Float_t & ntr)\r
+{\r
+  // Read the PYTHIA statistics from the file pyxsec.root created by\r
+  // the function WriteXsection():\r
+  // integrated cross section (xsection) and\r
+  // the  number of Pyevent() calls (ntrials)\r
+  // and calculate the weight per one event xsection/ntrials\r
+  // The spectrum calculated by a user should be\r
+  // multiplied by this weight, something like this:\r
+  // TH1F *userSpectrum ... // book and fill the spectrum\r
+  // userSpectrum->Scale(weight)\r
+  //\r
+  // Yuri Kharlov 19 June 2007\r
+  // Gustavo Conesa 15 April 2008\r
+  Double_t xsection = 0;\r
+  UInt_t    ntrials = 0;\r
+  xs = 0;\r
+  ntr = 0;\r
+  \r
+  Int_t nfiles =  tree->GetEntries()  ;\r
+  if (tree && nfiles > 0) {\r
+    tree->SetBranchAddress("xsection",&xsection);\r
+    tree->SetBranchAddress("ntrials",&ntrials);\r
+    for(Int_t i = 0; i < nfiles; i++){\r
+      tree->GetEntry(i);\r
+      xs += xsection ;\r
+      ntr += ntrials ;\r
+      cout << "xsection " <<xsection<<" ntrials "<<ntrials<<endl; \r
+    }\r
+    \r
+    xs =   xs /  nfiles;\r
+    ntr =  ntr / nfiles;\r
+    cout << "-----------------------------------------------------------------"<<endl;\r
+    cout << "Average of "<< nfiles<<" files: xsection " <<xs<<" ntrials "<<ntr<<endl; \r
+    cout << "-----------------------------------------------------------------"<<endl;\r
+  } \r
+  else cout << " >>>> Empty tree !!!! <<<<< "<<endl;\r
+  \r
+}\r
diff --git a/PWG4/macros/electrons/anaElectron.jdl b/PWG4/macros/electrons/anaElectron.jdl
new file mode 100644 (file)
index 0000000..8adf336
--- /dev/null
@@ -0,0 +1,34 @@
+Executable="/alice/cern.ch/user/j/jklay/bin/anaElectron.sh";
+      Jobtag ={"Analysis: Processing ESD collection for run "};
+      Packages =
+          {
+             "VO_ALICE@ROOT::v5-23-02",
+             "VO_ALICE@APISCONFIG::V2.4"
+          };
+
+      TTL=72000;
+
+      InputFile={"LF:/alice/cern.ch/user/j/jklay/work4/anaElectron.C",
+                 "LF:/alice/cern.ch/user/j/jklay/work4/ConfigAnalysisElectron.C",
+                 "LF:/alice/cern.ch/user/j/jklay/work4/STEERBase.par",
+                 "LF:/alice/cern.ch/user/j/jklay/work4/ESD.par",
+                 "LF:/alice/cern.ch/user/j/jklay/work4/AOD.par",
+                 "LF:/alice/cern.ch/user/j/jklay/work4/ANALYSIS.par",
+                 "LF:/alice/cern.ch/user/j/jklay/work4/ANALYSISalice.par",
+                 "LF:/alice/cern.ch/user/j/jklay/work4/PWG4PartCorrBase.par",
+                 "LF:/alice/cern.ch/user/j/jklay/work4/PWG4PartCorrDep.par"};
+      OutputArchive={"log_archive:stdout,stderr,*.log@ALICE::LLNL::FILE",
+                     "root_archive:*.root@ALICE::LLNL::FILE"};
+
+      OutputDir = "/alice/cern.ch/user/j/jklay/work4/output/#alien_counter_03i#";
+
+      InputDataCollection = "LF:/alice/cern.ch/user/j/jklay/work4/mycollect.xml,nodownload";
+
+      InputDataListFormat = "xml-single";
+      InputDataList = "collection.xml";
+
+      Split = "se";
+      SplitMaxInputFileNumber = "15";
+      OutputFile="histos.root";
+      MergeOutputDir = "/alice/cern.ch/user/j/jklay/work4/output/merged";
+      Merge = {"histos.root:/alice/cern.ch/user/j/jklay/work4/mergeElectron.jdl:histos-merged.root"};
diff --git a/PWG4/macros/electrons/anaElectron.sh b/PWG4/macros/electrons/anaElectron.sh
new file mode 100644 (file)
index 0000000..0b2bc82
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+# ana.sh
+# 
+#
+# Author K. Read
+#
+# Even though plugin version of anaElectron.C is launched using mode 4,
+# this file should use mode 3 since it is executed on each GRID cpu.
+#
+
+root -b  > anaElectron.log 2>&1 <<EOF
+.L anaElectron.C
+anaElectron(3,"ConfigAnalysisElectron")
+EOF
diff --git a/PWG4/macros/electrons/mergeElectron.jdl b/PWG4/macros/electrons/mergeElectron.jdl
new file mode 100644 (file)
index 0000000..c9a1e38
--- /dev/null
@@ -0,0 +1,12 @@
+Packages =
+           {
+              "VO_ALICE@ROOT::v5-23-04",
+              "VO_ALICE@APISCONFIG::V2.4"
+           };
+
+      Arguments = "27498605 histos.root histos-merged.root jklay /alice/cern.ch/user/j/jklay/work4/output";
+      Executable = "/alice/bin/mergerootfile";
+      Email = "jklay@calpoly.edu";
+      OutputFile = "histos-merged.root@ALICE::Subatech::DPM";
+      InputFile  = "LF:/alice/macros/mergerootfile.C";
+      OutputDir  = "/alice/cern.ch/user/j/jklay/work4/output/merged";
diff --git a/PWG4/macros/electrons/mylauncher.C b/PWG4/macros/electrons/mylauncher.C
new file mode 100644 (file)
index 0000000..8168ed9
--- /dev/null
@@ -0,0 +1,101 @@
+
+//
+// Copy files to AliEn space and submit AliEn job
+// Author: K. Read
+//
+
+void mylauncher()
+{
+  TString worksubdir = "work4";
+  // Name of JDL file to upload.  Leave blank for no upload and no submit.
+  TString jdlfilename = "anaElectron.jdl";
+  // Name of executable to upload.  Leave blank for no upload.
+  TString execfilename = "anaElectron.sh";
+  // List any other files to upload in string filenames separated by blanks.
+  TString filelist = "anaElectron.C ConfigAnalysisElectron.C mergeElectron.jdl mycollect.xml ANALYSIS.par ANALYSISalice.par AOD.par ESD.par STEERBase.par PWG4PartCorrBase.par PWG4PartCorrDep.par";
+  TString filename;
+
+  gSystem->Load("libNetx.so") ;
+  gSystem->Load("libRAliEn.so");
+
+  TGrid::Connect("alien://") ;
+  if (gGrid && gGrid->IsConnected()) {
+    TString homedir = gGrid->GetHomeDirectory(); // has a trailing slash
+    TString workdir = homedir + worksubdir;
+    if (gGrid->Cd(workdir)) {
+
+      // Upload files listed
+      if (filelist.Length()) {
+         arr = filelist.Tokenize(" ");
+         TObjString *os;
+         TIter next(arr);
+         while ((os=(TObjString*)next())) {
+           Info("Grid Upload", "Copying %s to your AliEn work directory", os->GetString().Data());
+          if (FileExists(os->GetString())) gGrid->Rm(os->GetString());
+          TFile::Cp(Form("file:%s",os->GetString().Data()), Form("alien://%s/%s", workdir.Data(), os->GetString().Data()));
+        }   
+        delete arr;   
+      }
+
+      // Upload executable if listed
+      if (execfilename.Length()) {
+        filename = Form("%sbin/%s", homedir.Data(), execfilename.Data());
+        if (FileExists(filename)) gGrid->Rm(filename);
+        Info("Grid Upload", "Copying executable file %s to your AliEn bin directory", execfilename.Data());
+        TFile::Cp(Form("file:%s",execfilename.Data()), Form("alien://%s", filename.Data()));
+      }
+
+      // Upload and submit JDL if listed
+      if (jdlfilename.Length()) {
+        filename = Form("%s/%s", workdir.Data(), jdlfilename.Data());
+        if (FileExists(filename)) gGrid->Rm(filename);
+        Info("Grid Upload", "Copying JDL file %s to your AliEn work directory", jdlfilename.Data());
+        TFile::Cp(Form("file:%s",jdlfilename.Data()), Form("alien://%s", filename.Data()));
+
+       TGridResult *res;
+        TString jobID = "";
+        res = gGrid->Command(Form("submit %s", jdlfilename.Data()));
+        Info("Launcher:", "Submitting %s ", jdlfilename.Data());
+        if (res) {
+          const char *cjobId = res->GetKey(0,"jobId");
+          if (!cjobId) {
+            Error("Launcher:", "Your JDL %s could not be submitted", jdlfilename.Data());
+            return;
+          } 
+          else {
+            Info("Launcher:", "Your JDL %s was successfully submitted.\n\n\t\t\t THE JOB ID IS: %s\n",
+                jdlfilename.Data(), cjobId);
+          }          
+          delete res;
+        }
+      }
+
+      // Launch alien shell
+      gSystem->Exec("aliensh");
+
+    }
+  }
+}
+
+Bool_t FileExists(const char *lfn) const
+{
+// Returns true if file exists.
+   if (!gGrid) {
+      Error("FileExists", "No connection to grid");
+      return kFALSE;
+   }
+   TGridResult *res = gGrid->Ls(lfn);
+   if (!res) return kFALSE;
+   TMap *map = dynamic_cast<TMap*>(res->At(0));
+   if (!map) {
+      delete res;
+      return kFALSE;
+   }   
+   TObjString *objs = dynamic_cast<TObjString*>(map->GetValue("name"));
+   if (!objs || !objs->GetString().Length()) {
+      delete res;
+      return kFALSE;
+   }
+   delete res;   
+   return kTRUE;
+}
diff --git a/PWG4/macros/electrons/parmaker b/PWG4/macros/electrons/parmaker
new file mode 100755 (executable)
index 0000000..b493c5b
--- /dev/null
@@ -0,0 +1,104 @@
+#!/bin/bash
+
+#
+# Author: K. Read
+#
+# This script makes PAR files without requiring write access to $ALICE_ROOT.
+# Execute this script in your local area with write access.
+# Usage:
+# parmaker ANALYSIS
+# parmaker ANALYSIS remote
+# parmaker PWG4PartCorrDep
+# parmaker PWG4PartCorrDep remote
+#
+# So far only available for these par files:
+# ANALYSIS ANALYSISalice AOD ESD PWG4PartCorrBase PWG4PartCorrDep STEERBase
+#
+
+case $2 in
+
+  "remote")
+
+    case $1 in
+      "ANALYSIS")
+         parmaker_input_basedir="ANALYSIS"
+         parmaker_input_dir_subdir="ANALYSIS"
+         parmaker_output_dir_subdir="ANALYSIS"
+         ;;
+      "ANALYSISalice")
+         parmaker_input_basedir="ANALYSIS"
+         parmaker_input_dir_subdir="ANALYSIS"
+         parmaker_output_dir_subdir="ANALYSISalice"
+         ;;
+      "AOD")
+         parmaker_input_basedir="STEER"
+         parmaker_input_dir_subdir="STEER"
+         parmaker_output_dir_subdir="AOD"
+         ;;
+      "ESD")
+         parmaker_input_basedir="STEER"
+         parmaker_input_dir_subdir="STEER"
+         parmaker_output_dir_subdir="ESD"
+         ;;
+      "PWG4PartCorrBase")
+         parmaker_input_basedir="PWG4"
+         parmaker_input_dir_subdir="PWG4/PartCorrBase"
+         parmaker_output_dir_subdir="PWG4PartCorrBase/PartCorrBase"
+        ;;
+      "PWG4PartCorrDep")
+         parmaker_input_basedir="PWG4"
+         parmaker_input_dir_subdir="PWG4/PartCorrDep"
+         parmaker_output_dir_subdir="PWG4PartCorrDep/PartCorrDep"
+         ;;
+      "STEERBase")
+         parmaker_input_basedir="STEER"
+         parmaker_input_dir_subdir="STEER"
+         parmaker_output_dir_subdir="STEERBase"
+         ;;
+      *)
+        echo "parmaker: I'm sorry Dave, I'm afraid I can't do that."
+        exit
+    esac
+
+    echo "parmaker to use source $ALICE_ROOT/$parmaker_input_dir_subdir"
+    if [ -e "$ALICE_ROOT/$parmaker_input_dir_subdir" ]
+    then
+      echo "parmaker creating $1.par"
+      mkdir $1
+      if [ $parmaker_input_basedir != $parmaker_input_dir_subdir ]
+      then
+        mkdir $parmaker_output_dir_subdir
+      fi
+
+      list=`grep Ali ${ALICE_ROOT}/${parmaker_input_basedir}/lib${1}.pkg | sed -e 's:.cxx::g' -e 's:SRCS::' -e 's:=::' -e 's:+::' -e 's:\\\::'`
+      for i in $list; do
+        cp $ALICE_ROOT/$parmaker_input_basedir/$i.cxx $parmaker_output_dir_subdir
+        cp $ALICE_ROOT/$parmaker_input_basedir/$i.h   $parmaker_output_dir_subdir
+      done
+
+      mkdir $1/PROOF-INF
+      cp -r $ALICE_ROOT/$parmaker_input_basedir/PROOF-INF.$1/* $1/PROOF-INF
+      cp $ALICE_ROOT/$parmaker_input_basedir/${1}LinkDef.h $1
+      cp $ALICE_ROOT/$parmaker_input_basedir/lib${1}.pkg $1
+      cp $ROOTSYS/test/Makefile.arch $1
+      cp $ALICE_ROOT/$parmaker_input_basedir/Makefile $1/Makefiletemp
+      sed -e 's:include \$(ROOTSYS)\/test\/Makefile.arch:include Makefile.arch:' -e "s:PACKAGE = .*:PACKAGE = ${1}:" $1/Makefiletemp > $1/Makefile
+
+      /bin/rm $1/Makefiletemp
+      tar cfzh $1.par $1
+      /bin/rm -rf $1
+    fi
+    ;;
+
+  *)
+    echo "parmaker to use local source $1"
+    if [ -e "$1" ]
+    then
+      echo "parmaker creating $1.par"
+      tar cfzh $1.par $1
+    else
+      echo "local subdirectory $1 not found"
+    fi
+
+esac