CMS 3D CMS Logo

EcalSimHitDump.cc
Go to the documentation of this file.
5 
15 
18 
19 #include <string>
20 #include <vector>
21 
23 public:
25  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
26 
27 protected:
28  void analyze(edm::Event const&, edm::EventSetup const&) override;
29 
30 private:
32  const std::vector<std::string> hitLab_;
33  const std::vector<edm::EDGetTokenT<edm::PCaloHitContainer>> toksCalo_;
34  const std::vector<int> types_;
35  const int maxEvent_;
36  int kount_;
37 };
38 
40  : g4Label_(ps.getParameter<std::string>("ModuleLabel")),
41  hitLab_(ps.getParameter<std::vector<std::string>>("HitCollections")),
43  [this](const std::string& name) {
44  return consumes<edm::PCaloHitContainer>(edm::InputTag{g4Label_, name});
45  })},
46  types_(ps.getParameter<std::vector<int>>("CollectionTypes")),
47  maxEvent_(ps.getParameter<int>("MaxEvent")),
48  kount_(0) {
49  edm::LogVerbatim("HitStudy") << "Module Label: " << g4Label_ << " with " << hitLab_.size()
50  << " collections and maxEvent = " << maxEvent_;
51  for (unsigned int k = 0; k < hitLab_.size(); ++k)
52  edm::LogVerbatim("HitStudy") << "[" << k << "] Type " << types_[k] << " Label " << hitLab_[k];
53 }
54 
57  std::vector<std::string> coll = {"EcalHitsEB", "EcalHitsEE", "EcalHitsES"};
58  std::vector<int> type = {0, 1, 2};
59  desc.add<std::string>("ModuleLabel", "g4SimHits");
60  desc.add<std::vector<std::string>>("HitCollections", coll);
61  desc.add<std::vector<int>>("CollectionTypes", type);
62  desc.add<int>("MaxEvent", 10);
63  descriptions.add("ecalSimHitDump", desc);
64 }
65 
67  ++kount_;
68  edm::LogVerbatim("HitStudy") << "[" << kount_ << "] Run = " << e.id().run() << " Event = " << e.id().event();
69 
70  if ((kount_ <= maxEvent_) || (maxEvent_ <= 0)) {
71  for (unsigned int k = 0; k < toksCalo_.size(); ++k) {
73  e.getByToken(toksCalo_[k], hitsCalo);
74  if (hitsCalo.isValid())
75  edm::LogVerbatim("HitStudy") << "EcalSimHitDump: Input " << hitsCalo->size() << " hits of type " << types_[k];
76  unsigned int i(0);
77  for (auto const& hit : *hitsCalo) {
78  double edep = hit.energy();
79  double time = hit.time();
80  unsigned int id = hit.id();
81  if (types_[k] == 0)
82  edm::LogVerbatim("HitStudy") << "[" << i << "] " << EBDetId(id) << " E" << edep << " T " << time;
83  else if (types_[k] == 1)
84  edm::LogVerbatim("HitStudy") << "[" << i << "] " << EEDetId(id) << " E" << edep << " T " << time;
85  else
86  edm::LogVerbatim("HitStudy") << "[" << i << "] " << ESDetId(id) << " E" << edep << " T " << time;
87  ++i;
88  }
89  }
90  }
91 }
92 
93 //define this as a plug-in
EDAnalyzer.h
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
hit::id
unsigned int id
Definition: SiStripHitEffFromCalibTree.cc:92
EBDetId
Definition: EBDetId.h:17
EBDetId.h
EEDetId.h
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
protons_cff.time
time
Definition: protons_cff.py:39
EcalSimHitDump::EcalSimHitDump
EcalSimHitDump(const edm::ParameterSet &ps)
Definition: EcalSimHitDump.cc:39
EcalSimHitDump::hitLab_
const std::vector< std::string > hitLab_
Definition: EcalSimHitDump.cc:32
ESDetId
Definition: ESDetId.h:15
ESDetId.h
edm::one::EDAnalyzer
Definition: EDAnalyzer.h:30
edm::Handle
Definition: AssociativeIterator.h:50
MakerMacros.h
EcalSimHitDump::types_
const std::vector< int > types_
Definition: EcalSimHitDump.cc:34
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
EcalSimHitDump::toksCalo_
const std::vector< edm::EDGetTokenT< edm::PCaloHitContainer > > toksCalo_
Definition: EcalSimHitDump.cc:33
dqmdumpme.k
k
Definition: dqmdumpme.py:60
EcalSimHitDump::g4Label_
const std::string g4Label_
Definition: EcalSimHitDump.cc:31
EEDetId
Definition: EEDetId.h:14
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::vector_transform
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
EcalSubdetector.h
edm::ParameterSet
Definition: ParameterSet.h:47
EcalSimHitDump::maxEvent_
const int maxEvent_
Definition: EcalSimHitDump.cc:35
Event.h
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:40
PCaloHit.h
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::EventSetup
Definition: EventSetup.h:58
InputTag.h
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
std
Definition: JetResolutionObject.h:76
Frameworkfwd.h
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
transform.h
EcalSimHitDump
Definition: EcalSimHitDump.cc:22
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
EventSetup.h
PCaloHitContainer.h
EcalSimHitDump::analyze
void analyze(edm::Event const &, edm::EventSetup const &) override
Definition: EcalSimHitDump.cc:66
EcalSimHitDump::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: EcalSimHitDump.cc:55
ParameterSet.h
EcalSimHitDump::kount_
int kount_
Definition: EcalSimHitDump.cc:36
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
edm::Log
Definition: MessageLogger.h:70
edm::InputTag
Definition: InputTag.h:15
hit
Definition: SiStripHitEffFromCalibTree.cc:88
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37