Added analysis task for checking basic properties in ITS, TPC, and TRD in order to...
authoresicking <esicking@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 22 Jul 2010 14:17:27 +0000 (14:17 +0000)
committeresicking <esicking@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 22 Jul 2010 14:17:27 +0000 (14:17 +0000)
test/vmctest/scripts/cluster/AliAnalysisTaskCluster.cxx [new file with mode: 0644]
test/vmctest/scripts/cluster/AliAnalysisTaskCluster.h [new file with mode: 0644]
test/vmctest/scripts/cluster/file.txt [new file with mode: 0644]
test/vmctest/scripts/cluster/runlocal.C [new file with mode: 0644]

diff --git a/test/vmctest/scripts/cluster/AliAnalysisTaskCluster.cxx b/test/vmctest/scripts/cluster/AliAnalysisTaskCluster.cxx
new file mode 100644 (file)
index 0000000..2d1380f
--- /dev/null
@@ -0,0 +1,263 @@
+#include "TChain.h"
+#include "TTree.h"
+#include "TH1F.h"
+#include "TH2F.h"
+#include "TH3F.h"
+#include "TCanvas.h"
+#include "TList.h"
+#include "TParticle.h"
+#include "TParticlePDG.h"
+#include "TProfile.h"
+#include "TNtuple.h"
+#include "TFile.h"
+
+#include "AliAnalysisTask.h"
+#include "AliAnalysisManager.h"
+
+#include "AliESDEvent.h"
+#include "AliLog.h"
+#include "AliESDVertex.h"
+#include "AliESDInputHandler.h"
+#include "AliESDtrackCuts.h"
+#include "AliMultiplicity.h"
+
+#include "AliAnalysisTaskCluster.h"
+#include "AliExternalTrackParam.h"
+#include "AliTrackReference.h"
+#include "AliHeader.h"
+#include "AliGenEventHeader.h"
+#include "AliGenDPMjetEventHeader.h"
+
+// Analysis Task for basic QA on cluster numbers
+
+// Authors: Eva Sicking
+
+ClassImp(AliAnalysisTaskCluster)
+
+  //________________________________________________________________________
+  AliAnalysisTaskCluster::AliAnalysisTaskCluster(const char *name) 
+    : AliAnalysisTaskSE(name) 
+    ,fTrackType(0)
+    ,fFieldOn(kTRUE)
+    ,fHists(0)
+  
+    ,fHistRECpt(0)
+    ,fITSncl(0)
+    ,fTPCncl(0)
+    ,fTPCnclSA(0)
+    ,fTRDncl(0)
+
+    ,pEtaITSncl(0)
+    ,pEtaTPCncl(0)
+    ,pEtaTPCnclR(0)
+    ,pEtaTRDncl(0)
+
+    ,pPhiITSncl(0)
+    ,pPhiTPCncl(0)
+    ,pPhiTPCnclR(0)
+    ,pPhiTRDncl(0)
+
+    ,pPtITSncl(0)
+    ,pPtTPCncl(0)
+    ,pPtTPCnclR(0)
+    ,pPtTRDncl(0)
+
+    ,fITSlayer(0)
+    ,fITSlayerPhi(0)
+    ,fITSlayerEta(0)
+
+    ,fCuts(0)
+
+{
+
+  DefineOutput(1,  TList::Class()); 
+
+  
+  
+}
+
+
+//________________________________________________________________________
+void AliAnalysisTaskCluster::UserCreateOutputObjects()
+{
+  // Create histograms
+  // Called once
+
+  Bool_t oldStatus = TH1::AddDirectoryStatus();
+  TH1::AddDirectory(kFALSE);
+
+
+  Double_t pt = 20.;
+
+  fHists = new TList();
+  fHistRECpt   = new TH1F("fHistRECpt", " p_{T}", 100, 0., pt);
+
+  fITSncl = new TH1F("fITSncl", "fITSncl", 11, -1.5, 9.5);
+  fTPCncl = new TH1F("fTPCncl", "fTPCncl", 182, -1.5, 180.5);
+  fTPCnclSA = new TH1F("fTPCnclSA", "fTPCnclSA", 182, -1.5, 180.5);
+  fTRDncl = new TH1F("fTRDncl", "fTRDncl", 182, -1.5, 180.5);
+
+  //Create Profiles
+  pEtaITSncl = new TProfile("pEtaITSncl", "pEtaITSncl", 20, -2, 2);
+  pEtaTPCncl = new TProfile("pEtaTPCncl", "pEtaTPCncl", 20, -2, 2);
+  pEtaTPCnclR = new TProfile("pEtaTPCnclR", "pEtaTPCnclR", 20, -2, 2, 90, 180);
+  pEtaTRDncl = new TProfile("pEtaTRDncl", "pEtaTRDncl", 20, -2, 2);
+
+  pPhiITSncl = new TProfile("pPhiITSncl", "pPhiITSncl", 90, 0, 2*TMath::Pi());
+  pPhiTPCncl = new TProfile("pPhiTPCncl", "pPhiTPCncl", 90, 0, 2*TMath::Pi());
+  pPhiTPCnclR = new TProfile("pPhiTPCnclR", "pPhiTPCnclR", 90, 0, 2*TMath::Pi(), 90, 180);
+  pPhiTRDncl = new TProfile("pPhiTRDncl", "pPhiTRDncl", 90, 0, 2*TMath::Pi());
+
+  pPtITSncl = new TProfile("pPtITSncl", "pPtITSncl", 40, 0, 20);
+  pPtTPCncl = new TProfile("pPtTPCncl", "pPtTPCncl", 40, 0, 20);
+  pPtTPCnclR = new TProfile("pPtTPCnclR", "pPtTPCnclR", 40, 0, 20, 90, 180);
+  pPtTRDncl = new TProfile("pPtTRDncl", "pPtTRDncl", 40, 0, 20);
+
+  fITSlayer = new TH1F("fITSlayer", "fITSlayer", 8, -1.5, 6.5);
+  fITSlayerPhi = new TH2F("fITSlayerPhi", "fITSlayerPhi", 8, -1.5, 6.5,90, 0, 2*TMath::Pi());
+  fITSlayerEta = new TH2F("fITSlayerEta", "fITSlayerEta", 8, -1.5, 6.5,100, -2, 2);
+
+  fHists->SetOwner();
+  fHists->Add(fHistRECpt);
+  fHists->Add(fITSncl);
+  fHists->Add(fTPCncl);
+  fHists->Add(fTPCnclSA);
+  fHists->Add(fTRDncl);
+
+  fHists->Add(pEtaITSncl);
+  fHists->Add(pEtaTPCncl);
+  fHists->Add(pEtaTPCnclR);
+  fHists->Add(pEtaTRDncl);
+
+  fHists->Add(pPhiITSncl);
+  fHists->Add(pPhiTPCncl);
+  fHists->Add(pPhiTPCnclR);
+  fHists->Add(pPhiTRDncl);
+
+  fHists->Add(pPtITSncl);
+  fHists->Add(pPtTPCncl);
+  fHists->Add(pPtTPCnclR);
+  fHists->Add(pPtTRDncl);
+
+  fHists->Add(fITSlayer);
+  fHists->Add(fITSlayerPhi);
+  fHists->Add(fITSlayerEta);
+
+    
+  //   for (Int_t i=0; i<fHists->GetEntries(); ++i) {
+  //     TH1 *h1 = dynamic_cast<TH1*>(fHists->At(i));
+  //     if (h1){
+  //       // Printf("%s ",h1->GetName());
+  //       h1->Sumw2();
+  //     }
+  //   }
+
+
+  TH1::AddDirectory(oldStatus);
+}
+
+//__________________________________________________________
+
+void AliAnalysisTaskCluster::UserExec(Option_t *) 
+{
+  AliVEvent *event = InputEvent();
+  if (!event) {
+    Printf("ERROR: Could not retrieve event");
+    return;
+  }
+
+
+  if(Entry()==0){
+    AliESDEvent* esd = dynamic_cast<AliESDEvent*>(event);
+    if(esd){
+      Printf("We are reading from ESD");
+    }
+   
+  }
+
+
+  if(fDebug>1)Printf("There are %d tracks in this event", event->GetNumberOfTracks());
+
+  
+  const AliVVertex* vertex = event->GetPrimaryVertex();
+  Float_t vz = vertex->GetZ();
+  if (TMath::Abs(vz) > 10.) return;
+
+  for (Int_t iTrack = 0; iTrack < event->GetNumberOfTracks(); iTrack++) {
+   
+    AliVParticle *track = event->GetTrack(iTrack);
+    AliESDtrack *esdtrack =  dynamic_cast<AliESDtrack*>(track);
+
+
+    if (!track) {
+      Printf("ERROR: Could not receive track %d", iTrack);
+      continue;
+    }
+    
+    if (!fCuts->AcceptTrack(esdtrack)) continue;
+  
+
+    fHistRECpt->Fill(esdtrack->Pt());
+    fITSncl->Fill(esdtrack->GetNcls(0)); //0=ITS
+    fTPCncl->Fill(esdtrack->GetNcls(1)); //1=TPC
+    fTRDncl->Fill(esdtrack->GetNcls(2)); //2=TRD
+    
+    const AliExternalTrackParam *tpcP = 0x0;
+    tpcP = esdtrack->GetTPCInnerParam();
+    if(tpcP){
+      fTPCnclSA->Fill(esdtrack->GetNcls(1));
+    }
+
+    
+    if(esdtrack->GetNcls(0)!=0){
+      for(Int_t layer=0;layer<6;layer++){
+       if(esdtrack->HasPointOnITSLayer(layer)){
+         fITSlayer->Fill(layer);
+         fITSlayerPhi->Fill(layer, esdtrack->Phi());
+         fITSlayerEta->Fill(layer, esdtrack->Eta());
+       }
+      }
+
+      pEtaITSncl->Fill(esdtrack->Eta(),esdtrack->GetNcls(0));
+      pPhiITSncl->Fill(esdtrack->Phi(),esdtrack->GetNcls(0));
+      pPtITSncl->Fill(esdtrack->Pt(),esdtrack->GetNcls(0));
+    }
+    if(esdtrack->GetNcls(1)!=0){
+      pEtaTPCncl->Fill(esdtrack->Eta(),esdtrack->GetNcls(1));
+      pPhiTPCncl->Fill(esdtrack->Phi(),esdtrack->GetNcls(1));
+      pPtTPCncl->Fill(esdtrack->Pt(),esdtrack->GetNcls(1));
+
+      pEtaTPCnclR->Fill(esdtrack->Eta(),esdtrack->GetNcls(1));
+      pPhiTPCnclR->Fill(esdtrack->Phi(),esdtrack->GetNcls(1));
+      pPtTPCnclR->Fill(esdtrack->Pt(),esdtrack->GetNcls(1));
+    }
+    if(esdtrack->GetNcls(2)!=0){
+      pPhiTRDncl->Fill(esdtrack->Phi(),esdtrack->GetNcls(2));  
+      pEtaTRDncl->Fill(esdtrack->Eta(),esdtrack->GetNcls(2));
+      pPtTRDncl->Fill(esdtrack->Pt(),esdtrack->GetNcls(2));
+    }
+
+
+  
+  }//first track loop
+
+  
+  // Post output data.
+  // PostData(1, fHistPt);
+  PostData(1, fHists);
+}      
+
+
+
+//________________________________________________________________________
+void AliAnalysisTaskCluster::Terminate(Option_t *) 
+{
+
+
+}  
+
+
+
+
+
diff --git a/test/vmctest/scripts/cluster/AliAnalysisTaskCluster.h b/test/vmctest/scripts/cluster/AliAnalysisTaskCluster.h
new file mode 100644 (file)
index 0000000..aebeacf
--- /dev/null
@@ -0,0 +1,83 @@
+#ifndef AliAnalysisTaskCluster_cxx
+#define AliAnalysisTaskCluster_cxx
+
+class TH1F;
+class TH2F;
+class TH3F;
+class TList;
+class TNtuple;
+
+class AliESDEvent;
+class AliESDtrack;
+class AliESDtrackCuts;
+
+
+#include "AliAnalysisTaskSE.h"
+#include "TFile.h"
+#include "TNtuple.h"
+
+class AliAnalysisTaskCluster : public AliAnalysisTaskSE {
+ public:
+  AliAnalysisTaskCluster(const char *name = "AliAnalysisTaskCluster");
+  virtual ~AliAnalysisTaskCluster() {}
+  
+  virtual void   UserCreateOutputObjects();
+  virtual void   UserExec(Option_t *option);
+  virtual void   Terminate(Option_t *);
+  virtual void   SetTrackType(Int_t type) {fTrackType = type;}  
+  
+  
+  virtual void   SetCuts(AliESDtrackCuts* cuts)
+     {fCuts = cuts;}
+
+  virtual void   SetFieldOn(Bool_t b = kTRUE){fFieldOn = b;} 
+
+  
+ private:
+
+  Int_t       fTrackType;       // setter for track types (not implemented yet)
+  Bool_t      fFieldOn;         // magnetic field
+
+  TList       *fHists;          // List of histos
+
+  //old
+  TH1F        * fHistRECpt;      // pt 
+  TH1F        * fITSncl;         // number of clusters in ITS (from global track)
+  TH1F        * fTPCncl;         // number of clusters in TPC ("")
+  TH1F        * fTPCnclSA;       // number of clusters in TPC from TPC track
+  TH1F        * fTRDncl;         // number of clusters in TRD
+
+  TProfile    * pEtaITSncl;      // average ncl vs eta
+  TProfile    * pEtaTPCncl;      // average ncl vs eta
+  TProfile    * pEtaTPCnclR;     // average ncl vs eta
+  TProfile    * pEtaTRDncl;      // average ncl vs eta
+
+  TProfile    * pPhiITSncl;      // average ncl vs phi
+  TProfile    * pPhiTPCncl;      // average ncl vs phi
+  TProfile    * pPhiTPCnclR;     // average ncl vs phi
+  TProfile    * pPhiTRDncl;      // average ncl vs phi
+
+  TProfile    * pPtITSncl;       // average ncl vs pt
+  TProfile    * pPtTPCncl;       // average ncl vs pt
+  TProfile    * pPtTPCnclR;      // average ncl vs pt
+  TProfile    * pPtTRDncl;       // average ncl vs pt
+
+  TH1F        * fITSlayer;       //hits per ITS layer
+  TH2F        * fITSlayerPhi;    //hits per ITS layer vs phi
+  TH2F        * fITSlayerEta;    //hits per ITS layer vs eta
+
+
+
+  AliESDtrackCuts* fCuts;        // List of cuts
+
+
+
+  AliAnalysisTaskCluster(const AliAnalysisTaskCluster&); // not implemented
+  AliAnalysisTaskCluster& operator=(const AliAnalysisTaskCluster&); // not implemented
+  
+  ClassDef(AliAnalysisTaskCluster, 1); // Basic QA exploiting cluster numbers
+};
+
+#endif
diff --git a/test/vmctest/scripts/cluster/file.txt b/test/vmctest/scripts/cluster/file.txt
new file mode 100644 (file)
index 0000000..48a5cc1
--- /dev/null
@@ -0,0 +1,4 @@
+$ALICE_ROOT/test/vmctest/ppbench/g4/AliESDs.root
+
+
+
diff --git a/test/vmctest/scripts/cluster/runlocal.C b/test/vmctest/scripts/cluster/runlocal.C
new file mode 100644 (file)
index 0000000..a28ed3c
--- /dev/null
@@ -0,0 +1,85 @@
+void runlocal() {
+  TStopwatch timer;
+  timer.Start();
+
+
+  gSystem->SetIncludePath("-I$ROOTSYS/include -I$ALICE_ROOT/include"); 
+  gSystem->Load("libTree.so");
+  gSystem->Load("libGeom.so");
+  gSystem->Load("libVMC.so");
+  gSystem->Load("libPhysics.so");
+  
+  //Enable the needed package
+  gSystem->Load("libSTEERBase");
+  gSystem->Load("libESD");
+  gSystem->Load("libAOD");
+  gSystem->Load("libANALYSIS");
+  gSystem->Load("libANALYSISalice");
+
+ // Create chain of input files
+  gROOT->LoadMacro("$ALICE_ROOT/PWG0/CreateESDChain.C");
+  TChain* chain = CreateESDChain("file.txt", 3);
+  //ANALYSIS PART
+  gROOT->LoadMacro("AliAnalysisTaskCluster.cxx++g");
+
+    
+  //____________________________________________//
+  // Make the analysis manager
+  AliAnalysisManager *mgr = new AliAnalysisManager("TestManager");
+  
+  //AliVEventHandler* esdH = new AliESDInputHandler;
+  AliESDInputHandler* esdH = new AliESDInputHandler;
+  esdH->SetReadFriends(0);
+  mgr->SetInputEventHandler(esdH);  
+
+  AliMCEventHandler* mcH = new AliMCEventHandler();
+  mcH->SetReadTR(kFALSE);
+  mgr->SetMCtruthEventHandler(mcH);
+
+
+ //____________________________________________//
+  // event selection 
+
+  gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
+  AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection();
+  physSelTask->GetPhysicsSelection()->SetAnalyzeMC(); 
+
+  AliPhysicsSelection* physSel = physSelTask->GetPhysicsSelection();
+  physSel->AddBackgroundIdentification(new AliBackgroundSelection());
+
+  
+  //____________________________________________//
+  // analysis task and esd track cuts
+  AliAnalysisTaskCluster *task1 = new AliAnalysisTaskCluster("AliAnalysisTaskCluster");
+
+  AliESDtrackCuts* esdTrackCutsL1 = new AliESDtrackCuts("AliESDtrackCuts","test");
+  esdTrackCutsL1->SetMaxDCAToVertexXY(3.);
+  esdTrackCutsL1->SetMaxDCAToVertexZ(3.);
+  esdTrackCutsL1->SetAcceptKinkDaughters(kFALSE);
+  
+
+  task1->SetCuts(esdTrackCutsL1);
+  task1->SelectCollisionCandidates();
+
+
+  mgr->AddTask(task1);
+  // Create containers for input/output
+  AliAnalysisDataContainer *cinput1 = 
+    mgr->CreateContainer("cchain",TChain::Class(),AliAnalysisManager::kInputContainer);
+  AliAnalysisDataContainer *coutput1 = 
+    mgr->CreateContainer("chist1",TList::Class(),AliAnalysisManager::kOutputContainer,
+                        "Cluster.local.root");
+  
+  //____________________________________________//
+  mgr->ConnectInput(task1, 0, mgr->GetCommonInputContainer());
+  mgr->ConnectOutput(task1,1,coutput1);
+  if (!mgr->InitAnalysis()) return;
+  mgr->PrintStatus();
+  mgr->StartAnalysis("local",chain);
+  //mgr->StartAnalysis("local",chain, 100,200);//startevent, nevents
+
+  timer.Stop();
+  timer.Print();
+}
+