83 : detectorEE_(iConfig.getParameter<
std::
string>(
"DetectorEE")),
84 detectorBeam_(iConfig.getParameter<
std::
string>(
"DetectorBeam")),
85 groupHits_(iConfig.getParameter<
bool>(
"GroupHits")),
86 timeUnit_((!groupHits_) ? 0.000001 : (iConfig.getParameter<double>(
"TimeUnit"))),
87 doTree_(iConfig.getUntrackedParameter<
bool>(
"DoTree",
false)),
93 labelGen_(iConfig.getParameter<
edm::
InputTag>(
"GeneratorSrc")),
94 labelHitEE_(iConfig.getParameter<
std::
string>(
"CaloHitSrcEE")),
95 labelHitBeam_(iConfig.getParameter<
std::
string>(
"CaloHitSrcBeam")),
101 usesResource(
"TFileService");
107 std::ostringstream st1;
124 desc.add<
bool>(
"GroupHits",
false);
125 desc.add<
double>(
"TimeUnit", 0.001);
126 std::vector<int> ids = {1001, 1002, 1003, 1004, 1005};
127 desc.add<std::vector<int>>(
"IDBeams", ids);
128 desc.addUntracked<
bool>(
"DoTree",
true);
132 descriptions.
add(
"HGCalTimingAnalyzer",
desc);
170 for (HepMC::GenEvent::particle_const_iterator
p = myGenEvent->particles_begin();
p != myGenEvent->particles_end();
172 edm::LogVerbatim(
"HGCSim") <<
"Particle[" <<
k <<
"] with p " << (*p)->momentum().rho() <<
" theta " 173 << (*p)->momentum().theta() <<
" phi " << (*p)->momentum().phi();
190 std::vector<PCaloHit> caloHits;
192 if (theCaloHitContainers.
isValid()) {
198 caloHits.insert(caloHits.end(), theCaloHitContainers->begin(), theCaloHitContainers->end());
207 if (caloHitContainerBeam.
isValid()) {
213 caloHits.insert(caloHits.end(), caloHitContainerBeam->begin(), caloHitContainerBeam->end());
228 std::map<std::pair<uint32_t, uint64_t>, std::pair<double, double>> map_hits;
232 uint32_t
id =
hit.
id();
242 << recoLayerCell.second <<
" Energy " <<
energy <<
" Time " <<
time;
248 edm::LogVerbatim(
"HGCSim") <<
"SimHit:Hit[" <<
i <<
"] Beam Subdet " << subdet <<
" Layer " <<
layer <<
" x|y " 249 <<
x <<
":" <<
y <<
" Energy " <<
energy <<
" Time " <<
time;
253 std::pair<uint32_t, uint64_t>
key(
id, tid);
254 auto itr = map_hits.find(
key);
255 if (itr == map_hits.end()) {
256 map_hits[
key] = std::pair<double, double>(
time, 0.0);
257 itr = map_hits.find(
key);
260 map_hits[
key] = std::pair<double, double>((itr->second).
first,
energy);
267 edm::LogVerbatim(
"HGCSim") <<
"analyzeSimHits: Finds " << map_hits.size() <<
" hits " 268 <<
" from the Hit Vector of size " <<
hits.size() <<
" for type " <<
type;
270 for (
const auto& itr : map_hits) {
271 uint32_t
id = (itr.first).
first;
293 for (edm::SimTrackContainer::const_iterator simTrkItr = SimTk->begin(); simTrkItr != SimTk->end(); simTrkItr++) {
295 edm::LogVerbatim(
"HGCSim") <<
"Track " << simTrkItr->trackId() <<
" Vertex " << simTrkItr->vertIndex() <<
" Type " 296 << simTrkItr->type() <<
" Charge " << simTrkItr->charge() <<
" momentum " 297 << simTrkItr->momentum() <<
" " << simTrkItr->momentum().P();
299 if (vertIndex == -1) {
300 vertIndex = simTrkItr->vertIndex();
301 pBeam_ = simTrkItr->momentum().P();
304 if (vertIndex != -1 && vertIndex < (
int)SimVtx->size()) {
305 edm::SimVertexContainer::const_iterator simVtxItr = SimVtx->begin();
306 for (
int iv = 0;
iv < vertIndex;
iv++)
309 edm::LogVerbatim(
"HGCSim") <<
"Vertex " << vertIndex <<
" position " << simVtxItr->position();
311 xBeam_ = simVtxItr->position().X();
312 yBeam_ = simVtxItr->position().Y();
313 zBeam_ = simVtxItr->position().Z();
Log< level::Info, true > LogVerbatim
std::vector< PCaloHit > PCaloHitContainer
const HGCalTBDDDConstants * hgcons_
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
void analyze(edm::Event const &, edm::EventSetup const &) override
const edm::EDGetTokenT< edm::PCaloHitContainer > tok_hitsBeam_
const edm::ESGetToken< HGCalTBDDDConstants, IdealGeometryRecord > tokDDD_
const std::vector< int > idBeamDef_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const edm::InputTag labelGen_
U second(std::pair< T, U > const &p)
HGCalTimingAnalyzer(edm::ParameterSet const &)
std::vector< float > simHitCellEnEE_
const std::vector< int > idBeams_
const std::string labelHitBeam_
const edm::EDGetTokenT< edm::HepMCProduct > tok_hepMC_
#define DEFINE_FWK_MODULE(type)
const std::string labelHitEE_
std::vector< float > simHitCellTmBeam_
const std::string detectorBeam_
std::vector< float > simHitCellEnBeam_
const edm::EDGetTokenT< edm::PCaloHitContainer > tok_hitsEE_
std::vector< uint32_t > simHitCellIdBeam_
std::vector< float > simHitCellTmEE_
const HepMC::GenEvent * GetEvent() const
std::vector< uint32_t > simHitCellIdEE_
void endRun(edm::Run const &, edm::EventSetup const &) override
edm::Service< TFileService > fs_
~HGCalTimingAnalyzer() override=default
unsigned long long uint64_t
constexpr uint32_t rawId() const
get the raw id
const edm::EDGetTokenT< edm::SimVertexContainer > tok_simVtx_
std::vector< SimVertex > SimVertexContainer
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const edm::EDGetTokenT< edm::SimTrackContainer > tok_simTk_
const std::string detectorEE_
unsigned int layers(bool reco) const
void beginRun(edm::Run const &, edm::EventSetup const &) override
T * make(const Args &...args) const
make new ROOT object
static void unpackIndex(const uint32_t &idx, int &det, int &lay, int &x, int &y)
Log< level::Warning, false > LogWarning
void analyzeSimHits(int type, std::vector< PCaloHit > const &hits)
std::vector< SimTrack > SimTrackContainer
static void unpackHexagonIndex(const uint32_t &idx, int &subdet, int &z, int &lay, int &wafer, int &celltyp, int &cell)
void analyzeSimTracks(edm::Handle< edm::SimTrackContainer > const &SimTk, edm::Handle< edm::SimVertexContainer > const &SimVtx)
std::pair< int, int > simToReco(int cell, int layer, int mod, bool half) const