00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "DQMServices/Examples/interface/DQMSourceExample.h"
00014
00015 #include "FWCore/ServiceRegistry/interface/Service.h"
00016
00017 #include "TRandom.h"
00018 #include <math.h>
00019
00020 using namespace std;
00021 using namespace edm;
00022
00023
00024
00025
00026 DQMSourceExample::DQMSourceExample( const edm::ParameterSet& ps ) :
00027 counterEvt_(0)
00028 {
00029 dbe_ = Service<DQMStore>().operator->();
00030 parameters_ = ps;
00031 monitorName_ = parameters_.getUntrackedParameter<string>("monitorName","YourSubsystemName");
00032 cout << "Monitor name = " << monitorName_ << endl;
00033 if (monitorName_ != "" ) monitorName_ = monitorName_+"/" ;
00034 prescaleEvt_ = parameters_.getUntrackedParameter<int>("prescaleEvt", -1);
00035 cout << "===>DQM event prescale = " << prescaleEvt_ << " events "<< endl;
00036
00038
00039
00040
00042
00043
00044
00048
00049
00050
00052
00053
00055 const int NBINS = 50; XMIN = 0; XMAX = 50;
00056
00057
00058 rooth1 = new TH1F("rooth1","rooth1",NBINS,XMIN,XMAX);
00059 rooth1->GetXaxis()->SetTitle("X axis title");
00060 rooth1->GetYaxis()->SetTitle("Y axis title");
00061
00062
00063 dbe_->setCurrentFolder(monitorName_+"C1");
00064 h1 = dbe_->book1D("histo", "Example 1D histogram.", NBINS, XMIN, XMAX);
00065 h1->setAxisTitle("x-axis title", 1);
00066 h1->setAxisTitle("y-axis title", 2);
00067 h2 = dbe_->book2D("histo2", "Example 2 2D histogram.", NBINS, XMIN, XMAX,
00068 NBINS, XMIN, XMAX);
00069 p1 = dbe_->bookProfile("prof1","my profile",NBINS,XMIN,XMAX,NBINS,XMIN,XMAX,"");
00070
00071 dbe_->setCurrentFolder(monitorName_+"C1/C2");
00072 h3 = dbe_->book1D("histo3", "Example 3 1D histogram.", NBINS, XMIN, XMAX);
00073 h4 = dbe_->book1D("histo4", "Example 4 1D histogram.", NBINS, XMIN, XMAX);
00074 h5 = dbe_->book1D("histo5", "Example 5 1D histogram.", NBINS, XMIN, XMAX);
00075 h6 = dbe_->book1D("histo6", "Example 6 1D histogram.", NBINS, XMIN, XMAX);
00076
00077 dbe_->setCurrentFolder(monitorName_+"C1/C3");
00078 const int NBINS2 = 10;
00079 h7 = dbe_->book1D("histo7", "Example 7 1D histogram.", NBINS2, XMIN, XMAX);
00080 char temp[1024];
00081 for(int i = 1; i <= NBINS2; ++i)
00082 {
00083 sprintf(temp, " bin no. %d", i);
00084 h7->setBinLabel(i, temp);
00085 }
00086 i1 = dbe_->bookInt("int1");
00087 f1 = dbe_->bookFloat("float1");
00088 s1 = dbe_->bookString("s1", "my string");
00089
00090 h2->setAxisTitle("Customized x-axis", 1);
00091 h2->setAxisTitle("Customized y-axis", 2);
00092
00093
00094 const unsigned int detector_id = 17;
00095 dbe_->tag(h1, detector_id);
00096 dbe_->tag(h2, detector_id);
00097 dbe_->tag(h7, detector_id);
00098
00099 dbe_->tagContents(monitorName_+"C1/C3", detector_id);
00100
00101
00102 const unsigned int detector_id2 = 25;
00103 const unsigned int detector_id3 = 50;
00104 dbe_->tag(h4, detector_id2);
00105 dbe_->tag(h6, detector_id3);
00106
00107
00108 h5->setResetMe(true);
00109 h6->setResetMe(true);
00110 dbe_->showDirStructure();
00111 std::vector<std::string> tags;
00112 dbe_->getAllTags(tags);
00113 for (size_t i = 0, e = tags.size(); i < e; ++i)
00114 std::cout << "TAGS [" << i << "] = " << tags[i] << std::endl;
00115
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130 }
00131
00132
00133 DQMSourceExample::~DQMSourceExample()
00134 {
00135
00136
00137
00138
00139 }
00140
00141
00142
00143 void DQMSourceExample::beginJob(const EventSetup& context){
00144
00145 }
00146
00147
00148 void DQMSourceExample::beginRun(const edm::Run& r, const EventSetup& context) {
00149
00150 }
00151
00152
00153 void DQMSourceExample::beginLuminosityBlock(const LuminosityBlock& lumiSeg,
00154 const EventSetup& context) {
00155
00156 }
00157
00158
00159 void DQMSourceExample::analyze(const Event& iEvent,
00160 const EventSetup& iSetup )
00161 {
00162 counterEvt_++;
00163 if (prescaleEvt_ > 0 && counterEvt_%prescaleEvt_!=0) return;
00164
00165
00166 i1->Fill(4);
00167 f1->Fill(-3.14);
00168
00169
00170 srand( 0 );
00171
00172 if(counterEvt_%1000 == 0)
00173 cout << " # of events = " << counterEvt_ << endl;
00174
00175 for(int i = 0; i != 20; ++i )
00176 {
00177 float x = gRandom->Uniform(XMAX);
00178 h1->Fill(x,1./log(x+1));
00179 rooth1->Fill(x,1./log(x+1));
00180 h3->Fill(x, 1);
00181 h4->Fill(gRandom->Gaus(30, 3), 1.0);
00182 h5->Fill(gRandom->Poisson(15), 0.5);
00183 h6->Fill(gRandom->Gaus(25, 15), 1.0);
00184 h7->Fill(gRandom->Gaus(25, 8), 1.0);
00185 }
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195 for ( int i = 0; i != 10; ++i )
00196 {
00197 float x = gRandom->Gaus(15, 7);
00198 float y = gRandom->Gaus(20, 5);
00199 h2->Fill(x,y);
00200 p1->Fill(x,y);
00201 }
00202
00203 usleep(100);
00204
00205 }
00206
00207
00208
00209
00210
00211 void DQMSourceExample::endLuminosityBlock(const LuminosityBlock& lumiSeg,
00212 const EventSetup& context) {
00213 }
00214
00215 void DQMSourceExample::endRun(const Run& r, const EventSetup& context){
00216
00217
00218 dbe_->setCurrentFolder(monitorName_+"C1");
00219
00220
00221 }
00222
00223 void DQMSourceExample::endJob(){
00224 }
00225
00226