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; class ActivityRegistry;}
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, edm::ActivityRegistry&);
00053 DQMStore(const edm::ParameterSet &pset);
00054 ~DQMStore(void);
00055
00056
00057 void setVerbose(unsigned level);
00058
00059
00060 const std::string & pwd(void) const;
00061 void cd(void);
00062 void cd(const std::string &subdir);
00063 void setCurrentFolder(const std::string &fullpath);
00064 void goUp(void);
00065
00066 bool dirExists(const std::string &path) const;
00067
00068
00069
00070
00071 MonitorElement * bookInt (const char *name);
00072 MonitorElement * bookInt (const std::string &name);
00073
00074 MonitorElement * bookFloat (const char *name);
00075 MonitorElement * bookFloat (const std::string &name);
00076
00077 MonitorElement * bookString (const char *name,
00078 const char *value);
00079 MonitorElement * bookString (const std::string &name,
00080 const std::string &value);
00081
00082 MonitorElement * book1D (const char *name,
00083 const char *title,
00084 int nchX, double lowX, double highX);
00085 MonitorElement * book1D (const std::string &name,
00086 const std::string &title,
00087 int nchX, double lowX, double highX);
00088 MonitorElement * book1D (const char *name,
00089 const char *title,
00090 int nchX, float *xbinsize);
00091 MonitorElement * book1D (const std::string &name,
00092 const std::string &title,
00093 int nchX, float *xbinsize);
00094 MonitorElement * book1D (const char *name, TH1F *h);
00095 MonitorElement * book1D (const std::string &name, TH1F *h);
00096
00097 MonitorElement * book1S (const char *name,
00098 const char *title,
00099 int nchX, double lowX, double highX);
00100 MonitorElement * book1S (const std::string &name,
00101 const std::string &title,
00102 int nchX, double lowX, double highX);
00103 MonitorElement * book1S (const char *name,
00104 const char *title,
00105 int nchX, float *xbinsize);
00106 MonitorElement * book1S (const std::string &name,
00107 const std::string &title,
00108 int nchX, float *xbinsize);
00109 MonitorElement * book1S (const char *name, TH1S *h);
00110 MonitorElement * book1S (const std::string &name, TH1S *h);
00111
00112 MonitorElement * book1DD (const char *name,
00113 const char *title,
00114 int nchX, double lowX, double highX);
00115 MonitorElement * book1DD (const std::string &name,
00116 const std::string &title,
00117 int nchX, double lowX, double highX);
00118 MonitorElement * book1DD (const char *name,
00119 const char *title,
00120 int nchX, float *xbinsize);
00121 MonitorElement * book1DD (const std::string &name,
00122 const std::string &title,
00123 int nchX, float *xbinsize);
00124 MonitorElement * book1DD (const char *name, TH1D *h);
00125 MonitorElement * book1DD (const std::string &name, TH1D *h);
00126
00127 MonitorElement * book2D (const char *name,
00128 const char *title,
00129 int nchX, double lowX, double highX,
00130 int nchY, double lowY, double highY);
00131 MonitorElement * book2D (const std::string &name,
00132 const std::string &title,
00133 int nchX, double lowX, double highX,
00134 int nchY, double lowY, double highY);
00135 MonitorElement * book2D (const char *name,
00136 const char *title,
00137 int nchX, float *xbinsize,
00138 int nchY, float *ybinsize);
00139 MonitorElement * book2D (const std::string &name,
00140 const std::string &title,
00141 int nchX, float *xbinsize,
00142 int nchY, float *ybinsize);
00143 MonitorElement * book2D (const char *name, TH2F *h);
00144 MonitorElement * book2D (const std::string &name, TH2F *h);
00145
00146 MonitorElement * book2S (const char *name,
00147 const char *title,
00148 int nchX, double lowX, double highX,
00149 int nchY, double lowY, double highY);
00150 MonitorElement * book2S (const std::string &name,
00151 const std::string &title,
00152 int nchX, double lowX, double highX,
00153 int nchY, double lowY, double highY);
00154 MonitorElement * book2S (const char *name,
00155 const char *title,
00156 int nchX, float *xbinsize,
00157 int nchY, float *ybinsize);
00158 MonitorElement * book2S (const std::string &name,
00159 const std::string &title,
00160 int nchX, float *xbinsize,
00161 int nchY, float *ybinsize);
00162 MonitorElement * book2S (const char *name, TH2S *h);
00163 MonitorElement * book2S (const std::string &name, TH2S *h);
00164
00165 MonitorElement * book2DD (const char *name,
00166 const char *title,
00167 int nchX, double lowX, double highX,
00168 int nchY, double lowY, double highY);
00169 MonitorElement * book2DD (const std::string &name,
00170 const std::string &title,
00171 int nchX, double lowX, double highX,
00172 int nchY, double lowY, double highY);
00173 MonitorElement * book2DD (const char *name,
00174 const char *title,
00175 int nchX, float *xbinsize,
00176 int nchY, float *ybinsize);
00177 MonitorElement * book2DD (const std::string &name,
00178 const std::string &title,
00179 int nchX, float *xbinsize,
00180 int nchY, float *ybinsize);
00181 MonitorElement * book2DD (const char *name, TH2D *h);
00182 MonitorElement * book2DD (const std::string &name, TH2D *h);
00183
00184 MonitorElement * book3D (const char *name,
00185 const char *title,
00186 int nchX, double lowX, double highX,
00187 int nchY, double lowY, double highY,
00188 int nchZ, double lowZ, double highZ);
00189 MonitorElement * book3D (const std::string &name,
00190 const std::string &title,
00191 int nchX, double lowX, double highX,
00192 int nchY, double lowY, double highY,
00193 int nchZ, double lowZ, double highZ);
00194 MonitorElement * book3D (const char *name, TH3F *h);
00195 MonitorElement * book3D (const std::string &name, TH3F *h);
00196
00197 MonitorElement * bookProfile (const char *name,
00198 const char *title,
00199 int nchX, double lowX, double highX,
00200 int nchY, double lowY, double highY,
00201 const char *option = "s");
00202 MonitorElement * bookProfile (const std::string &name,
00203 const std::string &title,
00204 int nchX, double lowX, double highX,
00205 int nchY, double lowY, double highY,
00206 const char *option = "s");
00207 MonitorElement * bookProfile (const char *name,
00208 const char *title,
00209 int nchX, double lowX, double highX,
00210 double lowY, double highY,
00211 const char *option = "s");
00212 MonitorElement * bookProfile (const std::string &name,
00213 const std::string &title,
00214 int nchX, double lowX, double highX,
00215 double lowY, double highY,
00216 const char *option = "s");
00217 MonitorElement * bookProfile (const char *name,
00218 const char *title,
00219 int nchX, double *xbinsize,
00220 int nchY, double lowY, double highY,
00221 const char *option = "s");
00222 MonitorElement * bookProfile (const std::string &name,
00223 const std::string &title,
00224 int nchX, double *xbinsize,
00225 int nchY, double lowY, double highY,
00226 const char *option = "s");
00227 MonitorElement * bookProfile (const char *name,
00228 const char *title,
00229 int nchX, double *xbinsize,
00230 double lowY, double highY,
00231 const char *option = "s");
00232 MonitorElement * bookProfile (const std::string &name,
00233 const std::string &title,
00234 int nchX, double *xbinsize,
00235 double lowY, double highY,
00236 const char *option = "s");
00237 MonitorElement * bookProfile (const char *name, TProfile *h);
00238 MonitorElement * bookProfile (const std::string &name, TProfile *h);
00239
00240 MonitorElement * bookProfile2D(const char *name,
00241 const char *title,
00242 int nchX, double lowX, double highX,
00243 int nchY, double lowY, double highY,
00244 int nchZ, double lowZ, double highZ,
00245 const char *option = "s");
00246 MonitorElement * bookProfile2D(const std::string &name,
00247 const std::string &title,
00248 int nchX, double lowX, double highX,
00249 int nchY, double lowY, double highY,
00250 int nchZ, double lowZ, double highZ,
00251 const char *option = "s");
00252 MonitorElement * bookProfile2D(const char *name,
00253 const char *title,
00254 int nchX, double lowX, double highX,
00255 int nchY, double lowY, double highY,
00256 double lowZ, double highZ,
00257 const char *option = "s");
00258 MonitorElement * bookProfile2D(const std::string &name,
00259 const std::string &title,
00260 int nchX, double lowX, double highX,
00261 int nchY, double lowY, double highY,
00262 double lowZ, double highZ,
00263 const char *option = "s");
00264 MonitorElement * bookProfile2D(const char *name, TProfile2D *h);
00265 MonitorElement * bookProfile2D(const std::string &name, TProfile2D *h);
00266
00267
00268
00269 void tag(MonitorElement *me, unsigned int myTag);
00270 void tag(const std::string &path, unsigned int myTag);
00271 void tagContents(const std::string &path, unsigned int myTag);
00272 void tagAllContents(const std::string &path, unsigned int myTag);
00273
00274
00275
00276 std::vector<std::string> getSubdirs(void) const;
00277 std::vector<std::string> getMEs(void) const;
00278 bool containsAnyMonitorable(const std::string &path) const;
00279
00280 MonitorElement * get(const std::string &path) const;
00281 std::vector<MonitorElement *> get(unsigned int tag) const;
00282 std::vector<MonitorElement *> getContents(const std::string &path) const;
00283 std::vector<MonitorElement *> getContents(const std::string &path, unsigned int tag) const;
00284 void getContents(std::vector<std::string> &into, bool showContents = true) const;
00285
00286
00287 void softReset(MonitorElement *me);
00288 void disableSoftReset(MonitorElement *me);
00289
00290
00291 void rmdir(const std::string &fullpath);
00292 void removeContents(void);
00293 void removeContents(const std::string &dir);
00294 void removeElement(const std::string &name);
00295 void removeElement(const std::string &dir, const std::string &name, bool warning = true);
00296
00297
00298
00299 void save(const std::string &filename,
00300 const std::string &path = "",
00301 const std::string &pattern = "",
00302 const std::string &rewrite = "",
00303 SaveReferenceTag ref = SaveWithReference,
00304 int minStatus = dqm::qstatus::STATUS_OK,
00305 const std::string &fileupdate = "RECREATE");
00306 bool open(const std::string &filename,
00307 bool overwrite = false,
00308 const std::string &path ="",
00309 const std::string &prepend = "",
00310 OpenRunDirs stripdirs = KeepRunDirs,
00311 bool fileMustExist = true);
00312 bool load(const std::string &filename,
00313 OpenRunDirs stripdirs = StripRunDirs,
00314 bool fileMustExist = true);
00315
00316
00317
00318 void showDirStructure(void) const;
00319
00320
00321
00322 QCriterion * getQCriterion(const std::string &qtname) const;
00323 QCriterion * createQTest(const std::string &algoname, const std::string &qtname);
00324 void useQTest(const std::string &dir, const std::string &qtname);
00325 int useQTestByMatch(const std::string &pattern, const std::string &qtname);
00326 void runQTests(void);
00327 int getStatus(const std::string &path = "") const;
00328
00329 private:
00330
00331 bool cdInto(const std::string &path) const;
00332
00333
00334 bool isCollateME(MonitorElement *me) const;
00335
00336
00337 bool readFile(const std::string &filename,
00338 bool overwrite = false,
00339 const std::string &path ="",
00340 const std::string &prepend = "",
00341 OpenRunDirs stripdirs = StripRunDirs,
00342 bool fileMustExist = true);
00343 void makeDirectory(const std::string &path);
00344 unsigned int readDirectory(TFile *file,
00345 bool overwrite,
00346 const std::string &path,
00347 const std::string &prepend,
00348 const std::string &curdir,
00349 OpenRunDirs stripdirs);
00350
00351 MonitorElement * findObject(const std::string &dir, const std::string &name) const;
00352
00353 public:
00354 void getAllTags(std::vector<std::string> &into) const;
00355 std::vector<MonitorElement*> getAllContents(const std::string &path) const;
00356 std::vector<MonitorElement*> getMatchingContents(const std::string &pattern, lat::Regexp::Syntax syntaxType = lat::Regexp::Wildcard) const;
00357 private:
00358
00359
00360 void initializeFrom(const edm::ParameterSet&);
00361 void reset(void);
00362 void forceReset(void);
00363
00364 bool extract(TObject *obj, const std::string &dir, bool overwrite);
00365
00366
00367 MonitorElement * initialise(MonitorElement *me, const std::string &path);
00368 MonitorElement * book(const std::string &dir,
00369 const std::string &name,
00370 const char *context);
00371 template <class HISTO, class COLLATE>
00372 MonitorElement * book(const std::string &dir, const std::string &name,
00373 const char *context, int kind,
00374 HISTO *h, COLLATE collate);
00375
00376 MonitorElement * bookInt(const std::string &dir, const std::string &name);
00377 MonitorElement * bookFloat(const std::string &dir, const std::string &name);
00378 MonitorElement * bookString(const std::string &dir, const std::string &name, const std::string &value);
00379 MonitorElement * book1D(const std::string &dir, const std::string &name, TH1F *h);
00380 MonitorElement * book1S(const std::string &dir, const std::string &name, TH1S *h);
00381 MonitorElement * book1DD(const std::string &dir, const std::string &name, TH1D *h);
00382 MonitorElement * book2D(const std::string &dir, const std::string &name, TH2F *h);
00383 MonitorElement * book2S(const std::string &dir, const std::string &name, TH2S *h);
00384 MonitorElement * book2DD(const std::string &dir, const std::string &name, TH2D *h);
00385 MonitorElement * book3D(const std::string &dir, const std::string &name, TH3F *h);
00386 MonitorElement * bookProfile(const std::string &dir, const std::string &name, TProfile *h);
00387 MonitorElement * bookProfile2D(const std::string &folder, const std::string &name, TProfile2D *h);
00388
00389 static bool checkBinningMatches(MonitorElement *me, TH1 *h);
00390
00391 static void collate1D(MonitorElement *me, TH1F *h);
00392 static void collate1S(MonitorElement *me, TH1S *h);
00393 static void collate1DD(MonitorElement *me, TH1D *h);
00394 static void collate2D(MonitorElement *me, TH2F *h);
00395 static void collate2S(MonitorElement *me, TH2S *h);
00396 static void collate2DD(MonitorElement *me, TH2D *h);
00397 static void collate3D(MonitorElement *me, TH3F *h);
00398 static void collateProfile(MonitorElement *me, TProfile *h);
00399 static void collateProfile2D(MonitorElement *me, TProfile2D *h);
00400
00401
00402 void setAccumulate(MonitorElement *me, bool flag);
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 DQMService;
00432 friend class DQMNet;
00433 friend class DQMArchiver;
00434 friend class DQMStoreExample;
00435 };
00436
00437 #endif // DQMSERVICES_CORE_DQM_STORE_H