CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CastorHitAnalyzer.cc
Go to the documentation of this file.
1 
16 
17 #include <iostream>
18 #include <string>
19 
21 public:
22  explicit CastorHitAnalyzer(edm::ParameterSet const &conf);
23  void analyze(edm::Event const &e, edm::EventSetup const &c) override;
24 
25 private:
31 };
32 
34  : hitReadoutName_("CastorHits"),
35  simParameterMap_(),
36  castorFilter_(),
37  castorAnalyzer_("CASTOR", 1., &simParameterMap_, &castorFilter_),
38  castorRecHitCollectionTag_(conf.getParameter<edm::InputTag>("castorRecHitCollectionTag")) {}
39 
40 namespace CastorHitAnalyzerImpl {
41  template <class Collection>
42  void analyze(edm::Event const &e, CaloHitAnalyzer &analyzer, edm::InputTag &tag) {
44  e.getByLabel(tag, recHits);
45  if (!recHits.isValid()) {
46  edm::LogError("CastorHitAnalyzer") << "Could not find Castor RecHitContainer ";
47  } else {
48  for (unsigned i = 0; i < recHits->size(); ++i) {
49  analyzer.analyze((*recHits)[i].id().rawId(), (*recHits)[i].energy());
50  }
51  }
52  }
53 } // namespace CastorHitAnalyzerImpl
54 
57  e.getByLabel("mix", "g4SimHitsCastorFI", castorcf);
58 
59  // access to SimHits
60  std::unique_ptr<MixCollection<PCaloHit>> hits(new MixCollection<PCaloHit>(castorcf.product()));
62  CastorHitAnalyzerImpl::analyze<CastorRecHitCollection>(e, castorAnalyzer_, castorRecHitCollectionTag_);
63 }
64 
66 
CastorHitAnalyzer(edm::ParameterSet const &conf)
const edm::EventSetup & c
void analyze(int detId, double recEnergy)
to be called for each RecHit
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Log< level::Error, false > LogError
CastorHitFilter castorFilter_
void analyze(edm::Event const &e, edm::EventSetup const &c) override
void analyze(edm::Event const &e, CaloHitAnalyzer &analyzer, edm::InputTag &tag)
edm::InputTag castorRecHitCollectionTag_
void fillHits(MixCollection< PCaloHit > &hits)
should be called each event
CastorSimParameterMap simParameterMap_
bool isValid() const
Definition: HandleBase.h:70
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:500
CaloHitAnalyzer castorAnalyzer_
std::string hitReadoutName_
T const * product() const
Definition: Handle.h:70