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;
113 <<
" with tags " << tmp1 << std::endl;
118 std::cout <<
"HGCalTimingAnalyzer:: Detector " << detectorBeam_
119 <<
" with tags " << tmp1 << std::endl;
129 desc.
add<
bool>(
"GroupHits",
false);
130 desc.
add<
double>(
"TimeUnit",0.001);
131 std::vector<int>
ids = {1001,1002,1003,1004,1005};
132 desc.
add<std::vector<int>>(
"IDBeams",
ids);
137 descriptions.
add(
"HGCalTimingAnalyzer",desc);
179 const HepMC::GenEvent * myGenEvent = evtMC->
GetEvent();
181 for (HepMC::GenEvent::particle_const_iterator
p = myGenEvent->particles_begin();
182 p != myGenEvent->particles_end(); ++
p, ++
k) {
183 std::cout <<
"Particle[" << k <<
"] with p " << (*p)->momentum().rho()
184 <<
" theta " << (*p)->momentum().theta() <<
" phi " 185 << (*p)->momentum().phi() << std::endl;
202 std::vector<PCaloHit> caloHits;
204 if (theCaloHitContainers.
isValid()) {
207 << theCaloHitContainers->size() <<
" hits" << std::endl;
210 caloHits.insert(caloHits.end(), theCaloHitContainers->begin(),
211 theCaloHitContainers->end());
216 <<
" !!!" << std::endl;
221 if (theCaloHitContainers.
isValid()) {
224 << theCaloHitContainers->size() <<
" hits" << std::endl;
227 caloHits.insert(caloHits.end(), theCaloHitContainers->begin(),
228 theCaloHitContainers->end());
233 <<
" !!!" << std::endl;
241 std::vector<PCaloHit>
const&
hits) {
246 std::map<std::pair<uint32_t,uint64_t>,std::pair<double,double> > map_hits;
247 for (
const auto&
hit : hits) {
248 double energy =
hit.energy();
250 uint32_t
id =
hit.
id();
252 int subdet,
zside, layer, sector, subsector, cell;
255 std::pair<int,int> recoLayerCell =
hgcons_->
simToReco(cell,layer,sector,
true);
257 recoLayerCell.second,subsector,sector,
258 recoLayerCell.first).
rawId();
260 std::cout <<
"SimHit:Hit[" << i <<
"] Id " << subdet <<
":" << zside
261 <<
":" << layer <<
":" << sector <<
":" << subsector <<
":" 262 << recoLayerCell.first <<
":" << recoLayerCell.second
263 <<
" Energy " << energy <<
" Time " << time << std::endl;
267 int subdet, layer,
x,
y;
269 std::cout <<
"SimHit:Hit[" << i <<
"] Beam Subdet " << subdet
270 <<
" Layer " << layer <<
" x|y " << x <<
":" << y
271 <<
" Energy " << energy <<
" Time " << time << std::endl;
275 std::pair<uint32_t,uint64_t>
key(
id,tid);
276 auto itr = map_hits.find(key);
277 if (itr == map_hits.end()) {
278 map_hits[
key] = std::pair<double,double>(
time,0.0);
279 itr = map_hits.find(key);
281 energy += (itr->second).
second;
282 map_hits[
key] = std::pair<double,double>((itr->second).
first,energy);
289 std::cout <<
"analyzeSimHits: Finds " << map_hits.size() <<
" hits " 290 <<
" from the Hit Vector of size " << hits.size() <<
" for type " 291 << type << std::endl;
293 for (
const auto& itr: map_hits) {
294 uint32_t
id = (itr.first).
first;
296 double energy = (itr.second).
second;
308 <<
" E: " << energy << std::endl;
319 for (edm::SimTrackContainer::const_iterator simTrkItr = SimTk->begin();
320 simTrkItr!= SimTk->end(); simTrkItr++) {
322 std::cout <<
"Track " << simTrkItr->trackId() <<
" Vertex " 323 << simTrkItr->vertIndex() <<
" Type " << simTrkItr->type()
324 <<
" Charge " << simTrkItr->charge() <<
" momentum " 325 << simTrkItr->momentum() <<
" " << simTrkItr->momentum().P()
328 if (vertIndex == -1) {
329 vertIndex = simTrkItr->vertIndex();
330 pBeam_ = simTrkItr->momentum().P();
333 if (vertIndex != -1 && vertIndex < (
int)SimVtx->size()) {
334 edm::SimVertexContainer::const_iterator simVtxItr= SimVtx->begin();
335 for (
int iv=0; iv<vertIndex; iv++) simVtxItr++;
337 std::cout <<
"Vertex " << vertIndex <<
" position " 338 << simVtxItr->position() << std::endl;
340 xBeam_ = simVtxItr->position().X();
341 yBeam_ = simVtxItr->position().Y();
342 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
#define DEFINE_FWK_MODULE(type)
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)
uint32_t rawId() const
get the raw id
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_
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_