Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:25:27

0001 // myRawAna.cc
0002 // Description:  Access raw data, specifically event fragment size per FED
0003 // Author: Jim Hirschauer
0004 // Date:  28 - July - 2009
0005 //
0006 #include "RecoJets/JetAnalyzers/interface/myRawAna.h"
0007 
0008 #include "DataFormats/Common/interface/Handle.h"
0009 #include "DataFormats/Candidate/interface/Candidate.h"
0010 #include "FWCore/Framework/interface/Event.h"
0011 
0012 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
0013 
0014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0015 #include <TROOT.h>
0016 #include <TSystem.h>
0017 #include <TFile.h>
0018 #include <TCanvas.h>
0019 #include <cmath>
0020 
0021 using namespace edm;
0022 using namespace reco;
0023 using namespace std;
0024 
0025 #define DEBUG 1
0026 #define MAXJETS 100
0027 
0028 // Nothing passed from .cfg yet, but I leave the syntax here for
0029 // future reference.
0030 
0031 myRawAna::myRawAna(const ParameterSet& cfg) { usesResource(TFileService::kSharedResource); }
0032 
0033 // ************************
0034 // ************************
0035 
0036 void myRawAna::beginJob() {
0037   edm::Service<TFileService> fs;
0038 
0039   fedSize = fs->make<TH2F>("fedSize", "fedSize", 901, -0.5, 900.5, 20000, 0., 20000.);
0040   totFedSize = fs->make<TH1F>("totFedSize", "totFedSize", 200, 0., 20000.);
0041 }
0042 
0043 // ************************
0044 // ************************
0045 void myRawAna::analyze(const edm::Event& evt, const edm::EventSetup& es) {
0046   // **************************************************************
0047   // ** Access FED Information
0048   // **************************************************************
0049 
0050   edm::Handle<FEDRawDataCollection> theRaw;
0051   bool getFed = evt.getByLabel("source", theRaw);
0052 
0053   if (!getFed) {
0054     std::cout << "fedRawData not available" << std::endl;
0055   } else {  // got the fed raw data
0056     unsigned int totalFEDsize = 0;
0057 
0058     // HCAL FEDs are 700-730
0059     unsigned int fedStart_ = 0;
0060     unsigned int fedStop_ = 900;
0061 
0062     for (unsigned int i = fedStart_; i <= fedStop_; ++i) {
0063       fedSize->Fill(i, theRaw->FEDData(i).size());
0064       totalFEDsize += theRaw->FEDData(i).size();
0065     }
0066     totFedSize->Fill(totalFEDsize);
0067   }
0068 }
0069 
0070 // ***********************************
0071 // ***********************************
0072 void myRawAna::endJob() {}
0073 #include "FWCore/Framework/interface/MakerMacros.h"
0074 DEFINE_FWK_MODULE(myRawAna);