79 usesResource(
"TFileService");
93 std::cout <<
"HGCalTimingAnalyzer:: Group Hits " << groupHits_ <<
" in " << timeUnit_ <<
" IdBeam " << idBeams_.size()
95 for (
const auto&
id : idBeams_)
100 idBeams_.push_back(1001);
103 tok_hepMC_ = consumes<edm::HepMCProduct>(tmp0);
105 std::cout <<
"HGCalTimingAnalyzer:: GeneratorSource = " << tmp0 << std::endl;
112 std::cout <<
"HGCalTimingAnalyzer:: Detector " <<
detectorEE_ <<
" with tags " << tmp1 << std::endl;
117 std::cout <<
"HGCalTimingAnalyzer:: Detector " << detectorBeam_ <<
" with tags " << tmp1 << std::endl;
127 desc.
add<
bool>(
"GroupHits",
false);
128 desc.
add<
double>(
"TimeUnit", 0.001);
129 std::vector<int>
ids = {1001, 1002, 1003, 1004, 1005};
130 desc.
add<std::vector<int>>(
"IDBeams",
ids);
135 descriptions.
add(
"HGCalTimingAnalyzer", desc);
176 for (HepMC::GenEvent::particle_const_iterator
p = myGenEvent->particles_begin();
p != myGenEvent->particles_end();
178 std::cout <<
"Particle[" << k <<
"] with p " << (*p)->momentum().rho() <<
" theta " << (*p)->momentum().theta()
179 <<
" phi " << (*p)->momentum().phi() << std::endl;
199 std::vector<PCaloHit> caloHits;
201 if (theCaloHitContainers.
isValid()) {
203 std::cout <<
"PcalohitContainer for " <<
detectorEE_ <<
" has " << theCaloHitContainers->size() <<
" hits" 207 caloHits.insert(caloHits.end(), theCaloHitContainers->begin(), theCaloHitContainers->end());
216 if (theCaloHitContainers.
isValid()) {
218 std::cout <<
"PcalohitContainer for " <<
detectorBeam_ <<
" has " << theCaloHitContainers->size() <<
" hits" 222 caloHits.insert(caloHits.end(), theCaloHitContainers->begin(), theCaloHitContainers->end());
237 std::map<std::pair<uint32_t, uint64_t>, std::pair<double, double>> map_hits;
238 for (
const auto&
hit : hits) {
241 uint32_t
id =
hit.
id();
243 int subdet,
zside, layer, sector, subsector, cell;
245 std::pair<int, int> recoLayerCell =
hgcons_->
simToReco(cell, layer, sector,
true);
249 std::cout <<
"SimHit:Hit[" << i <<
"] Id " << subdet <<
":" << zside <<
":" << layer <<
":" << sector <<
":" 250 << subsector <<
":" << recoLayerCell.first <<
":" << recoLayerCell.second <<
" Energy " << energy
251 <<
" Time " << time << std::endl;
255 int subdet, layer,
x,
y;
257 std::cout <<
"SimHit:Hit[" << i <<
"] Beam Subdet " << subdet <<
" Layer " << layer <<
" x|y " << x <<
":" << y
258 <<
" Energy " << energy <<
" Time " << time << std::endl;
262 std::pair<uint32_t, uint64_t>
key(
id, tid);
263 auto itr = map_hits.find(key);
264 if (itr == map_hits.end()) {
265 map_hits[
key] = std::pair<double, double>(
time, 0.0);
266 itr = map_hits.find(key);
268 energy += (itr->second).
second;
269 map_hits[
key] = std::pair<double, double>((itr->second).
first, energy);
276 std::cout <<
"analyzeSimHits: Finds " << map_hits.size() <<
" hits " 277 <<
" from the Hit Vector of size " << hits.size() <<
" for type " << type << std::endl;
279 for (
const auto& itr : map_hits) {
280 uint32_t
id = (itr.first).
first;
293 std::cout <<
"SimHit::ID: " << std::hex <<
id <<
std::dec <<
" T: " << time <<
" E: " << energy << std::endl;
302 for (edm::SimTrackContainer::const_iterator simTrkItr = SimTk->begin(); simTrkItr != SimTk->end(); simTrkItr++) {
304 std::cout <<
"Track " << simTrkItr->trackId() <<
" Vertex " << simTrkItr->vertIndex() <<
" Type " 305 << simTrkItr->type() <<
" Charge " << simTrkItr->charge() <<
" momentum " << simTrkItr->momentum() <<
" " 306 << simTrkItr->momentum().P() << std::endl;
308 if (vertIndex == -1) {
309 vertIndex = simTrkItr->vertIndex();
310 pBeam_ = simTrkItr->momentum().P();
313 if (vertIndex != -1 && vertIndex < (
int)SimVtx->size()) {
314 edm::SimVertexContainer::const_iterator simVtxItr = SimVtx->begin();
315 for (
int iv = 0; iv < vertIndex; iv++)
318 std::cout <<
"Vertex " << vertIndex <<
" position " << simVtxItr->position() << std::endl;
320 xBeam_ = simVtxItr->position().X();
321 yBeam_ = simVtxItr->position().Y();
322 zBeam_ = simVtxItr->position().Z();
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
const HGCalDDDConstants * hgcons_
~HGCalTimingAnalyzer() override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void analyze(edm::Event const &, edm::EventSetup const &) override
constexpr uint32_t rawId() const
get the raw id
edm::EDGetTokenT< edm::SimTrackContainer > tok_simTk_
edm::EDGetTokenT< edm::PCaloHitContainer > tok_hitsEE_
T * make(const Args &...args) const
make new ROOT object
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
U second(std::pair< T, U > const &p)
HGCalTimingAnalyzer(edm::ParameterSet const &)
edm::EDGetTokenT< edm::HepMCProduct > tok_hepMC_
std::pair< int, int > simToReco(int cell, int layer, int mod, bool half) const
std::vector< float > simHitCellEnEE_
#define DEFINE_FWK_MODULE(type)
unsigned int layers(bool reco) const
std::vector< float > simHitCellTmBeam_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::vector< int > idBeams_
std::vector< float > simHitCellEnBeam_
std::vector< uint32_t > simHitCellIdBeam_
std::vector< float > simHitCellTmEE_
std::vector< uint32_t > simHitCellIdEE_
void endRun(edm::Run const &, edm::EventSetup const &) override
const HepMC::GenEvent * GetEvent() const
edm::Service< TFileService > fs_
unsigned long long uint64_t
edm::EDGetTokenT< edm::SimVertexContainer > tok_simVtx_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void beginRun(edm::Run const &, edm::EventSetup const &) override
static void unpackIndex(const uint32_t &idx, int &det, int &lay, int &x, int &y)
std::string detectorBeam_
void analyzeSimHits(int type, std::vector< PCaloHit > const &hits)
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)
edm::EDGetTokenT< edm::PCaloHitContainer > tok_hitsBeam_