00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "DQMServices/Examples/interface/DQMSourceExample.h"
00014 #include "FWCore/ServiceRegistry/interface/Service.h"
00015
00016 #include "TRandom.h"
00017 #include <math.h>
00018
00019 using namespace std;
00020 using namespace edm;
00021
00022
00023
00024
00025 DQMSourceExample::DQMSourceExample( const edm::ParameterSet& ps ){
00026 parameters_ = ps;
00027 initialize();
00028 }
00029
00030 DQMSourceExample::~DQMSourceExample(){
00031 }
00032
00033
00034
00035
00036 void DQMSourceExample::initialize() {
00037
00039 counterEvt_ = 0; counterLS_ = 0;
00040
00042 dbe_ = Service<DQMStore>().operator->();
00043
00045 monitorName_ = parameters_.getUntrackedParameter<string>("monitorName","YourSubsystemName");
00046 cout << "DQMSourceExample: Monitor name = " << monitorName_ << endl;
00047 if (monitorName_ != "" ) monitorName_ = monitorName_+"/" ;
00048
00050 prescaleLS_ = parameters_.getUntrackedParameter<int>("prescaleLS", -1);
00051 cout << "DQMSourceExample: DQM lumi section prescale = " << prescaleLS_ << " lumi section(s)"<< endl;
00052 prescaleEvt_ = parameters_.getUntrackedParameter<int>("prescaleEvt", -1);
00053 cout << "DQMSourceExample: DQM event prescale = " << prescaleEvt_ << " events(s)"<< endl;
00054
00055
00056
00057
00058 }
00059
00060
00061
00062
00063 void DQMSourceExample::beginJob() {
00065 dbe_ = Service<DQMStore>().operator->();
00066
00068 dbe_->setCurrentFolder(monitorName_+"DQMsource/Summary");
00069 summ = dbe_->book1D("summary", "Run Summary", 100, 0, 100);
00070
00071
00072
00073
00074
00076 dbe_->setCurrentFolder(monitorName_+"DQMsource/QTests");
00077
00079 NBINS = 40 ; XMIN = 0.; XMAX = 40.;
00080
00084 xTrue = dbe_->book1D("XTrue", "X Range QTest", NBINS, XMIN, XMAX);
00085 xFalse = dbe_->book1D("XFalse", "X Range QTest", NBINS, XMIN, XMAX);
00086 yTrue = dbe_->book1D("YTrue", "Y Range QTest", NBINS, XMIN, XMAX);
00087 yFalse = dbe_->book1D("YFalse", "Y Range QTest", NBINS, XMIN, XMAX);
00088 wExpTrue = dbe_->book2D("WExpTrue", "Contents Within Expected QTest", NBINS, XMIN, XMAX, NBINS, XMIN, XMAX);
00089 wExpFalse = dbe_->book2D("WExpFalse", "Contents Within Expected QTest", NBINS, XMIN, XMAX, NBINS, XMIN, XMAX);
00090 meanTrue = dbe_->book1D("MeanTrue", "Mean Within Expected QTest", NBINS, XMIN, XMAX);
00091 meanFalse = dbe_->book1D("MeanFalse", "Mean Within Expected QTest", NBINS, XMIN, XMAX);
00092 deadTrue = dbe_->book1D("DeadTrue", "Dead Channel QTest", NBINS, XMIN, XMAX);
00093 deadFalse = dbe_->book1D("DeadFalse", "Dead Channel QTest", NBINS, XMIN, XMAX);
00094 noisyTrue = dbe_->book1D("NoisyTrue", "Noisy Channel QTest", NBINS, XMIN, XMAX);
00095 noisyFalse = dbe_->book1D("NoisyFalse", "Noisy Channel QTest", NBINS, XMIN, XMAX);
00096
00097
00098
00099
00100
00101
00103 dbe_->setCurrentFolder(monitorName_+"DQMsource/C1");
00104 const int NBINS2 = 10;
00105
00106 i1 = dbe_->bookInt("int1");
00107 f1 = dbe_->bookFloat("float1");
00108 s1 = dbe_->bookString("s1", "My string");
00109 h1 = dbe_->book1D("h1f", "Example TH1F 1D histogram.", NBINS2, XMIN, XMAX);
00110 h2 = dbe_->book1S("h1s", "Example TH1S histogram.", NBINS, XMIN, XMAX);
00111
00112
00113 p1 = dbe_->bookProfile( "prof1", "My profile 1D", NBINS,XMIN,XMAX,NBINS,XMIN,XMAX,"");
00114 p2 = dbe_->bookProfile2D("prof2", "My profile 2D", NBINS,XMIN,XMAX,NBINS,XMIN,XMAX,NBINS,XMIN,XMAX,"");
00115 h1hist = dbe_->book1D("history 1D","Example 1 1D history plot", 30, 0.,30.);
00116
00117
00118 char temp[1024];
00119 for(int i = 1; i <= NBINS2; ++i) {
00120 sprintf(temp, " bin no. %d", i);
00121 h1->setBinLabel(i, temp);
00122 }
00123
00124
00125 const unsigned int detector_id = 17;
00126 dbe_->tag(h1, detector_id);
00127
00128
00129 dbe_->tagContents(monitorName_+"DQMsource/C1", detector_id);
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142 dbe_->showDirStructure ();
00143 }
00144
00145
00146
00147
00148 void DQMSourceExample::beginRun(const edm::Run& r, const EventSetup& context) {
00149 }
00150
00151
00152
00153
00154
00155 void DQMSourceExample::beginLuminosityBlock(const LuminosityBlock& lumiSeg,
00156 const EventSetup& context) {
00157 }
00158
00159
00160
00161
00162
00163 void DQMSourceExample::analyze(const Event& iEvent, const EventSetup& iSetup) {
00164 counterEvt_++;
00165 if (prescaleEvt_<1) return;
00166 if (prescaleEvt_ > 0 && counterEvt_%prescaleEvt_!=0) return;
00167
00168
00169
00170
00171 i1->Fill(400000000000000LL);
00172 f1->Fill(-3.14);
00173
00174
00175
00176
00177
00178 srand( 0 );
00179
00180 if(counterEvt_%1000 == 0) {
00181 cout << " # of events = " << counterEvt_ << endl;
00182 summ->Fill(counterEvt_/1000., counterEvt_);
00183 }
00184
00185 if(counterEvt_%100 == 0) {
00186 h1hist->ShiftFillLast(gRandom->Gaus(12,1.),1.,5);
00187 }
00188
00189 float z = gRandom->Uniform(XMAX);
00190 xTrue->Fill( z, 1./log(z+1.) );
00191 xFalse->Fill( z+(XMAX/2.), z );
00192 yTrue->Fill( z, 1./log(z+1.) );
00193 yFalse->Fill( z, z );
00194 meanTrue->Fill( gRandom->Gaus(10, 2), 1.);
00195 meanFalse->Fill( gRandom->Gaus(12, 3), 1.);
00196 wExpTrue->Fill( gRandom->Gaus(12, 1), gRandom->Gaus(12, 1), 1.);
00197 wExpFalse->Fill( gRandom->Gaus(20, 2), gRandom->Gaus(20, 2), 1.);
00198 deadTrue->Fill( gRandom->Gaus(20, 10), 2.);
00199 deadFalse->Fill( gRandom->Gaus(20, 4), 1.);
00200 h2->Fill( gRandom->Gaus(20, 4), 1.);
00201
00202
00203
00204
00205
00206
00207 for ( int i = 0; i != 10; ++i ) {
00208 float w = gRandom->Uniform(XMAX);
00209 noisyTrue->Fill( w, 1.);
00210 noisyFalse->Fill( z, 1.);
00211 float x = gRandom->Gaus(12, 1);
00212 float y = gRandom->Gaus(20, 2);
00213 p1->Fill(x, y);
00214 p2->Fill(x, y, (x+y)/2.);
00215 h1->Fill(y, 1.);
00216 }
00217
00218
00219
00220 }
00221
00222
00223
00224
00225 void DQMSourceExample::endLuminosityBlock(const LuminosityBlock& lumiSeg,
00226 const EventSetup& context) {
00227
00228 }
00229
00230
00231
00232
00233 void DQMSourceExample::endRun(const Run& r, const EventSetup& context) {
00234
00235 }
00236
00237
00238
00239
00240 void DQMSourceExample::endJob() {
00241 std::cout << "DQMSourceExample::endJob()" << std::endl;
00242 }