CMS 3D CMS Logo

HeterogeneousHGCalRecHitsValidator.cc
Go to the documentation of this file.
2 
4  : tokens_({{{{consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("cpuRecHitsEEToken")),
5  consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("gpuRecHitsEEToken"))}},
6  {{consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("cpuRecHitsHSiToken")),
7  consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("gpuRecHitsHSiToken"))}},
8  {{consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("cpuRecHitsHSciToken")),
9  consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("gpuRecHitsHSciToken"))}}}}),
10  treenames_({{"CEE", "CHSi", "CHSci"}}) {
11  usesResource(TFileService::kSharedResource);
12  estokenGeom_ = esConsumes<CaloGeometry, CaloGeometryRecord>();
14  for (unsigned i(0); i < nsubdetectors; ++i) {
15  estokens_[i] = esConsumes<HGCalGeometry, IdealGeometryRecord>(edm::ESInputTag{"", handles_str_[i]});
16  trees_[i] = fs->make<TTree>(treenames_[i].c_str(), treenames_[i].c_str());
17  trees_[i]->Branch("cpu", "ValidHitCollection", &cpuValidRecHits[i]);
18  trees_[i]->Branch("gpu", "ValidHitCollection", &gpuValidRecHits[i]);
19  trees_[i]->Branch("diffs", "ValidHitCollection", &diffsValidRecHits[i]);
20  }
21 }
22 
24 
26 
29 }
30 
33 
34  //future subdetector loop
35  for (size_t idet = 0; idet < nsubdetectors; ++idet) {
36  set_geometry_(setup, idet);
37 
38  //get hits produced with the CPU
39  const auto &cpuhits = event.get(tokens_[idet][0]);
40 
41  //get hits produced with the GPU
42  const auto &gpuhits = event.get(tokens_[idet][1]);
43 
44  size_t nhits = cpuhits.size();
45  std::cout << nhits << ", " << gpuhits.size() << std::endl;
46  assert(nhits == gpuhits.size());
47  //float sum_cpu = 0.f, sum_gpu = 0.f, sum_son_cpu = 0.f, sum_son_gpu = 0.f;
48  for (unsigned i(0); i < nhits; i++) {
49  const HGCRecHit &cpuHit = cpuhits[i];
50  const HGCRecHit &gpuHit = gpuhits[i];
51 
52  const float cpuEn = cpuHit.energy();
53  const float gpuEn = gpuHit.energy();
54  //sum_cpu += cpuEn; sum_gpu += gpuEn;
55 
56  const float cpuTime = cpuHit.time();
57  const float gpuTime = gpuHit.time();
58  const float cpuTimeErr = cpuHit.timeError();
59  const float gpuTimeErr = gpuHit.timeError();
60  const HGCalDetId cpuDetId = cpuHit.detid();
61  const HGCalDetId gpuDetId = gpuHit.detid();
62  const float cpuFB = cpuHit.flagBits();
63  const float gpuFB = gpuHit.flagBits();
64  const float cpuSoN = cpuHit.signalOverSigmaNoise();
65  const float gpuSoN = gpuHit.signalOverSigmaNoise();
66  //sum_son_cpu += cpuSoN; sum_son_gpu += gpuSoN;
67 
68  ValidHit vCPU(cpuEn, cpuTime, cpuTimeErr, cpuDetId, cpuFB, cpuSoN);
69  ValidHit vGPU(gpuEn, gpuTime, gpuTimeErr, gpuDetId, gpuFB, gpuSoN);
70  ValidHit vDiffs(cpuEn - gpuEn,
71  cpuTime - gpuTime,
72  cpuTimeErr - gpuTimeErr,
73  cpuDetId - gpuDetId,
74  cpuFB - gpuFB,
75  cpuSoN - gpuSoN);
76 
77  cpuValidRecHits[idet].push_back(vCPU);
78  gpuValidRecHits[idet].push_back(vGPU);
79  diffsValidRecHits[idet].push_back(vDiffs);
80  }
81  trees_[idet]->Fill();
82  }
83 }
84 
85 //define this as a plug-in
mps_fire.i
i
Definition: mps_fire.py:428
edm::ESInputTag
Definition: ESInputTag.h:87
CaloRecHit::energy
constexpr float energy() const
Definition: CaloRecHit.h:29
HeterogeneousHGCalRecHitsValidator::trees_
std::array< TTree *, nsubdetectors > trees_
Definition: HeterogeneousHGCalRecHitsValidator.h:53
patZpeak.handle
handle
Definition: patZpeak.py:23
HeterogeneousHGCalRecHitsValidator.h
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HeterogeneousHGCalRecHitsValidator::tokens_
std::array< std::array< edm::EDGetTokenT< HGChefRecHitCollection >, ncomputingdevices >, nsubdetectors > tokens_
Definition: HeterogeneousHGCalRecHitsValidator.h:45
cms::cuda::assert
assert(be >=bs)
HeterogeneousHGCalRecHitsValidator::recHitTools_
hgcal::RecHitTools recHitTools_
Definition: HeterogeneousHGCalRecHitsValidator.h:51
CaloRecHit::detid
constexpr const DetId & detid() const
Definition: CaloRecHit.h:33
HeterogeneousHGCalRecHitsValidator::~HeterogeneousHGCalRecHitsValidator
~HeterogeneousHGCalRecHitsValidator() override
Definition: HeterogeneousHGCalRecHitsValidator.cc:23
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
HeterogeneousHGCalRecHitsValidator::diffsValidRecHits
std::array< ValidHitCollection, nsubdetectors > diffsValidRecHits
Definition: HeterogeneousHGCalRecHitsValidator.h:55
HGCRecHit::timeError
float timeError() const
Definition: HGCRecHit.cc:79
HeterogeneousHGCalRecHitsValidator::estokenGeom_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > estokenGeom_
Definition: HeterogeneousHGCalRecHitsValidator.h:47
HeterogeneousHGCalRecHitsValidator::gpuValidRecHits
std::array< ValidHitCollection, nsubdetectors > gpuValidRecHits
Definition: HeterogeneousHGCalRecHitsValidator.h:55
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ESHandle
Definition: DTSurvey.h:22
tokens_
std::vector< edm::EDGetTokenT< int > > tokens_
Definition: TimeStudyModules.cc:75
nhits
Definition: HIMultiTrackSelector.h:42
HeterogeneousHGCalRecHitsValidator::cpuValidRecHits
std::array< ValidHitCollection, nsubdetectors > cpuValidRecHits
Definition: HeterogeneousHGCalRecHitsValidator.h:55
CaloRecHit::time
constexpr float time() const
Definition: CaloRecHit.h:31
HGCRecHit
Definition: HGCRecHit.h:14
HeterogeneousHGCalRecHitsValidator
Definition: HeterogeneousHGCalRecHitsValidator.h:34
edm::ParameterSet
Definition: ParameterSet.h:47
ValidHit
Definition: ValidHit.h:8
edm::Service< TFileService >
HeterogeneousHGCalRecHitsValidator::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: HeterogeneousHGCalRecHitsValidator.cc:31
HeterogeneousHGCalRecHitsValidator::estokens_
std::array< edm::ESGetToken< HGCalGeometry, IdealGeometryRecord >, nsubdetectors > estokens_
Definition: HeterogeneousHGCalRecHitsValidator.h:46
edm::EventSetup
Definition: EventSetup.h:58
TFileService::make
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
HGCalDetId
Definition: HGCalDetId.h:8
hgcal::RecHitTools::setGeometry
void setGeometry(CaloGeometry const &)
Definition: RecHitTools.cc:68
HeterogeneousHGCalRecHitsValidator::HeterogeneousHGCalRecHitsValidator
HeterogeneousHGCalRecHitsValidator(const edm::ParameterSet &)
Definition: HeterogeneousHGCalRecHitsValidator.cc:3
TFileService::kSharedResource
static const std::string kSharedResource
Definition: TFileService.h:76
HeterogeneousHGCalRecHitsValidator::nsubdetectors
static const unsigned nsubdetectors
Definition: HeterogeneousHGCalRecHitsValidator.h:42
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
HeterogeneousHGCalRecHitsValidator::set_geometry_
void set_geometry_(const edm::EventSetup &, const unsigned &)
Definition: HeterogeneousHGCalRecHitsValidator.cc:27
HGCRecHit::signalOverSigmaNoise
float signalOverSigmaNoise() const
Definition: HGCRecHit.cc:72
HGCRecHit::flagBits
uint32_t flagBits() const
Definition: HGCRecHit.h:111
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
HeterogeneousHGCalRecHitsValidator::endJob
void endJob() override
Definition: HeterogeneousHGCalRecHitsValidator.cc:25