CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes
HGCalTestScintHits Class Reference
Inheritance diagram for HGCalTestScintHits:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 HGCalTestScintHits (const edm::ParameterSet &ps)
 
 ~HGCalTestScintHits () override=default
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 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)
 

Protected Member Functions

void analyze (edm::Event const &, edm::EventSetup const &) override
 
void beginJob () override
 
void endJob () override
 
- 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)
 

Private Attributes

const std::string caloHitSource_
 
const std::string g4Label_
 
const edm::ESGetToken< HGCalGeometry, IdealGeometryRecordgeomToken_
 
const std::string nameSense_
 
const std::string tileFileName_
 
std::vector< int > tiles_
 
const edm::EDGetTokenT< edm::PCaloHitContainertok_calo_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Detailed Description

Definition at line 30 of file HGCalTestScintHits.cc.

Constructor & Destructor Documentation

◆ HGCalTestScintHits()

HGCalTestScintHits::HGCalTestScintHits ( const edm::ParameterSet ps)

Definition at line 48 of file HGCalTestScintHits.cc.

References nameSense_.

49  : g4Label_(ps.getParameter<std::string>("moduleLabel")),
50  caloHitSource_(ps.getParameter<std::string>("caloHitSource")),
51  nameSense_(ps.getParameter<std::string>("nameSense")),
52  tileFileName_(ps.getParameter<std::string>("tileFileName")),
53  tok_calo_(consumes<edm::PCaloHitContainer>(edm::InputTag(g4Label_, caloHitSource_))),
54  geomToken_(esConsumes<HGCalGeometry, IdealGeometryRecord>(edm::ESInputTag{"", nameSense_})) {
55  edm::LogVerbatim("HGCalSim") << "Test Hit ID using SimHits for " << nameSense_ << " with module Label: " << g4Label_
56  << " Hits: " << caloHitSource_ << " Tile file " << tileFileName_;
57  if (!tileFileName_.empty()) {
58  edm::FileInPath filetmp("SimG4CMS/Calo/data/" + tileFileName_);
59  std::string fileName = filetmp.fullPath();
60  std::ifstream fInput(fileName.c_str());
61  if (!fInput.good()) {
62  edm::LogVerbatim("HGCalSim") << "Cannot open file " << fileName;
63  } else {
64  char buffer[80];
65  while (fInput.getline(buffer, 80)) {
66  std::vector<std::string> items = CaloSimUtils::splitString(std::string(buffer));
67  if (items.size() > 2) {
68  int layer = std::atoi(items[0].c_str());
69  int ring = std::atoi(items[1].c_str());
70  int phi = std::atoi(items[2].c_str());
72  }
73  }
74  edm::LogVerbatim("HGCalSim") << "Reads in " << tiles_.size() << " tile information from " << fileName;
75  fInput.close();
76  }
77  }
78 }
Log< level::Info, true > LogVerbatim
std::vector< int > tiles_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const std::string tileFileName_
const edm::EDGetTokenT< edm::PCaloHitContainer > tok_calo_
int32_t tileIndex(int32_t layer, int32_t ring, int32_t phi)
const std::string caloHitSource_
std::vector< std::string > splitString(const std::string &)
Definition: CaloSimUtils.cc:3
const edm::ESGetToken< HGCalGeometry, IdealGeometryRecord > geomToken_
const std::string nameSense_
const std::string g4Label_

◆ ~HGCalTestScintHits()

HGCalTestScintHits::~HGCalTestScintHits ( )
overridedefault

Member Function Documentation

◆ analyze()

void HGCalTestScintHits::analyze ( edm::Event const &  e,
edm::EventSetup const &  iS 
)
overrideprotectedvirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 89 of file HGCalTestScintHits.cc.

References python.cmstools::all(), MillePedeFileConverter_cfg::e, spr::find(), relativeConstraints::geom, geomToken_, edm::EventSetup::getData(), caHitNtupletGeneratorKernels::good, hfClusterShapes_cfi::hits, l1ctLayer2EG_cff::id, hit::id, edm::HandleBase::isValid(), nhits, HGCalTileIndex::tileIndex(), tiles_, and tok_calo_.

89  {
90  // get hcalGeometry
91  const HGCalGeometry* geom = &iS.getData(geomToken_);
92  const HGCalDDDConstants& hgc = geom->topology().dddConstants();
93  int firstLayer = hgc.firstLayer() - 1;
94  // get the hit collection
95  const edm::Handle<edm::PCaloHitContainer>& hitsCalo = e.getHandle(tok_calo_);
96  bool getHits = (hitsCalo.isValid());
97  uint32_t nhits = (getHits) ? hitsCalo->size() : 0;
98  uint32_t good(0), all(0);
99  edm::LogVerbatim("HGCalSim") << "HGCalTestScintHits: Input flags Hits " << getHits << " with " << nhits
100  << " hits first Layer " << firstLayer;
101 
102  if (getHits) {
103  std::vector<PCaloHit> hits;
104  hits.insert(hits.end(), hitsCalo->begin(), hitsCalo->end());
105  if (!hits.empty()) {
106  // Loop over all hits
107  for (auto hit : hits) {
108  ++all;
109  DetId id(hit.id());
110  HGCScintillatorDetId hid(id);
111  std::pair<int, int> typm = hgc.tileType(hid.layer(), hid.ring(), 0);
112  if (typm.first >= 0) {
113  hid.setType(typm.first);
114  hid.setSiPM(typm.second);
115  id = static_cast<DetId>(hid);
116  }
117  bool toCheck(true);
118  if (!tiles_.empty()) {
119  int indx = HGCalTileIndex::tileIndex(firstLayer + hid.layer(), hid.ring(), hid.iphi());
120  if (std::find(tiles_.begin(), tiles_.end(), indx) != tiles_.end())
121  toCheck = true;
122  }
123  if (toCheck) {
124  ++good;
125  GlobalPoint pos = geom->getPosition(id);
126  bool valid1 = geom->topology().valid(id);
127  bool valid2 = hgc.isValidTrap(hid.zside(), hid.layer(), hid.ring(), hid.iphi());
128  edm::LogVerbatim("HGCalSim") << "Hit[" << all << ":" << good << "]" << hid << " at (" << pos.x() << ", "
129  << pos.y() << ", " << pos.z() << ") Validity " << valid1 << ":" << valid2
130  << " Energy " << hit.energy() << " Time " << hit.time();
131  }
132  }
133  }
134  }
135  edm::LogVerbatim("HGCalSim") << "Total hits = " << all << ":" << nhits << " Good DetIds = " << good;
136 }
Log< level::Info, true > LogVerbatim
std::vector< int > tiles_
def all(container)
workaround iterator generators for ROOT classes
Definition: cmstools.py:25
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
const edm::EDGetTokenT< edm::PCaloHitContainer > tok_calo_
int32_t tileIndex(int32_t layer, int32_t ring, int32_t phi)
const edm::ESGetToken< HGCalGeometry, IdealGeometryRecord > geomToken_
unsigned int id
Definition: DetId.h:17
bool isValid() const
Definition: HandleBase.h:70

◆ beginJob()

void HGCalTestScintHits::beginJob ( void  )
inlineoverrideprotectedvirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 38 of file HGCalTestScintHits.cc.

38 {}

◆ endJob()

void HGCalTestScintHits::endJob ( void  )
inlineoverrideprotectedvirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 39 of file HGCalTestScintHits.cc.

39 {}

◆ fillDescriptions()

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

Definition at line 80 of file HGCalTestScintHits.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, and AlCaHLTBitMon_QueryRunRegistry::string.

80  {
82  desc.add<std::string>("moduleLabel", "g4SimHits");
83  desc.add<std::string>("caloHitSource", "HGCHitsHEback");
84  desc.add<std::string>("nameSense", "HGCalHEScintillatorSensitive");
85  desc.add<std::string>("tileFileName", "");
86  descriptions.add("hgcalHitScintillator", desc);
87 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

Member Data Documentation

◆ caloHitSource_

const std::string HGCalTestScintHits::caloHitSource_
private

Definition at line 42 of file HGCalTestScintHits.cc.

◆ g4Label_

const std::string HGCalTestScintHits::g4Label_
private

Definition at line 42 of file HGCalTestScintHits.cc.

◆ geomToken_

const edm::ESGetToken<HGCalGeometry, IdealGeometryRecord> HGCalTestScintHits::geomToken_
private

Definition at line 44 of file HGCalTestScintHits.cc.

Referenced by analyze().

◆ nameSense_

const std::string HGCalTestScintHits::nameSense_
private

Definition at line 42 of file HGCalTestScintHits.cc.

Referenced by HGCalTestScintHits().

◆ tileFileName_

const std::string HGCalTestScintHits::tileFileName_
private

Definition at line 42 of file HGCalTestScintHits.cc.

◆ tiles_

std::vector<int> HGCalTestScintHits::tiles_
private

Definition at line 45 of file HGCalTestScintHits.cc.

Referenced by analyze().

◆ tok_calo_

const edm::EDGetTokenT<edm::PCaloHitContainer> HGCalTestScintHits::tok_calo_
private

Definition at line 43 of file HGCalTestScintHits.cc.

Referenced by analyze().