OADB for spectra
authormorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 15 Mar 2011 07:20:52 +0000 (07:20 +0000)
committermorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 15 Mar 2011 07:20:52 +0000 (07:20 +0000)
M. Floris

OADB/AliOADBPWG2Spectra.cxx [new file with mode: 0644]
OADB/AliOADBPWG2Spectra.h [new file with mode: 0644]
OADB/CMakelibOADB.pkg
OADB/OADBLinkDef.h

diff --git a/OADB/AliOADBPWG2Spectra.cxx b/OADB/AliOADBPWG2Spectra.cxx
new file mode 100644 (file)
index 0000000..716cacc
--- /dev/null
@@ -0,0 +1,125 @@
+#include "AliOADBPWG2Spectra.h"
+#include "TNamed.h"
+#include "TString.h"
+#include "TH1D.h"
+#include "TObject.h"
+#include "TList.h"
+#include "AliAnalysisManager.h"
+#include "TBrowser.h"
+#include "AliLog.h"
+
+ClassImp(AliOADBPWG2Spectra)
+
+const char * AliOADBPWG2Spectra::fDetectorNames[] = {"ITS", "ITSTPC", "TPC", "TOF", "TOFTPC"};
+const char * AliOADBPWG2Spectra::fPidTypeNames[]  = {"GaussFit", "NSigma", "Bayes", "Kinks"};
+const char * AliOADBPWG2Spectra::fChargeTags[]    = {"Pos", "Neg"};
+const char * AliOADBPWG2Spectra::fParticleNames[] = {"Pion", "Kaon", "Proton"};
+
+
+AliOADBPWG2Spectra::AliOADBPWG2Spectra():
+TNamed("Dummy", "OADB Object for PWG2 Spectra" ), fHistos(0)
+{
+  // ctor
+  
+
+
+}
+AliOADBPWG2Spectra::AliOADBPWG2Spectra(char* name) :
+TNamed(name, "OADB Object for PWG2 Spectra" ), fHistos(0) 
+
+{
+  // ctor
+  // name is appended to all histos (e.g. "Corrected")
+
+  Init();
+
+}
+
+AliOADBPWG2Spectra::~AliOADBPWG2Spectra() {
+  // dtor
+  if(fHistos) delete fHistos;
+}
+
+void AliOADBPWG2Spectra::Init() {
+  fHistos = new TList();
+}
+
+
+const char * AliOADBPWG2Spectra::GetOADBPWG2SpectraFileName()  {
+  // get file name to the OADB
+  static TString filename;
+  filename.Form("%s/PWG2/SPECTRA/spectraResults.root", AliAnalysisManager::GetOADBPath()); 
+  return filename.Data();
+
+}
+const char * AliOADBPWG2Spectra::GetHistoName(EPWG2SpectraDetector det, EPWG2SpectraPIDType pidType, EPWG2SpectraParticle part, 
+                                                    EPWG2SpectraCharge charge, const char * centrTag, Int_t centrBin) {
+
+  // Returns histogram name
+  // h[Name]_[Detector(s)]_[PIDType]_[Particle]_[Pos|Neg]_[MultiplicityOrCentralityIndex]
+  // where "name" is the name of this container
+
+  static TString histoName;
+  if (centrTag)
+    histoName.Form("h%s_%s_%s_%s_%s_%s_%d", GetName(), fDetectorNames[det], fPidTypeNames[pidType], fParticleNames[part], fChargeTags[charge], centrTag, centrBin);
+  else 
+    histoName.Form("h%s_%s_%s_%s_%s",       GetName(), fDetectorNames[det], fPidTypeNames[pidType], fParticleNames[part], fChargeTags[charge]);
+
+  return histoName.Data();
+}
+
+TH1D * AliOADBPWG2Spectra::GetHisto(EPWG2SpectraDetector det, EPWG2SpectraPIDType pidType, EPWG2SpectraParticle part, 
+                                   EPWG2SpectraCharge charge, const char * centrTag, Int_t centrBin){
+
+  // Get an histogram from the list
+  const char * name = GetHistoName(det,pidType,part,charge,centrTag,centrBin);
+  TH1D * h = (TH1D*) fHistos->FindObject(name);
+  return h;
+
+}
+
+void  AliOADBPWG2Spectra::AddHisto(TH1D * h, EPWG2SpectraDetector det, EPWG2SpectraPIDType pidType, EPWG2SpectraParticle part, 
+                                   EPWG2SpectraCharge charge, const char * centrTag, Int_t centrBin) {
+  // Add a histogram to the list
+  
+  const char * name = GetHistoName(det,pidType,part,charge,centrTag,centrBin);
+  TH1D * hold = (TH1D*) fHistos->FindObject(name);
+  if (hold) fHistos->Remove(hold);
+  delete hold;
+  if(strcmp(h->GetName(),name)){
+    AliError(Form("Histogram namws are not consinstent %s-%s, resetting", h->GetName(),name));
+    h->SetName(name); 
+  }
+  fHistos->Add(h);
+
+
+}
+
+TH1D * AliOADBPWG2Spectra::BookHisto(EPWG2SpectraDetector det, EPWG2SpectraPIDType pidType, EPWG2SpectraParticle part, 
+                                    EPWG2SpectraCharge charge, const char * centrTag, Int_t centrBin) {
+
+  // book a histogram according to the template. All the histograms
+  // should have the same binning (if possible/reasonable) to
+  // facilitate the compoarison and the combination
+
+  const Float_t templBins[] = {0.05,0.1,0.12,0.14,0.16,0.18,0.20,0.25,0.30,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.75,0.8,0.85,0.9,0.95,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,2,2.2,2.4,2.6};
+  Int_t nbinsTempl=34;
+  const char * name = GetHistoName(det,pidType,part,charge,centrTag,centrBin);
+  TH1D * h = new TH1D(name, name, nbinsTempl, templBins);
+  return h;
+
+}
+
+void AliOADBPWG2Spectra::Browse(TBrowser *b)
+{
+  // Browse this object.
+   // If b=0, there is no Browse call TObject::Browse(0) instead.
+   //         This means TObject::Inspect() will be invoked indirectly
+
+
+  if (b) {
+    b->Add(fHistos);        
+  }     
+   else
+      TObject::Browse(b);
+}
diff --git a/OADB/AliOADBPWG2Spectra.h b/OADB/AliOADBPWG2Spectra.h
new file mode 100644 (file)
index 0000000..f89c8ba
--- /dev/null
@@ -0,0 +1,63 @@
+#ifndef AliOADBPWG2Spectra_H
+#define AliOADBPWG2Spectra_H
+
+//-------------------------------------------------------------------------
+//     OADB interface for the PWG2 spectra
+//     Author: Michele Floris, CERN
+//    
+// -------------------------------------------------------------------------
+#include "TNamed.h"
+#include "TList.h"
+
+class TList;
+class TH1D;
+
+class AliOADBPWG2Spectra : public TNamed {
+
+ public :
+
+  enum EPWG2SpectraDetector { kITSsa=0, kITSTPC, kTPC, kTOF, kTOFTPC, kNDetectors };
+  enum EPWG2SpectraPIDType  { kGaussFit=0, kNSigma, kBayes, kKinks, kNPIDTypes };
+  enum EPWG2SpectraCharge   { kPos=0, kNeg, kNCharge };
+  enum EPWG2SpectraParticle { kPion = 0, kKaon, kProton };
+  AliOADBPWG2Spectra();
+  AliOADBPWG2Spectra(char* name);
+  virtual ~AliOADBPWG2Spectra();
+
+  void Init();
+
+  static const char * GetOADBPWG2SpectraFileName();
+  const char * GetHistoName(EPWG2SpectraDetector det, EPWG2SpectraPIDType pidType, EPWG2SpectraParticle part, 
+                                  EPWG2SpectraCharge charge, const char * centrTag = 0, Int_t centrBin = -1) ;
+  void AddHisto(TH1D * h, EPWG2SpectraDetector det, EPWG2SpectraPIDType pidType, EPWG2SpectraParticle part, 
+                 EPWG2SpectraCharge charge, const char * centrTag = 0, Int_t centrBin = -1) ;
+  TH1D * GetHisto(EPWG2SpectraDetector det, EPWG2SpectraPIDType pidType, EPWG2SpectraParticle part, 
+                 EPWG2SpectraCharge charge, const char * centrTag = 0, Int_t centrBin = -1);
+  TH1D * BookHisto(EPWG2SpectraDetector det, EPWG2SpectraPIDType pidType, EPWG2SpectraParticle part, 
+                  EPWG2SpectraCharge charge, const char * centrTag = 0, Int_t centrBin = -1) ;
+    
+
+  virtual void Print (const Option_t * opt = "") const  { fHistos->Print(opt); }
+
+// Browsable
+  virtual Bool_t       IsFolder() const { return kTRUE; }
+  void Browse(TBrowser *b);
+
+  
+
+ private:
+  AliOADBPWG2Spectra(const AliOADBPWG2Spectra& cont); 
+  AliOADBPWG2Spectra& operator=(const AliOADBPWG2Spectra& cont);
+
+ private :
+  
+  TList * fHistos; // List containtig all the histograms
+  static const char * fDetectorNames[] ; // Detector tags
+  static const char * fPidTypeNames[]  ; // Name of the PID technique
+  static const char * fChargeTags[]    ; // tags for charges
+  static const char * fParticleNames[] ; // Particle tags
+
+  ClassDef(AliOADBPWG2Spectra, 1);
+};
+
+#endif
index d728656b02569ea891d3c0c25b90a212b901c0ce..b43cfe74a92504f1e2c7dcd92c0d05578f7c5577 100644 (file)
@@ -1,5 +1,5 @@
 #-*- Mode: CMake -*-
-set ( SRCS  AliOADBContainer.cxx AliOADBCentrality.cxx)
+set ( SRCS  AliOADBContainer.cxx AliOADBCentrality.cxx AliOADBPWG2Spectra.cxx)
 
 string(REPLACE ".cxx" ".h" HDRS  "${SRCS}")
 
index f85b2d76510a8ee72f24c0814826c9d23f9db12b..60f680750d27da8f60ea2d38804d7191b9e2ab3f 100644 (file)
@@ -11,4 +11,5 @@
 
 #pragma link C++ class AliOADBContainer+;
 #pragma link C++ class AliOADBCentrality+;
+#pragma link C++ class AliOADBPWG2Spectra+;
 #endif