CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/SimCalorimetry/CastorSim/plugins/CastorHitAnalyzer.cc

Go to the documentation of this file.
00001 #include "SimCalorimetry/CastorSim/plugins/CastorHitAnalyzer.h"
00002 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
00003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00004 #include<iostream>
00005 
00006 
00007 CastorHitAnalyzer::CastorHitAnalyzer(edm::ParameterSet const& conf) 
00008   : hitReadoutName_("CastorHits"),
00009   simParameterMap_(),
00010   castorFilter_(),
00011   castorAnalyzer_("CASTOR", 1., &simParameterMap_, &castorFilter_),
00012   castorRecHitCollectionTag_(conf.getParameter<edm::InputTag>("castorRecHitCollectionTag"))
00013 {
00014 }
00015 
00016 
00017 namespace CastorHitAnalyzerImpl {
00018   template<class Collection>
00019   void analyze(edm::Event const& e, CaloHitAnalyzer & analyzer, edm::InputTag& tag) {
00020     edm::Handle<Collection> recHits;
00021     e.getByLabel(tag, recHits);
00022     if (!recHits.isValid()) {
00023       edm::LogError("CastorHitAnalyzer") << "Could not find Castor RecHitContainer ";
00024     } else {
00025       for(unsigned i = 0 ; i < recHits->size(); ++i) {
00026         analyzer.analyze((*recHits)[i].id().rawId(), (*recHits)[i].energy());
00027       }
00028     }
00029   }
00030 }
00031 
00032 
00033 void CastorHitAnalyzer::analyze(edm::Event const& e, edm::EventSetup const& c) {
00034 edm::Handle<CrossingFrame<PCaloHit> > castorcf;
00035 e.getByLabel("mix", "g4SimHitsCastorFI", castorcf);  
00036 
00037 
00038   // access to SimHits
00039 std::auto_ptr<MixCollection<PCaloHit> > hits(new MixCollection<PCaloHit>(castorcf.product()));
00040     castorAnalyzer_.fillHits(*hits);
00041     CastorHitAnalyzerImpl::analyze<CastorRecHitCollection>(e, castorAnalyzer_, castorRecHitCollectionTag_);
00042   }
00043 
00044 
00045