51 edm::SimTrackContainer::const_iterator
parentSimTrack(edm::SimTrackContainer::const_iterator thisTrkItr);
52 bool validSimTrack(
unsigned int simTkId, edm::SimTrackContainer::const_iterator thisTrkItr);
97 edm::LogVerbatim(
"HitParentTest") <<
"Module Label: " << g4Label <<
" Hits: " << hitLabEB <<
", " << hitLabEE
98 <<
", " << hitLabES <<
", " <<
hitLabHC;
107 for (
unsigned int i = 0;
i < 2; ++
i) {
113 std::string dets[7] = {
"EB",
"EE",
"ES",
"HB",
"HE",
"HO",
"HF"};
114 for (
unsigned int i = 0;
i < 7; ++
i) {
131 descriptions.
add(
"HitParentTest", desc);
137 edm::LogVerbatim(
"HitParentTest") <<
"TFileService unavailable: no histograms";
142 for (
unsigned int i = 0;
i < 7; ++
i) {
143 sprintf(name,
"HitType%d",
i);
144 sprintf(title,
"Hit types for %s",
detector[
i].c_str());
146 hitType[
i]->GetXaxis()->SetTitle(title);
147 hitType[
i]->GetYaxis()->SetTitle(
"Hits");
148 sprintf(name,
"RhoVertex%d",
i);
149 sprintf(title,
"#rho of the vertex for %s Hits",
detector[
i].c_str());
151 hitRho[
i]->GetXaxis()->SetTitle(title);
152 hitRho[
i]->GetYaxis()->SetTitle(
"Hits");
153 sprintf(name,
"ZVertex%d",
i);
154 sprintf(title,
"z of the vertex for %s Hits",
detector[
i].c_str());
156 hitZ[
i]->GetXaxis()->SetTitle(title);
157 hitZ[
i]->GetYaxis()->SetTitle(
"Hits");
188 <<
" valid[EE]: " << caloHitEE.
isValid() <<
" valid[ES]: " << caloHitES.
isValid()
189 <<
" valid[HC]: " << caloHitHC.
isValid();
217 edm::LogVerbatim(
"HitParentTest") <<
"HitParentTest::Total number of APD hits seen: "
221 <<
" Total = " << total_num_apd_hits_seen[
depth];
223 <<
" number of APD hits with zero geant track id: "
225 <<
"number of APD hits for which the parent simtrack was not found "
227 <<
"number of APD hits for which no generator particle was "
231 for (
unsigned int det = 0; det < 7; ++det) {
234 <<
"number of hits with zero geant track id: " <<
noParent[det] <<
"\n"
235 <<
"number of hits for which the parent simtrack was not found in "
236 <<
"the simtrack collection: " <<
noSimTrack[det] <<
"\n"
237 <<
"number of hits for which no generator particle was found: "
242 std::vector<int> sorted_pids;
244 sorted_pids.push_back(it->first);
250 edm::LogVerbatim(
"HitParentTest") <<
"HitParentTest::Frequency particle types through the APD "
251 <<
"(pid/frequency):";
252 for (
unsigned i = 0;
i < sorted_pids.size(); ++
i) {
253 int pid = sorted_pids[
i];
254 edm::LogVerbatim(
"HitParentTest") <<
" pid " << std::setw(6) << pid <<
": count " << std::setw(6)
260 for (std::vector<PCaloHit>::const_iterator hit_it = hits.begin(); hit_it != hits.end(); ++hit_it) {
261 int id(type), flag(0);
264 int subdet = id_.
subdet();
267 else if (subdet == static_cast<int>(
HcalOuter))
275 int hit_geant_track_id = hit_it->geantTrackId();
277 if (hit_geant_track_id <= 0) {
284 for (edm::SimTrackContainer::const_iterator simTrkItr =
SimTk->begin(); simTrkItr !=
SimTk->end() && !
found;
286 if (hit_geant_track_id == (
int)(simTrkItr->trackId())) {
292 <<
"[" <<
detector[
type] <<
"] Match = " << match <<
" hit_geant_track_id=" << hit_geant_track_id
293 <<
" particle id=" << simTrkItr->type();
301 int pid = simTrkItr->type();
304 edm::SimTrackContainer::const_iterator oldest_parent_track =
parentSimTrack(simTrkItr);
307 <<
"[" <<
detector[
type] <<
"] Hit pid = " << pid <<
" hit track id = " << hit_geant_track_id
308 <<
" Oldest Parent's Vertex: " << oldest_parent_vertex <<
" rho = " << oldest_parent_vertex.Rho()
309 <<
" Oldest Parent's pid: " << oldest_parent_track->type()
310 <<
" Oldest Parent's track id: " << oldest_parent_track->trackId()
311 <<
"\nHit vertex index: " << simTrkItr->vertIndex() <<
" (tot #vertices: " <<
SimVtx->size() <<
")"
312 <<
"\nHit vertex parent track: " << (*SimVtx)[simTrkItr->vertIndex()].parentIndex()
315 hitRho[
id]->Fill(oldest_parent_vertex.Rho());
316 hitZ[
id]->Fill(oldest_parent_vertex.Z());
330 for (std::vector<PCaloHit>::const_iterator hit_it = hits.begin(); hit_it != hits.end(); ++hit_it) {
331 if (hit_it->depth() ==
depth) {
335 int hit_geant_track_id = hit_it->geantTrackId();
337 if (hit_geant_track_id <= 0) {
342 for (edm::SimTrackContainer::const_iterator simTrkItr =
SimTk->begin(); simTrkItr !=
SimTk->end() && !
found;
344 if (hit_geant_track_id == (
int)(simTrkItr->trackId())) {
349 <<
"APDHIT Match = " << match <<
" hit_geant_track_id = " << hit_geant_track_id
350 <<
" particle id=" << simTrkItr->type();
357 int apd_pid = simTrkItr->type();
370 edm::SimTrackContainer::const_iterator oldest_parent_track =
parentSimTrack(simTrkItr);
373 <<
"APD hit pid = " << apd_pid <<
" APD hit track id = " << hit_geant_track_id
374 <<
" depth = " << hit_it->depth() <<
" OLDEST PARENT'S VERTEX: " << oldest_parent_vertex
375 <<
" rho = " << oldest_parent_vertex.Rho() <<
" OLDEST PARENT'S PID: " << oldest_parent_track->type()
376 <<
" OLDEST PARENT'S track id: " << oldest_parent_track->trackId() <<
"\n"
377 <<
"APD hit vertex index: " << simTrkItr->vertIndex() <<
" (tot #vertices: " <<
SimVtx->size() <<
")"
379 <<
"APD hit vertex parent track: " << (*SimVtx)[simTrkItr->vertIndex()].parentIndex()
393 for (edm::SimTrackContainer::const_iterator simTrkItr =
SimTk->begin(); simTrkItr !=
SimTk->end(); ++simTrkItr) {
394 if ((
int)(simTrkItr->trackId()) ==
id)
402 10000, 10000, 10000, 10000);
404 edm::SimTrackContainer::const_iterator oldest_parent_track =
parentSimTrack(track);
406 int vertex_index = oldest_parent_track->vertIndex();
409 if (vertex_index < 0 || vertex_index >= (
int)(
SimVtx->size()))
410 return invalid_vertex;
412 return (*
SimVtx)[vertex_index].position();
416 edm::SimTrackContainer::const_iterator itr =
SimTk->end();
418 int vertIndex = thisTrkItr->vertIndex();
419 int type = thisTrkItr->type();
420 int charge = (int)thisTrkItr->charge();
421 edm::LogVerbatim(
"HitParentTest") <<
"SimTrackParent:: " << thisTrkItr->trackId() <<
" Vertex " << vertIndex
422 <<
" Type " << type <<
" Charge " <<
charge;
426 else if (vertIndex >= (
int)
SimVtx->size())
429 edm::SimVertexContainer::const_iterator simVtxItr =
SimVtx->begin();
430 for (
int iv = 0;
iv < vertIndex;
iv++)
432 int parent = simVtxItr->parentIndex();
434 if (parent < 0 && simVtxItr != SimVtx->
begin()) {
436 for (simVtxItr =
SimVtx->begin(); simVtxItr !=
SimVtx->end(); ++simVtxItr) {
437 if (simVtxItr->parentIndex() > 0) {
439 double dist = pos2.P();
441 parent = simVtxItr->parentIndex();
447 for (edm::SimTrackContainer::const_iterator simTrkItr =
SimTk->begin(); simTrkItr !=
SimTk->end(); simTrkItr++) {
448 if ((
int)simTrkItr->trackId() == parent && simTrkItr != thisTrkItr)
456 edm::LogVerbatim(
"HitParentTest") <<
"Inside validSimTrack: trackId " << thisTrkItr->trackId() <<
" vtxIndex "
457 << thisTrkItr->vertIndex() <<
" to be matched to " << simTkId;
460 if (thisTrkItr->trackId() == simTkId)
464 int vertIndex = thisTrkItr->vertIndex();
465 if (vertIndex == -1 || vertIndex >= (
int)
SimVtx->size())
467 edm::SimVertexContainer::const_iterator simVtxItr =
SimVtx->begin();
468 for (
int iv = 0;
iv < vertIndex;
iv++)
470 int parent = simVtxItr->parentIndex();
471 edm::LogVerbatim(
"HitParentTest") <<
"validSimTrack:: parent index " << parent <<
" ";
472 if (parent < 0 && simVtxItr != SimVtx->
begin()) {
474 for (simVtxItr =
SimVtx->begin(); simVtxItr !=
SimVtx->end(); ++simVtxItr) {
475 if (simVtxItr->parentIndex() > 0) {
477 double dist = pos2.P();
479 parent = simVtxItr->parentIndex();
486 for (edm::SimTrackContainer::const_iterator simTrkItr =
SimTk->begin(); simTrkItr !=
SimTk->end(); simTrkItr++) {
487 if ((
int)simTrkItr->trackId() == parent && simTrkItr != thisTrkItr)
static const std::string kSharedResource
Log< level::Info, true > LogVerbatim
EventNumber_t event() const
edm::EDGetTokenT< edm::SimTrackContainer > tok_tk_
T getUntrackedParameter(std::string const &, T const &) const
const edm::EventSetup & c
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
uint16_t *__restrict__ id
edm::EDGetTokenT< edm::SimVertexContainer > tok_vtx_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
unsigned int noGenParticle[7]
#define DEFINE_FWK_MODULE(type)
bool operator()(int pid1, int pid2) const
unsigned int num_apd_hits_no_simtrack[2]
const std::map< int, unsigned > & particle_type_count
edm::SimTrackContainer::const_iterator parentSimTrack(edm::SimTrackContainer::const_iterator thisTrkItr)
unsigned int noSimTrack[7]
T * make(const Args &...args) const
make new ROOT object
edm::Handle< edm::SimVertexContainer > SimVtx
constexpr HcalSubdetector subdet() const
get the subdetector
unsigned int num_apd_hits_no_gen_particle[2]
void analyze(const edm::Event &e, const edm::EventSetup &c) override
edm::EDGetTokenT< edm::PCaloHitContainer > tok_ee_
edm::Handle< edm::SimTrackContainer > SimTk
void endRun(edm::Run const &, edm::EventSetup const &) override
std::map< int, unsigned > particle_type_count
HitParentTest(const edm::ParameterSet &ps)
edm::EDGetTokenT< edm::PCaloHitContainer > tok_eb_
bool validSimTrack(unsigned int simTkId, edm::SimTrackContainer::const_iterator thisTrkItr)
unsigned int num_apd_hits_no_parent[2]
math::XYZTLorentzVectorD getOldestParentVertex(edm::SimTrackContainer::const_iterator track)
HitParentTestComparison(const std::map< int, unsigned > &_particle_type_count)
edm::EDGetTokenT< edm::PCaloHitContainer > tok_hc_
void beginRun(edm::Run const &, edm::EventSetup const &) override
void analyzeHits(const std::vector< PCaloHit > &, int type)
bool simTrackPresent(int id)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
unsigned int total_num_apd_hits_seen[2]
void analyzeAPDHits(const std::vector< PCaloHit > &, int depth)
unsigned int totalHits[7]
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
edm::EDGetTokenT< edm::PCaloHitContainer > tok_es_
~HitParentTest() override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)