CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2_patch1/src/RecoJets/JetAnalyzers/src/myRawAna.cc

Go to the documentation of this file.
00001 // myRawAna.cc
00002 // Description:  Access raw data, specifically event fragment size per FED
00003 // Author: Jim Hirschauer
00004 // Date:  28 - July - 2009
00005 // 
00006 #include "RecoJets/JetAnalyzers/interface/myRawAna.h"
00007 
00008 #include "DataFormats/Common/interface/Handle.h"
00009 #include "DataFormats/Candidate/interface/Candidate.h"
00010 #include "FWCore/Framework/interface/Event.h"
00011 
00012 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
00013 
00014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00015 #include <TROOT.h>
00016 #include <TSystem.h>
00017 #include <TFile.h>
00018 #include <TCanvas.h>
00019 #include <cmath>
00020 
00021 using namespace edm;
00022 using namespace reco;
00023 using namespace std;
00024 
00025 #define DEBUG 1
00026 #define MAXJETS 100
00027 
00028 // Nothing passed from .cfg yet, but I leave the syntax here for
00029 // future reference.
00030 
00031 myRawAna::myRawAna( const ParameterSet & cfg ) {
00032 }
00033 
00034 
00035 // ************************
00036 // ************************
00037 
00038 void myRawAna::beginJob(  ) {
00039 
00040   edm::Service<TFileService> fs;
00041 
00042   fedSize = fs->make<TH2F>( "fedSize", "fedSize", 901, -0.5, 900.5, 20000, 0., 20000. );
00043   totFedSize = fs->make<TH1F>( "totFedSize", "totFedSize", 200, 0., 20000. );
00044 
00045 
00046 }
00047 
00048 // ************************
00049 // ************************
00050 void myRawAna::analyze( const edm::Event& evt, const edm::EventSetup& es ) {
00051   
00052   // **************************************************************
00053   // ** Access FED Information
00054   // **************************************************************
00055 
00056 
00057   edm::Handle<FEDRawDataCollection> theRaw;
00058   bool getFed = evt.getByLabel("source", theRaw);
00059   
00060   if ( ! getFed ) {
00061     std::cout << "fedRawData not available" << std::endl;
00062   } else { // got the fed raw data
00063     unsigned int totalFEDsize = 0 ; 
00064     
00065     // HCAL FEDs are 700-730
00066     unsigned int fedStart_ = 0;
00067     unsigned int fedStop_ = 900;
00068     
00069     for (unsigned int i=fedStart_; i<=fedStop_; ++i) {
00070       fedSize->Fill(i,theRaw->FEDData(i).size());
00071       totalFEDsize += theRaw->FEDData(i).size() ; 
00072     }
00073     totFedSize->Fill(totalFEDsize);
00074   }
00075   
00076   
00077 }
00078 
00079 // ***********************************
00080 // ***********************************
00081 void myRawAna::endJob() {
00082 
00083 }
00084 #include "FWCore/Framework/interface/MakerMacros.h"
00085 DEFINE_FWK_MODULE(myRawAna);