CMS 3D CMS Logo

Public Member Functions | Public Attributes | Static Private Member Functions | Private Attributes

HLTBitAnalyzer Class Reference

#include <HLTBitAnalyzer.h>

Inheritance diagram for HLTBitAnalyzer:
edm::EDAnalyzer edm::EDConsumerBase

List of all members.

Public Member Functions

virtual void analyze (edm::Event const &e, edm::EventSetup const &iSetup)
virtual void beginRun (edm::Run const &, edm::EventSetup const &)
virtual void endJob ()
 HLTBitAnalyzer (edm::ParameterSet const &conf)

Public Attributes

TTree * HltTree

Static Private Member Functions

static int errMax ()

Private Attributes

double _EtaMax
double _EtaMin
std::string _HistName
bool _UseTFileService
int errCnt
EventHeader evt_header_
 Default analyses.
edm::InputTag gctBitCounts_
edm::InputTag gctRingSums_
edm::InputTag genEventInfo_
edm::InputTag gtObjectMap_
edm::InputTag gtReadoutRecord_
HLTInfo hlt_analysis_
edm::InputTag hltresults_
std::string l1extramc_
std::string l1extramu_
TFile * m_file
edm::InputTag m_l1extraemi
edm::InputTag m_l1extraemn
edm::InputTag m_l1extrajet
edm::InputTag m_l1extrajetc
edm::InputTag m_l1extrajetf
edm::InputTag m_l1extramet
edm::InputTag m_l1extramht
edm::InputTag m_l1extramu
edm::InputTag m_l1extrataujet
HLTMCtruth mct_analysis_
edm::InputTag mctruth_
edm::InputTag pileupInfo_
edm::InputTag simhits_
edm::InputTag VertexTagOffline0_
RECOVertex vrt_analysisOffline0_

Detailed Description

$Date: November 2006 $Revision:

Author:
P. Bargassa - Rice U.

Definition at line 35 of file HLTBitAnalyzer.h.


Constructor & Destructor Documentation

HLTBitAnalyzer::HLTBitAnalyzer ( edm::ParameterSet const &  conf) [explicit]

Definition at line 28 of file HLTBitAnalyzer.cc.

References _HistName, _UseTFileService, gather_cfg::cout, errCnt, evt_header_, gctBitCounts_, gctRingSums_, genEventInfo_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), gtObjectMap_, gtReadoutRecord_, hlt_analysis_, hltresults_, HltTree, l1extramc_, l1extramu_, edm::InputTag::label(), m_file, m_l1extraemi, m_l1extraemn, m_l1extrajet, m_l1extrajetc, m_l1extrajetf, m_l1extramet, m_l1extramht, m_l1extramu, m_l1extrataujet, mct_analysis_, mctruth_, pileupInfo_, environment_file_cff::runParameters, RECOVertex::setup(), EventHeader::setup(), HLTMCtruth::setup(), HLTInfo::setup(), simhits_, AlCaHLTBitMon_QueryRunRegistry::string, VertexTagOffline0_, and vrt_analysisOffline0_.

                                                          {

  // If your module takes parameters, here is where you would define
  // their names and types, and access them to initialize internal
  // variables. Example as follows:
  std::cout << " Beginning HLTBitAnalyzer Analysis " << std::endl;

  l1extramu_        = conf.getParameter<std::string>   ("l1extramu");
  m_l1extramu       = edm::InputTag(l1extramu_, "");

  // read the L1Extra collection name, and add the instance names as needed
  l1extramc_        = conf.getParameter<std::string>   ("l1extramc");
  m_l1extraemi      = edm::InputTag(l1extramc_, "Isolated");
  m_l1extraemn      = edm::InputTag(l1extramc_, "NonIsolated");
  m_l1extrajetc     = edm::InputTag(l1extramc_, "Central");
  m_l1extrajetf     = edm::InputTag(l1extramc_, "Forward");
  m_l1extrajet      = edm::InputTag("gctInternJetProducer","Internal","ANALYSIS");
  m_l1extrataujet   = edm::InputTag(l1extramc_, "Tau");
  m_l1extramet      = edm::InputTag(l1extramc_, "MET");
  m_l1extramht      = edm::InputTag(l1extramc_, "MHT");

  mctruth_            = conf.getParameter<edm::InputTag> ("mctruth");
  genEventInfo_       = conf.getParameter<edm::InputTag> ("genEventInfo");
  VertexTagOffline0_  = conf.getParameter<edm::InputTag> ("OfflinePrimaryVertices0");
  simhits_            = conf.getParameter<edm::InputTag> ("simhits");

  hltresults_       = conf.getParameter<edm::InputTag> ("hltresults");
  gtReadoutRecord_  = conf.getParameter<edm::InputTag> ("l1GtReadoutRecord");
  gtObjectMap_      = conf.getParameter<edm::InputTag> ("l1GtObjectMapRecord");

  gctBitCounts_        = edm::InputTag( conf.getParameter<edm::InputTag>("l1GctHFBitCounts").label(), "" );
  gctRingSums_         = edm::InputTag( conf.getParameter<edm::InputTag>("l1GctHFRingSums").label(), "" );

  pileupInfo_         = edm::InputTag("addPileupInfo");

        _UseTFileService = conf.getUntrackedParameter<bool>("UseTFileService",false);
        
  m_file = 0;   // set to null
  errCnt = 0;

  // read run parameters with a default value
  edm::ParameterSet runParameters = conf.getParameter<edm::ParameterSet>("RunParameters");
  _HistName = runParameters.getUntrackedParameter<std::string>("HistogramFile", "test.root");

  // open the tree file and initialize the tree
  if(_UseTFileService){
    edm::Service<TFileService> fs;
    HltTree = fs->make<TTree>("HltTree", "");
  }else{
    m_file = new TFile(_HistName.c_str(), "RECREATE");
    if (m_file)
      m_file->cd();
    HltTree = new TTree("HltTree", "");
  }

  // Setup the different analysis
  hlt_analysis_.setup(conf, HltTree);
  mct_analysis_.setup(conf, HltTree);
  vrt_analysisOffline0_.setup(conf, HltTree, "Offline0");
  evt_header_.setup(HltTree);
}

Member Function Documentation

void HLTBitAnalyzer::analyze ( edm::Event const &  e,
edm::EventSetup const &  iSetup 
) [virtual]

Implements edm::EDAnalyzer.

Definition at line 91 of file HLTBitAnalyzer.cc.

References RECOVertex::analyze(), HLTMCtruth::analyze(), HLTInfo::analyze(), EventHeader::analyze(), errCnt, errMax(), evt_header_, gctBitCounts_, gctRingSums_, genEventInfo_, getCollection(), edm::EventSetup::getData(), gtObjectMap_, gtReadoutRecord_, hlt_analysis_, hltresults_, HltTree, edm::HandleBase::isValid(), kGenEventInfo, kHltresults, kL1extemi, kL1extemn, kL1extjet, kL1extjetc, kL1extjetf, kL1extmet, kL1extmht, kL1extmu, kL1exttaujet, kL1GctBitCounts, kL1GctRingSums, kL1GtOMRec, kL1GtRR, kMctruth, kPileupInfo, kRecoVerticesOffline0, kSimhit, m_file, m_l1extraemi, m_l1extraemn, m_l1extrajet, m_l1extrajetc, m_l1extrajetf, m_l1extramet, m_l1extramht, m_l1extramu, m_l1extrataujet, mct_analysis_, mctruth_, combine::missing, dbtoconf::out, pileupInfo_, simhits_, VertexTagOffline0_, and vrt_analysisOffline0_.

                                                                                {

  edm::Handle<edm::TriggerResults>                  hltresults;
  edm::Handle<l1extra::L1EmParticleCollection>      l1extemi, l1extemn;
  edm::Handle<l1extra::L1MuonParticleCollection>    l1extmu;
  edm::Handle<l1extra::L1JetParticleCollection>     l1extjetc, l1extjetf, l1extjet, l1exttaujet;
  edm::Handle<l1extra::L1EtMissParticleCollection>  l1extmet,l1extmht;
  edm::Handle<L1GlobalTriggerReadoutRecord>         l1GtRR;
  edm::Handle<L1GlobalTriggerObjectMapRecord>       l1GtOMRec;
  edm::Handle<L1GlobalTriggerObjectMap>             l1GtOM;
  edm::Handle< L1GctHFBitCountsCollection >         gctBitCounts ;
  edm::Handle< L1GctHFRingEtSumsCollection >        gctRingSums ;

  edm::Handle<reco::CandidateView>                  mctruth;
  edm::Handle<GenEventInfoProduct>                  genEventInfo;
  edm::Handle<std::vector<SimTrack> >               simTracks;
  edm::Handle<std::vector<SimVertex> >              simVertices;
  edm::Handle<reco::VertexCollection>               recoVertexsOffline0; 
  edm::Handle<std::vector< PileupSummaryInfo > >    pupInfo; 

  // extract the collections from the event, check their validity and log which are missing
  std::vector<MissingCollectionInfo> missing;

  getCollection( iEvent, missing, hltresults,      hltresults_,        kHltresults );
  getCollection( iEvent, missing, l1extemi,        m_l1extraemi,       kL1extemi );
  getCollection( iEvent, missing, l1extemn,        m_l1extraemn,       kL1extemn );
  getCollection( iEvent, missing, l1extmu,         m_l1extramu,        kL1extmu );
  getCollection( iEvent, missing, l1extjetc,       m_l1extrajetc,      kL1extjetc );
  getCollection( iEvent, missing, l1extjetf,       m_l1extrajetf,      kL1extjetf );
  getCollection( iEvent, missing, l1extjet,        m_l1extrajet,       kL1extjet );
  getCollection( iEvent, missing, l1exttaujet,     m_l1extrataujet,    kL1exttaujet );
  getCollection( iEvent, missing, l1extmet,        m_l1extramet,       kL1extmet );
  getCollection( iEvent, missing, l1extmht,        m_l1extramht,       kL1extmht );
  getCollection( iEvent, missing, l1GtRR,          gtReadoutRecord_,   kL1GtRR );
  getCollection( iEvent, missing, l1GtOMRec,       gtObjectMap_,       kL1GtOMRec );
  getCollection( iEvent, missing, gctBitCounts,     gctBitCounts_,      kL1GctBitCounts );
  getCollection( iEvent, missing, gctRingSums,      gctRingSums_,       kL1GctRingSums );

  getCollection( iEvent, missing, mctruth,         mctruth_,           kMctruth );
  getCollection( iEvent, missing, simTracks,       simhits_,           kSimhit );
  getCollection( iEvent, missing, simVertices,     simhits_,           kSimhit );
  getCollection( iEvent, missing, genEventInfo,    genEventInfo_,      kGenEventInfo );
  getCollection( iEvent, missing, pupInfo,         pileupInfo_,        kPileupInfo );

  getCollection( iEvent, missing, recoVertexsOffline0,      VertexTagOffline0_,         kRecoVerticesOffline0 );
  double ptHat=-1.;
  if (genEventInfo.isValid()) {ptHat=genEventInfo->qScale();}

  edm::ESHandle<LumiCorrectionParam> lumicorrdatahandle; //get LumiCorrectionParam object from event setup 
  iSetup.getData(lumicorrdatahandle); 

  // print missing collections
  if (not missing.empty() and (errCnt < errMax())) {
    errCnt++;
    std::stringstream out;       
    out <<  "OpenHLT analyser - missing collections:";
    BOOST_FOREACH(const MissingCollectionInfo & entry, missing)
      out << "\n\t" << entry.first << ": " << entry.second->encode();
    edm::LogPrint("OpenHLT") << out.str() << std::endl; 
    if (errCnt == errMax())
      edm::LogWarning("OpenHLT") << "Maximum error count reached -- No more messages will be printed.";
  }

  // run the analysis, passing required event fragments
  hlt_analysis_.analyze(
    hltresults,
    l1extemi,
    l1extemn,
    l1extmu,
    l1extjetc,
    l1extjetf,
    l1extjet,
    l1exttaujet,
    l1extmet,
    l1extmht,
    l1GtRR,
    gctBitCounts,
    gctRingSums,
    iSetup,
    iEvent,
    HltTree);

  evt_header_.analyze(iEvent, lumicorrdatahandle, HltTree);
  //evt_header_.analyze(iEvent, HltTree);

  mct_analysis_.analyze(
                        mctruth,
                        ptHat,
                        simTracks,
                        simVertices,
                        pupInfo,
                        HltTree);

  vrt_analysisOffline0_.analyze(
                                recoVertexsOffline0,
                                HltTree);


  // std::cout << " Ending Event Analysis" << std::endl;
  // After analysis, fill the variables tree
  if (m_file)
    m_file->cd();
  HltTree->Fill();
}
void HLTBitAnalyzer::beginRun ( edm::Run const &  run,
edm::EventSetup const &  es 
) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 198 of file HLTBitAnalyzer.cc.

References HLTInfo::beginRun(), and hlt_analysis_.

void HLTBitAnalyzer::endJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 204 of file HLTBitAnalyzer.cc.

References _UseTFileService, HltTree, and m_file.

                            {
        
        if(!_UseTFileService){
                if (m_file)
                        m_file->cd();
                
                HltTree->Write();
                delete HltTree;
                HltTree = 0;
                
                if (m_file) {         // if there was a tree file...
                        m_file->Write();    // write out the branches
                        delete m_file;      // close and delete the file
                        m_file = 0;         // set to zero to clean up
                }
        }
}
static int HLTBitAnalyzer::errMax ( ) [inline, static, private]

Definition at line 78 of file HLTBitAnalyzer.h.

Referenced by analyze().

{ return 5; }

Member Data Documentation

double HLTBitAnalyzer::_EtaMax [private]

Definition at line 81 of file HLTBitAnalyzer.h.

double HLTBitAnalyzer::_EtaMin [private]

Definition at line 81 of file HLTBitAnalyzer.h.

std::string HLTBitAnalyzer::_HistName [private]

Definition at line 80 of file HLTBitAnalyzer.h.

Referenced by HLTBitAnalyzer().

Definition at line 83 of file HLTBitAnalyzer.h.

Referenced by endJob(), and HLTBitAnalyzer().

int HLTBitAnalyzer::errCnt [private]

Definition at line 77 of file HLTBitAnalyzer.h.

Referenced by analyze(), and HLTBitAnalyzer().

Default analyses.

Definition at line 52 of file HLTBitAnalyzer.h.

Referenced by analyze(), and HLTBitAnalyzer().

Definition at line 71 of file HLTBitAnalyzer.h.

Referenced by analyze(), and HLTBitAnalyzer().

Definition at line 71 of file HLTBitAnalyzer.h.

Referenced by analyze(), and HLTBitAnalyzer().

Definition at line 58 of file HLTBitAnalyzer.h.

Referenced by analyze(), and HLTBitAnalyzer().

Definition at line 70 of file HLTBitAnalyzer.h.

Referenced by analyze(), and HLTBitAnalyzer().

Definition at line 70 of file HLTBitAnalyzer.h.

Referenced by analyze(), and HLTBitAnalyzer().

Definition at line 53 of file HLTBitAnalyzer.h.

Referenced by analyze(), beginRun(), and HLTBitAnalyzer().

Definition at line 58 of file HLTBitAnalyzer.h.

Referenced by analyze(), and HLTBitAnalyzer().

Definition at line 45 of file HLTBitAnalyzer.h.

Referenced by analyze(), endJob(), and HLTBitAnalyzer().

std::string HLTBitAnalyzer::l1extramc_ [private]

Definition at line 59 of file HLTBitAnalyzer.h.

Referenced by HLTBitAnalyzer().

std::string HLTBitAnalyzer::l1extramu_ [private]

Definition at line 59 of file HLTBitAnalyzer.h.

Referenced by HLTBitAnalyzer().

TFile* HLTBitAnalyzer::m_file [private]

Definition at line 82 of file HLTBitAnalyzer.h.

Referenced by analyze(), endJob(), and HLTBitAnalyzer().

Definition at line 61 of file HLTBitAnalyzer.h.

Referenced by analyze(), and HLTBitAnalyzer().

Definition at line 62 of file HLTBitAnalyzer.h.

Referenced by analyze(), and HLTBitAnalyzer().

Definition at line 65 of file HLTBitAnalyzer.h.

Referenced by analyze(), and HLTBitAnalyzer().

Definition at line 63 of file HLTBitAnalyzer.h.

Referenced by analyze(), and HLTBitAnalyzer().

Definition at line 64 of file HLTBitAnalyzer.h.

Referenced by analyze(), and HLTBitAnalyzer().

Definition at line 67 of file HLTBitAnalyzer.h.

Referenced by analyze(), and HLTBitAnalyzer().

Definition at line 68 of file HLTBitAnalyzer.h.

Referenced by analyze(), and HLTBitAnalyzer().

Definition at line 60 of file HLTBitAnalyzer.h.

Referenced by analyze(), and HLTBitAnalyzer().

Definition at line 66 of file HLTBitAnalyzer.h.

Referenced by analyze(), and HLTBitAnalyzer().

Definition at line 55 of file HLTBitAnalyzer.h.

Referenced by analyze(), and HLTBitAnalyzer().

Definition at line 73 of file HLTBitAnalyzer.h.

Referenced by analyze(), and HLTBitAnalyzer().

Definition at line 75 of file HLTBitAnalyzer.h.

Referenced by analyze(), and HLTBitAnalyzer().

Definition at line 73 of file HLTBitAnalyzer.h.

Referenced by analyze(), and HLTBitAnalyzer().

Definition at line 74 of file HLTBitAnalyzer.h.

Referenced by analyze(), and HLTBitAnalyzer().

Definition at line 56 of file HLTBitAnalyzer.h.

Referenced by analyze(), and HLTBitAnalyzer().