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