]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Adding analysis task for equalizing the VZERO signals in 2010 p-p data (David)
authorcvetan <cvetan.cheshkov@cern.ch>
Mon, 17 Feb 2014 22:18:39 +0000 (23:18 +0100)
committercvetan <cvetan.cheshkov@cern.ch>
Mon, 17 Feb 2014 22:18:39 +0000 (23:18 +0100)
ANALYSIS/TenderSupplies/AliAnalysisTaskVZEROEqFactorTask.cxx [new file with mode: 0644]
ANALYSIS/TenderSupplies/AliAnalysisTaskVZEROEqFactorTask.h [new file with mode: 0644]
ANALYSIS/macros/AddTaskVZEROEqFactorTask.C [new file with mode: 0644]

diff --git a/ANALYSIS/TenderSupplies/AliAnalysisTaskVZEROEqFactorTask.cxx b/ANALYSIS/TenderSupplies/AliAnalysisTaskVZEROEqFactorTask.cxx
new file mode 100644 (file)
index 0000000..fb02ea5
--- /dev/null
@@ -0,0 +1,247 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+
+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+//
+//  AliAnalysisTaskVZEROEqFactorTask.cxx, February 12th 2014
+//   --- David Dobrigkeit Chinellato
+//
+// This task is meant to set correct VZERO equalization factors in AliESDRun 
+// so that AliCentrality makes use of the correct values. NB This task has to
+// be executed prior to AliCentrality for this to work properly! It is meant
+// to be used as a Tender. 
+//
+//    Comments, Suggestions, Bug reports: Please send them to: 
+//          --- daviddc@ifi.unicamp.br
+//
+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+class TTree;
+class TParticle;
+class TVector3;
+
+//class AliMCEventHandler;
+//class AliMCEvent;
+//class AliStack;
+
+class AliESDVertex;
+class AliAODVertex;
+class AliESDv0;
+class AliAODv0;
+
+#include <Riostream.h>
+#include "TList.h"
+#include "TH1.h"
+#include "TH2.h"
+#include "TH3.h"
+#include "TFile.h"
+#include "THnSparse.h"
+#include "TVector3.h"
+#include "TCanvas.h"
+#include "TMath.h"
+#include "TLegend.h"
+//#include "AliLog.h"
+
+#include "AliAnalysisTaskSE.h"
+#include "AliESDEvent.h"
+#include "AliAODEvent.h"
+#include "AliV0vertexer.h"
+#include "AliCascadeVertexer.h"
+#include "AliESDpid.h"
+#include "AliESDRun.h"
+#include "AliESDtrack.h"
+#include "AliESDtrackCuts.h"
+#include "AliInputEventHandler.h"
+#include "AliAnalysisManager.h"
+#include "AliMCEventHandler.h"
+#include "AliMCEvent.h"
+#include "AliStack.h"
+
+#include "AliCFContainer.h"
+#include "AliMultiplicity.h"
+#include "AliAODMCParticle.h"
+#include "AliESDcascade.h"
+#include "AliAODcascade.h"
+#include "AliESDUtils.h"
+#include "AliGenEventHeader.h"
+
+#include "AliAnalysisUtils.h"
+#include "AliAnalysisTaskVZEROEqFactorTask.h"
+#include "AliCDBManager.h"
+#include "AliCDBStorage.h"
+#include "AliCDBEntry.h"
+
+#include "AliVZEROCalibData.h"
+
+using std::cout;
+using std::endl;
+
+ClassImp(AliAnalysisTaskVZEROEqFactorTask)
+
+AliAnalysisTaskVZEROEqFactorTask::AliAnalysisTaskVZEROEqFactorTask()
+  : AliAnalysisTaskSE(), fListHist(0), fEqFactors(0), fCalibData(0), fRunNumber(0), fHistEventCounter(0)
+//------------------------------------------------
+// Tree Variables 
+{
+  // Dummy Constructor  
+}
+
+AliAnalysisTaskVZEROEqFactorTask::AliAnalysisTaskVZEROEqFactorTask(const char *name) 
+  : AliAnalysisTaskSE(name), fListHist(0), fEqFactors(0), fCalibData(0), fRunNumber(0), fHistEventCounter(0)
+{
+  // Constructor
+  DefineOutput(1, TList::Class());
+}
+
+
+AliAnalysisTaskVZEROEqFactorTask::~AliAnalysisTaskVZEROEqFactorTask()
+{
+//------------------------------------------------
+// DESTRUCTOR
+//------------------------------------------------
+
+   if (fListHist){
+      delete fListHist;
+      fListHist = 0x0;
+   }
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskVZEROEqFactorTask::UserCreateOutputObjects()
+{
+//------------------------------------------------
+// Output: Empty at the moment 
+//------------------------------------------------
+
+   fListHist = new TList();
+   fListHist->SetOwner();  // See http://root.cern.ch/root/html/TCollection.html#TCollection:SetOwner
+
+   if(! fHistEventCounter ) {
+    //Histogram Output: Event-by-Event
+    // --- Single "Events Processed" Counter at this stage 
+    fHistEventCounter = new TH1D( "fHistEventCounter", ";Evt. Sel. Step;Count",4,0,4); 
+    fHistEventCounter->GetXaxis()->SetBinLabel(1, "Processed");
+    fHistEventCounter->GetXaxis()->SetBinLabel(2, "Has ESD");
+    fHistEventCounter->GetXaxis()->SetBinLabel(3, "Has ESDRun");
+    fHistEventCounter->GetXaxis()->SetBinLabel(4, "Rewrote EqFactors");
+    fListHist->Add(fHistEventCounter); 
+   }
+
+   //List of Histograms
+   PostData(1, fListHist);
+}// end UserCreateOutputObjects
+
+
+//________________________________________________________________________
+void AliAnalysisTaskVZEROEqFactorTask::UserExec(Option_t *) 
+{
+  // Main loop
+  // Called for each event
+
+   AliESDEvent *lESDevent = 0x0;
+  // Connect to the InputEvent   
+  // After these lines, we should have an ESD/AOD event + the number of V0s in it.
+
+   // Appropriate for ESD analysis! 
+   //Count Processed Events 
+   fHistEventCounter->Fill(0.5);  
+      
+   lESDevent = dynamic_cast<AliESDEvent*>( InputEvent() );
+   if (!lESDevent) {
+      AliWarning("ERROR: lESDevent not available \n");
+      return;
+   }
+   fHistEventCounter->Fill(1.5);    
+       
+   
+   //Acquire ESDRun object - Will be needed to invoke AliESDEvent::SetVZEROEqFactors
+   const AliESDRun *lESDRun = lESDevent->GetESDRun();
+   if (!lESDRun) {
+      AliWarning("ERROR: lESDRun not available, won't be able to write Equalization Factors! Exiting. \n");
+      return;
+   }
+
+   fHistEventCounter->Fill(2.5);  
+
+   //CDB Processing only necessary if Run Number changed! Check for change (no need to redo this every event) 
+   if( lESDevent->GetRunNumber() != fRunNumber ){ 
+      AliWarning("Run Changed! Reloading CDB values!");
+      //Load CDB Entries - Mirroring AliVZEROReconstructor
+      AliCDBEntry *entry7 = AliCDBManager::Instance()->Get("VZERO/Calib/EqualizationFactors");
+      if (!entry7) AliFatal("ERROR: VZERO equalization factors are not found in OCDB !");
+      fEqFactors = (TH1F*)entry7->GetObject();
+
+      //Load Calibration object fCalibData
+      fCalibData = GetCalibData(); // Mirror AliVZEROReconstructor Functionality 
+      fRunNumber = lESDevent->GetRunNumber(); //New Run 
+   }
+
+
+   Float_t factors[64];
+   Float_t factorSum = 0;
+   for(Int_t i = 0; i < 64; ++i) {
+      factors[i] = fEqFactors->GetBinContent(i+1)*fCalibData->GetMIPperADC(i);
+      factorSum += factors[i];
+   }
+   for(Int_t i = 0; i < 64; ++i) { 
+      factors[i] *= (64./factorSum);
+   }
+   lESDevent->SetVZEROEqFactors(factors);
+   fHistEventCounter->Fill(3.5);  
+
+
+   // Post output data.
+   PostData(1, fListHist);
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskVZEROEqFactorTask::Terminate(Option_t *)
+{
+   // Draw result to the screen
+   // Called once at the end of the query
+
+   TList *cRetrievedList = 0x0;
+   cRetrievedList = (TList*)GetOutputData(1);
+   if(!cRetrievedList){
+      Printf("ERROR - AliAnalysisTaskVZEROEqFactorTask : ouput data container list not available\n");
+      return;
+   }   
+       
+   fHistEventCounter = dynamic_cast<TH1D*> (  cRetrievedList->FindObject("fHistEventCounter")  );
+   if (!fHistEventCounter) {
+      Printf("ERROR - AliAnalysisTaskVZEROEqFactorTask : fHistEventCounter not available");
+      return;
+   }
+  
+   TCanvas *canCheck = new TCanvas("AliAnalysisTaskVZEROEqFactorTask","V0 Multiplicity",10,10,510,510);
+   canCheck->cd(1)->SetLogy();
+
+   fHistEventCounter->SetMarkerStyle(22);
+   fHistEventCounter->DrawCopy("E");
+}
+
+//_____________________________________________________________________________
+AliVZEROCalibData* AliAnalysisTaskVZEROEqFactorTask::GetCalibData() const
+{
+  // Gets calibration object for VZERO set
+  AliCDBManager *man = AliCDBManager::Instance();
+  AliCDBEntry *entry=0;
+  entry = man->Get("VZERO/Calib/Data");
+  AliVZEROCalibData *calibdata = 0;
+  if (entry) calibdata = (AliVZEROCalibData*) entry->GetObject();
+  if (!calibdata)  AliFatal("No calibration data from calibration database !");
+  return calibdata;
+}
diff --git a/ANALYSIS/TenderSupplies/AliAnalysisTaskVZEROEqFactorTask.h b/ANALYSIS/TenderSupplies/AliAnalysisTaskVZEROEqFactorTask.h
new file mode 100644 (file)
index 0000000..8ae50ae
--- /dev/null
@@ -0,0 +1,85 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+
+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+//
+// Modified version of AliAnalysisTaskCheckCascade.h
+// Used bits of code from AliAnalysisTaskCheckPerformanceStrange
+//
+// --- David Dobrigkeit Chinellato
+//
+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+#ifndef ALIANALYSISTASKVZEROEQFACTORTASK_H
+#define ALIANALYSISTASKVZEROEQFACTORTASK_H
+
+//Needed for this task
+#include "AliAnalysisTaskSE.h"
+
+class TList;
+class TH1F;
+class TH2F;
+class TH3F;
+class TVector3;
+class THnSparse;
+
+class AliESDpid;
+class AliESDtrackCuts;
+class AliAnalysisUtils;
+class AliESDEvent;
+class AliPhysicsSelection;
+class AliCFContainer;
+class AliVZEROCalibData; 
+//class AliAnalysisTaskSE;
+
+//#include "TString.h"
+//#include "AliESDtrackCuts.h"
+
+
+class AliAnalysisTaskVZEROEqFactorTask : public AliAnalysisTaskSE {
+ public:
+  AliAnalysisTaskVZEROEqFactorTask();
+  AliAnalysisTaskVZEROEqFactorTask(const char *name);
+  virtual ~AliAnalysisTaskVZEROEqFactorTask();
+  
+  virtual void   UserCreateOutputObjects();
+  virtual void   UserExec(Option_t *option);
+  virtual void   Terminate(Option_t *);
+  AliVZEROCalibData* GetCalibData() const;
+  
+ private:
+        // Note : In ROOT, "//!" means "do not stream the data from Master node to Worker node" ...
+        // your data member object is created on the worker nodes and streaming is not needed.
+        // http://root.cern.ch/download/doc/11InputOutput.pdf, page 14
+  TList  *fListHist;  //! List of Cascade histograms
+
+  //Re-loaded per event if required, a la AliCentrality
+  TH1F*   fEqFactors;               //! Histogram with the equalization factors used in event-plane reconstruction
+  AliVZEROCalibData* fCalibData;    //! calibration data
+  Long_t fRunNumber;                //! Needed to make sure we haven't swapped runs
+//===========================================================================================
+//   Histograms - Event Counting only 
+//===========================================================================================
+
+  TH1D *fHistEventCounter; //! 
+
+   AliAnalysisTaskVZEROEqFactorTask(const AliAnalysisTaskVZEROEqFactorTask&);            // not implemented
+   AliAnalysisTaskVZEROEqFactorTask& operator=(const AliAnalysisTaskVZEROEqFactorTask&); // not implemented
+   
+   ClassDef(AliAnalysisTaskVZEROEqFactorTask, 11);
+};
+
+#endif
diff --git a/ANALYSIS/macros/AddTaskVZEROEqFactorTask.C b/ANALYSIS/macros/AddTaskVZEROEqFactorTask.C
new file mode 100644 (file)
index 0000000..6749af7
--- /dev/null
@@ -0,0 +1,41 @@
+AliAnalysisTaskVZEROEqFactorTask *AddTaskVZEROEqFactorTask( const TString lMasterJobSessionFlag = "")
+{
+// Creates, configures and attaches to the train a cascades check task.
+   // Get the pointer to the existing analysis manager via the static access method.
+   //==============================================================================
+   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+   if (!mgr) {
+      ::Error("AddTaskExtractPerformanceV0", "No analysis manager to connect to.");
+      return NULL;
+   }   
+
+   // Check the analysis type using the event handlers connected to the analysis manager.
+   //==============================================================================
+   if (!mgr->GetInputEventHandler()) {
+      ::Error("AddTaskExtractPerformanceV0", "This task requires an input event handler");
+      return NULL;
+   }   
+   TString type = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
+
+  // Create and configure the task
+  AliAnalysisTaskVZEROEqFactorTask *taskVZEROAuxiliary = new AliAnalysisTaskVZEROEqFactorTask("taskVZEROAuxiliary");
+
+  mgr->AddTask(taskVZEROAuxiliary);
+  TString outputFileName = AliAnalysisManager::GetCommonFileName();
+   
+  outputFileName += ":PWGLF_VZEROEqFactorTask";
+  if (mgr->GetMCtruthEventHandler()) outputFileName += "_MC";
+   
+  Printf("Set OutputFileName : \n %s\n", outputFileName.Data() );
+
+  AliAnalysisDataContainer *coutputList = mgr->CreateContainer("cList_VZERO",
+                                                            TList::Class(),
+                                                            AliAnalysisManager::kOutputContainer,
+                                                            outputFileName );
+
+  //Recommendation: Tree as a single output slot
+  mgr->ConnectInput( taskVZEROAuxiliary, 0, mgr->GetCommonInputContainer());
+  mgr->ConnectOutput(taskVZEROAuxiliary, 1, coutputList);
+  
+  return taskVZEROAuxiliary;
+}