]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/AliFMDBaseDA.h
Bringing CMakeLists under svn maintenance
[u/mrichter/AliRoot.git] / FMD / AliFMDBaseDA.h
index 1051ed9d472611fa9e1fecc8b66dbbcf090455f1..36fda2ee4f670fd500913717173d7ee69eff3b91 100644 (file)
@@ -1,3 +1,4 @@
+// -*- mode: C++ -*- 
 #ifndef ALIFMDBASEDA_H
 #define ALIFMDBASEDA_H
 
  * See cxx source for full Copyright notice                               
  */
 //
-//This class provides a base interface for the Detector Algorithms (DA) of the FMD. 
-//At least three implementations are needed: AliFMDPedestalDA, AliFMDGainDA and AliFMDPhysicsDA . 
-//These classes will provide the calibration data for the AliFMDPreprocessor to be used in the shuttle.
-//The input for this class are raw data (AliRawReader) and the output is a comma-separated file
-//(std::ofstream) that contains the values defined in the implementations of this class.
+// This class provides a base interface for the Detector Algorithms
+// (DA) of the FMD.  At least three implementations are needed:
+// AliFMDPedestalDA, AliFMDGainDA and AliFMDPhysicsDA .  These classes
+// will provide the calibration data for the AliFMDPreprocessor to be
+// used in the shuttle.  The input for this class are raw data
+// (AliRawReader) and the output is a comma-separated file
+// (std::ofstream) that contains the values defined in the
+// implementations of this class.
 //
-//Author: Hans Hjersing Dalsgaard, hans.dalsgaard@cern.ch
+// Author: Hans Hjersing Dalsgaard, hans.dalsgaard@cern.ch
 //
 
 #include "TNamed.h"
 #include "TObjArray.h"
-#include "TClonesArray.h"
-#include "TFile.h"
-#include "iostream"
-#include "fstream"
+#include "TString.h"
+#include "TArrayS.h"
+#include <iosfwd>
+#include <fstream>
+class AliFMDDigit;
+class AliRawReader;
+class AliFMDParameters;
+class AliFMDRawReader;
+class TDirectory;
+class TH2;
+class TFile;
+class TClonesArray;
 
-#include "AliRawReader.h"
-#include "AliFMDDigit.h"
-#include "AliFMDParameters.h"
-
-
-class AliFMDBaseDA: public TNamed {
-  
- public:
+class AliFMDBaseDA: public TNamed 
+{
+public:
+  /** 
+   * Constructor 
+   * 
+   */
   AliFMDBaseDA() ;
+  /** 
+   * Copy constructor 
+   * 
+   * @param baseDA 
+   */
   AliFMDBaseDA(const AliFMDBaseDA & baseDA) ;
-  AliFMDBaseDA& operator = (const AliFMDBaseDA & baseDA) ; 
-  
+  //  AliFMDBaseDA& operator = (const AliFMDBaseDA & baseDA) ; 
+  /** 
+   * Destructor
+   * 
+   */  
   ~AliFMDBaseDA() ;
-  
+  AliFMDBaseDA& operator=(const AliFMDBaseDA&) { return *this; }
+  /** 
+   * Run this DA
+   * 
+   * @param fmdReader Raw input reader
+   */  
   void Run(AliRawReader* fmdReader);
+  /** 
+   * Set whether to save diagnostics 
+   * 
+   * @param save If true, will output diagnostics file
+   */
   void SetSaveDiagnostics(Bool_t save) {fSaveHistograms = save;}
+  /** 
+   * Set whether to make summary histograms to be published to AMORE
+   * 
+   * @param save If true, will generate summary QA histograms
+   */
+  void SetMakeSummaries(Bool_t save) {fMakeSummaries = save;}
+  /** 
+   * Set the number of requried events
+   * 
+   * @param nEvents Number of event we need
+   */
   void SetRequiredEvents(Int_t nEvents) {fRequiredEvents = nEvents;}
-  Int_t GetRequiredEvents() {return fRequiredEvents ;}
- protected:
-  
+  /** 
+   * Get the number of required events
+   * 
+   * 
+   * @return number of required events
+   */
+  Int_t GetRequiredEvents() const {return fRequiredEvents ;}
+  /** 
+   * Get list of summary histograms 
+   *
+   * @return Array of summary histograms or null if not defined 
+   */
+  const TObjArray& GetSummaries() const { return fSummaries; }
+  /** 
+   * Check if we saw data for detector 
+   * 
+   * @param det Detector number to check 
+   * @return true if the code has seen data from the detector 
+   */
+  Bool_t HasSeenDetector(UShort_t d) const;
+protected:
+  /** 
+   * Initialize 
+   */  
   virtual void Init()  {};
+  /** 
+   * Fill channels 
+   */
   virtual void FillChannels(AliFMDDigit* )  {};
-  virtual void Analyse(UShort_t, Char_t, UShort_t, UShort_t )  {};
+  /** 
+   * Analyse a single strip result
+   */
+  virtual void Analyse(UShort_t, Char_t, UShort_t, UShort_t)  {};
+  /** 
+   * Write header to output file
+   */
   virtual void WriteHeaderToFile()  {};
-  virtual void AddChannelContainer(TObjArray*, UShort_t, Char_t, UShort_t, UShort_t )  {};
+  /** 
+   * Add a strip container 
+   */
+  virtual void AddChannelContainer(TObjArray*, UShort_t, Char_t, 
+                                  UShort_t, UShort_t )  {};
+  /** 
+   * End of event
+   */
   virtual void FinishEvent()  {};
-  
-  
-  Int_t GetCurrentEvent() {return fCurrentEvent;}
-  
-  static const UInt_t kBaseDDL = 3072;
-  Char_t* fDiagnosticsFilename;
-  std::ofstream fOutputFile;
-  std::ofstream fConditionsFile;
-  Bool_t fSaveHistograms;
-  TObjArray fDetectorArray;
-  
-  
- private:
-  void WriteConditionsData();
+  /** 
+   * End of run
+   */
+  virtual void Terminate(TFile* ) {};
+  /** 
+   * Current event number
+   * 
+   * 
+   * @return 
+   */  
+  Int_t GetCurrentEvent() const {return fCurrentEvent;}
+  /** 
+   * Rotate a set of files.   @a base is the basic name of the files.
+   * If the file @a base.max exists it is removed. 
+   * If the file @a base.n exists (where n < max) it is renamed to @a
+   * base.(n-1).  
+   * If the file @a base exists, it is renamed to @a base.1 
+   * 
+   * @param base Base name of the files
+   * @param max  Maximum number to keep (minus one for the current).
+   */
+  void Rotate(const char* base, int max) const;
+  /** 
+   * Ge the half-ring index 
+   * 
+   * @param UShort_t 
+   * @param Char_t 
+   * @param UShort_t 
+   * 
+   * @return 
+   */
+  Int_t GetHalfringIndex(UShort_t, Char_t, UShort_t) const;
+  /** 
+   * Get the pulse size 
+   * 
+   * @param det   Detector number
+   * @param ring  Rin identifier
+   * @param board Board number 
+   * 
+   * @return Pulse step size
+   */
+  Int_t GetPulseSize(UShort_t det , 
+                    Char_t ring, 
+                    UShort_t board) 
+  {
+    return fPulseSize.At(GetHalfringIndex(det,ring,board));
+  }
+  /** 
+   * Get number of events per pulse size 
+   * 
+   * @param det   Detector number
+   * @param ring  Rin identifier
+   * @param board Board number 
+   * 
+   * @return number of events per Pulse size
+   */
+  Int_t GetPulseLength(UShort_t det, 
+                      Char_t ring, 
+                      UShort_t board) 
+  {
+    return fPulseLength.At(GetHalfringIndex(det,ring,board));
+  }
+
+  /** 
+   * Get the detector path in diagnositcs file
+   * 
+   * @param det  Detector number
+   * @param full If true, return full path
+   * 
+   * @return Path to detector
+   */  
+  const char* GetDetectorPath(UShort_t det, Bool_t full=kTRUE) const;
+  /** 
+   * Get the ring path in diagnositcs file
+   * 
+   * @param det  Detector number
+   * @param ring Ring identifier 
+   * @param full If true, return full path
+   * 
+   * @return Path to ring
+   */  
+  const char* GetRingPath(UShort_t det, Char_t ring, Bool_t full=kTRUE) const;
+  /** 
+   * Get the sector path in diagnositcs file
+   * 
+   * @param det  Detector number
+   * @param ring Ring identifier 
+   * @param sec  Sector number
+   * @param full If true, return full path
+   * 
+   * @return Path to sector
+   */  
+  const char* GetSectorPath(UShort_t det, Char_t ring, UShort_t sec, 
+                           Bool_t full=kTRUE) const;
+  /** 
+   * Get the strip path in diagnositcs file
+   * 
+   * @param det  Detector number
+   * @param ring Ring identifier 
+   * @param sec  Sector number
+   * @param str  Strip number
+   * @param full If true, return full path
+   * 
+   * @return Path to strip
+   */  
+  const char* GetStripPath(UShort_t det, Char_t ring, UShort_t sec, 
+                          UShort_t str, Bool_t full=kTRUE) const;
+  /** 
+   * Write conditions file 
+   * 
+   * @param fmdReader Raw input
+   */ 
+  void WriteConditionsData(AliFMDRawReader* fmdReader);
+  /** 
+   * Set the current event 
+   * 
+   * @param currentEvent 
+   */
   void SetCurrentEvent(Int_t currentEvent) {fCurrentEvent = currentEvent; }
-  void InitContainer();
-  Int_t fRequiredEvents;
-  Int_t fCurrentEvent;   
-   
-  ClassDef(AliFMDBaseDA,0)
+  /** 
+   * Initialize container 
+   * 
+   * @param dir Directory to make containers in 
+   */
+  void InitContainer(TDirectory* dir);
+  /** 
+   * Utility function for defining summary histograms 
+   *
+   * @param det    Detector 
+   * @param ring   Ring identifier 
+   * @param prefix Histogram prefix 
+   * @param title  Histogram title 
+   */
+  TH2* MakeSummaryHistogram(const char* prefix, const char* title, 
+                           UShort_t det, Char_t ring);
+  /** 
+   * Make a summary
+   * 
+   */
+  virtual void  MakeSummary(UShort_t, Char_t) { }
+
+
+
+  static const UInt_t fgkBaseDDL = 3072;   // base FMD ddl
+  //Char_t* fDiagnosticsFilename;
+  TString       fDiagnosticsFilename;  // name of diagnostics file
+  std::ofstream fOutputFile;           // output file
+  std::ofstream fConditionsFile;       // conditions file
+  Bool_t        fSaveHistograms;       // save hists or not
+  Bool_t        fMakeSummaries;        // save hists or not
+  TObjArray     fDetectorArray;        // array indiced by detector
+  TArrayS       fPulseSize;            // Pulse size for gain calib
+  TArrayS       fPulseLength;          // Pulse length for gain calib
+  Bool_t        fSeenDetectors[3];     // Detectors seen so far
+  Int_t         fRequiredEvents;       // # events required for this calib
+  Int_t         fCurrentEvent;         // the current event       
+  UInt_t        fRunno;                // Current run number 
+  TObjArray     fSummaries;            // Summary histograms 
+  
+  ClassDef(AliFMDBaseDA,0) // Base Detector algorithm for all run types
 
 };
+//____________________________________________________________________
+inline Bool_t
+AliFMDBaseDA::HasSeenDetector(UShort_t d) const
+{ 
+  return (d == 0 || d > 3) ? false : fSeenDetectors[d-1]; 
+}
+
 #endif