10 verboseSimTrack_ =
simTrack.getParameter<
int>(
"verbose");
20 iEvent.getByToken(simTrackInput_, simTracksH_);
21 iEvent.getByToken(simVertexInput_, simVerticesH_);
22 iEvent.getByToken(simHitInput_, simHitsH_);
27 simTracks_ = *simTracksH_.product();
28 simVertices_ = *simVerticesH_.product();
29 simHits_ = *simHitsH_.product();
33 trkid_to_index_.clear();
34 for (
const auto&
t : simTracks_) {
35 trkid_to_index_[
t.trackId()] = no;
39 track_ids_ = getIdsOfSimTrackShower(
track.trackId(), simTracks_, simVertices_);
40 if (verboseSimTrack_) {
41 edm::LogInfo(
"MuonSimHitMatcher") <<
"Printing track_ids" << std::endl;
42 for (
const auto&
id : track_ids_)
43 edm::LogInfo(
"MuonSimHitMatcher") <<
"id: " <<
id << std::endl;
50 vector<unsigned int>
result;
51 result.push_back(initial_trk_id);
56 for (
const auto&
t : simTracks_) {
59 bool is_child =
false;
63 if (simVertices_[last_trk.
vertIndex()].noParent())
66 unsigned parentId = simVertices_[last_trk.
vertIndex()].parentIndex();
67 if (parentId == initial_trk_id) {
72 const auto&
association = trkid_to_index_.find(parentId);
88 if (detid_to_hits_.find(detid) == detid_to_hits_.end())
90 return detid_to_hits_.at(detid);
94 if (chamber_to_hits_.find(detid) == chamber_to_hits_.end())
96 return chamber_to_hits_.at(detid);
100 if (sim_hits.empty())
103 float sumx, sumy, sumz;
104 sumx = sumy = sumz = 0.f;
106 for (
const auto&
h : sim_hits) {
108 const GlobalPoint& gp = geometry_->idToDet(
h.detUnitId())->surface().toGlobal(lp);
120 if (sim_hits.empty())
123 float sumx, sumy, sumz;
124 sumx = sumy = sumz = 0.f;
126 for (
const auto&
h : sim_hits) {
128 const GlobalVector& gv = geometry_->idToDet(
h.detUnitId())->surface().toGlobal(lv);
141 trkid_to_index_.clear();
143 detid_to_hits_.clear();
144 chamber_to_hits_.clear();
const edm::PSimHitContainer & hitsInChamber(unsigned int) const
GlobalPoint simHitsMeanPosition(const edm::PSimHitContainer &sim_hits) const
GlobalVector simHitsMeanMomentum(const edm::PSimHitContainer &sim_hits) const
ParameterSet const & getParameterSet(std::string const &) const
Global3DPoint GlobalPoint
const edm::PSimHitContainer & simHits(int) const
int vertIndex() const
index of the vertex in the Event container (-1 if no vertex)
std::tuple< layerClusterToCaloParticle, caloParticleToLayerCluster > association
Log< level::Info, false > LogInfo
std::vector< SimVertex > SimVertexContainer
void match(const SimTrack &t, const SimVertex &v)
do the matching
const edm::PSimHitContainer & hitsInDetId(unsigned int) const
MuonSimHitMatcher(const edm::ParameterSet &iPS, edm::ConsumesCollector &&iC)
std::vector< PSimHit > PSimHitContainer
std::vector< unsigned int > getIdsOfSimTrackShower(unsigned trk_id, const edm::SimTrackContainer &simTracks, const edm::SimVertexContainer &simVertices)
void init(const edm::Event &e, const edm::EventSetup &eventSetup)
initialize the event
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
std::vector< SimTrack > SimTrackContainer
Global3DVector GlobalVector