CMS 3D CMS Logo

EcalTBHodoscopeRawInfoDumper.cc

Go to the documentation of this file.
00001 #include "RecoTBCalo/EcalTBHodoscopeReconstructor/interface/EcalTBHodoscopeRawInfoDumper.h"
00002 #include "TBDataFormats/EcalTBObjects/interface/EcalTBHodoscopeRawInfo.h"
00003 #include "DataFormats/Common/interface/EDCollection.h"
00004 #include "DataFormats/Common/interface/Handle.h"
00005 #include "FWCore/Framework/interface/Selector.h"
00006 #include "FWCore/Framework/interface/ESHandle.h"
00007 #include "FWCore/Framework/interface/EventSetup.h"
00008 
00009 #include <TFile.h>
00010 #include <FWCore/Framework/interface/MakerMacros.h>
00011 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00012     
00013 EcalTBHodoscopeRawInfoDumper::EcalTBHodoscopeRawInfoDumper(edm::ParameterSet const& ps)
00014 {
00015   rawInfoCollection_ = ps.getParameter<std::string>("rawInfoCollection");
00016   rawInfoProducer_   = ps.getParameter<std::string>("rawInfoProducer");
00017   rootfile_          = ps.getUntrackedParameter<std::string>("rootfile","ecalHodoscopeRawInfoPlots.root");
00018 }
00019 
00020 EcalTBHodoscopeRawInfoDumper::~EcalTBHodoscopeRawInfoDumper() {
00021 }
00022 
00023 //========================================================================
00024 void
00025 EcalTBHodoscopeRawInfoDumper::beginJob(edm::EventSetup const&) {
00026 //========================================================================
00027 
00028   char histoName[100];
00029   char histoTitle[100];
00030   
00031   for (int i=0; i<4; i++)
00032     {
00033       sprintf(histoName,"h_numberOfFiredHits_%d",i);
00034       sprintf(histoTitle,"NumberOfFiredHits Plane %d",i);
00035       h_numberOfFiredHits_[i]=new TH1F(histoName,histoTitle,10,0.,10.);
00036     }
00037 
00038   for (int i=0; i<4; i++)
00039     {
00040       sprintf(histoName,"h_firedHits_%d",i);
00041       sprintf(histoTitle,"firedHits Plane %d",i);
00042       h_firedHits_[i]=new TH1F(histoName,histoTitle,64,-0.5,63.5);
00043     }  
00044 }
00045 
00046 //========================================================================
00047 void
00048 EcalTBHodoscopeRawInfoDumper::endJob() {
00049 //========================================================================
00050 
00051   TFile f(rootfile_.c_str(),"RECREATE");
00052   
00053   for (int i=0; i<4; i++)
00054     h_numberOfFiredHits_[i]->Write();
00055   
00056   for (int i=0; i<4; i++)
00057     h_firedHits_[i]->Write();
00058 
00059   f.Close();
00060 }
00061 
00062 void EcalTBHodoscopeRawInfoDumper::analyze(const edm::Event& e, const edm::EventSetup& es)
00063 {
00064   // Get input
00065    edm::Handle<EcalTBHodoscopeRawInfo> ecalRawHodoscope;  
00066    const EcalTBHodoscopeRawInfo* hodoscopeRawInfo = 0;
00067    //evt.getByLabel( digiProducer_, digiCollection_, pDigis);
00068    e.getByLabel( rawInfoProducer_, ecalRawHodoscope);
00069    if (!ecalRawHodoscope.isValid()) {
00070      edm::LogError("EcalTBHodoscopeRecInfoError") << "Error! can't get the product " << rawInfoCollection_.c_str() ;
00071    } else {
00072      hodoscopeRawInfo = ecalRawHodoscope.product();
00073    }
00074 
00075    if (hodoscopeRawInfo)
00076      for (int i=0; i<4; i++)
00077        {
00078          std::ostringstream str;
00079          str << " Hits " ;
00080          std::vector<int> firedHits;
00081          h_numberOfFiredHits_[i]->Fill((*hodoscopeRawInfo)[i].numberOfFiredHits());
00082          for (int j=0;j<64;j++)
00083            if ((*hodoscopeRawInfo)[i][j])
00084              {
00085                h_firedHits_[i]->Fill(j);
00086                firedHits.push_back(j);
00087                str << j << " " ;
00088              }
00089          LogDebug("EcalTBHodoscope") << "Looking plane " << i << " number of hits " << (*hodoscopeRawInfo)[i].numberOfFiredHits() << str.str();
00090        }
00091   // Create empty output
00092 } 
00093 
00094 

Generated on Tue Jun 9 17:45:11 2009 for CMSSW by  doxygen 1.5.4