00001 #ifndef DQMSERVICES_CORE_DQM_STORE_H
00002 # define DQMSERVICES_CORE_DQM_STORE_H
00003
00004 # if __GNUC__ && ! defined DQM_DEPRECATED
00005 # define DQM_DEPRECATED __attribute__((deprecated))
00006 # endif
00007
00008 # include "DQMServices/Core/interface/DQMDefinitions.h"
00009 # include "classlib/utils/Regexp.h"
00010 # include <vector>
00011 # include <string>
00012 # include <list>
00013 # include <map>
00014 # include <set>
00015
00016 namespace edm { class DQMHttpSource; class ParameterSet; }
00017 namespace lat { class Regexp; }
00018
00019 class MonitorElement;
00020 class QCriterion;
00021 class TFile;
00022 class TObject;
00023 class TH1;
00024 class TObjString;
00025 class TH1F;
00026 class TH1S;
00027 class TH1D;
00028 class TH2F;
00029 class TH2S;
00030 class TH2D;
00031 class TH3F;
00032 class TProfile;
00033 class TProfile2D;
00034
00035 class DQMStore
00036 {
00037 public:
00038 enum SaveReferenceTag
00039 {
00040 SaveWithoutReference,
00041 SaveWithReference,
00042 SaveWithReferenceForQTest
00043 };
00044 enum OpenRunDirs
00045 {
00046 KeepRunDirs,
00047 StripRunDirs
00048 };
00049
00050
00051
00052 DQMStore(const edm::ParameterSet &pset);
00053 ~DQMStore(void);
00054
00055
00056 void setVerbose(unsigned level);
00057
00058
00059 const std::string & pwd(void) const;
00060 void cd(void);
00061 void cd(const std::string &subdir);
00062 void setCurrentFolder(const std::string &fullpath);
00063 void goUp(void);
00064
00065 bool dirExists(const std::string &path) const;
00066
00067
00068
00069
00070 MonitorElement * bookInt (const char *name);
00071 MonitorElement * bookInt (const std::string &name);
00072
00073 MonitorElement * bookFloat (const char *name);
00074 MonitorElement * bookFloat (const std::string &name);
00075
00076 MonitorElement * bookString (const char *name,
00077 const char *value);
00078 MonitorElement * bookString (const std::string &name,
00079 const std::string &value);
00080
00081 MonitorElement * book1D (const char *name,
00082 const char *title,
00083 int nchX, double lowX, double highX);
00084 MonitorElement * book1D (const std::string &name,
00085 const std::string &title,
00086 int nchX, double lowX, double highX);
00087 MonitorElement * book1D (const char *name,
00088 const char *title,
00089 int nchX, float *xbinsize);
00090 MonitorElement * book1D (const std::string &name,
00091 const std::string &title,
00092 int nchX, float *xbinsize);
00093 MonitorElement * book1D (const char *name, TH1F *h);
00094 MonitorElement * book1D (const std::string &name, TH1F *h);
00095
00096 MonitorElement * book1S (const char *name,
00097 const char *title,
00098 int nchX, double lowX, double highX);
00099 MonitorElement * book1S (const std::string &name,
00100 const std::string &title,
00101 int nchX, double lowX, double highX);
00102 MonitorElement * book1S (const char *name,
00103 const char *title,
00104 int nchX, float *xbinsize);
00105 MonitorElement * book1S (const std::string &name,
00106 const std::string &title,
00107 int nchX, float *xbinsize);
00108 MonitorElement * book1S (const char *name, TH1S *h);
00109 MonitorElement * book1S (const std::string &name, TH1S *h);
00110
00111 MonitorElement * book1DD (const char *name,
00112 const char *title,
00113 int nchX, double lowX, double highX);
00114 MonitorElement * book1DD (const std::string &name,
00115 const std::string &title,
00116 int nchX, double lowX, double highX);
00117 MonitorElement * book1DD (const char *name,
00118 const char *title,
00119 int nchX, float *xbinsize);
00120 MonitorElement * book1DD (const std::string &name,
00121 const std::string &title,
00122 int nchX, float *xbinsize);
00123 MonitorElement * book1DD (const char *name, TH1D *h);
00124 MonitorElement * book1DD (const std::string &name, TH1D *h);
00125
00126 MonitorElement * book2D (const char *name,
00127 const char *title,
00128 int nchX, double lowX, double highX,
00129 int nchY, double lowY, double highY);
00130 MonitorElement * book2D (const std::string &name,
00131 const std::string &title,
00132 int nchX, double lowX, double highX,
00133 int nchY, double lowY, double highY);
00134 MonitorElement * book2D (const char *name,
00135 const char *title,
00136 int nchX, float *xbinsize,
00137 int nchY, float *ybinsize);
00138 MonitorElement * book2D (const std::string &name,
00139 const std::string &title,
00140 int nchX, float *xbinsize,
00141 int nchY, float *ybinsize);
00142 MonitorElement * book2D (const char *name, TH2F *h);
00143 MonitorElement * book2D (const std::string &name, TH2F *h);
00144
00145 MonitorElement * book2S (const char *name,
00146 const char *title,
00147 int nchX, double lowX, double highX,
00148 int nchY, double lowY, double highY);
00149 MonitorElement * book2S (const std::string &name,
00150 const std::string &title,
00151 int nchX, double lowX, double highX,
00152 int nchY, double lowY, double highY);
00153 MonitorElement * book2S (const char *name,
00154 const char *title,
00155 int nchX, float *xbinsize,
00156 int nchY, float *ybinsize);
00157 MonitorElement * book2S (const std::string &name,
00158 const std::string &title,
00159 int nchX, float *xbinsize,
00160 int nchY, float *ybinsize);
00161 MonitorElement * book2S (const char *name, TH2S *h);
00162 MonitorElement * book2S (const std::string &name, TH2S *h);
00163
00164 MonitorElement * book2DD (const char *name,
00165 const char *title,
00166 int nchX, double lowX, double highX,
00167 int nchY, double lowY, double highY);
00168 MonitorElement * book2DD (const std::string &name,
00169 const std::string &title,
00170 int nchX, double lowX, double highX,
00171 int nchY, double lowY, double highY);
00172 MonitorElement * book2DD (const char *name,
00173 const char *title,
00174 int nchX, float *xbinsize,
00175 int nchY, float *ybinsize);
00176 MonitorElement * book2DD (const std::string &name,
00177 const std::string &title,
00178 int nchX, float *xbinsize,
00179 int nchY, float *ybinsize);
00180 MonitorElement * book2DD (const char *name, TH2D *h);
00181 MonitorElement * book2DD (const std::string &name, TH2D *h);
00182
00183 MonitorElement * book3D (const char *name,
00184 const char *title,
00185 int nchX, double lowX, double highX,
00186 int nchY, double lowY, double highY,
00187 int nchZ, double lowZ, double highZ);
00188 MonitorElement * book3D (const std::string &name,
00189 const std::string &title,
00190 int nchX, double lowX, double highX,
00191 int nchY, double lowY, double highY,
00192 int nchZ, double lowZ, double highZ);
00193 MonitorElement * book3D (const char *name, TH3F *h);
00194 MonitorElement * book3D (const std::string &name, TH3F *h);
00195
00196 MonitorElement * bookProfile (const char *name,
00197 const char *title,
00198 int nchX, double lowX, double highX,
00199 int nchY, double lowY, double highY,
00200 const char *option = "s");
00201 MonitorElement * bookProfile (const std::string &name,
00202 const std::string &title,
00203 int nchX, double lowX, double highX,
00204 int nchY, double lowY, double highY,
00205 const char *option = "s");
00206 MonitorElement * bookProfile (const char *name,
00207 const char *title,
00208 int nchX, double lowX, double highX,
00209 double lowY, double highY,
00210 const char *option = "s");
00211 MonitorElement * bookProfile (const std::string &name,
00212 const std::string &title,
00213 int nchX, double lowX, double highX,
00214 double lowY, double highY,
00215 const char *option = "s");
00216 MonitorElement * bookProfile (const char *name,
00217 const char *title,
00218 int nchX, double *xbinsize,
00219 int nchY, double lowY, double highY,
00220 const char *option = "s");
00221 MonitorElement * bookProfile (const std::string &name,
00222 const std::string &title,
00223 int nchX, double *xbinsize,
00224 int nchY, double lowY, double highY,
00225 const char *option = "s");
00226 MonitorElement * bookProfile (const char *name,
00227 const char *title,
00228 int nchX, double *xbinsize,
00229 double lowY, double highY,
00230 const char *option = "s");
00231 MonitorElement * bookProfile (const std::string &name,
00232 const std::string &title,
00233 int nchX, double *xbinsize,
00234 double lowY, double highY,
00235 const char *option = "s");
00236 MonitorElement * bookProfile (const char *name, TProfile *h);
00237 MonitorElement * bookProfile (const std::string &name, TProfile *h);
00238
00239 MonitorElement * bookProfile2D(const char *name,
00240 const char *title,
00241 int nchX, double lowX, double highX,
00242 int nchY, double lowY, double highY,
00243 int nchZ, double lowZ, double highZ,
00244 const char *option = "s");
00245 MonitorElement * bookProfile2D(const std::string &name,
00246 const std::string &title,
00247 int nchX, double lowX, double highX,
00248 int nchY, double lowY, double highY,
00249 int nchZ, double lowZ, double highZ,
00250 const char *option = "s");
00251 MonitorElement * bookProfile2D(const char *name,
00252 const char *title,
00253 int nchX, double lowX, double highX,
00254 int nchY, double lowY, double highY,
00255 double lowZ, double highZ,
00256 const char *option = "s");
00257 MonitorElement * bookProfile2D(const std::string &name,
00258 const std::string &title,
00259 int nchX, double lowX, double highX,
00260 int nchY, double lowY, double highY,
00261 double lowZ, double highZ,
00262 const char *option = "s");
00263 MonitorElement * bookProfile2D(const char *name, TProfile2D *h);
00264 MonitorElement * bookProfile2D(const std::string &name, TProfile2D *h);
00265
00266
00267
00268 void tag(MonitorElement *me, unsigned int myTag);
00269 void tag(const std::string &path, unsigned int myTag);
00270 void tagContents(const std::string &path, unsigned int myTag);
00271 void tagAllContents(const std::string &path, unsigned int myTag);
00272
00273
00274
00275 std::vector<std::string> getSubdirs(void) const;
00276 std::vector<std::string> getMEs(void) const;
00277 bool containsAnyMonitorable(const std::string &path) const;
00278
00279 MonitorElement * get(const std::string &path) const;
00280 std::vector<MonitorElement *> get(unsigned int tag) const;
00281 std::vector<MonitorElement *> getContents(const std::string &path) const;
00282 std::vector<MonitorElement *> getContents(const std::string &path, unsigned int tag) const;
00283 void getContents(std::vector<std::string> &into, bool showContents = true) const;
00284
00285
00286 void softReset(MonitorElement *me);
00287 void disableSoftReset(MonitorElement *me);
00288
00289
00290 void rmdir(const std::string &fullpath);
00291 void removeContents(void);
00292 void removeContents(const std::string &dir);
00293 void removeElement(const std::string &name);
00294 void removeElement(const std::string &dir, const std::string &name, bool warning = true);
00295
00296
00297
00298 void save(const std::string &filename,
00299 const std::string &path = "",
00300 const std::string &pattern = "",
00301 const std::string &rewrite = "",
00302 SaveReferenceTag ref = SaveWithReference,
00303 int minStatus = dqm::qstatus::STATUS_OK,
00304 const std::string &fileupdate = "RECREATE");
00305 bool open(const std::string &filename,
00306 bool overwrite = false,
00307 const std::string &path ="",
00308 const std::string &prepend = "",
00309 OpenRunDirs stripdirs = KeepRunDirs,
00310 bool fileMustExist = true);
00311 bool load(const std::string &filename,
00312 OpenRunDirs stripdirs = StripRunDirs,
00313 bool fileMustExist = true);
00314
00315
00316
00317 void showDirStructure(void) const;
00318
00319
00320
00321 QCriterion * getQCriterion(const std::string &qtname) const;
00322 QCriterion * createQTest(const std::string &algoname, const std::string &qtname);
00323 void useQTest(const std::string &dir, const std::string &qtname);
00324 int useQTestByMatch(const std::string &pattern, const std::string &qtname);
00325 void runQTests(void);
00326 int getStatus(const std::string &path = "") const;
00327
00328 private:
00329
00330 bool cdInto(const std::string &path) const;
00331
00332
00333 bool isCollateME(MonitorElement *me) const;
00334
00335
00336 bool readFile(const std::string &filename,
00337 bool overwrite = false,
00338 const std::string &path ="",
00339 const std::string &prepend = "",
00340 OpenRunDirs stripdirs = StripRunDirs,
00341 bool fileMustExist = true);
00342 void makeDirectory(const std::string &path);
00343 unsigned int readDirectory(TFile *file,
00344 bool overwrite,
00345 const std::string &path,
00346 const std::string &prepend,
00347 const std::string &curdir,
00348 OpenRunDirs stripdirs);
00349
00350 MonitorElement * findObject(const std::string &dir, const std::string &name) const;
00351
00352 public:
00353 void getAllTags(std::vector<std::string> &into) const;
00354 std::vector<MonitorElement*> getAllContents(const std::string &path) const;
00355 std::vector<MonitorElement*> getMatchingContents(const std::string &pattern, lat::Regexp::Syntax syntaxType = lat::Regexp::Wildcard) const;
00356 private:
00357
00358
00359 void reset(void);
00360
00361 bool extract(TObject *obj, const std::string &dir, bool overwrite);
00362
00363
00364 MonitorElement * initialise(MonitorElement *me, const std::string &path);
00365 MonitorElement * book(const std::string &dir,
00366 const std::string &name,
00367 const char *context);
00368 template <class HISTO, class COLLATE>
00369 MonitorElement * book(const std::string &dir, const std::string &name,
00370 const char *context, int kind,
00371 HISTO *h, COLLATE collate);
00372
00373 MonitorElement * bookInt(const std::string &dir, const std::string &name);
00374 MonitorElement * bookFloat(const std::string &dir, const std::string &name);
00375 MonitorElement * bookString(const std::string &dir, const std::string &name, const std::string &value);
00376 MonitorElement * book1D(const std::string &dir, const std::string &name, TH1F *h);
00377 MonitorElement * book1S(const std::string &dir, const std::string &name, TH1S *h);
00378 MonitorElement * book1DD(const std::string &dir, const std::string &name, TH1D *h);
00379 MonitorElement * book2D(const std::string &dir, const std::string &name, TH2F *h);
00380 MonitorElement * book2S(const std::string &dir, const std::string &name, TH2S *h);
00381 MonitorElement * book2DD(const std::string &dir, const std::string &name, TH2D *h);
00382 MonitorElement * book3D(const std::string &dir, const std::string &name, TH3F *h);
00383 MonitorElement * bookProfile(const std::string &dir, const std::string &name, TProfile *h);
00384 MonitorElement * bookProfile2D(const std::string &folder, const std::string &name, TProfile2D *h);
00385
00386 static bool checkBinningMatches(MonitorElement *me, TH1 *h);
00387
00388 static void collate1D(MonitorElement *me, TH1F *h);
00389 static void collate1S(MonitorElement *me, TH1S *h);
00390 static void collate1DD(MonitorElement *me, TH1D *h);
00391 static void collate2D(MonitorElement *me, TH2F *h);
00392 static void collate2S(MonitorElement *me, TH2S *h);
00393 static void collate2DD(MonitorElement *me, TH2D *h);
00394 static void collate3D(MonitorElement *me, TH3F *h);
00395 static void collateProfile(MonitorElement *me, TProfile *h);
00396 static void collateProfile2D(MonitorElement *me, TProfile2D *h);
00397
00398
00399 void setAccumulate(MonitorElement *me, bool flag);
00400
00401
00402 static DQMStore * instance(void);
00403
00404
00405 DQMStore(const DQMStore&);
00406 const DQMStore& operator=(const DQMStore&);
00407
00408
00409
00410 typedef std::pair<lat::Regexp *, QCriterion *> QTestSpec;
00411 typedef std::list<QTestSpec> QTestSpecs;
00412 typedef std::set<MonitorElement> MEMap;
00413 typedef std::map<std::string, QCriterion *> QCMap;
00414 typedef std::map<std::string, QCriterion *(*)(const std::string &)> QAMap;
00415
00416 unsigned verbose_;
00417 unsigned verboseQT_;
00418 bool reset_;
00419 bool collateHistograms_;
00420 std::string readSelectedDirectory_;
00421
00422 std::string pwd_;
00423 MEMap data_;
00424 std::set<std::string> dirs_;
00425
00426 QCMap qtests_;
00427 QAMap qalgos_;
00428 QTestSpecs qtestspecs_;
00429
00430 friend class edm::DQMHttpSource;
00431 friend class DQMOldReceiver;
00432 friend class DQMService;
00433 friend class DQMNet;
00434 friend class DQMStoreExample;
00435 };
00436
00437 #endif // DQMSERVICES_CORE_DQM_STORE_H