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 hbheRecHitCollectionTag_(conf.getParameter<edm::InputTag>("hbheRecHitCollectionTag")),
00018 hoRecHitCollectionTag_(conf.getParameter<edm::InputTag>("hoRecHitCollectionTag")),
00019 hfRecHitCollectionTag_(conf.getParameter<edm::InputTag>("hfRecHitCollectionTag"))
00020 {
00021 }
00022
00023
00024 namespace HcalHitAnalyzerImpl {
00025 template<class Collection>
00026 void analyze(edm::Event const& e, CaloHitAnalyzer & analyzer, edm::InputTag& tag) {
00027 edm::Handle<Collection> recHits;
00028 e.getByLabel(tag, recHits);
00029 for(unsigned i = 0 ; i < recHits->size(); ++i) {
00030 analyzer.analyze((*recHits)[i].id().rawId(), (*recHits)[i].energy());
00031 }
00032 }
00033 }
00034
00035
00036 void HcalHitAnalyzer::analyze(edm::Event const& e, edm::EventSetup const& c) {
00037
00038 edm::Handle<CrossingFrame<PCaloHit> > cf, zdccf;
00039 e.getByLabel("mix", "g4SimHitsHcalHits",cf);
00040
00041
00042
00043 std::auto_ptr<MixCollection<PCaloHit> > hits(new MixCollection<PCaloHit>(cf.product()));
00044
00045 hbheAnalyzer_.fillHits(*hits);
00046
00047
00048
00049 HcalHitAnalyzerImpl::analyze<HBHERecHitCollection>(e, hbheAnalyzer_, hbheRecHitCollectionTag_);
00050 HcalHitAnalyzerImpl::analyze<HORecHitCollection>(e, hoAnalyzer_, hoRecHitCollectionTag_);
00051 HcalHitAnalyzerImpl::analyze<HFRecHitCollection>(e, hfAnalyzer_, hfRecHitCollectionTag_);
00052
00053 }