Task for LEGO train
authorcoppedis <coppedis@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 6 Feb 2013 18:58:50 +0000 (18:58 +0000)
committercoppedis <coppedis@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 6 Feb 2013 18:58:50 +0000 (18:58 +0000)
PWGLF/FORWARD/GEO/AliAnalysisTaskZDCpAcalib.cxx [new file with mode: 0644]
PWGLF/FORWARD/GEO/AliAnalysisTaskZDCpAcalib.h [new file with mode: 0644]
PWGLF/FORWARD/macros/AddTaskZDCpAcalib.C [new file with mode: 0644]

diff --git a/PWGLF/FORWARD/GEO/AliAnalysisTaskZDCpAcalib.cxx b/PWGLF/FORWARD/GEO/AliAnalysisTaskZDCpAcalib.cxx
new file mode 100644 (file)
index 0000000..7ec4e81
--- /dev/null
@@ -0,0 +1,234 @@
+/**************************************************************************
+ * Copyright(c) 1998-2008, 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.                  *
+ **************************************************************************/
+
+/////////////////////////////////////////////////////////////
+//                                                        //
+//     Class to analyze ZDC data                          //
+//                                                        //
+/////////////////////////////////////////////////////////////
+
+#include <TTree.h>
+#include <TList.h>
+#include <TFile.h>
+#include <TString.h>
+#include <TCanvas.h>
+
+#include "AliAnalysisManager.h"
+#include "AliInputEventHandler.h"
+#include "AliVEvent.h"
+#include "AliESD.h"
+#include "AliESDEvent.h"
+#include "AliESDHeader.h"
+#include "AliESDInputHandler.h"
+#include "AliESDZDC.h"
+#include "AliMultiplicity.h"
+#include "AliAODHandler.h"
+#include "AliAODEvent.h"
+#include "AliAODHeader.h"
+#include "AliAODVertex.h"
+#include "AliAODVZERO.h"
+#include "AliAODZDC.h"
+#include "AliAODMCHeader.h"
+#include "AliMCEventHandler.h"
+#include "AliMCEvent.h"
+#include "AliHeader.h"
+#include "AliAODMCParticle.h"
+#include "AliAnalysisTaskSE.h"
+#include "AliGenEventHeader.h"
+#include "AliGenHijingEventHeader.h"
+#include "AliPhysicsSelectionTask.h"
+#include "AliPhysicsSelection.h"
+#include "AliTriggerAnalysis.h"
+#include "AliCentrality.h"
+#include "AliAnalysisTaskZDCpAcalib.h"
+
+ClassImp(AliAnalysisTaskZDCpAcalib)
+
+
+//________________________________________________________________________
+AliAnalysisTaskZDCpAcalib::AliAnalysisTaskZDCpAcalib():
+  AliAnalysisTaskSE(),
+    fDebug(0),
+    fAnalysisInput("ESD"),
+    fIsMCInput(kFALSE),
+    fUseSpecialOutput(kFALSE),
+    fOutput(0x0),
+    fCentralityTree(0x0),
+    fIsEventSelected(kFALSE),
+    fIsV0ATriggered(0),
+    fIsV0CTriggered(0)
+{   
+   // Default constructor
+
+  for(Int_t itow=0; itow<5; itow++){
+     fZNCtower[itow]=0.;  
+     fZNAtower[itow]=0.;  
+     fZNCtowerLG[itow]=0.;
+     fZNAtowerLG[itow]=0.;
+
+  }
+  
+  for(Int_t itdc=0; itdc<32; itdc++){
+    for(Int_t ihit=0; ihit<4; ihit++) fTDCvalues[itdc][ihit]=9999;
+  }
+}   
+
+//________________________________________________________________________
+AliAnalysisTaskZDCpAcalib::AliAnalysisTaskZDCpAcalib(const char *name):
+  AliAnalysisTaskSE(name),
+    fDebug(0),
+    fAnalysisInput("ESD"),
+    fIsMCInput(kFALSE),
+    fUseSpecialOutput(kFALSE),
+    fOutput(0x0),
+    fCentralityTree(0x0),
+    fIsEventSelected(kFALSE),
+    fIsV0ATriggered(0),
+    fIsV0CTriggered(0)
+{
+  // Default constructor
+  for(Int_t itow=0; itow<5; itow++){
+     fZNCtower[itow]=0.;  
+     fZNAtower[itow]=0.;  
+     fZNCtowerLG[itow]=0.;
+     fZNAtowerLG[itow]=0.;
+
+  }
+  
+  for(Int_t itdc=0; itdc<32; itdc++){
+    for(Int_t ihit=0; ihit<4; ihit++) fTDCvalues[itdc][ihit]=9999;
+  }
+  
+  // Output slot #1 writes into a TList container
+  DefineOutput(1, TList::Class()); 
+  
+}
+//________________________________________________________________________
+AliAnalysisTaskZDCpAcalib::~AliAnalysisTaskZDCpAcalib()
+{
+  // Destructor
+  if(fOutput && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()){
+    delete fOutput; fOutput=0;
+  } 
+  if(fCentralityTree && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()){
+    delete fCentralityTree; fCentralityTree=0;
+  } 
+  
+}  
+
+//________________________________________________________________________
+void AliAnalysisTaskZDCpAcalib::UserCreateOutputObjects()
+{
+  // Create the output containers
+  if(fDebug>1) printf("AnalysisTaskZDCpAcalib::UserCreateOutputObjects() \n");
+
+  if (fUseSpecialOutput) OpenFile(1);
+
+  // Several histograms are more conveniently managed in a TList
+  fOutput = new TList;
+  fOutput->SetOwner();
+  //fOutput->SetName("output");
+
+    fCentralityTree = new TTree("fCentralityTree", "Centrality vs. multiplicity tree");
+    //
+    fCentralityTree->Branch("trigClass",&fTrigClass,"trigClass/C");
+    fCentralityTree->Branch("eventSelected",&fIsEventSelected,"eventSelected/O");
+    fCentralityTree->Branch("isV0ATriggered", &fIsV0ATriggered,"isV0ATriggered/I");
+    fCentralityTree->Branch("isV0CTriggered", &fIsV0CTriggered,"isV0CTriggered/I");
+    fCentralityTree->Branch("znctower", fZNCtower, "znctower[5]/F");
+    fCentralityTree->Branch("znatower", fZNAtower, "znatower[5]/F");
+    fCentralityTree->Branch("znctowerLG", fZNCtowerLG, "znctowerLG[5]/F");
+    fCentralityTree->Branch("znatowerLG", fZNAtowerLG, "znatowerLG[5]/F");
+    fCentralityTree->Branch("tdc", fTDCvalues, "tdc[32][4]/I");
+      
+    fOutput->Add(fCentralityTree);      
+    PostData(1, fOutput);
+  
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskZDCpAcalib::UserExec(Option_t */*option*/)
+{
+  // Execute analysis for current event:
+  if(fDebug>1) printf(" **** AliAnalysisTaskZDCpAcalib::UserExec() \n");
+  
+  if (!InputEvent()) {
+    Printf("ERROR: InputEvent not available");
+    return;
+  }
+
+  if(fAnalysisInput.CompareTo("ESD")==0){
+      
+      //printf(" \t ***Analizing ESD ev. %d\n",fNev);
+      
+      AliESDEvent* esd = dynamic_cast<AliESDEvent*> (InputEvent());
+      if(!esd) return;
+      
+      // Select PHYSICS events (type=7, for data)
+      if(!fIsMCInput && esd->GetEventType()!=7) return; 
+      
+      // ***** Trigger selection
+      TString triggerClass = esd->GetFiredTriggerClasses();
+      sprintf(fTrigClass,"%s",triggerClass.Data());
+      
+      // use response of AliPhysicsSelection
+      fIsEventSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kCINT5);       
+
+          
+      AliESDVZERO *vzeroAOD = esd->GetVZEROData();
+      fIsV0ATriggered = vzeroAOD->GetV0ADecision();
+      fIsV0CTriggered = vzeroAOD->GetV0CDecision();
+        
+      AliESDZDC *esdZDC = esd->GetESDZDC();
+       
+      const Double_t * towZNC = esdZDC->GetZN1TowerEnergy();
+      const Double_t * towZNA = esdZDC->GetZN2TowerEnergy();
+      //
+      const Double_t * towZNCLG = esdZDC->GetZN1TowerEnergyLR();
+      const Double_t * towZNALG = esdZDC->GetZN2TowerEnergyLR();
+      //
+      for(Int_t it=0; it<5; it++){
+         fZNCtower[it] = (Float_t) (towZNC[it]);
+         fZNAtower[it] = (Float_t) (towZNA[it]); 
+         fZNCtowerLG[it] = (Float_t) (towZNCLG[it]);
+         fZNAtowerLG[it] = (Float_t) (towZNALG[it]); 
+      }
+
+      for(Int_t itdc=0; itdc<32; itdc++){
+        for(Int_t i=0; i<4; i++){
+          fTDCvalues[itdc][i] = esdZDC->GetZDCTDCData(itdc, i);
+        }
+      }      
+  }   
+  
+  
+  fCentralityTree->Fill();
+  PostData(1, fOutput);
+  
+   
+}
+
+
+
+//________________________________________________________________________
+void AliAnalysisTaskZDCpAcalib::Terminate(Option_t */*option*/)
+{
+  // Terminate analysis
+  //
+  printf(" **** AliAnalysisTaskZDCpAcalib::Terminate() \n");
+}
diff --git a/PWGLF/FORWARD/GEO/AliAnalysisTaskZDCpAcalib.h b/PWGLF/FORWARD/GEO/AliAnalysisTaskZDCpAcalib.h
new file mode 100644 (file)
index 0000000..8cdfead
--- /dev/null
@@ -0,0 +1,71 @@
+#ifndef ALIANALYSISTASKZDCPACALIB_H
+#define ALIANALYSISTASKZDCPACALIB_H
+
+/* Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+//*****************************************************
+//   Class AliAnalysisTaskZDCpAcalib
+//   author: Chiara Oppedisano
+//*****************************************************
+
+#include "AliAnalysisTaskSE.h"
+
+class TROOT;
+class TSystem;
+class TList;
+class TFile;
+class TTree;
+
+class AliAnalysisTaskZDCpAcalib : public AliAnalysisTaskSE {
+
+ public:
+
+  AliAnalysisTaskZDCpAcalib();
+  AliAnalysisTaskZDCpAcalib(const char *name);
+  virtual ~AliAnalysisTaskZDCpAcalib();
+
+  // Implementation of interface methods
+  virtual void UserCreateOutputObjects();
+  virtual void UserExec(Option_t *option);
+  virtual void Terminate(Option_t *option);
+
+  virtual void  SetDebugLevel(Int_t level) {fDebug = level;}
+  void SetInput(const char* input) {fAnalysisInput = input;}
+  void SetMCInput() {fIsMCInput = kTRUE;}
+   void SetUseSpecialOutput(Bool_t v=kTRUE) {fUseSpecialOutput = v;}
+
+ private:
+
+  Int_t    fDebug;             //  Debug flag
+  TString  fAnalysisInput;     // "ESD", "AOD"
+  Bool_t   fIsMCInput;          // true when input is MC
+  Bool_t   fUseSpecialOutput;   // do we use special output instead of merging?
+  //
+  TList   *fOutput;            //! list send on output slot 0
+  //
+  TTree   *fCentralityTree;     //! output tree
+  //
+  char     fTrigClass[100];    //  fired trigger classes
+  //
+  Bool_t   fIsEventSelected;    //  is physics selection on
+  //
+  Int_t    fIsV0ATriggered;    //  VOA decision
+  Int_t    fIsV0CTriggered;    //  V0C decision
+  //
+  Float_t  fZNCtower[5];       //  ZNC 5 tower signals
+  Float_t  fZNAtower[5];       //  ZNA 5 tower signals
+  Float_t  fZNCtowerLG[5];     //  ZNC 5 tower signals
+  Float_t  fZNAtowerLG[5];     //  ZPC 5 tower signals
+  //
+  Int_t    fTDCvalues[32][4];   // TDC raw values !ONLY FOR ESDs ANALYSIS!
+  
+  AliAnalysisTaskZDCpAcalib& operator= (const AliAnalysisTaskZDCpAcalib& ana);
+  AliAnalysisTaskZDCpAcalib(const AliAnalysisTaskZDCpAcalib& c);
+  //
+  ClassDef(AliAnalysisTaskZDCpAcalib,1); 
+
+};
+
+#endif
+
diff --git a/PWGLF/FORWARD/macros/AddTaskZDCpAcalib.C b/PWGLF/FORWARD/macros/AddTaskZDCpAcalib.C
new file mode 100644 (file)
index 0000000..bfe41bd
--- /dev/null
@@ -0,0 +1,56 @@
+AliAnalysisTaskSE* AddTaskZDCPbPb(Bool_t  applyPS = kTRUE,
+                                 TString outfname = "ZDCpAcalib",
+                                 Bool_t  isMC = kFALSE)
+{
+  
+  // Get the pointer to the existing analysis manager via the static access method.
+  //==============================================================================
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if(!mgr){
+    ::Error("AddTaskZDCPbPb", "No analysis manager to connect to.");
+    return NULL;
+  }  
+
+  AliVEventHandler *inputHandler = mgr->GetInputEventHandler();
+  
+  // Check the analysis type using the event handlers connected to the analysis manager.
+  //==============================================================================
+  if(!inputHandler){
+    ::Error("AddTaskZDCPbPb", "This task requires an input event handler");
+    return NULL;
+  }
+  TString inputDataType = inputHandler->GetDataType(); // can be "ESD" or "AOD"
+  
+   // Configure analysis
+   //===========================================================================
+   AliAnalysisTaskZDCpAcalib* task = new AliAnalysisTaskZDCpAcalib("taskZDCpA");
+
+   if(inputDataType.CompareTo("ESD")==0){
+      task->SetInput(1);
+      //
+      // apply physics selection
+      if(applyPS) task->SelectCollisionCandidates();
+   }
+   else if(inputDataType.CompareTo("AOD")==0){
+      task->SetInput(2);
+      //printf("  AliAnalysisTaskZDCpAcalib initialized for AOD analysis\n");
+   }
+   
+   if(isMC==kTRUE) task->SetMCInput();
+
+   mgr->AddTask(task);
+
+   TString outputFileName = AliAnalysisManager::GetCommonFileName();
+   
+   AliAnalysisDataContainer *coutput  = mgr->CreateContainer(outfname.Data(), 
+                                       TList::Class(),
+                                       AliAnalysisManager::kOutputContainer,   
+                                       Form("%s:ZDCtree", mgr->GetCommonFileName()));
+
+   mgr->ConnectInput  (task, 0, mgr->GetCommonInputContainer());
+   mgr->ConnectOutput (task, 1, coutput);
+
+   return task;   
+}
+
+