00001 #ifndef DQMSERVICES_CORE_DQM_STORE_H
00002 # define DQMSERVICES_CORE_DQM_STORE_H
00003
00004 # include "DQMServices/Core/interface/DQMDefinitions.h"
00005 # include <vector>
00006 # include <string>
00007 # include <list>
00008 # include <map>
00009 # include <set>
00010
00011 namespace edm { class DQMHttpSource; class ParameterSet; }
00012 namespace lat { class Regexp; }
00013
00014 class MonitorElement;
00015 class QCriterion;
00016 class TFile;
00017 class TObject;
00018 class TObjString;
00019 class TH1F;
00020 class TH1S;
00021 class TH2F;
00022 class TH2S;
00023 class TH3F;
00024 class TProfile;
00025 class TProfile2D;
00026
00027 class DQMStore
00028 {
00029 public:
00030 enum SaveReferenceTag
00031 {
00032 SaveWithoutReference,
00033 SaveWithReference,
00034 SaveWithReferenceForQTest
00035 };
00036
00037
00038
00039 DQMStore(const edm::ParameterSet &pset);
00040 ~DQMStore(void);
00041
00042
00043 void setVerbose(unsigned level);
00044
00045
00046 const std::string & pwd(void) const;
00047 void cd(void);
00048 void cd(const std::string &subdir);
00049 void setCurrentFolder(const std::string &fullpath);
00050 void goUp(void);
00051
00052 bool dirExists(const std::string &path) const;
00053
00054
00055
00056
00057 MonitorElement * bookInt (const std::string &name);
00058 MonitorElement * bookFloat (const std::string &name);
00059 MonitorElement * bookString (const std::string &name,
00060 const std::string &value);
00061 MonitorElement * book1D (const std::string &name,
00062 const std::string &title,
00063 int nchX, double lowX, double highX);
00064 MonitorElement * book1D (const std::string &name,
00065 const std::string &title,
00066 int nchX, float *xbinsize);
00067 MonitorElement * book1D (const std::string &name, TH1F *h);
00068
00069 MonitorElement * book1S (const std::string &name,
00070 const std::string &title,
00071 int nchX, double lowX, double highX);
00072 MonitorElement * book1S (const std::string &name,
00073 const std::string &title,
00074 int nchX, float *xbinsize);
00075 MonitorElement * book1S (const std::string &name, TH1S *h);
00076
00077 MonitorElement * book2D (const std::string &name,
00078 const std::string &title,
00079 int nchX, double lowX, double highX,
00080 int nchY, double lowY, double highY);
00081 MonitorElement * book2D (const std::string &name,
00082 const std::string &title,
00083 int nchX, float *xbinsize,
00084 int nchY, float *ybinsize);
00085 MonitorElement * book2D (const std::string &name, TH2F *h);
00086
00087 MonitorElement * book2S (const std::string &name,
00088 const std::string &title,
00089 int nchX, double lowX, double highX,
00090 int nchY, double lowY, double highY);
00091 MonitorElement * book2S (const std::string &name,
00092 const std::string &title,
00093 int nchX, float *xbinsize,
00094 int nchY, float *ybinsize);
00095 MonitorElement * book2S (const std::string &name, TH2S *h);
00096
00097 MonitorElement * book3D (const std::string &name,
00098 const std::string &title,
00099 int nchX, double lowX, double highX,
00100 int nchY, double lowY, double highY,
00101 int nchZ, double lowZ, double highZ);
00102 MonitorElement * book3D (const std::string &name, TH3F *h);
00103
00104 MonitorElement * bookProfile (const std::string &name,
00105 const std::string &title,
00106 int nchX, double lowX, double highX,
00107 int nchY, double lowY, double highY,
00108 const char *option = "s");
00109 MonitorElement * bookProfile (const std::string &name, TProfile *h);
00110
00111 MonitorElement * bookProfile2D(const std::string &name,
00112 const std::string &title,
00113 int nchX, double lowX, double highX,
00114 int nchY, double lowY, double highY,
00115 int nchZ, double lowZ, double highZ,
00116 const char *option = "s");
00117 MonitorElement * bookProfile2D(const std::string &name, TProfile2D *h);
00118
00119
00120
00121 void tag(MonitorElement *me, unsigned int myTag);
00122 void tag(const std::string &path, unsigned int myTag);
00123 void tagContents(const std::string &path, unsigned int myTag);
00124 void tagAllContents(const std::string &path, unsigned int myTag);
00125
00126
00127
00128 std::vector<std::string> getSubdirs(void) const;
00129 std::vector<std::string> getMEs(void) const;
00130 bool containsAnyMonitorable(const std::string &path) const;
00131
00132 MonitorElement * get(const std::string &path) const;
00133 std::vector<MonitorElement *> get(unsigned int tag) const;
00134 std::vector<MonitorElement *> getContents(const std::string &path) const;
00135 std::vector<MonitorElement *> getContents(const std::string &path, unsigned int tag) const;
00136 void getContents(std::vector<std::string> &into, bool showContents = true) const;
00137
00138
00139 void softReset(MonitorElement *me);
00140
00141
00142 void rmdir(const std::string &fullpath);
00143 void removeContents(void);
00144 void removeElement(const std::string &name);
00145
00146
00147
00148 void save(const std::string &filename,
00149 const std::string &path = "",
00150 const std::string &pattern = "",
00151 const std::string &rewrite = "",
00152 SaveReferenceTag ref = SaveWithReferenceForQTest,
00153 int minStatus = dqm::qstatus::STATUS_OK);
00154 void open(const std::string &filename,
00155 bool overwrite = false,
00156 const std::string &path ="",
00157 const std::string &prepend = "");
00158 std::string getFileReleaseVersion(const std::string &filename);
00159 std::string getFileDQMPatchVersion(const std::string &filename);
00160 std::string getDQMPatchVersion(void);
00161
00162
00163
00164 void showDirStructure(void) const;
00165
00166
00167
00168 QCriterion * getQCriterion(const std::string &qtname) const;
00169 QCriterion * createQTest(const std::string &algoname, const std::string &qtname);
00170 void useQTest(const std::string &dir, const std::string &qtname);
00171 int useQTestByMatch(const std::string &pattern, const std::string &qtname);
00172 void runQTests(void);
00173 int getStatus(const std::string &path = "") const;
00174
00175 private:
00176
00177 void disableSoftReset(MonitorElement *me);
00178
00179
00180 bool cdInto(const std::string &path) const;
00181
00182
00183 bool makeReferenceME(MonitorElement *me);
00184 bool isReferenceME(MonitorElement *me) const;
00185 bool isCollateME(MonitorElement *me) const;
00186 MonitorElement * getReferenceME(MonitorElement *me) const;
00187
00188
00189 void makeDirectory(const std::string &path);
00190 unsigned int readDirectory(TFile *file,
00191 bool overwrite,
00192 const std::string &path,
00193 const std::string &prepend,
00194 const std::string &curdir);
00195
00196 MonitorElement * findObject(const std::string &dir,
00197 const std::string &name,
00198 std::string &path) const;
00199
00200 public:
00201 void getAllTags(std::vector<std::string> &into) const;
00202 std::vector<MonitorElement*> getAllContents(const std::string &path) const;
00203 std::vector<MonitorElement*> getMatchingContents(const std::string &pattern) const;
00204 private:
00205
00206
00207 void reset(void);
00208
00209 bool extract(TObject *obj, const std::string &dir, bool overwrite);
00210
00211
00212 MonitorElement * initialise(MonitorElement *me, const std::string &path);
00213 MonitorElement * book(const std::string &dir, const std::string &name,
00214 std::string &path, const char *context);
00215 template <class HISTO, class COLLATE>
00216 MonitorElement * book(const std::string &dir, const std::string &name,
00217 const char *context, int kind,
00218 HISTO *h, COLLATE collate);
00219
00220 MonitorElement * bookInt(const std::string &dir, const std::string &name);
00221 MonitorElement * bookFloat(const std::string &dir, const std::string &name);
00222 MonitorElement * bookString(const std::string &dir, const std::string &name, const std::string &value);
00223 MonitorElement * book1D(const std::string &dir, const std::string &name, TH1F *h);
00224 MonitorElement * book1S(const std::string &dir, const std::string &name, TH1S *h);
00225 MonitorElement * book2D(const std::string &dir, const std::string &name, TH2F *h);
00226 MonitorElement * book2S(const std::string &dir, const std::string &name, TH2S *h);
00227 MonitorElement * book3D(const std::string &dir, const std::string &name, TH3F *h);
00228 MonitorElement * bookProfile(const std::string &dir, const std::string &name, TProfile *h);
00229 MonitorElement * bookProfile2D(const std::string &folder, const std::string &name, TProfile2D *h);
00230
00231 static void collate1D(MonitorElement *me, TH1F *h);
00232 static void collate1S(MonitorElement *me, TH1S *h);
00233 static void collate2D(MonitorElement *me, TH2F *h);
00234 static void collate2S(MonitorElement *me, TH2S *h);
00235 static void collate3D(MonitorElement *me, TH3F *h);
00236 static void collateProfile(MonitorElement *me, TProfile *h);
00237 static void collateProfile2D(MonitorElement *me, TProfile2D *h);
00238
00240 void removeElement(const std::string &dir, const std::string &name, bool warning = true);
00241 void removeContents(const std::string &dir);
00242
00243
00244 void setAccumulate(MonitorElement *me, bool flag);
00245
00246
00247 static DQMStore * instance(void);
00248
00249
00250 DQMStore(const DQMStore&);
00251 const DQMStore& operator=(const DQMStore&);
00252
00253
00254
00255 typedef std::pair<lat::Regexp *, QCriterion *> QTestSpec;
00256 typedef std::list<QTestSpec> QTestSpecs;
00257 typedef std::map<std::string, MonitorElement> MEMap;
00258 typedef std::map<std::string, QCriterion *> QCMap;
00259 typedef std::map<std::string, QCriterion *(*)(const std::string &)> QAMap;
00260
00261 unsigned verbose_;
00262 bool reset_;
00263 bool collateHistograms_;
00264 std::string readSelectedDirectory_;
00265 bool firstTimeInRoot_;
00266
00267 std::string pwd_;
00268 MEMap data_;
00269 std::set<std::string> dirs_;
00270 std::vector<std::string> removed_;
00271
00272 QCMap qtests_;
00273 QAMap qalgos_;
00274 QTestSpecs qtestspecs_;
00275
00276 friend class edm::DQMHttpSource;
00277 friend class DQMOldReceiver;
00278 friend class DQMService;
00279 friend class DQMNet;
00280 friend class DQMStoreExample;
00281 };
00282
00283 #endif // DQMSERVICES_CORE_DQM_STORE_H