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 DetId cpuDetId = cpuHit.detid();
61  const DetId 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
static const std::string kSharedResource
Definition: TFileService.h:76
HeterogeneousHGCalRecHitsValidator(const edm::ParameterSet &)
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
constexpr const DetId & detid() const
Definition: CaloRecHit.h:33
float signalOverSigmaNoise() const
Definition: HGCRecHit.cc:72
std::array< ValidHitCollection, nsubdetectors > cpuValidRecHits
std::array< edm::ESGetToken< HGCalGeometry, IdealGeometryRecord >, nsubdetectors > estokens_
assert(be >=bs)
constexpr float energy() const
Definition: CaloRecHit.h:29
void analyze(const edm::Event &, const edm::EventSetup &) override
std::array< std::array< edm::EDGetTokenT< HGChefRecHitCollection >, ncomputingdevices >, nsubdetectors > tokens_
std::array< TTree *, nsubdetectors > trees_
void set_geometry_(const edm::EventSetup &, const unsigned &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::vector< edm::EDGetTokenT< int > > tokens_
Definition: DetId.h:17
std::array< ValidHitCollection, nsubdetectors > gpuValidRecHits
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > estokenGeom_
void setGeometry(CaloGeometry const &)
Definition: RecHitTools.cc:68
constexpr float time() const
Definition: CaloRecHit.h:31
float timeError() const
Definition: HGCRecHit.cc:79
uint32_t flagBits() const
Definition: HGCRecHit.h:111
std::array< ValidHitCollection, nsubdetectors > diffsValidRecHits
Definition: event.py:1