CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/CaloOnlineTools/EcalTools/plugins/EcalBxOrbitNumberGrapher.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:   EcalBxOrbitNumberGrapher 
00004 // Class:     EcalBxOrbitNumberGrapher 
00005 // 
00013 //
00014 // Original Author:  Seth COOPER
00015 //         Created:  Th Nov 22 5:46:22 CEST 2007
00016 // $Id: EcalBxOrbitNumberGrapher.cc,v 1.3 2011/10/10 09:05:21 eulisse Exp $
00017 //
00018 //
00019 
00020 #include "CaloOnlineTools/EcalTools/plugins/EcalBxOrbitNumberGrapher.h"
00021 
00022 using namespace cms;
00023 using namespace edm;
00024 using namespace std;
00025 
00026 //
00027 // constants, enums and typedefs
00028 //
00029 
00030 //
00031 // static data member definitions
00032 //
00033 
00034 //
00035 // constructors and destructor
00036 //
00037 EcalBxOrbitNumberGrapher::EcalBxOrbitNumberGrapher(const edm::ParameterSet& iConfig) :
00038   digiProducer_(iConfig.getParameter<std::string>("RawDigis")),
00039   runNum_(-1),
00040   fileName_ (iConfig.getUntrackedParameter<std::string>("fileName", std::string("ecalURechHitHists")))
00041 {
00042   
00043   
00044 }
00045 
00046 
00047 EcalBxOrbitNumberGrapher::~EcalBxOrbitNumberGrapher()
00048 {
00049 }
00050 
00051 
00052 //
00053 // member functions
00054 //
00055 
00056 // ------------ method called to for each event  ------------
00057 void
00058 EcalBxOrbitNumberGrapher::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00059 {
00060   using namespace edm;
00061    using namespace cms;
00062   //int ievt = iEvent.id().event();
00063   int orbit = -100;
00064   int bx = -100;
00065   int numorbiterrors = 0;
00066   bool orbiterror = false;
00067 
00068   
00069   edm::Handle<EcalRawDataCollection> DCCHeaders;
00070   iEvent.getByLabel(digiProducer_, DCCHeaders);
00071   if (!DCCHeaders.isValid()) {
00072         edm::LogError("BxOrbitNumber") << "can't get the product for EcalRawDataCollection";
00073   }
00074 
00075   //-----------------BX STuff here
00076    for ( EcalRawDataCollection::const_iterator headerItr= DCCHeaders->begin();headerItr != DCCHeaders->end(); 
00077           ++headerItr ) {
00078     headerItr->getEventSettings();
00079     int myorbit = headerItr->getOrbit();
00080     int mybx = headerItr->getBX();
00081     
00082     if ( orbit == -100 )
00083     {
00084       orbit = myorbit;
00085     }
00086     else if (orbit != myorbit)
00087     {
00088        std::cout << " NOOOO This header has a conflicting orbit OTHER " << orbit << " new " << myorbit  << std::endl;
00089        orbiterror = true; 
00090        numorbiterrors++;
00091        orbitErrorBxDiffPlot_->Fill(myorbit - orbit);
00092     }
00093     
00094     if ( bx == -100 )
00095     {
00096       bx = mybx;
00097     }
00098     else if (bx != mybx)
00099     {
00100        std::cout << " NOOOO This header has a conflicting bx OTHER " << bx << " new " << mybx  << std::endl; 
00101     }
00102     //LogDebug("EcalTimingCosmic") << " Lambda " << lambda; //hmm... this isn't good, I should keep a record of the wavelength in the headers as an inactive SM might have a different wavelength for this field and make this not go through.
00103   }
00104   
00105   if ( (bx != -100) & ( orbit != -100) )
00106   {
00107      std::cout << " Interesting event Orbit " << orbit << " BX " << bx << std::endl;
00108      bxnumberPlot_->Fill(bx);
00109      if (orbiterror) 
00110      {
00111         orbitErrorPlot_->Fill(bx);      
00112      }
00113   }
00114   numberofOrbitDiffPlot_->Fill(numorbiterrors);
00115   
00116   
00117   if(runNum_==-1)
00118   {
00119     runNum_ = iEvent.id().run();
00120   }
00121 }
00122 
00123 
00124 // insert the hist map into the map keyed by FED number
00125 void EcalBxOrbitNumberGrapher::initHists(int FED)
00126 {
00127  
00128   
00129 }
00130 
00131 // ------------ method called once each job just before starting event loop  ------------
00132 void 
00133 EcalBxOrbitNumberGrapher::beginJob()
00134 {
00135   bxnumberPlot_ = new TH1F("bxnumber", "BX number of interexting events",3600, 0., 3600.);
00136   orbitErrorPlot_ = new TH1F("bxOfOrbitDiffs", "BX number of interexting events with orbit changes",3600, 0., 3600.);
00137   orbitErrorBxDiffPlot_ = new TH1F("orbitErrorDiffPlot","Orbit Difference of those HEADERS that have a difference",20,-10.,10.);
00138   numberofOrbitDiffPlot_ = new TH1F("numberOfOrbitDiffsPlot","Number of Orbit Differences",54,0., 54.);
00139 }
00140 
00141 // ------------ method called once each job just after ending the event loop  ------------
00142 void 
00143 EcalBxOrbitNumberGrapher::endJob()
00144 {
00145   using namespace std;
00146   fileName_ += ".bx.root";
00147 
00148   TFile root_file_(fileName_.c_str() , "RECREATE");
00149 
00150   bxnumberPlot_->Write();
00151   orbitErrorPlot_->Write();
00152   numberofOrbitDiffPlot_->Write();
00153   orbitErrorBxDiffPlot_->Write();
00154   root_file_.Close();
00155 
00156 }
00157 
00158 
00159