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);
13  for (unsigned i(0); i < nsubdetectors; ++i) {
14  trees_[i] = fs->make<TTree>(treenames_[i].c_str(), treenames_[i].c_str());
15  trees_[i]->Branch("cpu", "ValidHitCollection", &cpuValidRecHits[i]);
16  trees_[i]->Branch("gpu", "ValidHitCollection", &gpuValidRecHits[i]);
17  trees_[i]->Branch("diffs", "ValidHitCollection", &diffsValidRecHits[i]);
18  }
19 }
20 
22 
24 
28 }
29 
32  setup.get<CaloGeometryRecord>().get(baseGeom);
33  recHitTools_.setGeometry(*baseGeom);
34 
35  //future subdetector loop
36  for (size_t idet = 0; idet < nsubdetectors; ++idet) {
37  set_geometry_(setup, idet);
38 
39  //get hits produced with the CPU
40  const auto &cpuhits = event.get(tokens_[idet][0]);
41 
42  //get hits produced with the GPU
43  const auto &gpuhits = event.get(tokens_[idet][1]);
44 
45  size_t nhits = cpuhits.size();
46  std::cout << nhits << ", " << gpuhits.size() << std::endl;
47  assert(nhits == gpuhits.size());
48  //float sum_cpu = 0.f, sum_gpu = 0.f, sum_son_cpu = 0.f, sum_son_gpu = 0.f;
49  for (unsigned i(0); i < nhits; i++) {
50  const HGCRecHit &cpuHit = cpuhits[i];
51  const HGCRecHit &gpuHit = gpuhits[i];
52 
53  const float cpuEn = cpuHit.energy();
54  const float gpuEn = gpuHit.energy();
55  //sum_cpu += cpuEn; sum_gpu += gpuEn;
56 
57  const float cpuTime = cpuHit.time();
58  const float gpuTime = gpuHit.time();
59  const float cpuTimeErr = cpuHit.timeError();
60  const float gpuTimeErr = gpuHit.timeError();
61  const HGCalDetId cpuDetId = cpuHit.detid();
62  const HGCalDetId gpuDetId = gpuHit.detid();
63  const float cpuFB = cpuHit.flagBits();
64  const float gpuFB = gpuHit.flagBits();
65  const float cpuSoN = cpuHit.signalOverSigmaNoise();
66  const float gpuSoN = gpuHit.signalOverSigmaNoise();
67  //sum_son_cpu += cpuSoN; sum_son_gpu += gpuSoN;
68 
69  ValidHit vCPU(cpuEn, cpuTime, cpuTimeErr, cpuDetId, cpuFB, cpuSoN);
70  ValidHit vGPU(gpuEn, gpuTime, gpuTimeErr, gpuDetId, gpuFB, gpuSoN);
71  ValidHit vDiffs(cpuEn - gpuEn,
72  cpuTime - gpuTime,
73  cpuTimeErr - gpuTimeErr,
74  cpuDetId - gpuDetId,
75  cpuFB - gpuFB,
76  cpuSoN - gpuSoN);
77 
78  cpuValidRecHits[idet].push_back(vCPU);
79  gpuValidRecHits[idet].push_back(vGPU);
80  diffsValidRecHits[idet].push_back(vDiffs);
81  }
82  trees_[idet]->Fill();
83  }
84 }
85 
86 //define this as a plug-in
mps_fire.i
i
Definition: mps_fire.py:428
CaloRecHit::energy
constexpr float energy() const
Definition: CaloRecHit.h:29
HeterogeneousHGCalRecHitsValidator::trees_
std::array< TTree *, nsubdetectors > trees_
Definition: HeterogeneousHGCalRecHitsValidator.h:48
patZpeak.handle
handle
Definition: patZpeak.py:23
CaloGeometryRecord
Definition: CaloGeometryRecord.h:30
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:43
cms::cuda::assert
assert(be >=bs)
HeterogeneousHGCalRecHitsValidator::recHitTools_
hgcal::RecHitTools recHitTools_
Definition: HeterogeneousHGCalRecHitsValidator.h:46
CaloRecHit::detid
constexpr const DetId & detid() const
Definition: CaloRecHit.h:33
HeterogeneousHGCalRecHitsValidator::~HeterogeneousHGCalRecHitsValidator
~HeterogeneousHGCalRecHitsValidator() override
Definition: HeterogeneousHGCalRecHitsValidator.cc:21
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
HeterogeneousHGCalRecHitsValidator::diffsValidRecHits
std::array< ValidHitCollection, nsubdetectors > diffsValidRecHits
Definition: HeterogeneousHGCalRecHitsValidator.h:50
HGCRecHit::timeError
float timeError() const
Definition: HGCRecHit.cc:79
HeterogeneousHGCalRecHitsValidator::gpuValidRecHits
std::array< ValidHitCollection, nsubdetectors > gpuValidRecHits
Definition: HeterogeneousHGCalRecHitsValidator.h:50
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:50
CaloRecHit::time
constexpr float time() const
Definition: CaloRecHit.h:31
HGCRecHit
Definition: HGCRecHit.h:14
HeterogeneousHGCalRecHitsValidator
Definition: HeterogeneousHGCalRecHitsValidator.h:32
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:30
edm::EventSetup
Definition: EventSetup.h:58
get
#define get
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:40
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:25
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
HeterogeneousHGCalRecHitsValidator::handles_str_
std::array< std::string, nsubdetectors > handles_str_
Definition: HeterogeneousHGCalRecHitsValidator.h:44
edm::InputTag
Definition: InputTag.h:15
HeterogeneousHGCalRecHitsValidator::endJob
void endJob() override
Definition: HeterogeneousHGCalRecHitsValidator.cc:23
IdealGeometryRecord
Definition: IdealGeometryRecord.h:25
TFileService::make
T * make(const Args &... args) const
make new ROOT object
Definition: TFileService.h:64