CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
constexpr float energy() const
Definition: CaloRecHit.h:29
static const std::string kSharedResource
Definition: TFileService.h:76
HeterogeneousHGCalRecHitsValidator(const edm::ParameterSet &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
constexpr const DetId & detid() const
Definition: CaloRecHit.h:33
std::array< ValidHitCollection, nsubdetectors > cpuValidRecHits
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
std::array< edm::ESGetToken< HGCalGeometry, IdealGeometryRecord >, nsubdetectors > estokens_
assert(be >=bs)
float signalOverSigmaNoise() const
Definition: HGCRecHit.cc:72
void analyze(const edm::Event &, const edm::EventSetup &) override
bool getData(T &iHolder) const
Definition: EventSetup.h:128
float timeError() const
Definition: HGCRecHit.cc:79
std::array< std::array< edm::EDGetTokenT< HGChefRecHitCollection >, ncomputingdevices >, nsubdetectors > tokens_
uint32_t flagBits() const
Definition: HGCRecHit.h:111
constexpr float time() const
Definition: CaloRecHit.h:31
void set_geometry_(const edm::EventSetup &, const unsigned &)
tuple handle
Definition: patZpeak.py:23
std::vector< edm::EDGetTokenT< int > > tokens_
std::array< ValidHitCollection, nsubdetectors > gpuValidRecHits
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > estokenGeom_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void setGeometry(CaloGeometry const &)
Definition: RecHitTools.cc:68
tuple cout
Definition: gather_cfg.py:144
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:157
treenames_({{"CEE","CHSi","CHSci"}})
std::array< ValidHitCollection, nsubdetectors > diffsValidRecHits