CMS 3D CMS Logo

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

Public Member Functions

 HGCalTestPartialWaferHits (const edm::ParameterSet &ps)
 
 ~HGCalTestPartialWaferHits () 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 noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept 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 noexcept
 
bool wantsStreamRuns () const noexcept
 
 ~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_
 
std::vector< int > dumpDets_
 
const std::string g4Label_
 
const edm::ESGetToken< HGCalGeometry, IdealGeometryRecordgeomToken_
 
const std::string missingFile_
 
const std::string nameSense_
 
const edm::EDGetTokenT< edm::PCaloHitContainertok_calo_
 
std::vector< int > wafers_
 

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 33 of file HGCalTestPartialWaferHits.cc.

Constructor & Destructor Documentation

◆ HGCalTestPartialWaferHits()

HGCalTestPartialWaferHits::HGCalTestPartialWaferHits ( const edm::ParameterSet ps)

Definition at line 52 of file HGCalTestPartialWaferHits.cc.

References nameSense_.

53  : g4Label_(ps.getParameter<std::string>("moduleLabel")),
54  caloHitSource_(ps.getParameter<std::string>("caloHitSource")),
55  nameSense_(ps.getParameter<std::string>("nameSense")),
56  missingFile_(ps.getParameter<std::string>("missingFile")),
57  tok_calo_(consumes<edm::PCaloHitContainer>(edm::InputTag(g4Label_, caloHitSource_))),
58  geomToken_(esConsumes<HGCalGeometry, IdealGeometryRecord>(edm::ESInputTag{"", nameSense_})) {
59  edm::LogVerbatim("HGCalSim") << "Test Hit ID using SimHits for " << nameSense_ << " with module Label: " << g4Label_
60  << " Hits: " << caloHitSource_ << " Missing Wafer file " << missingFile_;
61  if (!missingFile_.empty()) {
62  edm::FileInPath filetmp("SimG4CMS/Calo/data/" + missingFile_);
63  std::string fileName = filetmp.fullPath();
64  std::ifstream fInput(fileName.c_str());
65  if (!fInput.good()) {
66  edm::LogVerbatim("HGCalSim") << "Cannot open file " << fileName;
67  } else {
68  char buffer[80];
69  while (fInput.getline(buffer, 80)) {
70  std::vector<std::string> items = CaloSimUtils::splitString(std::string(buffer));
71  if (items.size() > 2) {
72  int layer = std::atoi(items[0].c_str());
73  int waferU = std::atoi(items[1].c_str());
74  int waferV = std::atoi(items[2].c_str());
75  wafers_.emplace_back(HGCalWaferIndex::waferIndex(layer, waferU, waferV, false));
76  } else if (items.size() == 1) {
77  int dumpdet = std::atoi(items[0].c_str());
78  dumpDets_.emplace_back(dumpdet);
79  edm::LogVerbatim("HGCalSim") << nameSense_ << " Dump detector " << dumpdet;
80  }
81  }
82  edm::LogVerbatim("HGCalSim") << "HGCalTestPartialWaferHits::Reads in " << wafers_.size() << ":"
83  << dumpDets_.size() << " wafer|detector information from " << fileName;
84  fInput.close();
85  }
86  }
87 }
Log< level::Info, true > LogVerbatim
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
int32_t waferU(const int32_t index)
std::vector< std::string > splitString(const std::string &)
Definition: CaloSimUtils.cc:3
int32_t waferIndex(int32_t layer, int32_t waferU, int32_t waferV, bool old=false)
const edm::EDGetTokenT< edm::PCaloHitContainer > tok_calo_
int32_t waferV(const int32_t index)
const edm::ESGetToken< HGCalGeometry, IdealGeometryRecord > geomToken_

◆ ~HGCalTestPartialWaferHits()

HGCalTestPartialWaferHits::~HGCalTestPartialWaferHits ( )
overridedefault

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 98 of file HGCalTestPartialWaferHits.cc.

References python.cmstools::all(), ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), TauDecayModes::dec, change_name::diff, dumpDets_, PVValHelper::dx, PVValHelper::dy, MillePedeFileConverter_cfg::e, spr::find(), relativeConstraints::geom, geomToken_, edm::EventSetup::getData(), caHitNtupletGeneratorKernels::good, DetId::HGCalEE, DetId::HGCalHSc, DetId::HGCalHSi, hfClusterShapes_cfi::hits, EcalPhiSymFlatTableProducers_cfi::id, hit::id, info(), edm::HandleBase::isValid(), nameSense_, TrackingDataMCValidation_Standalone_cff::nhits, mathSSE::sqrt(), tok_calo_, validateGeometry_cfg::valid, HGCalTypes::WaferFull, HGCalWaferIndex::waferIndex(), wafers_, geometryCSVtoXML::xx, and geometryCSVtoXML::xy.

98  {
99  // get HGCalGeometry
100  const HGCalGeometry* geom = &iS.getData(geomToken_);
101  const HGCalDDDConstants& hgc = geom->topology().dddConstants();
102  int firstLayer = hgc.getLayerOffset();
103  // get the hit collection
104  const edm::Handle<edm::PCaloHitContainer>& hitsCalo = e.getHandle(tok_calo_);
105  bool getHits = (hitsCalo.isValid());
106  uint32_t nhits = (getHits) ? hitsCalo->size() : 0;
107  uint32_t good(0), allSi(0), all(0), allSc(0), bad(0);
108  constexpr double tol = 2.0;
109  edm::LogVerbatim("HGCalSim") << "HGCalTestPartialWaferHits: Input flags Hits " << getHits << " with " << nhits
110  << " hits: Layer Offset " << firstLayer;
111 
112  if (getHits) {
113  std::vector<PCaloHit> hits;
114  hits.insert(hits.end(), hitsCalo->begin(), hitsCalo->end());
115  if (!hits.empty()) {
116  // Loop over all hits
117  for (auto hit : hits) {
118  ++all;
119  DetId id(hit.id());
120  bool valid = (geom->topology()).valid(id);
121  std::ostringstream st1;
122  if ((id.det() == DetId::HGCalEE) || (id.det() == DetId::HGCalHSi)) {
123  ++allSi;
124  HGCSiliconDetId hid(id);
125  st1 << hid;
126  if (((id.det() == DetId::HGCalEE) && (nameSense_ == "HGCalEESensitive")) ||
127  ((id.det() == DetId::HGCalHSi) && (nameSense_ == "HGCalHESiliconSensitive"))) {
128  std::string_view pid =
129  ((hgc.cassetteShiftSilicon(hid.zside(), hid.layer(), hid.waferU(), hid.waferV())) ? "HGCSim"
130  : "HGCalSim");
131  const auto& info = hgc.waferInfo(hid.layer(), hid.waferU(), hid.waferV());
132  if (!valid)
133  st1 << " Wafer Type:Part:Orient:Cassette " << info.type << ":" << info.part << ":" << info.orient << ":"
134  << info.cassette;
135  bool toCheck(false);
136  if (!wafers_.empty()) {
137  int indx = HGCalWaferIndex::waferIndex(firstLayer + hid.layer(), hid.waferU(), hid.waferV(), false);
138  if (std::find(wafers_.begin(), wafers_.end(), indx) != wafers_.end())
139  toCheck = true;
140  } else if (!dumpDets_.empty()) {
141  if ((std::find(dumpDets_.begin(), dumpDets_.end(), static_cast<int>(id.det())) != dumpDets_.end()) &&
142  (info.part != HGCalTypes::WaferFull))
143  toCheck = true;
144  } else {
145  // Only partial wafers
146  toCheck = (info.part != HGCalTypes::WaferFull);
147  }
148  if (toCheck) {
149  ++good;
150  GlobalPoint pos = geom->getPosition(id);
151  bool valid1 = geom->topology().valid(id);
152  bool valid2 = hgc.isValidHex8(hid.layer(), hid.waferU(), hid.waferV(), hid.cellU(), hid.cellV(), false);
153  auto xy = hgc.locateCell(hid, false);
154  double xx = (hid.zside() > 0) ? xy.first : -xy.first;
155  double dx = xx - pos.x();
156  double dy = xy.second - pos.y();
157  double diff = std::sqrt(dx * dx + dy * dy);
158  if ((diff > tol) || (!valid1) || (!valid2))
159  pid = "HGCalError";
160  edm::LogVerbatim(pid) << "Hit[" << all << ":" << allSi << ":" << good << "]" << hid
161  << " Wafer Type:Part:Orient:Cassette " << info.type << ":" << info.part << ":"
162  << info.orient << ":" << info.cassette << " at (" << pos.x() << ":" << xx << ":"
163  << dx << ", " << pos.y() << ":" << xy.second << ":" << dy << ", " << pos.z()
164  << ") Valid " << valid1 << ":" << valid2 << " Distance " << diff;
165  }
166  }
167  } else if (id.det() == DetId::HGCalHSc) {
168  ++allSc;
169  HGCScintillatorDetId hid(id);
170  st1 << hid;
171  if ((id.det() == DetId::HGCalHSc) && (nameSense_ == "HGCalHEScintillatorSensitive")) {
172  std::string_view pid =
173  ((hgc.cassetteShiftScintillator(hid.zside(), hid.layer(), hid.iphi())) ? "HGCSim" : "HGCalSim");
174  GlobalPoint pos = geom->getPosition(id);
175  bool valid1 = geom->topology().valid(id);
176  bool valid2 = hgc.isValidTrap(hid.zside(), hid.layer(), hid.ring(), hid.iphi());
177  if ((!valid1) || (!valid2))
178  pid = "HGCalError";
179  int cassette = hgc.cassetteTile(hid.iphi());
180  edm::LogVerbatim(pid) << "Hit[" << all << ":" << allSc << "] " << hid << " Cassette " << cassette << " at ("
181  << pos.x() << ", " << pos.y() << ", " << pos.z() << ") Valid " << valid1 << ":"
182  << valid2;
183  }
184  } else {
185  st1 << std::hex << id.rawId() << std::dec;
186  }
187  if (!valid) {
188  edm::LogVerbatim("HGCalError") << "Invalid ID " << st1.str();
189  ++bad;
190  }
191  }
192  }
193  }
194  edm::LogVerbatim("HGCalSim") << "Total hits = " << all << ":" << nhits << " Good Silicon DetIds = " << allSi << ":"
195  << good << " Scintitllator = " << allSc << " Invalid = " << bad;
196 }
Log< level::Info, true > LogVerbatim
static const TGPicture * info(bool iBackgroundIsBlack)
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
static constexpr int32_t WaferFull
Definition: HGCalTypes.h:35
T sqrt(T t)
Definition: SSEVec.h:23
int32_t waferIndex(int32_t layer, int32_t waferU, int32_t waferV, bool old=false)
unsigned int id
Definition: DetId.h:17
const edm::EDGetTokenT< edm::PCaloHitContainer > tok_calo_
bool isValid() const
Definition: HandleBase.h:70
const edm::ESGetToken< HGCalGeometry, IdealGeometryRecord > geomToken_

◆ beginJob()

void HGCalTestPartialWaferHits::beginJob ( void  )
inlineoverrideprotectedvirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 41 of file HGCalTestPartialWaferHits.cc.

41 {}

◆ endJob()

void HGCalTestPartialWaferHits::endJob ( void  )
inlineoverrideprotectedvirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 42 of file HGCalTestPartialWaferHits.cc.

42 {}

◆ fillDescriptions()

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

Definition at line 89 of file HGCalTestPartialWaferHits.cc.

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

89  {
91  desc.add<std::string>("moduleLabel", "g4SimHits");
92  desc.add<std::string>("caloHitSource", "HGCHitsEE");
93  desc.add<std::string>("nameSense", "HGCalEESensitive");
94  desc.add<std::string>("missingFile", "");
95  descriptions.add("hgcalHitPartialEE", desc);
96 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

Member Data Documentation

◆ caloHitSource_

const std::string HGCalTestPartialWaferHits::caloHitSource_
private

Definition at line 45 of file HGCalTestPartialWaferHits.cc.

◆ dumpDets_

std::vector<int> HGCalTestPartialWaferHits::dumpDets_
private

Definition at line 49 of file HGCalTestPartialWaferHits.cc.

Referenced by analyze().

◆ g4Label_

const std::string HGCalTestPartialWaferHits::g4Label_
private

Definition at line 45 of file HGCalTestPartialWaferHits.cc.

◆ geomToken_

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

Definition at line 47 of file HGCalTestPartialWaferHits.cc.

Referenced by analyze().

◆ missingFile_

const std::string HGCalTestPartialWaferHits::missingFile_
private

Definition at line 45 of file HGCalTestPartialWaferHits.cc.

◆ nameSense_

const std::string HGCalTestPartialWaferHits::nameSense_
private

Definition at line 45 of file HGCalTestPartialWaferHits.cc.

Referenced by analyze(), and HGCalTestPartialWaferHits().

◆ tok_calo_

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

Definition at line 46 of file HGCalTestPartialWaferHits.cc.

Referenced by analyze().

◆ wafers_

std::vector<int> HGCalTestPartialWaferHits::wafers_
private

Definition at line 48 of file HGCalTestPartialWaferHits.cc.

Referenced by analyze().