48 edm::one::SharedResources> {
82 usesResource(
"TFileService");
93 if (!groupHits_) timeUnit_ = 0.000001;
95 std::cout <<
"HGCalTimingAnalyzer:: Group Hits " << groupHits_ <<
" in " 96 << timeUnit_ <<
" IdBeam " << idBeams_.size() <<
":";
97 for (
const auto&
id : idBeams_)
std::cout <<
" " <<
id;
100 if (idBeams_.empty()) idBeams_.push_back(1001);
103 tok_hepMC_ = consumes<edm::HepMCProduct>(tmp0);
105 std::cout <<
"HGCalTimingAnalyzer:: GeneratorSource = " << tmp0 << std::endl;
111 consumes<edm::PCaloHitContainer>(
edm::InputTag(
"g4SimHits", tmp1));
114 << tmp1 << std::endl;
118 consumes<edm::PCaloHitContainer>(
edm::InputTag(
"g4SimHits", tmp1));
120 std::cout <<
"HGCalTimingAnalyzer:: Detector " << detectorBeam_
121 <<
" with tags " << tmp1 << std::endl;
132 desc.
add<
bool>(
"GroupHits",
false);
133 desc.
add<
double>(
"TimeUnit", 0.001);
134 std::vector<int> ids = {1001, 1002, 1003, 1004, 1005};
135 desc.
add<std::vector<int>>(
"IDBeams", ids);
140 descriptions.
add(
"HGCalTimingAnalyzer", desc);
183 for (HepMC::GenEvent::particle_const_iterator
p =
184 myGenEvent->particles_begin();
185 p != myGenEvent->particles_end(); ++
p, ++
k) {
186 std::cout <<
"Particle[" << k <<
"] with p " << (*p)->momentum().rho()
187 <<
" theta " << (*p)->momentum().theta() <<
" phi " 188 << (*p)->momentum().phi() << std::endl;
208 std::vector<PCaloHit> caloHits;
210 if (theCaloHitContainers.
isValid()) {
213 << theCaloHitContainers->size() <<
" hits" << std::endl;
216 caloHits.insert(caloHits.end(), theCaloHitContainers->begin(),
217 theCaloHitContainers->end());
222 <<
" !!!" << std::endl;
227 if (theCaloHitContainers.
isValid()) {
230 << theCaloHitContainers->size() <<
" hits" << std::endl;
233 caloHits.insert(caloHits.end(), theCaloHitContainers->begin(),
234 theCaloHitContainers->end());
239 <<
" !!!" << std::endl;
246 std::vector<PCaloHit>
const&
hits) {
250 std::map<std::pair<uint32_t, uint64_t>, std::pair<double, double>> map_hits;
251 for (
const auto&
hit : hits) {
252 double energy =
hit.energy();
254 uint32_t
id =
hit.
id();
256 int subdet,
zside, layer, sector, subsector, cell;
259 std::pair<int, int> recoLayerCell =
262 subsector, sector, recoLayerCell.first)
265 std::cout <<
"SimHit:Hit[" << i <<
"] Id " << subdet <<
":" << zside
266 <<
":" << layer <<
":" << sector <<
":" << subsector <<
":" 267 << recoLayerCell.first <<
":" << recoLayerCell.second
268 <<
" Energy " << energy <<
" Time " << time << std::endl;
272 int subdet, layer,
x,
y;
274 std::cout <<
"SimHit:Hit[" << i <<
"] Beam Subdet " << subdet <<
" Layer " 275 << layer <<
" x|y " << x <<
":" << y <<
" Energy " << energy
276 <<
" Time " << time << std::endl;
280 std::pair<uint32_t, uint64_t>
key(
id, tid);
281 auto itr = map_hits.find(key);
282 if (itr == map_hits.end()) {
283 map_hits[
key] = std::pair<double, double>(
time, 0.0);
284 itr = map_hits.find(key);
286 energy += (itr->second).
second;
287 map_hits[
key] = std::pair<double, double>((itr->second).
first, energy);
294 std::cout <<
"analyzeSimHits: Finds " << map_hits.size() <<
" hits " 295 <<
" from the Hit Vector of size " << hits.size() <<
" for type " 296 << type << std::endl;
298 for (
const auto& itr : map_hits) {
299 uint32_t
id = (itr.first).
first;
301 double energy = (itr.second).
second;
313 <<
" E: " << energy << std::endl;
323 for (edm::SimTrackContainer::const_iterator simTrkItr = SimTk->begin();
324 simTrkItr != SimTk->end(); simTrkItr++) {
326 std::cout <<
"Track " << simTrkItr->trackId() <<
" Vertex " 327 << simTrkItr->vertIndex() <<
" Type " << simTrkItr->type()
328 <<
" Charge " << simTrkItr->charge() <<
" momentum " 329 << simTrkItr->momentum() <<
" " << simTrkItr->momentum().P()
332 if (vertIndex == -1) {
333 vertIndex = simTrkItr->vertIndex();
334 pBeam_ = simTrkItr->momentum().P();
337 if (vertIndex != -1 && vertIndex < (
int)SimVtx->size()) {
338 edm::SimVertexContainer::const_iterator simVtxItr = SimVtx->begin();
339 for (
int iv = 0; iv < vertIndex; iv++) simVtxItr++;
341 std::cout <<
"Vertex " << vertIndex <<
" position " << simVtxItr->position()
344 xBeam_ = simVtxItr->position().X();
345 yBeam_ = simVtxItr->position().Y();
346 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_