]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/AliFMDBaseDA.h
including extra debugging message
[u/mrichter/AliRoot.git] / FMD / AliFMDBaseDA.h
index 6e13dc52995a8306be748ae6d06e0346a9b4f00e..39f3181f65ed3cbd4a26e2f5c1280c61caa3f2b8 100644 (file)
 
 #include "TNamed.h"
 #include "TObjArray.h"
-#include "TClonesArray.h"
-#include "TFile.h"
-#include "iostream"
-#include "fstream"
 #include "TString.h"
-#include "AliRawReader.h"
-#include "AliFMDDigit.h"
-#include "AliFMDParameters.h"
 #include "TArrayS.h"
-class TDirectory;
+#include <iosfwd>
+#include <fstream>
+class AliFMDDigit;
+class AliRawReader;
+class AliFMDParameters;
 class AliFMDRawReader;
+class TDirectory;
+class TH2;
+class TFile;
+class TClonesArray;
 
 class AliFMDBaseDA: public TNamed 
 {
@@ -54,6 +55,7 @@ public:
    * 
    */  
   ~AliFMDBaseDA() ;
+  AliFMDBaseDA& operator=(const AliFMDBaseDA&) { return *this; }
   /** 
    * Run this DA
    * 
@@ -66,12 +68,30 @@ public:
    * @param save If true, will output diagnostics file
    */
   void SetSaveDiagnostics(Bool_t save) {fSaveHistograms = save;}
+  /** 
+   * Set the diagnostics file name 
+   * 
+   * @param f Diagnostics file name 
+   */
+  void SetDiagnosticsFilename(const TString& f) { fDiagnosticsFilename = f; }
+  /** 
+   * 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;}
+  /** 
+   * Set whether we should try to get all detectors 
+   *
+   * @param all If true, try to get all detectors 
+   */
+  void SetTryAll(Bool_t all=true) { fAll = all; }
   /** 
    * Get the number of required events
    * 
@@ -79,41 +99,73 @@ public:
    * @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;
+
+  /**
+   * Class to run the DAs 
+   */
+  struct Runner {
+    Runner();
+    Runner(const Runner&) 
+      : fReader(0), fDiagFile(""), fDiag(false), fAll(false) {}
+    ~Runner() {} 
+    Runner& operator=(const Runner&) { return *this; }
+    void   AddHandlers();
+    void   ShowUsage(std::ostream& o, const char* progname);
+    Int_t  Init(int argc, char** argv);
+    void   Exec(AliFMDBaseDA& da);
+    Int_t  RunNumber() const;
+    AliRawReader* fReader;
+    TString       fDiagFile;
+    Bool_t        fDiag;
+    Bool_t        fAll;
+  };
 protected:
   /** 
    * Initialize 
-   * 
    */  
   virtual void Init()  {};
   /** 
    * Fill channels 
-   * 
    */
   virtual void FillChannels(AliFMDDigit* )  {};
   /** 
    * Analyse a single strip result
-   * 
    */
-  virtual void Analyse(UShort_t, Char_t, UShort_t, UShort_t )  {};
+  virtual void Analyse(UShort_t, Char_t, UShort_t, UShort_t)  {};
   /** 
    * Write header to output file
-   * 
    */
   virtual void WriteHeaderToFile()  {};
   /** 
    * Add a strip container 
-   * 
    */
   virtual void AddChannelContainer(TObjArray*, UShort_t, Char_t, 
                                   UShort_t, UShort_t )  {};
   /** 
-   * End of event
+   * Add summary(s) for sectors 
    * 
    */
+  virtual void AddSectorSummary(TObjArray*, UShort_t, Char_t, UShort_t, 
+                               UShort_t) {}
+  /** 
+   * End of event
+   */
   virtual void FinishEvent()  {};
   /** 
    * End of run
-   * 
    */
   virtual void Terminate(TFile* ) {};
   /** 
@@ -134,13 +186,6 @@ protected:
    * @param max  Maximum number to keep (minus one for the current).
    */
   void Rotate(const char* base, int max) const;
-  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
-  TObjArray fDetectorArray;                // array indiced by detector
   /** 
    * Ge the half-ring index 
    * 
@@ -226,14 +271,11 @@ protected:
    */  
   const char* GetStripPath(UShort_t det, Char_t ring, UShort_t sec, 
                           UShort_t str, Bool_t full=kTRUE) const;
-  
-
-  
-  TArrayS fPulseSize;                     // Pulse size for gain calib
-  TArrayS fPulseLength;                   // Pulse length for gain calib
-
-  Bool_t  fSeenDetectors[3];              // Detectors seen so far
-private:
+  TObjArray* GetDetectorArray(UShort_t det);
+  TObjArray* GetRingArray(UShort_t det, Char_t ring);
+  TObjArray* GetSectorArray(UShort_t det, Char_t ring, UShort_t sector);
+  TObjArray* GetStripArray(UShort_t det, Char_t ring, 
+                          UShort_t sector, UShort_t strip);
   /** 
    * Write conditions file 
    * 
@@ -251,15 +293,55 @@ private:
    * 
    * @param dir Directory to make containers in 
    */
-  void InitContainer(TDirectory* dir);
-  Int_t fRequiredEvents;            // number of events required for this calib
-  Int_t fCurrentEvent;              // the current event       
-protected:
-  UInt_t fRunno;                    // Current run number 
+  virtual 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) { }
   
+  virtual Bool_t HaveEnough(Int_t nEvent) const;
+  virtual UShort_t GetProgress(Int_t nEvent) const;
+
+
+
+  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
+  UInt_t        fNEventsPerDetector[3];// # events per detector
+  Int_t         fRequiredEvents;       // # events required for this calib
+  Int_t         fCurrentEvent;         // the current event       
+  UInt_t        fRunno;                // Current run number 
+  TObjArray     fSummaries;            // Summary histograms 
+  Bool_t        fAll;                  // Try to get data from all dets
   
   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