CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
HCALGPUAnalyzer Class Reference

#include <ComparisonPlots/HCALGPUAnalyzer/plugins/HCALGPUAnalyzer.cc>

Inheritance diagram for HCALGPUAnalyzer:
edm::one::EDAnalyzer< edm::one::SharedResources > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 HCALGPUAnalyzer (const edm::ParameterSet &)
 
 ~HCALGPUAnalyzer () override=default
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::SharedResources >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginJob () override
 
void endJob () override
 

Private Attributes

int depth
 
int depthGPU
 
edm::Service< TFileServiceFileService
 
TH2F * hEnergy_2dM0
 
TH2F * hEnergy_2dMahi
 
TH1F * hEnergy_cpu
 
TH1F * hEnergy_cpugpu
 
TH1F * hEnergy_cpugpu_rel
 
TH1F * hEnergy_gpu
 
TH1F * hEnergyM0_cpu
 
TH1F * hEnergyM0_gpu
 
edm::EDGetTokenT< HBHERecHitCollectionhRhToken
 
edm::EDGetTokenT< HBHERecHitCollectionhRhTokenGPU
 
TH2F * hTime_2dMahi
 
TH1F * hTime_cpu
 
TH1F * hTime_gpu
 
double iEta
 
double iEtaGPU
 
double iPhi
 
double iPhiGPU
 
TH2F * Matched
 
double Method0Energy
 
double Method0EnergyGPU
 
double RecHitEnergy
 
double RecHitEnergyGPU
 
double RecHitTime
 
double RecHitTimeGPU
 
TH2F * Unmatched
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 54 of file HCALGPUAnalyzer.cc.

Constructor & Destructor Documentation

◆ HCALGPUAnalyzer()

HCALGPUAnalyzer::HCALGPUAnalyzer ( const edm::ParameterSet iConfig)
explicit

Definition at line 110 of file HCALGPUAnalyzer.cc.

References edm::ParameterSet::getUntrackedParameter(), and reco::Matched.

110  {
111  usesResource("TFileService");
112 
113  hRhToken = consumes<HBHERecHitCollection>(iConfig.getUntrackedParameter<string>("HBHERecHits", "hbheprereco"));
114  hRhTokenGPU = consumes<HBHERecHitCollection>(
115  iConfig.getUntrackedParameter<string>("HBHERecHits", "hcalCPURecHitsProducer:recHitsLegacyHBHE"));
116 
117  //
118 
119  hEnergy_2dM0 = FileService->make<TH2F>("hEnergy_2dM0", "hEnergy_2dM0", 1000, 0., 100., 1000, 0., 100.);
120  hEnergy_2dM0->GetXaxis()->SetTitle("Cpu M0 Energy");
121  hEnergy_2dM0->GetYaxis()->SetTitle("GPU M0 Energy");
122 
123  hEnergy_2dMahi = FileService->make<TH2F>("hEnergy_2dMahi", "hEnergy_2dMahi", 1000, 0., 100., 1000, 0., 100.);
124  hEnergy_2dMahi->GetXaxis()->SetTitle("CPU Energy");
125  hEnergy_2dMahi->GetYaxis()->SetTitle("GPU Energy");
126 
127  hTime_2dMahi = FileService->make<TH2F>("hTime_2dMahi", "hTime_2dMahi", 250, -12.5, 12.5, 250, -12.5, 12.5);
128  hTime_2dMahi->GetXaxis()->SetTitle("Mahi Time CPU");
129  hTime_2dMahi->GetYaxis()->SetTitle("Mahi Time GPU");
130 
131  //
132 
133  hEnergyM0_cpu = FileService->make<TH1F>("hEnergyM0_cpu", "hEnergyM0_cpu", 100, 0., 100.);
134  hEnergyM0_cpu->GetXaxis()->SetTitle("CPU Energy");
135 
136  hEnergy_cpu = FileService->make<TH1F>("hEnergy_cpu", "hEnergy_cpu", 50, 0., 50.);
137  hEnergy_cpu->GetXaxis()->SetTitle("CPU Energy");
138 
139  hEnergy_gpu = FileService->make<TH1F>("hEnergy_gpu", "hEnergy_gpu", 50, 0., 50.);
140  hEnergy_gpu->GetXaxis()->SetTitle("GPU Energy");
141 
142  //
143 
144  hEnergy_cpugpu = FileService->make<TH1F>("hEnergy_cpugpu", "hEnergy_cpugpu", 500, -2.5, 2.5);
145  hEnergy_cpugpu->GetXaxis()->SetTitle("GPU Energy - CPU Energy [GeV]");
146  hEnergy_cpugpu->GetYaxis()->SetTitle("# RecHits");
147 
149  FileService->make<TH1F>("hEnergy_cpugpu_rel", "hEnergy_cpugpu_rel ( E > 0.005 GeV)", 500, -2.5, 2.5);
150  hEnergy_cpugpu_rel->GetXaxis()->SetTitle("(GPU Energy - CPU Energy) / CPU energy");
151  hEnergy_cpugpu_rel->GetYaxis()->SetTitle("# RecHits");
152 
153  //
154 
155  hTime_cpu = FileService->make<TH1F>("hTime_cpu", "hTime_cpu", 50, -25., 25.);
156  hTime_cpu->GetXaxis()->SetTitle("CPU Time");
157 
158  hTime_gpu = FileService->make<TH1F>("hTime_gpu", "hTime_gpu", 50, -25., 25.);
159  hTime_gpu->GetXaxis()->SetTitle("GPU Time");
160 
161  Unmatched = FileService->make<TH2F>("Unmatched", "Unmatched (eta,phi)", 100, -50., 50., 85, 0., 85.);
162  Matched = FileService->make<TH2F>("Matched", "Matched (eta,phi)", 100, -50., 50., 85, 0., 85.);
163 
164  //now do what ever initialization is needed
165 }
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< HBHERecHitCollection > hRhToken
edm::EDGetTokenT< HBHERecHitCollection > hRhTokenGPU
edm::Service< TFileService > FileService
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64

◆ ~HCALGPUAnalyzer()

HCALGPUAnalyzer::~HCALGPUAnalyzer ( )
overridedefault

Member Function Documentation

◆ analyze()

void HCALGPUAnalyzer::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 172 of file HCALGPUAnalyzer.cc.

References hcalRecHitTable_cff::depth, hcalRecHitTable_cff::energy, mps_fire::i, l1tPhase2CaloJetEmulator_cfi::iEta, HcalDetId::ieta(), iEvent, createfilelist::int, HcalDetId::iphi(), dqmiolumiharvest::j, reco::Matched, DetId::rawId(), edm::SortedCollection< T, SORT >::size(), and hcalRecHitTable_cff::time.

172  {
173  using namespace edm;
174 
175  // Read events
177  iEvent.getByToken(hRhToken, hRecHits);
178 
179  Handle<HBHERecHitCollection> hRecHitsGPU;
180  iEvent.getByToken(hRhTokenGPU, hRecHitsGPU);
181 
182  // Loop over all rechits in one event
183  for (int i = 0; i < (int)hRecHits->size(); i++) {
184  // get ID information for the reconstructed hit
185  HcalDetId detID_rh = (*hRecHits)[i].id().rawId();
186 
187  // ID information can get us detector coordinates
188  depth = (*hRecHits)[i].id().depth();
189  iEta = detID_rh.ieta();
190  iPhi = detID_rh.iphi();
191 
192  // get some variables
193  Method0Energy = (*hRecHits)[i].eraw();
194  RecHitEnergy = (*hRecHits)[i].energy();
195  RecHitTime = (*hRecHits)[i].time();
196 
197  hEnergy_cpu->Fill(RecHitEnergy);
198  hTime_cpu->Fill(RecHitTime);
199 
200  /*
201  cout << "Run " << i << ": ";
202  cout << "Method0Energy: " << Method0Energy;
203  cout << "RecHitEnergy: " << RecHitEnergy;
204  cout << "depth: " << depth;
205  cout << "iEta: " << iEta;
206  cout << "iPhi: " << iPhi;
207  cout << "RecHitTime" << RecHitTime;
208  */
209  }
210 
211  for (int i = 0; i < (int)hRecHitsGPU->size(); i++) {
212  // get ID information for the reconstructed hit
213  HcalDetId detID_rh = (*hRecHitsGPU)[i].id().rawId();
214 
215  // ID information can get us detector coordinates
216  depthGPU = (*hRecHitsGPU)[i].id().depth();
217  iEtaGPU = detID_rh.ieta();
218  iPhiGPU = detID_rh.iphi();
219 
220  // get some variables
221  Method0EnergyGPU = (*hRecHitsGPU)[i].eraw();
222  RecHitEnergyGPU = (*hRecHitsGPU)[i].energy();
223  RecHitTimeGPU = (*hRecHitsGPU)[i].time();
224 
226  hTime_gpu->Fill(RecHitTimeGPU);
227 
228  /*
229  cout << "Run " << i << ": ";
230  cout << "Method0Energy: " << Method0EnergyGPU;
231  cout << "RecHitEnergy: " << RecHitEnergyGPU;
232  cout << "depth: " << depthGPU;
233  cout << "iEta: " << iEtaGPU;
234  cout << "iPhi: " << iPhiGPU;
235  cout << "RecHitTime" << RecHitTimeGPU;
236  */
237  }
238 
239  // Loop over all rechits in one event
240  for (int i = 0; i < (int)hRecHits->size(); i++) {
241  HcalDetId detID_rh = (*hRecHits)[i].id().rawId();
242 
243  bool unmatched = true;
244  // cout << "--------------------------------------------------------" << endl;
245 
246  for (int j = 0; j < (int)hRecHitsGPU->size(); j++) {
247  HcalDetId detID_gpu = (*hRecHitsGPU)[j].id().rawId();
248 
249  if ((detID_rh == detID_gpu)) {
250  /*
251  cout << "Mtime(cpu)" << (*hRecHits)[i].time() << endl;
252  cout << " Mtime(gpu)" << (*hRecHitsGPU)[j].time() << endl;
253 
254  cout << "M0E(cpu)" << (*hRecHits)[i].eraw() << endl;
255  cout << " M0E(gpu)" << (*hRecHitsGPU)[j].eraw() << endl;
256  */
257 
258  auto relValue = ((*hRecHitsGPU)[j].energy() - (*hRecHits)[i].energy()) / (*hRecHits)[i].energy();
259 
260  hEnergy_2dM0->Fill((*hRecHits)[i].eraw(), (*hRecHitsGPU)[j].eraw());
261  hEnergy_2dMahi->Fill((*hRecHits)[i].energy(), (*hRecHitsGPU)[j].energy());
262  hEnergy_cpugpu->Fill((*hRecHitsGPU)[j].energy() - (*hRecHits)[i].energy());
263  if ((*hRecHits)[i].energy() > 0.005)
264  hEnergy_cpugpu_rel->Fill(relValue);
265  hTime_2dMahi->Fill((*hRecHits)[i].time(), (*hRecHitsGPU)[j].time());
266 
267  /*
268  if((relValue < - 0.9) and ((*hRecHits)[i].energy()>0.005)) {
269  cout << "----------------------------------"<< endl;
270  cout << " detID = " << detID_rh.rawId() << endl;
271  cout << "ME(cpu)" << (*hRecHits)[i].energy() << endl;
272  cout << " ME(gpu)" << (*hRecHitsGPU)[j].energy() << endl;
273  }
274  */
275 
276  Matched->Fill(detID_rh.ieta(), detID_rh.iphi());
277 
278  unmatched = false;
279  }
280  }
281 
283 
284  if (unmatched) {
285  Unmatched->Fill(detID_rh.ieta(), detID_rh.iphi());
286  // cout << " recHit not matched =" << detID_rh << " E(raw)=" << (*hRecHits)[i].eraw() << " E=" << (*hRecHits)[i].energy() << endl;
287  }
288  }
289 }
size_type size() const
int iEvent
Definition: GenABIO.cc:224
constexpr int ieta() const
get the cell ieta
Definition: HcalDetId.h:155
edm::EDGetTokenT< HBHERecHitCollection > hRhToken
edm::EDGetTokenT< HBHERecHitCollection > hRhTokenGPU
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
HLT enums.
constexpr int iphi() const
get the cell iphi
Definition: HcalDetId.h:157

◆ beginJob()

void HCALGPUAnalyzer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 292 of file HCALGPUAnalyzer.cc.

292 {}

◆ endJob()

void HCALGPUAnalyzer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 295 of file HCALGPUAnalyzer.cc.

295 {}

◆ fillDescriptions()

void HCALGPUAnalyzer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 298 of file HCALGPUAnalyzer.cc.

References edm::ConfigurationDescriptions::addDefault(), and submitPVResolutionJobs::desc.

298  {
299  //The following says we do not know what parameters are allowed so do no validation
300  // Please change this to state exactly what you do use, even if it is no parameters
302  desc.setUnknown();
303  descriptions.addDefault(desc);
304 }
void addDefault(ParameterSetDescription const &psetDescription)

Member Data Documentation

◆ depth

int HCALGPUAnalyzer::depth
private

◆ depthGPU

int HCALGPUAnalyzer::depthGPU
private

Definition at line 75 of file HCALGPUAnalyzer.cc.

◆ FileService

edm::Service<TFileService> HCALGPUAnalyzer::FileService
private

Definition at line 93 of file HCALGPUAnalyzer.cc.

◆ hEnergy_2dM0

TH2F* HCALGPUAnalyzer::hEnergy_2dM0
private

Definition at line 78 of file HCALGPUAnalyzer.cc.

◆ hEnergy_2dMahi

TH2F* HCALGPUAnalyzer::hEnergy_2dMahi
private

Definition at line 77 of file HCALGPUAnalyzer.cc.

◆ hEnergy_cpu

TH1F* HCALGPUAnalyzer::hEnergy_cpu
private

Definition at line 83 of file HCALGPUAnalyzer.cc.

◆ hEnergy_cpugpu

TH1F* HCALGPUAnalyzer::hEnergy_cpugpu
private

Definition at line 85 of file HCALGPUAnalyzer.cc.

◆ hEnergy_cpugpu_rel

TH1F* HCALGPUAnalyzer::hEnergy_cpugpu_rel
private

Definition at line 86 of file HCALGPUAnalyzer.cc.

◆ hEnergy_gpu

TH1F* HCALGPUAnalyzer::hEnergy_gpu
private

Definition at line 84 of file HCALGPUAnalyzer.cc.

◆ hEnergyM0_cpu

TH1F* HCALGPUAnalyzer::hEnergyM0_cpu
private

Definition at line 87 of file HCALGPUAnalyzer.cc.

◆ hEnergyM0_gpu

TH1F* HCALGPUAnalyzer::hEnergyM0_gpu
private

Definition at line 88 of file HCALGPUAnalyzer.cc.

◆ hRhToken

edm::EDGetTokenT<HBHERecHitCollection> HCALGPUAnalyzer::hRhToken
private

Definition at line 95 of file HCALGPUAnalyzer.cc.

◆ hRhTokenGPU

edm::EDGetTokenT<HBHERecHitCollection> HCALGPUAnalyzer::hRhTokenGPU
private

Definition at line 96 of file HCALGPUAnalyzer.cc.

◆ hTime_2dMahi

TH2F* HCALGPUAnalyzer::hTime_2dMahi
private

Definition at line 79 of file HCALGPUAnalyzer.cc.

◆ hTime_cpu

TH1F* HCALGPUAnalyzer::hTime_cpu
private

Definition at line 89 of file HCALGPUAnalyzer.cc.

◆ hTime_gpu

TH1F* HCALGPUAnalyzer::hTime_gpu
private

Definition at line 90 of file HCALGPUAnalyzer.cc.

◆ iEta

double HCALGPUAnalyzer::iEta
private

Definition at line 73 of file HCALGPUAnalyzer.cc.

◆ iEtaGPU

double HCALGPUAnalyzer::iEtaGPU
private

Definition at line 73 of file HCALGPUAnalyzer.cc.

◆ iPhi

double HCALGPUAnalyzer::iPhi
private

Definition at line 74 of file HCALGPUAnalyzer.cc.

◆ iPhiGPU

double HCALGPUAnalyzer::iPhiGPU
private

Definition at line 74 of file HCALGPUAnalyzer.cc.

◆ Matched

TH2F* HCALGPUAnalyzer::Matched
private

Definition at line 82 of file HCALGPUAnalyzer.cc.

◆ Method0Energy

double HCALGPUAnalyzer::Method0Energy
private

Definition at line 70 of file HCALGPUAnalyzer.cc.

◆ Method0EnergyGPU

double HCALGPUAnalyzer::Method0EnergyGPU
private

Definition at line 70 of file HCALGPUAnalyzer.cc.

◆ RecHitEnergy

double HCALGPUAnalyzer::RecHitEnergy
private

Definition at line 71 of file HCALGPUAnalyzer.cc.

◆ RecHitEnergyGPU

double HCALGPUAnalyzer::RecHitEnergyGPU
private

Definition at line 71 of file HCALGPUAnalyzer.cc.

◆ RecHitTime

double HCALGPUAnalyzer::RecHitTime
private

Definition at line 72 of file HCALGPUAnalyzer.cc.

◆ RecHitTimeGPU

double HCALGPUAnalyzer::RecHitTimeGPU
private

Definition at line 72 of file HCALGPUAnalyzer.cc.

◆ Unmatched

TH2F* HCALGPUAnalyzer::Unmatched
private

Definition at line 81 of file HCALGPUAnalyzer.cc.