CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/Validation/GlobalHits/src/GlobalHitsTester.cc

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