Improved track cuts, added custom header variables for correlations test
authormfloris <michele.floris@cern.ch>
Tue, 11 Mar 2014 10:05:16 +0000 (11:05 +0100)
committermfloris <michele.floris@cern.ch>
Tue, 11 Mar 2014 10:08:14 +0000 (11:08 +0100)
PWG/DevNanoAOD/AliAnalysisNanoAODCuts.cxx
PWG/DevNanoAOD/AliAnalysisNanoAODCuts.h
PWG/DevNanoAOD/AliNanoAODHeader.h
PWG/DevNanoAOD/AliNanoAODReplicator.cxx [deleted file]
PWG/DevNanoAOD/runGridESE.C [new file with mode: 0644]
PWG/DevNanoAOD/runLocalCorrelations.C [new file with mode: 0644]
PWG/PWGDevNanoAODLinkDef.h

index fcef18c..72dd3c1 100644 (file)
@@ -3,13 +3,15 @@
 #include "AliAODEvent.h"
 #include "AliNanoAODHeader.h"
 #include "AliNanoAODTrack.h"
+#include <iomanip>
 
 ClassImp(AliAnalysisNanoAODTrackCuts)
-
+ClassImp(AliAnalysisNanoAODEventCuts)
+ClassImp(AliNanoAODSimpleSetter)
 
 
 AliAnalysisNanoAODTrackCuts::AliAnalysisNanoAODTrackCuts():
-  AliAnalysisCuts(), fBitMask(1) 
+AliAnalysisCuts(), fBitMask(1), fMinPt(0), fMaxEta(10)
 {
   // default ctor 
 }
@@ -18,9 +20,13 @@ Bool_t AliAnalysisNanoAODTrackCuts::IsSelected(TObject* obj)
 {
   // Returns true if the track is good!
   AliAODTrack* track = dynamic_cast<AliAODTrack*>(obj);
-
-  if (track->TestFilterBit(fBitMask)) return kTRUE;
-  return kFALSE;  
+  
+  
+  if (!track->TestFilterBit(fBitMask))    return kFALSE;
+  if (track->Pt() < fMinPt)               return kFALSE;
+  if (TMath::Abs(track->Eta()) > fMaxEta) return kFALSE; 
+  
+  return kTRUE;  
 
 }
 
@@ -38,6 +44,17 @@ Bool_t AliAnalysisNanoAODEventCuts::IsSelected(TObject* obj)
   AliAODVertex * vertex = evt->GetPrimaryVertex();
   if (!vertex) return kFALSE;
   if (TMath::Abs(vertex->GetZ()) > fVertexRange) return kFALSE;
+  
   return kTRUE;
   
 }
+
+
+void AliNanoAODSimpleSetter::SetNanoAODHeader(const AliAODEvent * event   , AliNanoAODHeader * head  ) {
+  // Set custom nano aod vars
+  Double_t centr    = event->GetHeader()->GetCentralityP()->GetCentralityPercentile("V0M");
+  Double_t magfield = event->GetHeader()->GetMagneticField();
+  head->SetVar(0, centr);
+  head->SetVar(1, magfield);
+
+}
index d575eb4..dbaec7b 100644 (file)
@@ -3,6 +3,7 @@
 
 #include "AliAnalysisCuts.h"
 #include "AliNanoAODCustomSetter.h"
+#include "AliNanoAODCustomSetter.h"
 
 class AliAnalysisNanoAODTrackCuts : public AliAnalysisCuts
 {
@@ -13,9 +14,21 @@ public:
   virtual Bool_t IsSelected(TList*   /* list */ ) { return kTRUE; }
   UInt_t GetBitMask() { return fBitMask; }
   void  SetBitMask (UInt_t var) { fBitMask = var;}
+  Float_t GetMinPt() { return fMinPt; }
+  void  SetMinPt (Float_t var) { fMinPt = var;}
+  Float_t GetMaxEta() { return fMaxEta; }
+  void  SetMaxEta (Float_t var) { fMaxEta = var;}
+
+
+// [11/3/14 09:15:20] Fiete: to make a full test with the CF train: we also need the possibility to copy values of the header: at least vertex and centrality
+// [11/3/14 09:15:29] Fiete: let's put this before i tag
 
 private:
   UInt_t fBitMask; // Only AOD tracks matching this bit mask are accepted
+  Float_t fMinPt; // miminum pt of the tracks
+  Float_t fMaxEta; // MaxEta
+
+
 
   ClassDef(AliAnalysisNanoAODTrackCuts,1); // Select muon spectrometer tracks
 };
@@ -36,6 +49,18 @@ public:
   ClassDef(AliAnalysisNanoAODEventCuts,1); // Select primary vertices
 };
 
+class AliNanoAODSimpleSetter : public AliNanoAODCustomSetter
+{
+public:
+  AliNanoAODSimpleSetter(){;}
+  virtual ~AliNanoAODSimpleSetter(){;}
+
+  virtual void SetNanoAODHeader(const AliAODEvent * event   , AliNanoAODHeader * head  );
+  virtual void SetNanoAODTrack (const AliAODTrack * /*aodTrack*/, AliNanoAODTrack * /*spTrack*/){;}
+
+  ClassDef(AliNanoAODSimpleSetter, 1)
+
+};
 
 
 
index 6237607..79d99e2 100644 (file)
@@ -26,6 +26,9 @@ public:
   virtual UChar_t   GetTriggerCluster()     const { AliError("Not implemented");return 0;}
   virtual UInt_t    GetEventType()          const { AliError("Not implemented");return 0;}
   virtual void Print(Option_t* /*option = ""*/) const  {Printf("I'm a special header!");}
+
+  Double_t  GetMagneticField()      const { return GetVar(1); }
+  Double_t  GetCentrality (const char *estimator = "V0M") { return GetVar(0);}
   
   ClassDef(AliNanoAODHeader, 1)
 
diff --git a/PWG/DevNanoAOD/AliNanoAODReplicator.cxx b/PWG/DevNanoAOD/AliNanoAODReplicator.cxx
deleted file mode 100644 (file)
index 796137c..0000000
+++ /dev/null
@@ -1,669 +0,0 @@
-/**************************************************************************
-* 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: AliNanoAODReplicator.cxx 56492 2012-05-15 18:42:47Z pcrochet $
-
-// Implementation of a branch replicator 
-// to produce nanoAODs.
-//
-//
-// This replicator is in charge of replicating the tracks,vertices,headers
-// branches of a standard AOD or ESD file into a nanoAODs 
-// (AliAOD.Special.root)
-// 
-// The class was inspired by AliAODMuonReplicator
-// 
-// Author: Michele Floris, michele.floris@cern.ch
-
-
-class AliESDv0;
-class AliESDVertex;
-class AliAODVertex;
-class AliAODRecoDecay;
-
-#include "AliAODDimuon.h"
-#include "AliAODEvent.h"
-#include "AliAODMCHeader.h"
-#include "AliAODMCParticle.h"
-#include "AliAODTZERO.h"
-#include "AliAODTrack.h"
-#include "AliAODVZERO.h"
-#include "AliAnalysisCuts.h"
-#include "TF1.h"
-#include "AliExternalTrackParam.h"
-#include "AliESDv0.h"
-#include "AliAODv0.h"
-#include "AliPIDResponse.h"
-#include <iostream>
-#include <cassert>
-#include "AliESDtrack.h"
-#include "TObjArray.h"
-#include "AliAnalysisFilter.h"
-#include "AliNanoAODTrack.h"
-
-#include <TFile.h>
-#include <TDatabasePDG.h>
-#include <TString.h>
-#include <TList.h>
-#include "AliLog.h"
-#include "AliVEvent.h"
-#include "AliVVertex.h"
-#include "AliVTrack.h"
-#include "AliVertexerTracks.h"
-#include "AliKFVertex.h"
-#include "AliESDEvent.h"
-#include "AliESDVertex.h"
-#include "AliESDtrackCuts.h"
-#include "AliAODEvent.h"
-#include "AliAnalysisFilter.h"
-
-#include "AliNanoAODReplicator.h"
-#include "TH1.h"
-#include "TCanvas.h"
-#include "AliNanoAODHeader.h"
-#include "AliNanoAODCustomSetter.h"
-
-using std::cout;
-using std::endl;
-
-ClassImp(AliNanoAODReplicator)
-
-//_____________________________________________________________________________
-AliNanoAODReplicator::AliNanoAODReplicator() :
-AliAODBranchReplicator(), 
-  fTrackCut(0), fTracks(0x0), fHeader(0x0), fNTracksVariables(0), // FIXME: Start using cuts, and check if fNTracksVariables is needed
-  fVertices(0x0), 
-  fList(0x0),
-  fMCParticles(0x0),
-  fMCHeader(0x0),
-  fMCMode(0),
-  fLabelMap(),
-  fParticleSelected(),
-  fVarList(""),
-  fVarListHeader(""),
-  fCustomSetter(0){
-  // Default ctor. we need it to avoid instantiating a wrong mapping when reading from file 
-  }
-
-AliNanoAODReplicator::AliNanoAODReplicator(const char* name, const char* title,
-                                          const char * varlist,
-                                          AliAnalysisCuts* trackCut,
-                                          Int_t mcMode
-                                            ) :
-  AliAODBranchReplicator(name,title), 
-
-  fTrackCut(trackCut), fTracks(0x0), fHeader(0x0), fNTracksVariables(0), // FIXME: Start using cuts, and check if fNTracksVariables is needed
-  fVertices(0x0), 
-  fList(0x0),
-  fMCParticles(0x0),
-  fMCHeader(0x0),
-  fMCMode(mcMode),
-  fLabelMap(),
-  fParticleSelected(),
-  fVarList(varlist),
-  fVarListHeader(""),// FIXME: this should be set to a meaningful value: add an arg to the constructor
-  fCustomSetter(0)
-{
-  // default ctor
-  AliNanoAODTrackMapping * tm =new AliNanoAODTrackMapping(fVarList);
-  fNTracksVariables = tm->GetSize();  
-  //  tm->Print();
-}
-
-//_____________________________________________________________________________
-AliNanoAODReplicator::~AliNanoAODReplicator()
-{
-  // dtor
-  delete fTrackCut;
-  delete fList;
-}
-
-//_____________________________________________________________________________
-void AliNanoAODReplicator::SelectParticle(Int_t i)
-{
-  // taking the absolute values here, need to take care 
-  // of negative daughter and mother
-  // IDs when setting!
-  
-  if (!IsParticleSelected(TMath::Abs(i)))
-  {
-    fParticleSelected.Add(TMath::Abs(i),1);    
-  }
-}
-
-//_____________________________________________________________________________
-Bool_t AliNanoAODReplicator::IsParticleSelected(Int_t i)  
-{
-  // taking the absolute values here, need to take 
-  // care with negative daughter and mother
-  // IDs when setting!
-  return (fParticleSelected.GetValue(TMath::Abs(i))==1);
-}
-
-
-//_____________________________________________________________________________
-void AliNanoAODReplicator::CreateLabelMap(const AliAODEvent& source)
-{  
-  //
-  // this should be called once all selections are done 
-  // This method associates to the original index of the mc particle
-  // (i) the new one (j). J runs only over particles which are
-  // actually kept.
-  //
-  
-  fLabelMap.Delete();
-  
-  TClonesArray* mcParticles = static_cast<TClonesArray*>(source.FindListObject(AliAODMCParticle::StdBranchName()));
-  
-  Int_t j(0);
-  Int_t i(0); // We need i, we cannot rely on part->GetLabel, because some of the original mc particles are not kept in the stack, apparently
-  
-  TIter next(mcParticles);
-
-  while ( next() )
-  {
-    if (IsParticleSelected(i))
-    {
-      fLabelMap.Add(i,j++);
-      //      std::cout << i <<  "->" << j-1 << std::endl;
-    }
-    ++i;
-  }  
-
-
-}
-
-//_____________________________________________________________________________
-Int_t AliNanoAODReplicator::GetNewLabel(Int_t i) 
-{
-  // Gets the label from the new created Map
-  // Call CreatLabelMap before
-  // otherwise only 0 returned
-  return fLabelMap.GetValue(TMath::Abs(i));
-}
-
-//_____________________________________________________________________________
-void AliNanoAODReplicator::FilterMC(const AliAODEvent& source)
-{
-  // Filter MC information
-
-
-  AliAODMCHeader* mcHeader(0x0);
-  TClonesArray* mcParticles(0x0);
-  
-  fParticleSelected.Delete();
-
-  //  std::cout << "MC Mode: " << fMCMode << ", Tracks " << fTracks->GetEntries() << std::endl;
-  
-  if ( fMCMode>=2 && !fTracks->GetEntries() ) {
-    return;
-  }
-  // for fMCMode==1 we only copy MC information for events where there's at least one muon track
-    
-  mcHeader = static_cast<AliAODMCHeader*>(source.FindListObject(AliAODMCHeader::StdBranchName()));
-  
-  if ( mcHeader ) 
-    {
-      *fMCHeader = *mcHeader;
-    }
-  
-  
-  mcParticles = static_cast<TClonesArray*>(source.FindListObject(AliAODMCParticle::StdBranchName()));
-  
-  if ( mcParticles && fMCMode>=2 )
-    {
-      // keep all primaries
-      TIter nextPart(mcParticles);
-      static Int_t iev = -1; // FIXME: remove this (debug)
-      iev ++;
-      AliAODMCParticle * prim = 0;
-      Int_t iprim = 0;  // We need iprim, we cannot rely on part->GetLabel, because some of the original mc particles are not kept in the stack, apparently
-      // also select all charged primaries 
-      while ((prim = (AliAODMCParticle*) nextPart())) {
-       if(prim->IsPhysicalPrimary() && prim->Charge()) SelectParticle(iprim);
-       // FIXME DEBUG
-       if(iev == 2009) {
-         // std::cout << "IEV " << iev << std::endl;
-         // std::cout << " PART " << iprim << " " << prim->IsPhysicalPrimary() <<","<<prim->Charge() << "=" << IsParticleSelected(iprim) <<  std::endl;
-         if(iprim == 15) {
-           prim->Print();
-         }
-         
-       }
-       iprim++;
-      } 
-
-      // loop on (kept) tracks to find their ancestors
-      TIter nextTRACK(fTracks);
-      AliNanoAODTrack* track;
-    
-      while ( ( track = static_cast<AliNanoAODTrack*>(nextTRACK()) ) )
-       {
-         Int_t label = TMath::Abs(track->GetLabel()); 
-      
-         while ( label >= 0 ) 
-           {
-             SelectParticle(label);
-             AliAODMCParticle* mother = static_cast<AliAODMCParticle*>(mcParticles->UncheckedAt(label));
-             if (!mother)
-               {
-                 AliError(Form("Got a null mother ! Check that ! (label %d",label)); // FIXME: I think this error is not needed
-                 label = -1;
-               }
-             else
-               {
-                 label = mother->GetMother();// do not only keep particles which created a track, but all their mothers
-               }
-           }
-       }
-    
-      CreateLabelMap(source);
-    
-      // Actual filtering and label remapping (shamelessly taken for the implementation of AliAODHandler::StoreMCParticles)
-      TIter nextMC(mcParticles);
-      AliAODMCParticle* p;
-      Int_t nmc(0);  // We need nmc, we cannot rely on part->GetLabel, because some of the original mc particles are not kept in the stack, apparently
-      Int_t nmcout(0);
-    
-      while ( ( p = static_cast<AliAODMCParticle*>(nextMC()) ) )
-       {
-         AliAODMCParticle c(*p);
-
-         if ( IsParticleSelected(nmc) )
-           {
-             // 
-             Int_t d0 =  p->GetDaughter(0);
-             Int_t d1 =  p->GetDaughter(1);
-             Int_t m =   p->GetMother();
-        
-             // other than for the track labels, negative values mean
-             // no daughter/mother so preserve it
-        
-             if(d0<0 && d1<0)
-               {
-                 // no first daughter -> no second daughter
-                 // nothing to be done
-                 // second condition not needed just for sanity check at the end
-                 c.SetDaughter(0,d0);
-                 c.SetDaughter(1,d1);
-               } else if(d1 < 0 && d0 >= 0) 
-               {
-                 // Only one daughter
-                 // second condition not needed just for sanity check at the end
-                 if(IsParticleSelected(d0))
-                   {
-                     c.SetDaughter(0,GetNewLabel(d0));
-                   } else 
-                   {
-                     c.SetDaughter(0,-1);
-                   }
-                 c.SetDaughter(1,d1);
-               }
-             else if (d0 > 0 && d1 > 0 )
-               {
-                 // we have two or more daughters loop on the stack to see if they are
-                 // selected
-                 Int_t d0tmp = -1;
-                 Int_t d1tmp = -1;
-                 for (int id = d0; id<=d1;++id)
-                   {
-                     if (IsParticleSelected(id))
-                       {
-                         if(d0tmp==-1)
-                           {
-                             // first time
-                             d0tmp = GetNewLabel(id);
-                             d1tmp = d0tmp; // this is to have the same schema as on the stack i.e. with one daugther d0 and d1 are the same 
-                           }
-                         else d1tmp = GetNewLabel(id);
-                       }
-                   }
-                 c.SetDaughter(0,d0tmp);
-                 c.SetDaughter(1,d1tmp);
-               } else 
-               {
-                 AliFatal(Form("Unxpected indices %d %d",d0,d1));
-               }
-        
-             if ( m < 0 )
-               {
-                 c.SetMother(m);
-               } else 
-               {
-                 if (IsParticleSelected(m)) 
-                   {
-                     c.SetMother(GetNewLabel(m));              
-                   }
-                 // else // FIXME: re-enable this checj. Sometimes it gets here. Still to be understood why
-                 //   {
-                 //     //                   AliError(Form("PROBLEM Mother not selected %d", m));              
-                 //   }
-               }
-        
-             new ((*fMCParticles)[nmcout++]) AliAODMCParticle(c);
-           }
-      
-         ++nmc;        
-       } //closes loop over MC particles
-    
-      // now remap the tracks...
-    
-      TIter nextTrack(fTracks);
-      AliNanoAODTrack* t;
-      //      std::cout << "Remapping tracks" << std::endl;
-    
-      while ( ( t = dynamic_cast<AliNanoAODTrack*>(nextTrack()) ) )
-       {
-         
-         t->SetLabel(GetNewLabel(t->GetLabel()));
-       }
-    
-    } // closes fMCMode == 1
-  else if ( mcParticles ) 
-    {
-      // simple copy of input MC particles to ouput MC particles
-      TIter nextMC(mcParticles);
-      AliAODMCParticle* p;
-      Int_t nmcout(0);
-    
-      while ( ( p = static_cast<AliAODMCParticle*>(nextMC()) ) )
-       {
-         new ((*fMCParticles)[nmcout++]) AliAODMCParticle(*p);
-       }
-    }
-  
-  AliDebug(1,Form("input mc %d output mc %d",
-                  mcParticles ? mcParticles->GetEntries() : 0,
-                  fMCParticles ? fMCParticles->GetEntries() : 0));
-  
-  Printf("input mc %d output mc %d",
-                  mcParticles ? mcParticles->GetEntries() : 0,
-                  fMCParticles ? fMCParticles->GetEntries() : 0);
-  
-
-}
-
-// //_____________________________________________________________________________
-TList* AliNanoAODReplicator::GetList() const
-{
-  // return (and build if not already done) our internal list of managed objects
-  
-  if (!fList)
-    {
-      fList = new TList;
-      fList->SetOwner(kTRUE);
-
-      fTracks = new TClonesArray("AliNanoAODTrack");      
-      fTracks->SetName("tracks"); // TODO: consider the possibility to use a different name to distinguish in AliAODEvent
-      fList->Add(fTracks);    
-
-      fHeader = new AliNanoAODHeader(3);// TODO: to be customized
-      fHeader->SetName("header"); // TODO: consider the possibility to use a different name to distinguish in AliAODEvent
-      fList->Add(fHeader);    
-
-
-      fVertices = new TClonesArray("AliAODVertex",2);
-      fVertices->SetName("vertices");    
-    
-        
-      fList->Add(fVertices);
-    
-      if ( fMCMode > 0 )
-       {
-         fMCHeader = new AliAODMCHeader;    
-         fMCParticles = new TClonesArray("AliAODMCParticle",1000);
-         fMCParticles->SetName(AliAODMCParticle::StdBranchName());
-         fList->Add(fMCHeader);
-         fList->Add(fMCParticles);
-       }
-    }
-  return fList;
-}
-
-//_____________________________________________________________________________
-void AliNanoAODReplicator::ReplicateAndFilter(const AliAODEvent& source)
-//void AliNanoAODReplicator::ReplicateAndFilter(AliAODEvent *source)
-{
-  // Replicate (and filter if filters are there) the relevant parts we're interested in AODEvent
-  
-
-  // assert(fTracks!=0x0);
-  
-  //*fTZERO = *(source.GetTZEROData());
-  
-  
-
-  fTracks->Clear("C");                 
-  assert(fVertices!=0x0);
-  fVertices->Clear("C");
-  if (fMCMode > 0){
-    if(!fMCHeader) {
-      AliFatal(Form("fMCMode = %d, but MC header not found", fMCMode));
-    }
-    fMCHeader->Reset();
-    if(!fMCParticles){
-      AliFatal(Form("fMCMode = %d, but MC particles not found", fMCMode));
-    }
-    fMCParticles->Clear("C");
-  }
-  Int_t ntracks(0);
-  Int_t input(0);
-
-  AliAODVertex *vtx = source.GetPrimaryVertex();
-
-  // TODO: implement header!
-  //  *fHeader = *source.GetHeader();
-  if(fCustomSetter){
-    // Set custom variables in the header if the callback is set
-    fCustomSetter->SetNanoAODHeader(&source, fHeader);
-  }
-
-
-  //  Int_t nindices=0;
-  const Int_t entries = source.GetNumberOfTracks();
-
-  Double_t pos[3],cov[6];
-  vtx->GetXYZ(pos);
-  vtx->GetCovarianceMatrix(cov);
-  
-  if(entries<=0) return;
-
-  if(vtx->GetNContributors()<1) {
-    // SPD vertex cut
-    vtx =source.GetPrimaryVertexSPD();    
-    if(vtx->GetNContributors()<1) { // FIXME: Keep this cut?
-      Info("AliNanoAODReplicator","No good vertex, skip event");
-      return; // NO GOOD VERTEX, SKIP EVENT 
-    }
-  }
-  
-  
-  for(Int_t j=0; j<entries; j++){
-    
-    AliVTrack *track = (AliVTrack*)source.GetTrack(j);
-    
-    AliAODTrack *aodtrack =(AliAODTrack*)track;// FIXME DYNAMIC CAST?
-    if(!fTrackCut->IsSelected(aodtrack)) continue;
-
-    AliNanoAODTrack * special = new  AliNanoAODTrack (aodtrack, fVarList);
-    
-    if(fCustomSetter) fCustomSetter->SetNanoAODTrack(aodtrack, special);
-    (*fTracks)[ntracks++] = special;
-    //new((*fTracks)[ntrac\ks++])
-  }  
-  //----------------------------------------------------------
-  
-  TIter nextV(source.GetVertices());
-  AliAODVertex* v;
-  Int_t nvertices(0);
-  
-  while ( ( v = static_cast<AliAODVertex*>(nextV()) ) )
-    {
-      AliAODVertex* tmp = v->CloneWithoutRefs();
-      AliAODVertex* copiedVertex = new((*fVertices)[nvertices++]) AliAODVertex(*tmp);
-      
-      // to insure the main vertex retains the ncontributors information
-      // (which is otherwise computed dynamically from
-      // references to tracks, which we do not keep in muon aods...)
-      // we set it here
-      
-      copiedVertex->SetNContributors(v->GetNContributors()); 
-      
-      //  fVertices->Delete();
-      //         delete copiedVertex;
-      delete tmp;
-    }
-  
-  
-  AliDebug(1,Form("input mu tracks=%d tracks=%d vertices=%d",
-                  input,fTracks->GetEntries(),fVertices->GetEntries())); 
-  
-  
-  // Finally, deal with MC information, if needed
-  
-  if ( fMCMode > 0 ) {
-    FilterMC(source);      
-  }
-  
-
-}
-
-
-
-//-----------------------------------------------------------------------------
-
-//----------------------------------------------------------------------------
-       
-
-//-----------------------------------------------------------------------------
-
-// AliAODVertex* AliNanoAODReplicator::PrimaryVertex(const TObjArray *trkArray,
-//                                                AliAODEvent &event) const
-// {
-//   // Returns primary vertex to be used for this candidate
-//   //AliCodeTimerAuto("",0);
-
-//   AliESDVertex *vertexESD = 0;
-//   AliAODVertex *vertexAOD = 0;
-
-
-//   if(!fRecoPrimVtxSkippingTrks && !fRmTrksFromPrimVtx) { 
-//     // primary vertex from the input event
-    
-//     vertexESD = new AliESDVertex(*fV1);
-
-//   } else {
-//     // primary vertex specific to this candidate
-
-//     Int_t nTrks = trkArray->GetEntriesFast();
-//     AliVertexerTracks *vertexer = new AliVertexerTracks(event.GetMagneticField());
-
-//     if(fRecoPrimVtxSkippingTrks) { 
-//       // recalculating the vertex
-      
-//       if(strstr(fV1->GetTitle(),"VertexerTracksWithConstraint")) {
-//     Float_t diamondcovxy[3];
-//     event.GetDiamondCovXY(diamondcovxy);
-//     Double_t pos[3]={event.GetDiamondX(),event.GetDiamondY(),0.};
-//     Double_t cov[6]={diamondcovxy[0],diamondcovxy[1],diamondcovxy[2],0.,0.,10.*10.};
-//     AliESDVertex *diamond = new AliESDVertex(pos,cov,1.,1);
-//     vertexer->SetVtxStart(diamond);
-//     delete diamond; diamond=NULL;
-//     if(strstr(fV1->GetTitle(),"VertexerTracksWithConstraintOnlyFitter")) 
-//       vertexer->SetOnlyFitter();
-//       }
-//       Int_t skipped[1000];
-//       Int_t nTrksToSkip=0,id;
-//       AliExternalTrackParam *t = 0;
-//       for(Int_t i=0; i<nTrks; i++) {
-//     t = (AliExternalTrackParam*)trkArray->UncheckedAt(i);
-//     id = (Int_t)t->GetID();
-//     if(id<0) continue;
-//     skipped[nTrksToSkip++] = id;
-//       }
-//       // TEMPORARY FIX
-//       // For AOD, skip also tracks without covariance matrix
-//       if(fInputAOD) {
-//     Double_t covtest[21];
-//     for(Int_t j=0; j<event.GetNumberOfTracks(); j++) {
-//       AliVTrack *vtrack = (AliVTrack*)event.GetTrack(j);
-//       if(!vtrack->GetCovarianceXYZPxPyPz(covtest)) {
-//         id = (Int_t)vtrack->GetID();
-//         if(id<0) continue;
-//         skipped[nTrksToSkip++] = id;
-//       }
-//     }
-//       }
-//       for(Int_t ijk=nTrksToSkip; ijk<1000; ijk++) skipped[ijk]=-1;
-//       //
-//       vertexer->SetSkipTracks(nTrksToSkip,skipped);
-//       vertexESD = (AliESDVertex*)vertexer->FindPrimaryVertex(event); 
-      
-//     } else if(fRmTrksFromPrimVtx && nTrks>0) { 
-//       // removing the prongs tracks
-      
-//       TObjArray rmArray(nTrks);
-//       UShort_t *rmId = new UShort_t[nTrks];
-//       AliESDtrack *esdTrack = 0;
-//       AliESDtrack *t = 0;
-//       for(Int_t i=0; i<nTrks; i++) {
-//     t = (AliESDtrack*)trkArray->UncheckedAt(i);
-//     esdTrack = new AliESDtrack(*t);
-//     rmArray.AddLast(esdTrack);
-//     if(esdTrack->GetID()>=0) {
-//       rmId[i]=(UShort_t)esdTrack->GetID();
-//     } else {
-//       rmId[i]=9999;
-//     }
-//       }
-//       Float_t diamondxy[2]={event.GetDiamondX(),event.GetDiamondY()};
-//       vertexESD = vertexer->RemoveTracksFromVertex(fV1,&rmArray,rmId,diamondxy);
-//       delete [] rmId; rmId=NULL;
-//       rmArray.Delete();
-      
-//     }
-
-//     if(!vertexESD) return vertexAOD;
-//     if(vertexESD->GetNContributors()<=0) { 
-//       //AliDebug(2,"vertexing failed"); 
-//       delete vertexESD; vertexESD=NULL;
-//       return vertexAOD;
-//     }
-
-//     delete vertexer; vertexer=NULL;
-
-//   }
-
-//   // convert to AliAODVertex
-//   Double_t pos[3],cov[6],chi2perNDF;
-//   vertexESD->GetXYZ(pos); // position
-//   vertexESD->GetCovMatrix(cov); //covariance matrix
-//   chi2perNDF = vertexESD->GetChi2toNDF();
-//   delete vertexESD; vertexESD=NULL;
-
-//   vertexAOD = new AliAODVertex(pos,cov,chi2perNDF);
-
-//   return vertexAOD;
-// }
-
-//_____________________________________________________________________________
-
-
-
-// //---------------------------------------------------------------------------
-
-void AliNanoAODReplicator::Terminate(){
-
-}
diff --git a/PWG/DevNanoAOD/runGridESE.C b/PWG/DevNanoAOD/runGridESE.C
new file mode 100644 (file)
index 0000000..9fcc150
--- /dev/null
@@ -0,0 +1,260 @@
+#if !defined (__CINT__) || (defined(__MAKECINT__))
+#include <iostream>
+#include "AliAnalysisGrid.h"
+#include "TSystem.h"
+#include "TROOT.h"
+#include "AliAnalysisManager.h"
+#include "AliAnalysisGrid.h"
+#include "AliVEventHandler.h"
+#include "AliAODInputHandler.h"
+#include "AliAnalysisAlien.h"
+#include "AliMCEventHandler.h"
+#include "AliPhysicsSelectionTask.h"
+#include "TRegexp.h"
+#include "AliTriggerAnalysis.h"
+#include "TChain.h"
+#include "AliAnalysisTaskPIDResponse.h"
+#include "AliAODHandler.h"
+#include "AliAnalysisTaskNanoAODFilter.h"
+#include "AliESEHelpers.h"
+
+#endif
+void LoadLibs();
+
+class AliAnalysisGrid;
+class AliESETrkCut;
+class AliESEEvtCut;
+
+AliESETrkCut * TrkCuts() {
+
+  AliESETrkCut * trk = new AliESETrkCut;
+
+  AliSpectraAODTrackCuts  * trcuts = new AliSpectraAODTrackCuts("TrackCuts");  
+  trcuts->SetDCA(100000);
+  trcuts->SetTrackBits(1);
+  trcuts->SetPt(50);
+  trcuts->SetPtTOFMatching(0.6);   
+  trcuts->SetEta(-0.8,0.8);
+  trcuts->SetMinTPCcls(70);
+  trcuts->PrintCuts();
+
+  trk->SetTrackCuts(trcuts);
+  trk->Init();
+
+  return trk;
+
+}
+
+AliESEEvtCut * EvtCuts(Int_t mc) {
+
+  AliESEEvtCut * evt = new AliESEEvtCut;
+
+  AliSpectraAODEventCuts * evcuts = new AliSpectraAODEventCuts("EventCuts");
+  evcuts->SetQVectorCut(0,100);
+  evcuts->SetCentralityCutMax(100);  
+  evcuts->SetCentralityCutMin(0);
+  if(mc>0)evcuts->SetIsMC(kTRUE);
+  TFile * fCalib = new TFile("./calibV0New.root");
+  evcuts->SetCalibFile(fCalib);
+  evcuts->SetIsLHC10h(kTRUE);
+  evcuts->PrintCuts();
+  //  evcuts->SetEventSelectionBit(AliVEvent::kAny);
+
+  evt->SetEventCuts(evcuts);
+  evt->Init();
+
+  return evt;
+
+}
+
+//______________________________________________________________________________
+void runGridESE(
+                const char *gridmode = "test", // Set the run mode (can be "full", "test", "offline", "submit" or "terminate"). Full & T                
+                const char * taskname = "DevNanoAOD",
+                const int iMCtruth = 2, 
+                const char * addTaskString = ".x AddTaskNanoAODFilter.C(%d,1)" // 
+                )
+{
+  LoadLibs();
+  // analysis manager
+  AliAnalysisManager* mgr = new AliAnalysisManager("NanoAOD Filter", "NanoAOD filter for nanoAOD production");
+
+  AliAnalysisGrid *plugin = CreateAlienHandler(taskname, gridmode); 
+  plugin->SetFileForTestMode("files.txt"); // file should contain path name to a local directory containg *ESDs.root or AOD etc
+  mgr->SetGridHandler(plugin);
+
+    
+  AliAODInputHandler* iH = new AliAODInputHandler();
+  mgr->SetInputEventHandler(iH);
+
+  // Define aod output handler
+  AliAODHandler* aodOutputHandler = new AliAODHandler();
+  aodOutputHandler->SetOutputFileName("AliAOD.NanoAOD.root");
+  mgr->SetOutputEventHandler(aodOutputHandler);
+  
+  gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
+  AliAnalysisTaskPIDResponse *taskPID=AddTaskPIDResponse(iMCtruth);
+  taskPID->SetUseTPCEtaCorrection(kTRUE); 
+
+  // create task
+  cout << "Macro: "<< addTaskString << " " << Form(addTaskString, iMCtruth) << endl;
+
+  AliAnalysisTaskNanoAODFilter * task = (AliAnalysisTaskNanoAODFilter*) gROOT->ProcessLine(Form(addTaskString, iMCtruth));
+
+  // Set Track event and vertex cuts here!
+  task->SetVarList("pt,theta,phi,cstNSigmaTPCPi,cstNSigmaTPCKa,cstNSigmaTPCPr,cstNSigmaTOFPi,cstNSigmaTOFKa,cstNSigmaTOFPr,cstBayesTPCPi,cstBayesTPCKa,cstBayesTPCPr,cstBayesTOFPi,cstBayesTOFKa,cstBayesTOFPr");
+  task->SetVarListHead("cstCentr,cstQVec");
+  AliESETrkCut * trkCuts = TrkCuts();
+  AliESEEvtCut * evtCuts = EvtCuts(iMCtruth);
+  evtCuts->SetTrackCuts(trkCuts->GetTrackCuts());
+  AliAnalysisESESetter * setter  = new AliAnalysisESESetter;
+  setter->SetEventCuts(evtCuts->GetEventCuts());
+
+  task->SetTrkCuts(trkCuts);
+  task->SetEvtCuts(evtCuts);
+  task->SetSetter(setter);
+
+  //task->SelectCollisionCandidates(AliVEvent::kMB);// FIXME
+  // enable debug printouts
+  mgr->SetDebugLevel(10);
+  //    mgr->SetNSysInfo(100);
+  if (!mgr->InitAnalysis()) return;
+  mgr->PrintStatus();
+  
+  // start analysis
+  // Always read the same file:
+  TChain * chain = new TChain("aodTree");
+  chain->Add("./AliAOD.root");
+
+  Printf("Starting Analysis....");
+  mgr->StartAnalysis("grid", chain,123456789);
+
+}
+
+//______________________________________________________________________________
+
+AliAnalysisGrid* CreateAlienHandler(const char *taskname, const char *gridmode)
+{
+    AliAnalysisAlien *plugin = new AliAnalysisAlien();
+    // Set the run mode (can be "full", "test", "offline", "submit" or "terminate")
+    plugin->SetRunMode(gridmode);
+
+    // Set versions of used packages
+    plugin->SetAPIVersion("V1.1x");
+    plugin->SetROOTVersion("v5-34-08-5");
+    plugin->SetAliROOTVersion("v5-05-73-AN");
+
+    // Declare input data to be processed.
+    //    plugin->SetCheckCopy(kFALSE);
+
+    // Method 1: Create automatically XML collections using alien 'find' command.
+    // Define production directory LFN
+    plugin->SetGridDataDir("/alice/sim/LHC11a10a_bis");
+    // On real reconstructed data:
+    // plugin->SetGridDataDir("/alice/data/2009/LHC09d");
+    // Set data search pattern
+    //plugin->SetDataPattern("*ESDs.root"); // THIS CHOOSES ALL PASSES
+    // Data pattern for reconstructed data
+    plugin->SetDataPattern("*AOD120/*/AliAOD.root"); // CHECK LATEST PASS OF DATA SET IN ALIENSH
+    //    plugin->SetDataPattern("ESDs/pass2/AOD038/*AliAOD.root"); // CHECK LATEST PASS OF DATA SET IN ALIENSH
+    //    plugin->SetRunPrefix("000");   // real data
+    // ...then add run numbers to be considered
+    Int_t runlist[1]={137366};  
+    for (Int_t ind=0; ind<1; ind++) {
+//     plugin->AddRunNumber(138275);
+      plugin->AddRunNumber(runlist[ind]);
+    }
+    //plugin->SetRunRange(114917,115322);
+    plugin->SetNrunsPerMaster(10); // 1
+    plugin->SetOutputToRunNo();
+    // comment out the next line when using the "terminate" option, unless
+    // you want separate merged files for each run
+    plugin->SetMergeViaJDL();
+
+    // Method 2: Declare existing data files (raw collections, xml collections, root file)
+    // If no path mentioned data is supposed to be in the work directory (see SetGridWorkingDir())
+    // XML collections added via this method can be combined with the first method if
+    // the content is compatible (using or not tags)
+    //   plugin->AddDataFile("tag.xml");
+    //   plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root");
+
+    // Define alien work directory where all files will be copied. Relative to alien $HOME.
+    plugin->SetGridWorkingDir(taskname);
+
+    // Declare alien output directory. Relative to working directory.
+    plugin->SetGridOutputDir("out"); // In this case will be $HOME/taskname/out
+
+    // Declare the analysis source files names separated by blancs. To be compiled runtime
+    // using ACLiC on the worker nodes.
+    //    plugin->SetAnalysisSource("AliAnalysisTaskEx01.cxx");
+
+    // Declare all libraries (other than the default ones for the framework. These will be
+    // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here.
+    plugin->SetAdditionalLibs("libPWGLFspectra.so libPWGDevNanoAOD.so");
+
+    // Declare the output file names separated by blancs.
+    // (can be like: file.root or file.root@ALICE::Niham::File)
+    // To only save certain files, use SetDefaultOutputs(kFALSE), and then
+    // SetOutputFiles("list.root other.filename") to choose which files to save
+    plugin->SetDefaultOutputs();
+    //plugin->SetOutputFiles("list.root");
+
+    // Optionally set a name for the generated analysis macro (default MyAnalysis.C)
+    plugin->SetAnalysisMacro(Form("%s.C",taskname));
+
+    // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore)
+    plugin->SetSplitMaxInputFileNumber(100);
+
+    // Optionally modify the executable name (default analysis.sh)
+    plugin->SetExecutable(Form("%s.sh",taskname));
+
+    // set number of test files to use in "test" mode
+    plugin->SetNtestFiles(10);
+
+    // Optionally resubmit threshold.
+    plugin->SetMasterResubmitThreshold(90);
+
+    // Optionally set time to live (default 30000 sec)
+    plugin->SetTTL(30000);
+
+    // Optionally set input format (default xml-single)
+    plugin->SetInputFormat("xml-single");
+
+    // Optionally modify the name of the generated JDL (default analysis.jdl)
+    plugin->SetJDLName(Form("%s.jdl",taskname));
+
+    // Optionally modify job price (default 1)
+    plugin->SetPrice(1);      
+
+    // Optionally modify split mode (default 'se')    
+    plugin->SetSplitMode("se");
+    
+    return plugin;
+}
+
+
+
+void LoadLibs() {
+  gSystem->Load("libCore.so");  
+  gSystem->Load("libGeom.so");
+  gSystem->Load("libPhysics.so");
+  gSystem->Load("libVMC");
+  gSystem->Load("libTree");
+  gSystem->Load("libProof");
+  gSystem->Load("libMatrix");
+  gSystem->Load("libMinuit");
+  gSystem->Load("libSTEERBase");
+  gSystem->Load("libESD");
+  gSystem->Load("libAOD");
+  gSystem->Load("libANALYSIS");
+  //  return;
+  gSystem->Load("libOADB");
+  gSystem->Load("libANALYSISalice");
+  gSystem->Load("libTENDER");
+  gSystem->Load("libCORRFW");
+
+  //  gSystem->Load("libNanoAOD.so");
+  gSystem->Load("libPWGLFspectra");
+  gSystem->Load("libPWGDevNanoAOD");
+
+}
diff --git a/PWG/DevNanoAOD/runLocalCorrelations.C b/PWG/DevNanoAOD/runLocalCorrelations.C
new file mode 100644 (file)
index 0000000..bfa2f32
--- /dev/null
@@ -0,0 +1,116 @@
+#if !defined (__CINT__) || (defined(__MAKECINT__))
+#include <iostream>
+#include "AliAnalysisGrid.h"
+#include "TSystem.h"
+#include "TROOT.h"
+#include "AliAnalysisManager.h"
+#include "AliAnalysisGrid.h"
+#include "AliVEventHandler.h"
+#include "AliAODInputHandler.h"
+#include "AliAnalysisAlien.h"
+#include "AliMCEventHandler.h"
+#include "AliPhysicsSelectionTask.h"
+#include "TRegexp.h"
+#include "AliTriggerAnalysis.h"
+#include "TChain.h"
+#include "AliAnalysisTaskPIDResponse.h"
+#include "AliAODHandler.h"
+#include "AliAnalysisTaskNanoAODFilter.h"
+#include "AliESEHelpers.h"
+
+#endif
+void LoadLibs();
+
+class AliAnalysisGrid;
+
+
+
+//______________________________________________________________________________
+void runLocalCorrelations(
+                         const int iMCtruth = 2, 
+                         const char * addTaskString = ".x AddTaskNanoAODFilter.C(%d,1)" // 
+                         )
+{
+  LoadLibs();
+  // analysis manager
+  AliAnalysisManager* mgr = new AliAnalysisManager("NanoAOD Filter", "NanoAOD filter for nanoAOD production");
+    
+  AliAODInputHandler* iH = new AliAODInputHandler();
+  mgr->SetInputEventHandler(iH);
+
+  // Define aod output handler
+  AliAODHandler* aodOutputHandler = new AliAODHandler();
+  aodOutputHandler->SetOutputFileName("AliAOD.NanoAOD.root");
+  mgr->SetOutputEventHandler(aodOutputHandler);
+  
+  gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
+  AliAnalysisTaskPIDResponse *taskPID=AddTaskPIDResponse(iMCtruth);
+  taskPID->SetUseTPCEtaCorrection(kTRUE); 
+
+  // create task
+  cout << "Macro: "<< addTaskString << " " << Form(addTaskString, iMCtruth) << endl;
+
+  AliAnalysisTaskNanoAODFilter * task = (AliAnalysisTaskNanoAODFilter*) gROOT->ProcessLine(Form(addTaskString, iMCtruth));
+
+  // Set Track event and vertex cuts here!
+  AliAnalysisNanoAODTrackCuts* trk = new AliAnalysisNanoAODTrackCuts;
+  //  trk->SetBitMask((1 << 4) | (1 << 8)); // hybrid 2010
+  trk->SetBitMask((1 << 9)); // ???
+  trk->SetMaxEta(0.9);
+  trk->SetMinPt(0.5);
+
+  AliAnalysisNanoAODEventCuts* evt = new AliAnalysisNanoAODEventCuts;
+  evt->SetVertexRange(7);
+
+  task->SetTrkCuts(trk);
+  task->SetEvtCuts(evt);
+  task->SetSetter(new AliNanoAODSimpleSetter);
+  task->SetVarList("pt,theta,phi");
+  task->SetVarListHead("cstCentr,cstMagField");
+
+  task->SelectCollisionCandidates(AliVEvent::kMB);
+
+
+  //task->SelectCollisionCandidates(AliVEvent::kMB);// FIXME
+  // enable debug printouts
+  mgr->SetDebugLevel(10);
+  //    mgr->SetNSysInfo(100);
+  if (!mgr->InitAnalysis()) return;
+  mgr->PrintStatus();
+  
+  // start analysis
+  // Always read the same file:
+  TChain * chain = new TChain("aodTree");
+  chain->Add("./AliAOD.root");
+
+  Printf("Starting Analysis....");
+  mgr->StartAnalysis("local", chain,123456789);
+
+}
+
+//______________________________________________________________________________
+
+void LoadLibs() {
+  gSystem->Load("libCore.so");  
+  gSystem->Load("libGeom.so");
+  gSystem->Load("libPhysics.so");
+  gSystem->Load("libVMC");
+  gSystem->Load("libTree");
+  gSystem->Load("libProof");
+  gSystem->Load("libMatrix");
+  gSystem->Load("libMinuit");
+  gSystem->Load("libSTEERBase");
+  gSystem->Load("libESD");
+  gSystem->Load("libAOD");
+  gSystem->Load("libANALYSIS");
+  //  return;
+  gSystem->Load("libOADB");
+  gSystem->Load("libANALYSISalice");
+  gSystem->Load("libTENDER");
+  gSystem->Load("libCORRFW");
+
+  //  gSystem->Load("libNanoAOD.so");
+  gSystem->Load("libPWGLFspectra");
+  gSystem->Load("libPWGDevNanoAOD");
+
+}
index 8597fa0..e493db1 100644 (file)
@@ -12,6 +12,7 @@
 #pragma link C++ class AliNanoAODCustomSetter+;
 #pragma link C++ class AliAnalysisNanoAODTrackCuts+;
 #pragma link C++ class AliAnalysisNanoAODEventCuts+;
+#pragma link C++ class AliNanoAODSimpleSetter+;         
 // Custom ESE classes: to be removed once the library is not in dev mode any more
 #pragma link C++ class AliESEEvtCut+;
 #pragma link C++ class AliESETrkCut+;
@@ -19,4 +20,5 @@
 
 
 
+
 #endif