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)),
88 idBeams_((iConfig.getParameter<std::
vector<int>>(
"IDBeams")).
empty()
90 : (iConfig.getParameter<std::
vector<int>>(
"IDBeams"))),
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);
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;
229 for (
const auto&
hit : hits) {
231 double time =
hit.time();
232 uint32_t
id =
hit.
id();
234 int subdet,
zside,
layer, sector, subsector, cell;
236 std::pair<int, int> recoLayerCell =
hgcons_->
simToReco(cell, layer, sector,
true);
240 edm::LogVerbatim(
"HGCSim") <<
"SimHit:Hit[" << i <<
"] Id " << subdet <<
":" << zside <<
":" << layer <<
":"
241 << sector <<
":" << subsector <<
":" << recoLayerCell.first <<
":"
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);
259 energy += (itr->second).
second;
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;
272 double time = (itr.second).
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
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
const HGCalDDDConstants * hgcons_
uint16_t *__restrict__ id
void analyze(edm::Event const &, edm::EventSetup const &) override
#define DEFINE_FWK_MODULE(type)
const edm::ESGetToken< HGCalDDDConstants, IdealGeometryRecord > tokDDD_
constexpr uint32_t rawId() const
get the raw id
const edm::EDGetTokenT< edm::PCaloHitContainer > tok_hitsBeam_
T * make(const Args &...args) const
make new ROOT object
const std::vector< int > idBeamDef_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
constexpr std::array< uint8_t, layerIndexSize > layer
const edm::InputTag labelGen_
bool getData(T &iHolder) const
U second(std::pair< T, U > const &p)
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
HGCalTimingAnalyzer(edm::ParameterSet const &)
std::pair< int, int > simToReco(int cell, int layer, int mod, bool half) const
std::vector< float > simHitCellEnEE_
unsigned int layers(bool reco) const
const std::vector< int > idBeams_
tuple key
prepare the HTCondor submission files and eventually submit them
const std::string labelHitBeam_
const edm::EDGetTokenT< edm::HepMCProduct > tok_hepMC_
const std::string labelHitEE_
std::vector< float > simHitCellTmBeam_
const std::string detectorBeam_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::vector< float > simHitCellEnBeam_
const edm::EDGetTokenT< edm::PCaloHitContainer > tok_hitsEE_
std::vector< uint32_t > simHitCellIdBeam_
std::vector< float > simHitCellTmEE_
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
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_
void beginRun(edm::Run const &, edm::EventSetup const &) override
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)