The class AliFMDAnaParameters works similarly to the AliFMDParameters class. It is...
authorhdalsgaa <hdalsgaa@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 22 Oct 2008 18:56:45 +0000 (18:56 +0000)
committerhdalsgaa <hdalsgaa@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 22 Oct 2008 18:56:45 +0000 (18:56 +0000)
FMD/analysis/AliFMDAnaParameters.cxx [new file with mode: 0644]
FMD/analysis/AliFMDAnaParameters.h [new file with mode: 0644]
FMD/analysis/FMDanalysisLinkDef.h [new file with mode: 0644]

diff --git a/FMD/analysis/AliFMDAnaParameters.cxx b/FMD/analysis/AliFMDAnaParameters.cxx
new file mode 100644 (file)
index 0000000..8dfd52f
--- /dev/null
@@ -0,0 +1,198 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+//
+//The design of this class is based on the AliFMDParameters class. Its purpose
+//is to hold parameters for the analysis such as background correction and 
+//fit functions.
+//
+//Author: Hans Hjersing Dalsgaard, NBI, hans.dalsgaard@cern.ch
+//
+
+#include "AliFMDDebug.h"                  // ALILOG_H
+#include "AliFMDAnaParameters.h"          // ALIFMDPARAMETERS_H
+#include <AliCDBManager.h>         // ALICDBMANAGER_H
+#include <AliCDBEntry.h>           // ALICDBMANAGER_H
+#include <AliLog.h>
+#include <Riostream.h>
+#include <sstream>
+#include <TSystem.h>
+#include <TH2D.h>
+
+//====================================================================
+ClassImp(AliFMDAnaParameters)
+#if 0
+  ; // This is here to keep Emacs for indenting the next line
+#endif
+
+const char* AliFMDAnaParameters::fgkBackgroundCorrection  = "FMD/AnalysisCalib/Background";
+const char* AliFMDAnaParameters::fgkEnergyDists  = "FMD/AnalysisCalib/EnergyDistribution";
+//____________________________________________________________________
+AliFMDAnaParameters* AliFMDAnaParameters::fgInstance = 0;
+
+//____________________________________________________________________
+
+AliFMDAnaParameters* 
+AliFMDAnaParameters::Instance() 
+{
+  // Get static instance 
+  if (!fgInstance) fgInstance = new AliFMDAnaParameters;
+  return fgInstance;
+}
+
+//____________________________________________________________________
+AliFMDAnaParameters::AliFMDAnaParameters() :
+  fIsInit(kFALSE),
+  fBackgroundArray(0),
+  fEdistArray(0)
+{
+  
+  // Default constructor 
+}
+//____________________________________________________________________
+void AliFMDAnaParameters::Init(Bool_t forceReInit, UInt_t what)
+{
+  // Initialize the parameters manager.  We need to get stuff from the
+  // CDB here. 
+  if (forceReInit) fIsInit = kFALSE;
+  if (fIsInit) return;
+  if (what & kBackgroundCorrection)       InitBackground();
+  if (what & kEnergyDistributions)        InitEnergyDists();
+  
+  fIsInit = kTRUE;
+}
+//____________________________________________________________________
+
+void AliFMDAnaParameters::InitBackground() {
+  
+  AliCDBEntry*   background = GetEntry(fgkBackgroundCorrection);
+  if (!background) return;
+  
+  fBackgroundArray = dynamic_cast<TObjArray*>(background->GetObject());
+  if (!fBackgroundArray) AliFatal("Invalid background object from CDB");
+  
+}
+//____________________________________________________________________
+
+void AliFMDAnaParameters::InitEnergyDists() {
+  
+  AliCDBEntry*   edist = GetEntry(fgkEnergyDists);
+  if (!edist) return;
+  
+  fEdistArray = dynamic_cast<TObjArray*>(edist->GetObject());
+  
+  if (!fEdistArray) AliFatal("Invalid background object from CDB");
+  
+}
+//____________________________________________________________________
+Float_t AliFMDAnaParameters::GetVtxCutZ() {
+  
+  if(!fIsInit) {
+    AliWarning("Not initialized yet. Call Init() to remedy");
+    return -1;
+  }
+  
+  TAxis* refAxis = GetRefAxis();
+  
+  return refAxis->GetXmax();
+}
+
+//____________________________________________________________________
+Int_t AliFMDAnaParameters::GetNvtxBins() {
+  
+  if(!fIsInit) {
+    AliWarning("Not initialized yet. Call Init() to remedy");
+    return -1;
+  }
+  
+  TAxis* refAxis = GetRefAxis();
+  
+  return refAxis->GetNbins();
+}
+//____________________________________________________________________
+TH1F* AliFMDAnaParameters::GetEnergyDistribution(Int_t det, Char_t ring) {
+  
+  if(!fIsInit) {
+    AliWarning("Not initialized yet. Call Init() to remedy");
+    return 0;
+  }
+  
+  TObjArray* detArray   = (TObjArray*)fEdistArray->At(det);
+  Int_t ringNumber      = (ring == 'I' ? 0 : 1);
+  TH1F* hEnergyDist     = (TH1F*)detArray->At(ringNumber);  
+  return hEnergyDist;
+}
+//____________________________________________________________________
+TH2F* AliFMDAnaParameters::GetBackgroundCorrection(Int_t det, 
+                                                  Char_t ring, 
+                                                  Int_t vtxbin) {
+
+  if(!fIsInit) {
+    AliWarning("Not initialized yet. Call Init() to remedy");
+    return 0;
+  }
+  if(vtxbin > GetNvtxBins()) {
+    AliWarning(Form("No background object for vertex bin %d", vtxbin));
+    return 0;
+  } 
+  
+  TObjArray* correction = GetBackgroundArray();
+  
+  TObjArray* detArray   = (TObjArray*)correction->At(det);
+  Int_t ringNumber      = (ring == 'I' ? 0 : 1);
+  TObjArray* ringArray  = (TObjArray*)detArray->At(ringNumber);
+  TH2F* bgHist          = (TH2F*)ringArray->At(vtxbin);
+  
+  return bgHist;
+}
+//____________________________________________________________________
+TAxis* AliFMDAnaParameters::GetRefAxis() {
+  
+  TAxis* refAxis = (TAxis*)fBackgroundArray->At(0);
+  
+  return refAxis;
+}
+//____________________________________________________________________
+TObjArray* AliFMDAnaParameters::GetBackgroundArray() {
+  
+  TObjArray* correction = (TObjArray*)fBackgroundArray->At(1);
+  
+  return correction;
+}
+
+//____________________________________________________________________
+AliCDBEntry* AliFMDAnaParameters::GetEntry(const char* path, Bool_t fatal) const
+{
+  // Get an entry from the CDB or via preprocessor 
+  AliCDBEntry* entry = 0;
+  AliCDBManager* cdb = AliCDBManager::Instance();
+  entry              = cdb->Get(path);
+  
+  if (!entry) { 
+    TString msg(Form("No %s found in CDB, perhaps you need to "
+                    "use AliFMDCalibFaker?", path));
+    if (fatal) { AliFatal(msg.Data()); }
+    else       AliLog::Message(AliLog::kWarning, msg.Data(), "FMD", 
+                              "AliFMDParameters", "GetEntry", __FILE__, 
+                              __LINE__);
+    return 0;
+  }
+  return entry;
+}
+
+
+//____________________________________________________________________
+//
+// EOF
+//
diff --git a/FMD/analysis/AliFMDAnaParameters.h b/FMD/analysis/AliFMDAnaParameters.h
new file mode 100644 (file)
index 0000000..8e84f08
--- /dev/null
@@ -0,0 +1,104 @@
+#ifndef ALIFMDANAPARAMETERS_H
+#define ALIFMDANAPARAMETERS_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights
+ * reserved. 
+ *
+ * Latest changes by Hans Hjersing Dalsgaard, NBI, hans.dalsgaard@cern.ch
+ *
+ * See cxx source for full Copyright notice                               
+ */
+//
+//The design of this class is based on the AliFMDParameters class. Its purpose
+//is to hold parameters for the analysis such as background correction and 
+//fit functions.
+//
+//Author: Hans Hjersing Dalsgaard, NBI, hans.dalsgaard@cern.ch
+//
+//____________________________________________________________________
+
+#ifndef ROOT_TNamed
+# include <TNamed.h>
+#endif
+#ifndef ROOT_TArrayI
+# include <TArrayI.h>
+#endif
+#ifndef ALIFMDUSHORTMAP_H
+# include <AliFMDUShortMap.h>
+#endif
+#ifndef ALIFMDBOOLMAP_H
+# include <AliFMDBoolMap.h>
+#endif
+#include "AliCDBEntry.h"
+
+#include "TFile.h"
+#include "TObjArray.h"
+#include "TH2F.h"
+#include "TAxis.h"
+#include "TH1F.h"
+
+//____________________________________________________________________
+//
+//  Singleton class to handle various parameters (not geometry) of the
+//  FMD
+//  Should get ata fromm Conditions DB.
+//
+
+class AliFMDAnaParameters : public TNamed
+{
+public:
+  /** Enumeration of things to initialize */ 
+  enum What { 
+    /** Pulser gain */ 
+    kBackgroundCorrection = 0x1, // Background Correction 
+    kEnergyDistributions  = 0x2 // Energy Distributions
+  };
+  
+  /** Singleton access
+      @return  single to */
+  static AliFMDAnaParameters* Instance();
+  
+  void Init(Bool_t forceReInit=kTRUE, UInt_t what=kBackgroundCorrection|kEnergyDistributions);
+  Float_t GetVtxCutZ();
+  Int_t GetNvtxBins();
+  static const char* GetBackgroundPath() { return fgkBackgroundCorrection;}
+  static const char* GetEdistPath()      { return fgkEnergyDists;}
+  TH2F* GetBackgroundCorrection(Int_t det, Char_t ring, Int_t vtxbin);
+  TH1F* GetEnergyDistribution(Int_t det, Char_t ring);
+protected:
+  
+  AliFMDAnaParameters();
+  
+  AliFMDAnaParameters(const AliFMDAnaParameters& o) 
+    : TNamed(o),
+      fIsInit(o.fIsInit),
+      fBackgroundArray(o.fBackgroundArray) 
+  {}
+  AliFMDAnaParameters& operator=(const AliFMDAnaParameters&) { return *this; }
+  virtual ~AliFMDAnaParameters() {}
+  
+  static AliFMDAnaParameters* fgInstance;   // Static singleton instance
+  
+  AliCDBEntry* GetEntry(const char* path, Bool_t fatal=kTRUE) const ;
+  void InitBackground();
+  void InitEnergyDists();
+  TAxis* GetRefAxis();
+  TObjArray* GetBackgroundArray();
+  
+  Bool_t fIsInit;
+  TObjArray*  fBackgroundArray;
+  TObjArray*  fEdistArray;
+  static const char* fgkBackgroundCorrection;
+  static const char* fgkEnergyDists;
+  ClassDef(AliFMDAnaParameters,0) // Manager of parameters
+};
+
+#endif
+//____________________________________________________________________
+//
+// Local Variables:
+//   mode: C++
+// End:
+//
+// EOF
+//
+
diff --git a/FMD/analysis/FMDanalysisLinkDef.h b/FMD/analysis/FMDanalysisLinkDef.h
new file mode 100644 (file)
index 0000000..ef2bd41
--- /dev/null
@@ -0,0 +1,37 @@
+// -*- mode: c++ -*- 
+/* Copyright (C) 2007 Christian Holm Christensen <cholm@nbi.dk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+#ifdef __CINT__
+/* $Id: FMDflowLinkDef.h 23165 2007-12-19 01:36:20Z cholm $ */
+/** @file    FMDbaseLinkDef.h
+    @author  Christian Holm Christensen <cholm@nbi.dk>
+    @date    Mon Mar 27 14:18:46 2006
+    @brief   Link specifications for base library 
+*/
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+
+#pragma link C++ class AliFMDAnaParameters+;
+#else
+# error Not for compilation 
+#endif
+//
+// EOF
+//