CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/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 {
00013 }
00014 
00015 
00016 namespace CastorHitAnalyzerImpl {
00017   template<class Collection>
00018   void analyze(edm::Event const& e, CaloHitAnalyzer & analyzer) {
00019     edm::Handle<Collection> recHits;
00020     e.getByType(recHits);
00021     if (!recHits.isValid()) {
00022       edm::LogError("CastorHitAnalyzer") << "Could not find Castor RecHitContainer ";
00023     } else {
00024       for(unsigned i = 0 ; i < recHits->size(); ++i) {
00025         analyzer.analyze((*recHits)[i].id().rawId(), (*recHits)[i].energy());
00026       }
00027     }
00028   }
00029 }
00030 
00031 
00032 void CastorHitAnalyzer::analyze(edm::Event const& e, edm::EventSetup const& c) {
00033 edm::Handle<CrossingFrame<PCaloHit> > castorcf;
00034 e.getByLabel("mix", "g4SimHitsCastorFI", castorcf);  
00035 
00036 
00037   // access to SimHits
00038 std::auto_ptr<MixCollection<PCaloHit> > hits(new MixCollection<PCaloHit>(castorcf.product()));
00039     castorAnalyzer_.fillHits(*hits);
00040     CastorHitAnalyzerImpl::analyze<CastorRecHitCollection>(e, castorAnalyzer_);
00041   }
00042 
00043 
00044