CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/DQMServices/Examples/src/ConverterTester.cc

Go to the documentation of this file.
00001 #include "DQMServices/Examples/interface/ConverterTester.h"
00002 
00003 ConverterTester::ConverterTester(const edm::ParameterSet& iPSet)
00004 {
00005   std::string MsgLoggerCat = "ConverterTester_ConverterTester";
00006 
00007   fName = iPSet.getUntrackedParameter<std::string>("Name");
00008   verbosity = iPSet.getUntrackedParameter<int>("Verbosity");
00009   frequency = iPSet.getUntrackedParameter<int>("Frequency");
00010  
00011   if (verbosity >= 0) {
00012     edm::LogInfo(MsgLoggerCat) 
00013       << "\n===============================\n"
00014       << "Initialized as EDAnalyzer with parameter values:\n"
00015       << "    Name          = " << fName << "\n"
00016       << "    Verbosity     = " << verbosity << "\n"
00017       << "    Frequency     = " << frequency << "\n"
00018       << "===============================\n";
00019   }
00020  
00021   dbe = 0;
00022   dbe = edm::Service<DQMStore>().operator->();
00023  
00024   count = 0;
00025 
00026 }
00027 
00028 ConverterTester::~ConverterTester() {}
00029 
00030 void ConverterTester::beginJob()
00031 {
00032 
00033   if(dbe){
00034     meTestString = 0;
00035     meTestInt = 0;
00036     meTestFloat = 0;
00037     meTestTH1FN = 0;
00038     meTestTH1FD = 0;
00039     meTestTH2F = 0;
00040     meTestTH3F = 0;
00041     meTestProfile1 = 0;
00042     meTestProfile2 = 0;
00043     Random = new TRandom3();
00044     
00045     dbe->setCurrentFolder("ConverterTest/String");
00046     meTestString = dbe->bookString("TestString","Test String" );
00047 
00048     dbe->setCurrentFolder("ConverterTest/Int");
00049     meTestInt = dbe->bookInt("TestInt");
00050 
00051     dbe->setCurrentFolder("ConverterTest/Float");
00052     meTestFloat = dbe->bookFloat("TestFloat");
00053 
00054     dbe->setCurrentFolder("ConverterTest/TH1F");
00055     meTestTH1FN = 
00056       dbe->book1D("Random1DN", "Random1D Numerator", 100, -10., 10.);
00057     meTestTH1FD = 
00058       dbe->book1D("Random1DD", "Random1D Denominator", 100, -10., 10.);
00059 
00060     dbe->setCurrentFolder("ConverterTest/TH2F");
00061     meTestTH2F = dbe->book2D("Random2D", "Random2D", 100, -10, 10., 100, -10., 
00062                              10.);
00063 
00064     dbe->setCurrentFolder("ConverterTest/TH3F");
00065     meTestTH3F = dbe->book3D("Random3D", "Random3D", 100, -10., 10., 100, 
00066                              -10., 10., 100, -10., 10.);
00067 
00068     dbe->setCurrentFolder("ConverterTest/TProfile");
00069     meTestProfile1 = dbe->bookProfile("Profile1", "Profile1", 100, -10., 10., 
00070                                       100, -10., 10.);
00071 
00072     dbe->setCurrentFolder("ConverterTest/TProfile2D");
00073     meTestProfile2 = dbe->bookProfile2D("Profile2", "Profile2", 100, -10., 
00074                                         10., 100, -10, 10., 100, -10., 10.);
00075 
00076     dbe->tag(meTestTH1FN->getFullname(),1);
00077     dbe->tag(meTestTH1FD->getFullname(),2);    
00078     dbe->tag(meTestTH2F->getFullname(),3);
00079     dbe->tag(meTestTH3F->getFullname(),4);
00080     dbe->tag(meTestProfile1->getFullname(),5);
00081     dbe->tag(meTestProfile2->getFullname(),6);
00082     dbe->tag(meTestString->getFullname(),7);
00083     dbe->tag(meTestInt->getFullname(),8);
00084     dbe->tag(meTestFloat->getFullname(),9);
00085   }
00086 
00087   return;
00088 }
00089 
00090 void ConverterTester::endJob()
00091 {
00092   std::string MsgLoggerCat = "ConverterTester_endJob";
00093   if (verbosity >= 0)
00094     edm::LogInfo(MsgLoggerCat) 
00095       << "Terminating having processed " << count << " events.";
00096   return;
00097 }
00098 
00099 void ConverterTester::beginRun(const edm::Run& iRun, 
00100                                 const edm::EventSetup& iSetup)
00101 {
00102   return;
00103 }
00104 
00105 void ConverterTester::endRun(const edm::Run& iRun, 
00106                               const edm::EventSetup& iSetup)
00107 {
00108   meTestInt->Fill(100);
00109   meTestFloat->Fill(3.141592);
00110 
00111   return;
00112 }
00113 
00114 void ConverterTester::analyze(const edm::Event& iEvent, 
00115                                const edm::EventSetup& iSetup)
00116 {
00117   
00118   ++count;
00119 
00120   for(int i = 0; i < 1000; ++i) {
00121     RandomVal1 = Random->Gaus(0.,1.);
00122     RandomVal2 = Random->Gaus(0.,1.);
00123     RandomVal3 = Random->Gaus(0.,1.);
00124     
00125     meTestTH1FN->Fill(0.5*RandomVal1);
00126     meTestTH1FD->Fill(RandomVal1);    
00127     meTestTH2F->Fill(RandomVal1, RandomVal2);
00128     meTestTH3F->Fill(RandomVal1, RandomVal2, RandomVal3);
00129     meTestProfile1->Fill(RandomVal1, RandomVal2);
00130     meTestProfile2->Fill(RandomVal1, RandomVal2, RandomVal3);
00131   }
00132 }