87 #include "HepPDT/ParticleID.hh"
95 #include <unordered_set>
96 #include <unordered_map>
111 using TrackingParticleRefKeyToIndex = std::unordered_map<reco::RecoToSimCollection::index_type, size_t>;
112 using TrackingVertexRefKeyToIndex = TrackingParticleRefKeyToIndex;
113 using SimHitFullKey = std::pair<TrackPSimHitRef::key_type, edm::ProductID>;
114 using SimHitRefKeyToIndex = std::map<SimHitFullKey, size_t>;
115 using TrackingParticleRefKeyToCount = TrackingParticleRefKeyToIndex;
132 return "UNKNOWN TRACKER HIT TYPE";
136 struct ProductIDSetPrinter {
137 ProductIDSetPrinter(
const std::set<edm::ProductID>& set) : set_(set) {}
139 void print(std::ostream& os)
const {
140 for (
const auto&
item : set_) {
145 const std::set<edm::ProductID>& set_;
147 std::ostream&
operator<<(std::ostream& os,
const ProductIDSetPrinter&
o) {
151 template <
typename T>
152 struct ProductIDMapPrinter {
153 ProductIDMapPrinter(
const std::map<edm::ProductID, T>&
map) : map_(
map) {}
155 void print(std::ostream& os)
const {
156 for (
const auto&
item : map_) {
157 os <<
item.first <<
" ";
161 const std::map<edm::ProductID, T>& map_;
163 template <
typename T>
164 auto make_ProductIDMapPrinter(
const std::map<edm::ProductID, T>&
map) {
165 return ProductIDMapPrinter<T>(
map);
167 template <
typename T>
168 std::ostream&
operator<<(std::ostream& os,
const ProductIDMapPrinter<T>&
o) {
173 template <
typename T>
174 struct VectorPrinter {
175 VectorPrinter(
const std::vector<T>& vec) : vec_(vec) {}
177 void print(std::ostream& os)
const {
178 for (
const auto&
item : vec_) {
183 const std::vector<T>& vec_;
185 template <
typename T>
186 auto make_VectorPrinter(
const std::vector<T>& vec) {
187 return VectorPrinter<T>(vec);
189 template <
typename T>
190 std::ostream&
operator<<(std::ostream& os,
const VectorPrinter<T>&
o) {
195 void checkProductID(
const std::set<edm::ProductID>& set,
const edm::ProductID&
id,
const char*
name) {
196 if (set.find(
id) == set.end())
198 <<
"Got " <<
name <<
" with a hit with ProductID " <<
id
199 <<
" which does not match to the set of ProductID's for the hits: " << ProductIDSetPrinter(set)
200 <<
". Usually this is caused by a wrong hit collection in the configuration.";
203 template <
typename SimLink,
typename Func>
206 if (
link.channel() == channel) {
213 template <
typename... Args>
214 void call_nop(Args&&...
args) {}
216 template <
typename...
Types>
223 unsigned int operator[](
size_t i)
const {
return std::get<0>(content_)[
i]; }
225 template <
typename... Args>
226 void book(Args&&...
args) {
227 impl([&](
auto& vec) { vec.book(std::forward<Args>(
args)...); });
230 template <
typename... Args>
231 void push_back(Args&&...
args) {
232 impl([&](
auto& vec) { vec.push_back(std::forward<Args>(
args)...); });
235 template <
typename... Args>
236 void resize(Args&&...
args) {
237 impl([&](
auto& vec) { vec.resize(std::forward<Args>(
args)...); });
240 template <
typename... Args>
241 void set(Args&&...
args) {
242 impl([&](
auto& vec) { vec.set(std::forward<Args>(
args)...); });
246 impl([&](
auto& vec) { vec.clear(); });
251 template <
typename F>
253 impl2(std::index_sequence_for<Types...>{}, std::forward<F>(
func));
261 template <std::size_t... Is,
typename F>
262 void impl2(std::index_sequence<Is...>,
F&&
func) {
263 call_nop((
func(std::get<Is>(content_)), 0)...);
266 std::tuple<
Types...> content_;
269 std::map<unsigned int, double> chargeFraction(
const SiPixelCluster& cluster,
272 std::map<unsigned int, double> simTrackIdToAdc;
274 auto idetset = digiSimLink.
find(detId);
275 if (idetset == digiSimLink.
end())
276 return simTrackIdToAdc;
280 for (
int iPix = 0; iPix != cluster.
size(); ++iPix) {
284 forEachMatchedSimLink(*idetset, channel, [&](
const PixelDigiSimLink& simLink) {
290 for (
auto& pair : simTrackIdToAdc) {
294 pair.second /= adcSum;
297 return simTrackIdToAdc;
300 std::map<unsigned int, double> chargeFraction(
const SiStripCluster& cluster,
303 std::map<unsigned int, double> simTrackIdToAdc;
305 auto idetset = digiSimLink.
find(detId);
306 if (idetset == digiSimLink.
end())
307 return simTrackIdToAdc;
319 for (
const auto& pair : simTrackIdToAdc) {
320 simTrackIdToAdc[pair.first] = (adcSum != 0. ? pair.second / adcSum : 0.);
323 return simTrackIdToAdc;
329 std::map<unsigned int, double> simTrackIdToAdc;
330 throw cms::Exception(
"LogicError") <<
"Not possible to use StripDigiSimLink with Phase2TrackerCluster1D! ";
331 return simTrackIdToAdc;
339 std::map<unsigned int, double> simTrackIdToAdc;
340 return simTrackIdToAdc;
343 struct TrackTPMatch {
345 int countClusters = 0;
350 const TrackingParticleRefKeyToIndex& tpKeyToIndex) {
356 std::vector<OmniClusterRef>
clusters =
359 std::unordered_map<int, Count>
count;
360 for (
size_t iCluster = 0,
end =
clusters.size(); iCluster <
end; ++iCluster) {
361 const auto& clusterRef =
clusters[iCluster];
364 for (
auto ip =
range.first; ip !=
range.second; ++ip) {
365 const auto tpKey = ip->second.key();
366 if (tpKeyToIndex.find(tpKey) == tpKeyToIndex.end())
369 auto& elem =
count[tpKey];
371 elem.innermostHit =
std::min(elem.innermostHit, iCluster);
380 for (
auto& keyCount :
count) {
381 if (keyCount.second.clusters > bestCount ||
382 (keyCount.second.clusters == bestCount && keyCount.second.innermostHit < bestInnermostHit)) {
383 best.key = keyCount.first;
384 best.countClusters = bestCount = keyCount.second.clusters;
385 bestInnermostHit = keyCount.second.innermostHit;
389 LogTrace(
"TrackingNtuple") <<
"findBestMatchingTrackingParticle key " << best.key;
394 TrackTPMatch findMatchingTrackingParticleFromFirstHit(
const reco::Track&
track,
396 const TrackingParticleRefKeyToIndex& tpKeyToIndex) {
399 std::vector<OmniClusterRef>
clusters =
405 auto operateCluster = [&](
const auto& clusterRef,
const auto&
func) {
407 for (
auto ip =
range.first; ip !=
range.second; ++ip) {
408 const auto tpKey = ip->second.key();
409 if (tpKeyToIndex.find(tpKey) == tpKeyToIndex.end())
415 std::vector<unsigned int>
418 operateCluster(*iCluster, [&](
unsigned int tpKey) { validTPs.push_back(tpKey); });
419 if (validTPs.empty()) {
423 ++best.countClusters;
425 std::vector<bool> foundTPs(validTPs.size(),
false);
426 for (
auto iEnd =
clusters.end(); iCluster != iEnd; ++iCluster) {
427 const auto& clusterRef = *iCluster;
430 operateCluster(clusterRef, [&](
unsigned int tpKey) {
432 if (
found != cend(validTPs)) {
438 auto iTP = validTPs.size();
442 if (!foundTPs[iTP]) {
443 validTPs.erase(validTPs.begin() + iTP);
444 foundTPs.erase(foundTPs.begin() + iTP);
447 if (!validTPs.empty()) {
451 best.key = validTPs[0];
457 ++best.countClusters;
461 return best.countClusters >= 3 ? best : TrackTPMatch();
502 if (
i.tpKey ==
j.tpKey) {
504 return i.detId <
j.detId;
506 return i.tof <
j.tof;
508 return i.tpKey <
j.tpKey;
514 const TrackingParticleRefKeyToIndex& tpKeyToIndex,
519 const SimHitRefKeyToIndex& simHitRefKeyToIndex,
520 std::set<edm::ProductID>& hitProductIds);
524 const TrackingParticleRefKeyToIndex& tpKeyToIndex,
529 const SimHitRefKeyToIndex& simHitRefKeyToIndex,
530 std::set<edm::ProductID>& hitProductIds);
535 std::vector<std::pair<int, int>>& monoStereoClusterList);
540 std::vector<std::pair<int, int>>& monoStereoClusterList);
544 const TrackingParticleRefKeyToIndex& tpKeyToIndex,
549 const SimHitRefKeyToIndex& simHitRefKeyToIndex,
550 std::set<edm::ProductID>& hitProductIds);
554 const TrackingParticleRefKeyToIndex& tpKeyToIndex,
561 std::vector<std::pair<int, int>>& monoStereoClusterList,
562 const std::set<edm::ProductID>& hitProductIds,
563 std::map<edm::ProductID, size_t>& seedToCollIndex);
567 const TrackingParticleRefKeyToIndex& tpKeyToIndex,
568 const TrackingParticleRefKeyToCount& tpKeyToClusterCount,
576 const std::set<edm::ProductID>& hitProductIds,
577 const std::map<edm::ProductID, size_t>& seedToCollIndex,
578 const std::vector<const MVACollection*>& mvaColls,
579 const std::vector<const QualityMaskCollection*>& qualColls);
582 const TrackingParticleRefKeyToIndex& tpKeyToIndex,
585 SimHitRefKeyToIndex& simHitRefKeyToIndex,
586 std::vector<TPHitIndex>& tpHitList);
593 const TrackingVertexRefKeyToIndex& tvKeyToIndex,
595 const std::vector<TPHitIndex>& tpHitList,
596 const TrackingParticleRefKeyToCount& tpKeyToClusterCount);
600 const TrackingParticleRefKeyToIndex& tpKeyToIndex,
601 const unsigned int seedOffset);
606 const TrackingParticleRefKeyToIndex& tpKeyToIndex);
616 template <
typename SimLink>
622 const TrackingParticleRefKeyToIndex& tpKeyToIndex,
625 const SimHitRefKeyToIndex& simHitRefKeyToIndex,
629 std::vector<edm::EDGetTokenT<edm::View<reco::Track>>>
seedTokens_;
666 #define BOOK(name) tree->Branch((prefix + "_" + #name).c_str(), &name);
682 detId.push_back(
id.rawId());
683 subdet.push_back(
id.subdetId());
687 unsigned short s = 0;
688 switch (
id.subdetId()) {
729 std::vector<unsigned short>
side;
773 const auto parsed =
parse(tTopo,
id);
774 order.push_back(parsed.order);
775 ring.push_back(parsed.ring);
776 rod.push_back(parsed.rod);
786 const auto parsed =
parse(tTopo,
id);
807 switch (
id.subdetId()) {
822 std::vector<unsigned short>
ring;
823 std::vector<unsigned short>
rod;
839 const auto parsed =
parse(tTopo,
id);
840 string.push_back(parsed.string);
844 isGlued.push_back(parsed.glued);
856 const auto parsed =
parse(tTopo,
id);
857 string[
index] = parsed.string;
876 unsigned int string = 0;
881 switch (
id.subdetId()) {
932 using DetIdPixel = CombineDetId<DetIdCommon, DetIdPixelOnly>;
933 using DetIdStrip = CombineDetId<DetIdCommon, DetIdOTCommon, DetIdStripOnly>;
934 using DetIdPhase2OT = CombineDetId<DetIdCommon, DetIdOTCommon, DetIdPhase2OTOnly>;
935 using DetIdAll = CombineDetId<DetIdCommon, DetIdPixelOnly, DetIdOTCommon, DetIdStripOnly>;
936 using DetIdAllPhase2 = CombineDetId<DetIdCommon, DetIdPixelOnly, DetIdOTCommon, DetIdPhase2OTOnly>;
1261 iConfig.getUntrackedParameter<
edm::
InputTag>(
"simHitTPMap"))),
1263 iConfig.getUntrackedParameter<
edm::
InputTag>(
"trackAssociator"))),
1265 iConfig.getUntrackedParameter<
edm::
InputTag>(
"pixelDigiSimLink"))),
1267 iConfig.getUntrackedParameter<
edm::
InputTag>(
"stripDigiSimLink"))),
1269 iConfig.getUntrackedParameter<
edm::
InputTag>(
"phase2OTSimLink"))),
1270 includeStripHits_(!iConfig.getUntrackedParameter<
edm::
InputTag>(
"stripDigiSimLink").
label().
empty()),
1271 includePhase2OTHits_(!iConfig.getUntrackedParameter<
edm::
InputTag>(
"phase2OTSimLink").
label().
empty()),
1275 stripRphiRecHitToken_(
1277 stripStereoRecHitToken_(
1280 iConfig.getUntrackedParameter<
edm::
InputTag>(
"stripMatchedRecHits"))),
1282 iConfig.getUntrackedParameter<
edm::
InputTag>(
"phase2OTRecHits"))),
1284 trackingVertexToken_(
1286 tpNLayersToken_(consumes<
edm::ValueMap<unsigned
int>>(
1287 iConfig.getUntrackedParameter<
edm::
InputTag>(
"trackingParticleNlayers"))),
1288 tpNPixelLayersToken_(consumes<
edm::ValueMap<unsigned
int>>(
1289 iConfig.getUntrackedParameter<
edm::
InputTag>(
"trackingParticleNpixellayers"))),
1290 tpNStripStereoLayersToken_(consumes<
edm::ValueMap<unsigned
int>>(
1291 iConfig.getUntrackedParameter<
edm::
InputTag>(
"trackingParticleNstripstereolayers"))),
1292 builderName_(iConfig.getUntrackedParameter<
std::
string>(
"TTRHBuilder")),
1293 parametersDefinerName_(iConfig.getUntrackedParameter<
std::
string>(
"parametersDefiner")),
1294 includeSeeds_(iConfig.getUntrackedParameter<
bool>(
"includeSeeds")),
1295 includeAllHits_(iConfig.getUntrackedParameter<
bool>(
"includeAllHits")),
1296 includeMVA_(iConfig.getUntrackedParameter<
bool>(
"includeMVA")),
1297 includeTrackingParticles_(iConfig.getUntrackedParameter<
bool>(
"includeTrackingParticles")) {
1301 [&](
const edm::InputTag&
tag) { return consumes<edm::View<reco::Track>>(tag); });
1304 [&](
const edm::InputTag&
tag) { return consumes<std::vector<SeedStopInfo>>(tag); });
1314 <<
"Both stripDigiSimLink and phase2OTSimLink are set, please set only either one (this information is used "
1315 "to infer if you're running phase0/1 or phase2 detector)";
1319 <<
"Neither stripDigiSimLink or phase2OTSimLink are set, please set either one.";
1336 return std::make_tuple(consumes<MVACollection>(edm::InputTag(tag,
"MVAValues")),
1337 consumes<QualityMaskCollection>(edm::InputTag(tag,
"QualityMasks")));
1343 t = fs->
make<TTree>(
"tree",
"tree");
1391 t->Branch((
"trk_mva" + std::to_string(
i + 1)).c_str(), &(
trk_mvas[
i]));
1396 t->Branch(
"trk_q", &
trk_q);
1461 t->Branch(
"sim_q", &
sim_q);
1494 t->Branch(
"pix_x", &
pix_x);
1495 t->Branch(
"pix_y", &
pix_y);
1496 t->Branch(
"pix_z", &
pix_z);
1519 t->Branch(
"str_x", &
str_x);
1520 t->Branch(
"str_y", &
str_y);
1521 t->Branch(
"str_z", &
str_z);
1538 t->Branch(
"glu_x", &
glu_x);
1539 t->Branch(
"glu_y", &
glu_y);
1540 t->Branch(
"glu_z", &
glu_z);
1562 t->Branch(
"ph2_x", &
ph2_x);
1563 t->Branch(
"ph2_y", &
ph2_y);
1564 t->Branch(
"ph2_z", &
ph2_z);
1601 t->Branch(
"bsp_x", &
bsp_x,
"bsp_x/F");
1602 t->Branch(
"bsp_y", &
bsp_y,
"bsp_y/F");
1603 t->Branch(
"bsp_z", &
bsp_z,
"bsp_z/F");
1604 t->Branch(
"bsp_sigmax", &
bsp_sigmax,
"bsp_sigmax/F");
1605 t->Branch(
"bsp_sigmay", &
bsp_sigmay,
"bsp_sigmay/F");
1606 t->Branch(
"bsp_sigmaz", &
bsp_sigmaz,
"bsp_sigmaz/F");
1630 t->Branch(
"see_q", &
see_q);
1660 t->Branch(
"vtx_x", &
vtx_x);
1661 t->Branch(
"vtx_y", &
vtx_y);
1662 t->Branch(
"vtx_z", &
vtx_z);
1984 using namespace edm;
1985 using namespace reco;
1986 using namespace std;
1990 const auto& mf = *mfHandle;
2007 LogDebug(
"TrackingNtuple") <<
"Analyzing new event";
2022 for (
size_t i = 0,
size = TPCollectionH->size();
i <
size; ++
i) {
2028 tmpTPptr = TPCollectionHRefVector.
product();
2033 TrackingParticleRefKeyToIndex tpKeyToIndex;
2034 for (
size_t i = 0;
i < tpCollection.
size(); ++
i) {
2035 tpKeyToIndex[tpCollection[
i].key()] =
i;
2045 TrackingVertexRefKeyToIndex tvKeyToIndex;
2046 for (
size_t i = 0;
i < tvs.size(); ++
i) {
2048 if (
v.eventId().bunchCrossing() != 0)
2050 tvKeyToIndex[
i] = tvRefs.
size();
2062 TrackingParticleRefKeyToCount tpKeyToClusterCount;
2063 for (
const auto& clusterTP : clusterToTPMap) {
2064 tpKeyToClusterCount[clusterTP.second.key()] += 1;
2068 SimHitRefKeyToIndex simHitRefKeyToIndex;
2071 std::vector<TPHitIndex> tpHitList;
2075 std::set<edm::ProductID> hitProductIds;
2076 std::map<edm::ProductID, size_t> seedCollToOffset;
2085 const auto& pixelDigiSimLinks = *pixelDigiSimLinksHandle;
2101 vector<pair<int, int>> monoStereoClusterList;
2105 fillSimHits(
tracker, tpKeyToIndex, *simHitsTPAssoc, tTopo, simHitRefKeyToIndex, tpHitList);
2116 simHitRefKeyToIndex,
2121 LogDebug(
"TrackingNtuple") <<
"foundStripSimLink";
2122 const auto& stripDigiSimLinks = *stripDigiSimLinksHandle;
2130 simHitRefKeyToIndex,
2138 LogDebug(
"TrackingNtuple") <<
"foundPhase2OTSimLinks";
2139 const auto& phase2OTSimLinks = *siphase2OTSimLinksHandle;
2147 simHitRefKeyToIndex,
2163 monoStereoClusterList,
2177 std::vector<const MVACollection*> mvaColls;
2178 std::vector<const QualityMaskCollection*> qualColls;
2184 iEvent.getByToken(std::get<0>(tokenTpl), hmva);
2185 iEvent.getByToken(std::get<1>(tokenTpl), hqual);
2187 mvaColls.push_back(hmva.
product());
2188 qualColls.push_back(hqual.
product());
2189 if (mvaColls.back()->size() !=
tracks.size()) {
2191 <<
"Inconsistency in track collection and MVA sizes. Track collection has " <<
tracks.size()
2192 <<
" tracks, whereas the MVA " << (mvaColls.size() - 1) <<
" has " << mvaColls.back()->size()
2193 <<
" entries. Double-check your configuration.";
2195 if (qualColls.back()->size() !=
tracks.size()) {
2197 <<
"Inconsistency in track collection and quality mask sizes. Track collection has " <<
tracks.size()
2198 <<
" tracks, whereas the quality mask " << (qualColls.size() - 1) <<
" has " << qualColls.back()->size()
2199 <<
" entries. Double-check your configuration.";
2210 tpKeyToClusterCount,
2227 iEvent, iSetup, trackRefs,
bs, tpCollection, tvKeyToIndex, associatorByHits, tpHitList, tpKeyToClusterCount);
2248 template <
typename SimLink>
2260 template <
typename SimLink>
2267 const TrackingParticleRefKeyToIndex& tpKeyToIndex,
2270 const SimHitRefKeyToIndex& simHitRefKeyToIndex,
2274 std::map<unsigned int, double> simTrackIdToChargeFraction;
2278 simTrackIdToChargeFraction = chargeFraction(GetCluster<SimLink>::call(cluster), hitId,
digiSimLinks);
2283 for (
auto ip =
range.first; ip !=
range.second; ++ip) {
2287 const auto event = trackingParticle->eventId().event();
2288 const auto bx = trackingParticle->eventId().bunchCrossing();
2293 ret.type = static_cast<HitSimType>(
std::min(static_cast<int>(
ret.type), static_cast<int>(
type)));
2296 auto tpIndex = tpKeyToIndex.find(trackingParticle.
key());
2297 if (tpIndex == tpKeyToIndex.end())
2301 std::pair<TrackingParticleRef, TrackPSimHitRef> simHitTPpairWithDummyTP(trackingParticle,
TrackPSimHitRef());
2303 auto range = std::equal_range(simHitsTPAssoc.begin(),
2304 simHitsTPAssoc.end(),
2305 simHitTPpairWithDummyTP,
2307 bool foundSimHit =
false;
2308 bool foundElectron =
false;
2309 for (
auto ip =
range.first; ip !=
range.second; ++ip) {
2314 if (
std::abs(TPhit->particleType()) == 11 &&
std::abs(trackingParticle->pdgId()) != 11) {
2315 foundElectron =
true;
2320 auto simHitKey = TPhit.
key();
2321 auto simHitID = TPhit.
id();
2323 auto simHitIndex = simHitRefKeyToIndex.at(std::make_pair(simHitKey, simHitID));
2324 ret.matchingSimHit.push_back(simHitIndex);
2326 double chargeFraction = 0.;
2327 for (
const SimTrack& simtrk : trackingParticle->g4Tracks()) {
2328 auto found = simTrackIdToChargeFraction.find(simtrk.trackId());
2329 if (
found != simTrackIdToChargeFraction.end()) {
2330 chargeFraction +=
found->second;
2333 ret.chargeFraction.push_back(chargeFraction);
2336 ret.bunchCrossing.push_back(
bx);
2340 simhit_hitType[simHitIndex].push_back(static_cast<int>(hitType));
2350 <<
"Did not find SimHit for reco hit DetId " << hitId.
rawId() <<
" for TP " << trackingParticle.
key()
2351 <<
" bx:event " <<
bx <<
":" <<
event <<
".\nFound SimHits from detectors ";
2352 for (
auto ip =
range.first; ip !=
range.second; ++ip) {
2355 ex << dId.
rawId() <<
" ";
2357 if (trackingParticle->eventId().event() != 0) {
2358 ex <<
"\nSince this is a TrackingParticle from pileup, check that you're running the pileup mixing in "
2370 const TrackingParticleRefKeyToIndex& tpKeyToIndex,
2373 SimHitRefKeyToIndex& simHitRefKeyToIndex,
2374 std::vector<TPHitIndex>& tpHitList) {
2375 for (
const auto&
assoc : simHitsTPAssoc) {
2376 auto tpKey =
assoc.first.key();
2380 auto found = tpKeyToIndex.find(tpKey);
2381 if (
found == tpKeyToIndex.end())
2383 const auto tpIndex =
found->second;
2386 const auto& simhit = *(
assoc.second);
2387 auto detId =
DetId(simhit.detUnitId());
2399 auto simHitKey = std::make_pair(
assoc.second.key(),
assoc.second.id());
2401 if (simHitRefKeyToIndex.find(simHitKey) != simHitRefKeyToIndex.end()) {
2402 for (
const auto& assoc2 : simHitsTPAssoc) {
2403 if (std::make_pair(assoc2.second.key(), assoc2.second.id()) == simHitKey) {
2405 auto range1 = std::equal_range(simHitsTPAssoc.begin(),
2406 simHitsTPAssoc.end(),
2409 auto range2 = std::equal_range(simHitsTPAssoc.begin(),
2410 simHitsTPAssoc.end(),
2414 LogTrace(
"TrackingNtuple") <<
"Earlier TP " << assoc2.first.key() <<
" SimTrack Ids";
2415 for (
const auto&
simTrack : assoc2.first->g4Tracks()) {
2417 <<
simTrack.eventId().bunchCrossing() <<
":" <<
simTrack.eventId().event();
2419 for (
auto iHit = range2.first; iHit != range2.second; ++iHit) {
2420 LogTrace(
"TrackingNtuple") <<
" SimHit " << iHit->second.key() <<
" " << iHit->second.id() <<
" tof "
2421 << iHit->second->tof() <<
" trackId " << iHit->second->trackId() <<
" BX:event "
2422 << iHit->second->eventId().bunchCrossing() <<
":"
2423 << iHit->second->eventId().event();
2425 LogTrace(
"TrackingNtuple") <<
"Current TP " <<
assoc.first.key() <<
" SimTrack Ids";
2428 <<
simTrack.eventId().bunchCrossing() <<
":" <<
simTrack.eventId().event();
2430 for (
auto iHit = range1.first; iHit != range1.second; ++iHit) {
2431 LogTrace(
"TrackingNtuple") <<
" SimHit " << iHit->second.key() <<
" " << iHit->second.id() <<
" tof "
2432 << iHit->second->tof() <<
" trackId " << iHit->second->trackId() <<
" BX:event "
2433 << iHit->second->eventId().bunchCrossing() <<
":"
2434 << iHit->second->eventId().event();
2439 <<
"Got second time the SimHit " << simHitKey.first <<
" of " << simHitKey.second
2440 <<
", first time with TrackingParticle " << assoc2.first.key() <<
", now with " << tpKey;
2443 throw cms::Exception(
"LogicError") <<
"Got second time the SimHit " << simHitKey.first <<
" of "
2444 << simHitKey.second <<
", now with TrackingParticle " << tpKey
2445 <<
", but I didn't find the first occurrance!";
2448 auto det =
tracker.idToDetUnit(detId);
2450 throw cms::Exception(
"LogicError") <<
"Did not find a det unit for DetId " << simhit.detUnitId()
2451 <<
" from tracker geometry";
2453 const auto pos = det->surface().toGlobal(simhit.localPosition());
2454 const float tof = simhit.timeOfFlight();
2456 const auto simHitIndex =
simhit_x.size();
2457 simHitRefKeyToIndex[simHitKey] = simHitIndex;
2477 tpHitList.emplace_back(tpKey, simHitIndex, tof, simhit.detUnitId());
2483 const TrackingParticleRefKeyToIndex& tpKeyToIndex,
2488 const SimHitRefKeyToIndex& simHitRefKeyToIndex,
2489 std::set<edm::ProductID>& hitProductIds) {
2492 for (
auto it = pixelHits->
begin(); it != pixelHits->
end(); it++) {
2493 const DetId hitId = it->detId();
2494 for (
auto hit = it->begin();
hit != it->end();
hit++) {
2497 hitProductIds.insert(
hit->cluster().
id());
2499 const int key =
hit->cluster().key();
2500 const int lay = tTopo.
layer(hitId);
2506 pix_x.push_back(ttrh->globalPosition().x());
2507 pix_y.push_back(ttrh->globalPosition().y());
2508 pix_z.push_back(ttrh->globalPosition().z());
2509 pix_xx.push_back(ttrh->globalPositionError().cxx());
2510 pix_xy.push_back(ttrh->globalPositionError().cyx());
2511 pix_yy.push_back(ttrh->globalPositionError().cyy());
2512 pix_yz.push_back(ttrh->globalPositionError().czy());
2513 pix_zz.push_back(ttrh->globalPositionError().czz());
2514 pix_zx.push_back(ttrh->globalPositionError().czx());
2515 pix_radL.push_back(ttrh->surface()->mediumProperties().radLen());
2516 pix_bbxi.push_back(ttrh->surface()->mediumProperties().xi());
2518 LogTrace(
"TrackingNtuple") <<
"pixHit cluster=" <<
key <<
" subdId=" << hitId.
subdetId() <<
" lay=" << lay
2519 <<
" rawId=" << hitId.
rawId() <<
" pos =" << ttrh->globalPosition();
2529 simHitRefKeyToIndex,
2537 LogTrace(
"TrackingNtuple") <<
" firstMatchingSimHit=" << simHitIdx <<
" simHitPos="
2543 <<
" event=" << simHitData.
event[0];
2552 const TrackingParticleRefKeyToIndex& tpKeyToIndex,
2557 const SimHitRefKeyToIndex& simHitRefKeyToIndex,
2558 std::set<edm::ProductID>& hitProductIds) {
2572 str_x.resize(totalStripHits);
2573 str_y.resize(totalStripHits);
2574 str_z.resize(totalStripHits);
2575 str_xx.resize(totalStripHits);
2576 str_xy.resize(totalStripHits);
2577 str_yy.resize(totalStripHits);
2578 str_yz.resize(totalStripHits);
2579 str_zz.resize(totalStripHits);
2580 str_zx.resize(totalStripHits);
2585 for (
const auto& detset :
hits) {
2586 const DetId hitId = detset.detId();
2587 for (
const auto&
hit : detset) {
2590 hitProductIds.insert(
hit.cluster().
id());
2592 const int key =
hit.cluster().key();
2593 const int lay = tTopo.
layer(hitId);
2596 str_x[
key] = ttrh->globalPosition().x();
2597 str_y[
key] = ttrh->globalPosition().y();
2598 str_z[
key] = ttrh->globalPosition().z();
2599 str_xx[
key] = ttrh->globalPositionError().cxx();
2600 str_xy[
key] = ttrh->globalPositionError().cyx();
2601 str_yy[
key] = ttrh->globalPositionError().cyy();
2602 str_yz[
key] = ttrh->globalPositionError().czy();
2603 str_zz[
key] = ttrh->globalPositionError().czz();
2604 str_zx[
key] = ttrh->globalPositionError().czx();
2605 str_radL[
key] = ttrh->surface()->mediumProperties().radLen();
2606 str_bbxi[
key] = ttrh->surface()->mediumProperties().xi();
2608 <<
" rawId=" << hitId.
rawId() <<
" pos =" << ttrh->globalPosition();
2619 simHitRefKeyToIndex,
2627 LogTrace(
"TrackingNtuple") <<
" firstMatchingSimHit=" << simHitIdx <<
" simHitPos="
2635 <<
" event=" << simHitData.
event[0];
2642 fill(*rphiHits,
"stripRPhiHit");
2643 fill(*stereoHits,
"stripStereoHit");
2649 std::vector<std::pair<int, int>>& monoStereoClusterList) {
2651 const auto hitId =
hit.geographicalId();
2652 const int lay = tTopo.
layer(hitId);
2653 monoStereoClusterList.emplace_back(
hit.monoHit().cluster().key(),
hit.stereoHit().cluster().key());
2659 glu_x.push_back(ttrh->globalPosition().x());
2660 glu_y.push_back(ttrh->globalPosition().y());
2661 glu_z.push_back(ttrh->globalPosition().z());
2662 glu_xx.push_back(ttrh->globalPositionError().cxx());
2663 glu_xy.push_back(ttrh->globalPositionError().cyx());
2664 glu_yy.push_back(ttrh->globalPositionError().cyy());
2665 glu_yz.push_back(ttrh->globalPositionError().czy());
2666 glu_zz.push_back(ttrh->globalPositionError().czz());
2667 glu_zx.push_back(ttrh->globalPositionError().czx());
2668 glu_radL.push_back(ttrh->surface()->mediumProperties().radLen());
2669 glu_bbxi.push_back(ttrh->surface()->mediumProperties().xi());
2670 LogTrace(
"TrackingNtuple") <<
"stripMatchedHit"
2671 <<
" cluster0=" <<
hit.stereoHit().cluster().key()
2672 <<
" cluster1=" <<
hit.monoHit().cluster().key() <<
" subdId=" << hitId.subdetId()
2673 <<
" lay=" << lay <<
" rawId=" << hitId.rawId() <<
" pos =" << ttrh->globalPosition();
2680 std::vector<std::pair<int, int>>& monoStereoClusterList) {
2683 for (
auto it = matchedHits->
begin(); it != matchedHits->
end(); it++) {
2684 for (
auto hit = it->begin();
hit != it->end();
hit++) {
2692 const TrackingParticleRefKeyToIndex& tpKeyToIndex,
2697 const SimHitRefKeyToIndex& simHitRefKeyToIndex,
2698 std::set<edm::ProductID>& hitProductIds) {
2701 for (
auto it = phase2OTHits->
begin(); it != phase2OTHits->
end(); it++) {
2702 const DetId hitId = it->detId();
2703 for (
auto hit = it->begin();
hit != it->end();
hit++) {
2706 hitProductIds.insert(
hit->cluster().
id());
2708 const int key =
hit->cluster().key();
2709 const int lay = tTopo.
layer(hitId);
2715 ph2_x.push_back(ttrh->globalPosition().x());
2716 ph2_y.push_back(ttrh->globalPosition().y());
2717 ph2_z.push_back(ttrh->globalPosition().z());
2718 ph2_xx.push_back(ttrh->globalPositionError().cxx());
2719 ph2_xy.push_back(ttrh->globalPositionError().cyx());
2720 ph2_yy.push_back(ttrh->globalPositionError().cyy());
2721 ph2_yz.push_back(ttrh->globalPositionError().czy());
2722 ph2_zz.push_back(ttrh->globalPositionError().czz());
2723 ph2_zx.push_back(ttrh->globalPositionError().czx());
2724 ph2_radL.push_back(ttrh->surface()->mediumProperties().radLen());
2725 ph2_bbxi.push_back(ttrh->surface()->mediumProperties().xi());
2727 LogTrace(
"TrackingNtuple") <<
"phase2 OT cluster=" <<
key <<
" subdId=" << hitId.
subdetId() <<
" lay=" << lay
2728 <<
" rawId=" << hitId.
rawId() <<
" pos =" << ttrh->globalPosition();
2739 simHitRefKeyToIndex,
2746 LogTrace(
"TrackingNtuple") <<
" firstMatchingSimHit=" << simHitIdx <<
" simHitPos="
2752 <<
" event=" << simHitData.
event[0];
2761 const TrackingParticleRefKeyToIndex& tpKeyToIndex,
2768 std::vector<std::pair<int, int>>& monoStereoClusterList,
2769 const std::set<edm::ProductID>& hitProductIds,
2770 std::map<edm::ProductID, size_t>& seedCollToOffset) {
2772 for (
size_t iColl = 0; iColl <
seedTokens_.size(); ++iColl) {
2776 iEvent.getByToken(seedToken, seedTracksHandle);
2787 iEvent.getByToken(seedStopInfoToken, seedStopInfoHandle);
2788 const auto& seedStopInfos = *seedStopInfoHandle;
2789 if (
seedTracks.size() != seedStopInfos.size()) {
2794 <<
" seed stopping infos for collections " <<
labels.module <<
", "
2808 label.ReplaceAll(
"seedTracks",
"");
2809 label.ReplaceAll(
"Seeds",
"");
2810 label.ReplaceAll(
"muonSeeded",
"muonSeededStep");
2815 auto inserted = seedCollToOffset.emplace(
id,
offset);
2816 if (!inserted.second)
2818 <<
"Trying to add seeds with ProductID " <<
id <<
" for a second time from collection " <<
labels.module
2819 <<
", seed algo " <<
label <<
". Typically this is caused by a configuration problem.";
2823 <<
" ProductID " <<
id;
2825 for (
size_t iSeed = 0; iSeed < seedTrackRefs.
size(); ++iSeed) {
2826 const auto& seedTrackRef = seedTrackRefs[iSeed];
2827 const auto& seedTrack = *seedTrackRef;
2828 const auto& seedRef = seedTrack.seedRef();
2829 const auto&
seed = *seedRef;
2831 const auto seedStopInfo = seedStopInfos[iSeed];
2833 if (seedRef.id() !=
id)
2835 <<
"All tracks in 'TracksFromSeeds' collection should point to seeds in the same collection. Now the "
2836 "element 0 had ProductID "
2837 <<
id <<
" while the element " << seedTrackRef.key() <<
" had " << seedTrackRef.id()
2838 <<
". The source collection is " <<
labels.module <<
".";
2840 std::vector<int> tpIdx;
2841 std::vector<float> sharedFraction;
2842 auto foundTPs = recSimColl.
find(seedTrackRef);
2843 if (foundTPs != recSimColl.
end()) {
2844 for (
const auto& tpQuality : foundTPs->val) {
2845 tpIdx.push_back(tpKeyToIndex.at(tpQuality.first.key()));
2846 sharedFraction.push_back(tpQuality.second);
2851 const int nHits = seedTrack.numberOfValidHits();
2853 seedTrack.recHitsBegin(),
2854 seedTrack.recHitsEnd());
2856 const auto bestKeyCount = findBestMatchingTrackingParticle(seedTrack, clusterToTPMap, tpKeyToIndex);
2857 const float bestShareFrac =
2858 nClusters > 0 ? static_cast<float>(bestKeyCount.countClusters) / static_cast<float>(
nClusters) : 0;
2860 const auto bestFirstHitKeyCount =
2861 findMatchingTrackingParticleFromFirstHit(seedTrack, clusterToTPMap, tpKeyToIndex);
2862 const float bestFirstHitShareFrac =
2863 nClusters > 0 ? static_cast<float>(bestFirstHitKeyCount.countClusters) / static_cast<float>(
nClusters) : 0;
2866 const int charge = seedTrack.charge();
2867 const float pt = seedFitOk ? seedTrack.pt() : 0;
2868 const float eta = seedFitOk ? seedTrack.eta() : 0;
2869 const float phi = seedFitOk ? seedTrack.phi() : 0;
2871 const auto seedIndex =
see_fitok.size();
2875 see_px.push_back(seedFitOk ? seedTrack.px() : 0);
2876 see_py.push_back(seedFitOk ? seedTrack.py() : 0);
2877 see_pz.push_back(seedFitOk ? seedTrack.pz() : 0);
2884 see_dxy.push_back(seedFitOk ? seedTrack.dxy(
bs.position()) : 0);
2885 see_dz.push_back(seedFitOk ? seedTrack.dz(
bs.position()) : 0);
2886 see_ptErr.push_back(seedFitOk ? seedTrack.ptError() : 0);
2887 see_etaErr.push_back(seedFitOk ? seedTrack.etaError() : 0);
2888 see_phiErr.push_back(seedFitOk ? seedTrack.phiError() : 0);
2889 see_dxyErr.push_back(seedFitOk ? seedTrack.dxyError() : 0);
2890 see_dzErr.push_back(seedFitOk ? seedTrack.dzError() : 0);
2893 see_nCands.push_back(seedStopInfo.candidatesPerSeed());
2895 const auto&
state = seedTrack.seedRef()->startingState();
2896 const auto&
pos =
state.parameters().position();
2897 const auto& mom =
state.parameters().momentum();
2909 see_bestSimTrkIdx.push_back(bestKeyCount.key >= 0 ? tpKeyToIndex.at(bestKeyCount.key) : -1);
2911 bestFirstHitKeyCount.key >= 0 ? tpKeyToIndex.at(bestFirstHitKeyCount.key) : -1);
2930 std::vector<int> hitIdx;
2931 std::vector<int> hitType;
2933 for (
auto const&
hit :
seed.recHits()) {
2935 int subid =
recHit->geographicalId().subdetId();
2941 checkProductID(hitProductIds, clusterRef.id(),
"seed");
2944 hitIdx.push_back(clusterKey);
2957 std::vector<std::pair<int, int>>::iterator
pos =
2958 find(monoStereoClusterList.begin(), monoStereoClusterList.end(), std::make_pair(monoIdx, stereoIdx));
2959 size_t gluedIndex = -1;
2960 if (
pos != monoStereoClusterList.end()) {
2967 gluedIndex =
addStripMatchedHit(*matchedHit, theTTRHBuilder, tTopo, monoStereoClusterList);
2972 hitIdx.push_back(gluedIndex);
2977 unsigned int clusterKey;
2978 if (clusterRef.isPhase2()) {
2981 clusterKey = clusterRef.cluster_strip().key();
2985 checkProductID(hitProductIds, clusterRef.id(),
"seed");
2986 if (clusterRef.isPhase2()) {
2993 hitIdx.push_back(clusterKey);
2994 if (clusterRef.isPhase2()) {
3001 LogTrace(
"TrackingNtuple") <<
" not pixel and not Strip detector";
3016 std::vector<GlobalPoint>
gp(2);
3017 std::vector<GlobalError> ge(2);
3018 gp[0] = recHit0->globalPosition();
3019 ge[0] = recHit0->globalPositionError();
3020 gp[1] = recHit1->globalPosition();
3021 ge[1] = recHit1->globalPositionError();
3023 <<
"seed " << seedTrackRef.key() <<
" pt=" <<
pt <<
" eta=" <<
eta <<
" phi=" <<
phi <<
" q=" <<
charge
3024 <<
" - PAIR - ids: " << recHit0->geographicalId().rawId() <<
" " << recHit1->geographicalId().rawId()
3025 <<
" hitpos: " <<
gp[0] <<
" " <<
gp[1] <<
" trans0: "
3026 << (recHit0->transientHits().size() > 1 ? recHit0->transientHits()[0]->globalPosition()
3029 << (recHit0->transientHits().size() > 1 ? recHit0->transientHits()[1]->globalPosition()
3032 << (recHit1->transientHits().size() > 1 ? recHit1->transientHits()[0]->globalPosition()
3035 << (recHit1->transientHits().size() > 1 ? recHit1->transientHits()[1]->globalPosition()
3037 <<
" eta,phi: " <<
gp[0].
eta() <<
"," <<
gp[0].phi();
3038 }
else if (nHits == 3) {
3045 gp[0] = recHit0->globalPosition();
3046 ge[0] = recHit0->globalPositionError();
3047 int subid0 = recHit0->geographicalId().subdetId();
3050 gp[1] = recHit1->globalPosition();
3051 ge[1] = recHit1->globalPositionError();
3052 int subid1 = recHit1->geographicalId().subdetId();
3055 gp[2] = recHit2->globalPosition();
3056 ge[2] = recHit2->globalPositionError();
3057 int subid2 = recHit2->geographicalId().subdetId();
3061 float seed_chi2 = rzLine.
chi2();
3065 <<
"seed " << seedTrackRef.key() <<
" pt=" <<
pt <<
" eta=" <<
eta <<
" phi=" <<
phi <<
" q=" <<
charge
3066 <<
" - TRIPLET - ids: " << recHit0->geographicalId().rawId() <<
" " << recHit1->geographicalId().rawId()
3067 <<
" " << recHit2->geographicalId().rawId() <<
" hitpos: " <<
gp[0] <<
" " <<
gp[1] <<
" " <<
gp[2]
3069 << (recHit0->transientHits().size() > 1 ? recHit0->transientHits()[0]->globalPosition()
3072 << (recHit0->transientHits().size() > 1 ? recHit0->transientHits()[1]->globalPosition()
3075 << (recHit1->transientHits().size() > 1 ? recHit1->transientHits()[0]->globalPosition()
3078 << (recHit1->transientHits().size() > 1 ? recHit1->transientHits()[1]->globalPosition()
3081 << (recHit2->transientHits().size() > 1 ? recHit2->transientHits()[0]->globalPosition()
3084 << (recHit2->transientHits().size() > 1 ? recHit2->transientHits()[1]->globalPosition()
3087 << recHit2->localPosition()
3089 <<
" eta,phi: " <<
gp[0].eta() <<
"," <<
gp[0].phi() <<
" pt,chi2: " << seed_pt <<
"," << seed_chi2;
3101 const TrackingParticleRefKeyToIndex& tpKeyToIndex,
3102 const TrackingParticleRefKeyToCount& tpKeyToClusterCount,
3110 const std::set<edm::ProductID>& hitProductIds,
3111 const std::map<edm::ProductID, size_t>& seedCollToOffset,
3112 const std::vector<const MVACollection*>& mvaColls,
3113 const std::vector<const QualityMaskCollection*>& qualColls) {
3117 LogTrace(
"TrackingNtuple") <<
"NEW TRACK LABEL: " <<
labels.module;
3119 auto pvPosition =
vertices[0].position();
3121 for (
size_t iTrack = 0; iTrack <
tracks.size(); ++iTrack) {
3122 const auto& itTrack =
tracks[iTrack];
3123 int charge = itTrack->charge();
3124 float pt = itTrack->pt();
3125 float eta = itTrack->eta();
3126 const double lambda = itTrack->lambda();
3127 float chi2 = itTrack->normalizedChi2();
3128 float ndof = itTrack->ndof();
3129 float phi = itTrack->phi();
3130 int nHits = itTrack->numberOfValidHits();
3133 const auto& tkParam = itTrack->parameters();
3134 auto tkCov = itTrack->covariance();
3139 bool isSimMatched =
false;
3140 std::vector<int> tpIdx;
3141 std::vector<float> sharedFraction;
3142 std::vector<float> tpChi2;
3143 auto foundTPs = recSimColl.
find(itTrack);
3144 if (foundTPs != recSimColl.
end()) {
3145 if (!foundTPs->val.empty()) {
3146 nSimHits = foundTPs->val[0].first->numberOfTrackerHits();
3147 isSimMatched =
true;
3149 for (
const auto& tpQuality : foundTPs->val) {
3150 tpIdx.push_back(tpKeyToIndex.at(tpQuality.first.key()));
3151 sharedFraction.push_back(tpQuality.second);
3158 itTrack->recHitsBegin(),
3159 itTrack->recHitsEnd());
3162 const auto bestKeyCount = findBestMatchingTrackingParticle(*itTrack, clusterToTPMap, tpKeyToIndex);
3163 const float bestShareFrac = static_cast<float>(bestKeyCount.countClusters) / static_cast<float>(
nClusters);
3164 float bestShareFracSimDenom = 0;
3165 float bestShareFracSimClusterDenom = 0;
3166 float bestChi2 = -1;
3167 if (bestKeyCount.key >= 0) {
3168 bestShareFracSimDenom =
3169 static_cast<float>(bestKeyCount.countClusters) /
3170 static_cast<float>(tpCollection[tpKeyToIndex.at(bestKeyCount.key)]->numberOfTrackerHits());
3171 bestShareFracSimClusterDenom =
3172 static_cast<float>(bestKeyCount.countClusters) / static_cast<float>(tpKeyToClusterCount.at(bestKeyCount.key));
3174 tkParam, tkCov, *(tpCollection[tpKeyToIndex.at(bestKeyCount.key)]), mf,
bs);
3177 const auto bestFirstHitKeyCount = findMatchingTrackingParticleFromFirstHit(*itTrack, clusterToTPMap, tpKeyToIndex);
3178 const float bestFirstHitShareFrac =
3179 static_cast<float>(bestFirstHitKeyCount.countClusters) / static_cast<float>(
nClusters);
3180 float bestFirstHitShareFracSimDenom = 0;
3181 float bestFirstHitShareFracSimClusterDenom = 0;
3182 float bestFirstHitChi2 = -1;
3183 if (bestFirstHitKeyCount.key >= 0) {
3184 bestFirstHitShareFracSimDenom =
3185 static_cast<float>(bestFirstHitKeyCount.countClusters) /
3186 static_cast<float>(tpCollection[tpKeyToIndex.at(bestFirstHitKeyCount.key)]->numberOfTrackerHits());
3187 bestFirstHitShareFracSimClusterDenom = static_cast<float>(bestFirstHitKeyCount.countClusters) /
3188 static_cast<float>(tpKeyToClusterCount.at(bestFirstHitKeyCount.key));
3190 tkParam, tkCov, *(tpCollection[tpKeyToIndex.at(bestFirstHitKeyCount.key)]), mf,
bs);
3193 float chi2_1Dmod =
chi2;
3194 int count1dhits = 0;
3195 for (
auto iHit = itTrack->recHitsBegin(), iEnd = itTrack->recHitsEnd(); iHit != iEnd; ++iHit) {
3200 if (count1dhits > 0) {
3201 chi2_1Dmod = (
chi2 + count1dhits) / (
ndof + count1dhits);
3206 trk_px.push_back(itTrack->px());
3207 trk_py.push_back(itTrack->py());
3208 trk_pz.push_back(itTrack->pz());
3213 trk_inner_pt.push_back(itTrack->innerMomentum().rho());
3217 trk_outer_pt.push_back(itTrack->outerMomentum().rho());
3222 trk_dxy.push_back(itTrack->dxy(
bs.position()));
3223 trk_dz.push_back(itTrack->dz(
bs.position()));
3224 trk_dxyPV.push_back(itTrack->dxy(pvPosition));
3225 trk_dzPV.push_back(itTrack->dz(pvPosition));
3228 trk_ptErr.push_back(itTrack->ptError());
3233 trk_dzErr.push_back(itTrack->dzError());
3252 trk_n3DLay.push_back(
hp.numberOfValidStripLayersWithMonoAndStereo() +
hp.pixelLayersWithMeasurement());
3255 trk_algo.push_back(itTrack->algo());
3262 trk_mvas[
i].push_back((*(mvaColls[
i]))[iTrack]);
3267 auto offset = seedCollToOffset.find(itTrack->seedRef().id());
3268 if (
offset == seedCollToOffset.end()) {
3272 << itTrack->seedRef().id()
3273 <<
", but that seed collection is not given as an input. The following collections were given as an input "
3274 << make_ProductIDMapPrinter(seedCollToOffset);
3277 const auto seedIndex =
offset->second + itTrack->seedRef().key();
3280 throw cms::Exception(
"LogicError") <<
"Track index has already been set for seed " << seedIndex <<
" to "
3281 <<
see_trkIdx[seedIndex] <<
"; was trying to set it to " << iTrack;
3290 trk_bestSimTrkIdx.push_back(bestKeyCount.key >= 0 ? tpKeyToIndex.at(bestKeyCount.key) : -1);
3305 LogTrace(
"TrackingNtuple") <<
"Track #" << itTrack.key() <<
" with q=" <<
charge <<
", pT=" <<
pt
3306 <<
" GeV, eta: " <<
eta <<
", phi: " <<
phi <<
", chi2=" <<
chi2 <<
", Nhits=" << nHits
3307 <<
", algo=" << itTrack->algoName(itTrack->algo()).c_str()
3309 <<
" seed#=" << itTrack->seedRef().key() <<
" simMatch=" << isSimMatched
3310 <<
" nSimHits=" << nSimHits
3311 <<
" sharedFraction=" << (sharedFraction.empty() ? -1 : sharedFraction[0])
3312 <<
" tpIdx=" << (tpIdx.empty() ? -1 : tpIdx[0]);
3313 std::vector<int> hitIdx;
3314 std::vector<int> hitType;
3316 for (
auto i = itTrack->recHitsBegin();
i != itTrack->recHitsEnd();
i++) {
3318 DetId hitId =
hit->geographicalId();
3326 if (
hit->isValid()) {
3330 unsigned int clusterKey;
3331 if (clusterRef.isPixel()) {
3333 }
else if (clusterRef.isPhase2()) {
3334 clusterKey = clusterRef.cluster_phase2OT().key();
3336 clusterKey = clusterRef.cluster_strip().key();
3339 LogTrace(
"TrackingNtuple") <<
" id: " << hitId.
rawId() <<
" - globalPos =" <<
hit->globalPosition()
3340 <<
" cluster=" << clusterKey <<
" clusterRef ID=" << clusterRef.
id()
3341 <<
" eta,phi: " <<
hit->globalPosition().eta() <<
"," <<
hit->globalPosition().phi();
3343 checkProductID(hitProductIds, clusterRef.id(),
"track");
3344 if (clusterRef.isPixel()) {
3346 }
else if (clusterRef.isPhase2()) {
3353 hitIdx.push_back(clusterKey);
3354 if (clusterRef.isPixel()) {
3356 }
else if (clusterRef.isPhase2()) {
3362 LogTrace(
"TrackingNtuple") <<
" - invalid hit";
3386 const TrackingVertexRefKeyToIndex& tvKeyToIndex,
3388 const std::vector<TPHitIndex>& tpHitList,
3389 const TrackingParticleRefKeyToCount& tpKeyToClusterCount) {
3397 const auto& nLayers_tPCeff = *tpNLayersH;
3400 const auto& nPixelLayers_tPCeff = *tpNLayersH;
3403 const auto& nStripMonoAndStereoLayers_tPCeff = *tpNLayersH;
3408 LogTrace(
"TrackingNtuple") <<
"tracking particle pt=" <<
tp->pt() <<
" eta=" <<
tp->eta() <<
" phi=" <<
tp->phi();
3409 bool isRecoMatched =
false;
3410 std::vector<int> tkIdx;
3411 std::vector<float> sharedFraction;
3412 auto foundTracks = simRecColl.
find(
tp);
3413 if (foundTracks != simRecColl.
end()) {
3414 isRecoMatched =
true;
3422 for (
const auto& genRef :
tp->genParticles()) {
3423 if (genRef.isNonnull())
3427 bool isFromBHadron =
false;
3432 for (
const auto& particle : recoGenParticleTrail) {
3435 isFromBHadron =
true;
3441 LogTrace(
"TrackingNtuple") <<
"matched to tracks = " << make_VectorPrinter(tkIdx)
3442 <<
" isRecoMatched=" << isRecoMatched;
3453 sim_q.push_back(
tp->charge());
3457 std::vector<int> decayIdx;
3458 for (
const auto&
v :
tp->decayVertices())
3459 decayIdx.push_back(tvKeyToIndex.at(
v.key()));
3467 const double lambdaSim =
M_PI / 2 - momentum.theta();
3476 std::vector<int> hitIdx;
3477 int nPixel = 0, nStrip = 0;
3479 for (
auto ip = rangeHit.first; ip != rangeHit.second; ++ip) {
3483 LogTrace(
"TrackingNtuple") <<
"simhit=" << ip->simHitIdx <<
" type=" << static_cast<int>(
type);
3484 hitIdx.push_back(ip->simHitIdx);
3487 throw cms::Exception(
"LogicError") <<
"Encountered SimHit for TP " <<
tp.key() <<
" with DetId "
3488 << detid.rawId() <<
" whose det() is not Tracker but " << detid.det();
3490 const auto subdet = detid.subdetId();
3503 throw cms::Exception(
"LogicError") <<
"Encountered SimHit for TP " <<
tp.key() <<
" with DetId "
3504 << detid.rawId() <<
" whose subdet is not recognized, is " << subdet;
3511 const auto nSimLayers = nLayers_tPCeff[
tp];
3512 const auto nSimPixelLayers = nPixelLayers_tPCeff[
tp];
3513 const auto nSimStripMonoAndStereoLayers = nStripMonoAndStereoLayers_tPCeff[
tp];
3516 sim_n3DLay.push_back(nSimPixelLayers + nSimStripMonoAndStereoLayers);
3519 auto found = tpKeyToClusterCount.find(
tp.key());
3529 const TrackingParticleRefKeyToIndex& tpKeyToIndex,
3530 const unsigned int seedOffset) {
3534 for (
const auto& keyVal : simRecColl) {
3535 const auto& tpRef = keyVal.key;
3536 auto found = tpKeyToIndex.find(tpRef.key());
3537 if (
found == tpKeyToIndex.end())
3538 throw cms::Exception(
"Assert") << __FILE__ <<
":" << __LINE__ <<
" fillTrackingParticlesForSeeds: tpRef.key() "
3539 << tpRef.key() <<
" not found from tpKeyToIndex. tpKeyToIndex size "
3540 << tpKeyToIndex.size();
3541 const auto tpIndex =
found->second;
3542 for (
const auto& pair : keyVal.val) {
3543 const auto& seedRef = pair.first->seedRef();
3544 sim_seedIdx[tpIndex].push_back(seedOffset + seedRef.key());
3551 for (
size_t iVertex = 0,
size =
vertices.size(); iVertex <
size; ++iVertex) {
3564 std::vector<int> trkIdx;
3565 for (
auto iTrack =
vertex.tracks_begin(); iTrack !=
vertex.tracks_end(); ++iTrack) {
3567 if (iTrack->id() !=
tracks.id())
3570 trkIdx.push_back(iTrack->key());
3573 throw cms::Exception(
"LogicError") <<
"Vertex index has already been set for track " << iTrack->key() <<
" to "
3574 <<
trk_vtxIdx[iTrack->key()] <<
"; was trying to set it to " << iVertex;
3583 const TrackingParticleRefKeyToIndex& tpKeyToIndex) {
3584 int current_event = -1;
3585 for (
const auto& ref : trackingVertices) {
3587 if (
v.eventId().event() != current_event) {
3589 current_event =
v.eventId().event();
3594 if (!
v.g4Vertices().empty()) {
3595 processType =
v.g4Vertices()[0].processType();
3607 for (
const auto& tpRef : tps) {
3608 auto found = tpKeyToIndex.find(tpRef.key());
3609 if (
found != tpKeyToIndex.end()) {
3615 std::vector<int> sourceIdx;
3616 std::vector<int> daughterIdx;
3617 fill(
v.sourceTracks(), sourceIdx);
3618 fill(
v.daughterTracks(), daughterIdx);
3630 desc.addUntracked<std::vector<edm::InputTag>>(
3632 std::vector<edm::InputTag>{
edm::InputTag(
"seedTracksinitialStepSeeds"),
3642 desc.addUntracked<std::vector<edm::InputTag>>(
3644 std::vector<edm::InputTag>{
edm::InputTag(
"initialStepTrackCandidates"),
3655 desc.addUntracked<std::vector<std::string>>(
"trackMVAs", std::vector<std::string>{{
"generalTracks"}});
3657 desc.addUntracked<
bool>(
"trackingParticlesRef",
false);
3673 edm::InputTag(
"trackingParticleNumberOfLayersProducer",
"trackerLayers"));
3675 edm::InputTag(
"trackingParticleNumberOfLayersProducer",
"pixelLayers"));
3677 edm::InputTag(
"trackingParticleNumberOfLayersProducer",
"stripStereoLayers"));
3679 desc.addUntracked<
std::string>(
"parametersDefiner",
"LhcParametersDefinerForTP");
3680 desc.addUntracked<
bool>(
"includeSeeds",
false);
3681 desc.addUntracked<
bool>(
"includeAllHits",
false);
3682 desc.addUntracked<
bool>(
"includeMVA",
true);
3683 desc.addUntracked<
bool>(
"includeTrackingParticles",
true);
3684 descriptions.
add(
"trackingNtuple",
desc);