emcGainEvolution.h

Go to the documentation of this file.
00001 #ifndef __EMCGAINEVOLUTION_H__
00002 #define __EMCGAINEVOLUTION_H__
00003 
00004 #include <string>
00005 #include <vector>
00006 #include <map>
00007 #include <ctime>
00008 #include <iostream>
00009 #include <set>
00010 
00011 class TGraphErrors;
00012 
00018 class emcGainEvolution
00019 {
00020  public:
00021 
00022   enum EHistogrammingType
00023     {
00024       kNone=-1,
00025       kOneFilePerRun,
00026       kOneFilePer1KRange,
00027       kOneFileForAll
00028     };
00029 
00030   emcGainEvolution(const char* outputfile);
00031 
00032   void setTimeOffset(time_t offset) { fTimeOffset = offset; }
00033 
00034   void setHistogrammingType(emcGainEvolution::EHistogrammingType htype);
00035 
00036   ~emcGainEvolution();
00037 
00038   void addRun(int runnumber)
00039   {
00040     fRuns.push_back(runnumber); 
00041   }
00042 
00043   void clearRun()
00044   {
00045     fRuns.clear();
00046   }
00047 
00048   void addSector(const char* sector)
00049   {
00050     fSectors.push_back(sector);
00051   }
00052 
00053   void clearSector()
00054   {
00055     fSectors.clear();
00056   }
00057 
00058   void addTrimmingPercentage(float percent)
00059   { 
00060     fPercent.push_back(percent);
00061   }
00062 
00063   void clearDetails()
00064   {
00065     fDetails.clear();
00066   }
00067 
00068   void clearTrimmingPercentage()
00069   {
00070     fPercent.clear();
00071   }
00072 
00073   void print(std::ostream& out = std::cout) const;
00074 
00075   void run();
00076 
00077   void addDetails(const char* femdetails)
00078   {
00079     fDetails.push_back(femdetails);
00080   }
00081 
00082   void reset()
00083   {
00084     clearRun();
00085     clearSector();
00086     clearTrimmingPercentage();
00087     clearDetails();
00088     fRunChecks.clear();
00089     fProcesses.clear();
00090   }
00091 
00092   void verbose(int verboselevel) { fVerbose=verboselevel; }
00093 
00094   int verbose() const { return fVerbose; }
00095 
00096  private:
00097 
00098   void writeGraphs();
00099 
00100  private:
00101 
00102   void createGraph(const std::string& graphname,
00103                    const std::vector<double>& x,
00104                    const std::vector<double>& y,
00105                    const std::vector<double>& xerr,
00106                    const std::vector<double>& yerr);
00107 
00108   std::string graphName(const std::string& process,
00109                         const std::string& suffix);
00110 
00111   void makeGraphs(const std::string& process);
00112   void makeGraph_absolute(const std::string& process);
00113   void makeGraph_wrt_production(const std::string& process);
00114   void makeGraph_distriShape(const std::string& process);
00115 
00116   void save(int run);
00117 
00118  private:
00119   
00120   std::string fOutputFile;
00121 
00122   class BaseLine;
00123   class RunCheck;
00124 
00125   class BaseLine
00126   {
00127   public:
00128     BaseLine(float value=0.0, float error=0.0,
00129              float diff=0.0, float diff_error=0.0,
00130              float skew=0.0, float kurt=0.0)
00131       : fValue(value), fError(error),
00132         fDiff(diff), fDiffError(error),
00133         fSkewness(skew), fKurtosis(kurt) {}
00134     
00135     float value() const { return fValue; }
00136     float error() const { return fError; }
00137     
00138     float diff() const { return fDiff; }
00139     float diffError() const { return fDiffError; }
00140     float skewness() const { return fSkewness; }
00141     float kurtosis() const { return fKurtosis; }
00142 
00143     void print(std::ostream& os = std::cout) const
00144     {
00145       os << "Value=" << value()
00146          << " Error=" << error()
00147          << " Diff to Ref=" << diff() << " % "
00148          << " +- " << diffError() << " %"
00149          << std::endl;
00150     }
00151     
00152   private:
00153     float fValue;
00154     float fError;
00155     float fDiff;
00156     float fDiffError;
00157     float fSkewness;
00158     float fKurtosis;
00159   };
00160   
00161   class RunCheck
00162   {
00163   public:
00164     RunCheck(int runnumber=-1)
00165       : fRunNumber(runnumber) {}
00166         
00167     int runnumber() const { return fRunNumber; }
00168     
00169     void set(const std::string& details, const BaseLine& value)
00170     { fValues[details] = value; }
00171     
00172     BaseLine get(const std::string& details) const;
00173     
00174   private:
00175     int fRunNumber;
00176     std::map<std::string,BaseLine> fValues;
00177   };
00178 
00179  private:
00180   
00181   time_t fTimeOffset;
00182   std::vector<int> fRuns;
00183   std::map<int,RunCheck> fRunChecks;
00184   std::vector<float> fPercent;
00185   std::vector<std::string> fSectors;
00186   std::set<std::string> fProcesses;
00187   std::vector<std::string> fDetails;
00188   std::map<std::string,TGraphErrors*> fGraphs;
00189   int fVerbose;
00190   EHistogrammingType fHistogrammingType;
00191 };
00192 
00193 #endif