CMS 3D CMS Logo

List of all members | Public Member Functions
hgcalUtils::DumpClusters Class Reference

#include <DumpClustersDetails.h>

Public Member Functions

 DumpClusters ()=default
 
template<typename T >
void dumpInfos (const T &clusters, const std::string &moduleLabel, edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi, edm::EventNumber_t event, bool dumpCellsDetId=false) const
 

Detailed Description

Definition at line 22 of file DumpClustersDetails.h.

Constructor & Destructor Documentation

◆ DumpClusters()

hgcalUtils::DumpClusters::DumpClusters ( )
default

Member Function Documentation

◆ dumpInfos()

template<typename T >
void hgcalUtils::DumpClusters::dumpInfos ( const T clusters,
const std::string &  moduleLabel,
edm::RunNumber_t  run,
edm::LuminosityBlockNumber_t  lumi,
edm::EventNumber_t  event,
bool  dumpCellsDetId = false 
) const
inline

Definition at line 27 of file DumpClustersDetails.h.

References DummyCfis::c, bsc_activity_cfg::clusters, submitPVResolutionJobs::count, corrVsCorr::filename, nano_mu_digi_cff::float, dqm-mbProfile::format, mps_fire::i, HerwigMaxPtPartonFilter_cfi::moduleLabel, timingPdfMaker::outfile, writedatasetfile::run, and hgcalUtils::sortByDetId().

Referenced by HGCalLayerClustersFromSoAProducer::produce(), and HGCalLayerClusterProducer::produce().

32  {
33  // Get the process ID
34  pid_t pid = getpid();
35 
36  // Create the filename using the PID
37  std::ostringstream filename;
38  filename << "CLUSTERS_" << pid << "_" << moduleLabel << "_" << run << "_" << lumi << "_" << event << ".txt";
39  // Open the file
40  std::ofstream outfile(filename.str());
41  int count = 0;
42  for (auto const& i : clusters) {
44  "Seed: {}, Idx: {}, energy: {:.{}f}, x: {:.{}f}, y: {:.{}f}, z: {:.{}f}, eta: {:.{}f}, phi: {:.{}f}",
45  i.seed().rawId(),
46  count++,
47  (float)i.energy(),
48  std::numeric_limits<float>::max_digits10,
49  i.x(),
50  std::numeric_limits<float>::max_digits10,
51  i.y(),
52  std::numeric_limits<float>::max_digits10,
53  i.z(),
54  std::numeric_limits<float>::max_digits10,
55  i.eta(),
56  std::numeric_limits<float>::max_digits10,
57  i.phi(),
58  std::numeric_limits<float>::max_digits10);
59  if (dumpCellsDetId) {
60  auto sorted = i.hitsAndFractions(); // copy...
61  std::stable_sort(std::begin(sorted), std::end(sorted), sortByDetId);
62  for (auto const& c : sorted) {
63  outfile << fmt::format(" ({}, {:.{}f})", c.first, c.second, std::numeric_limits<float>::max_digits10);
64  } // loop on hits and fractions
65  } else {
66  outfile << fmt::format(" ({} cells)", i.hitsAndFractions().size());
67  }
68  outfile << std::endl;
69  } // loop on clusters
70  outfile.close();
71  }
static bool sortByDetId(const std::pair< int, float > &pair1, const std::pair< int, float > &pair2)