CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/SimCalorimetry/HcalSimProducers/src/HcalHitAnalyzer.cc

Go to the documentation of this file.
00001 #include "SimCalorimetry/HcalSimProducers/src/HcalHitAnalyzer.h"
00002 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
00003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00004 #include<iostream>
00005 
00006 
00007 HcalHitAnalyzer::HcalHitAnalyzer(edm::ParameterSet const& conf) 
00008 : simParameterMap_(conf),
00009   hbheFilter_(),
00010   hoFilter_(),
00011   hfFilter_(true),
00012   zdcFilter_(),
00013   hbheAnalyzer_("HBHE", 1., &simParameterMap_, &hbheFilter_),
00014   hoAnalyzer_("HO", 1., &simParameterMap_, &hoFilter_),
00015   hfAnalyzer_("HF", 1., &simParameterMap_, &hfFilter_),
00016   zdcAnalyzer_("ZDC", 1., &simParameterMap_, &zdcFilter_)
00017 {
00018 }
00019 
00020 
00021 namespace HcalHitAnalyzerImpl {
00022   template<class Collection>
00023   void analyze(edm::Event const& e, CaloHitAnalyzer & analyzer) {
00024     edm::Handle<Collection> recHits;
00025     e.getByType(recHits);
00026     for(unsigned i = 0 ; i < recHits->size(); ++i) {
00027       analyzer.analyze((*recHits)[i].id().rawId(), (*recHits)[i].energy());
00028     }
00029   }
00030 }
00031 
00032 
00033 void HcalHitAnalyzer::analyze(edm::Event const& e, edm::EventSetup const& c) {
00034    // Step A: Get Inputs
00035   edm::Handle<CrossingFrame<PCaloHit> > cf, zdccf;
00036   e.getByLabel("mix", "g4SimHitsHcalHits",cf);
00037   //e.getByLabel("mix", "ZDCHits", zdccf);
00038 
00039   // test access to SimHits for HcalHits and ZDC hits
00040   std::auto_ptr<MixCollection<PCaloHit> > hits(new MixCollection<PCaloHit>(cf.product()));
00041   //std::auto_ptr<MixCollection<PCaloHit> > zdcHits(new MixCollection<PCaloHit>(zdccf.product()));
00042   hbheAnalyzer_.fillHits(*hits); 
00043   //hoAnalyzer_.fillHits(*hits);
00044   //hfAnalyzer_.fillHits(*hits);
00045   //zdcAnalyzer_.fillHits(*hits);
00046   HcalHitAnalyzerImpl::analyze<HBHERecHitCollection>(e, hbheAnalyzer_);
00047   HcalHitAnalyzerImpl::analyze<HORecHitCollection>(e, hoAnalyzer_);
00048   HcalHitAnalyzerImpl::analyze<HFRecHitCollection>(e, hfAnalyzer_);
00049   //HcalHitAnalyzerImpl::analyze<ZDCRecHitCollection>(e, zdcAnalyzer_);
00050 }
00051 
00052