2 #include "TObjString.h" 51 std::vector<float>
z0;
63 std::vector<float>
pt;
64 std::vector<float>
eta;
65 std::vector<float>
phi;
77 std::vector<float>
pt;
78 std::vector<float>
eta;
79 std::vector<float>
phi;
105 std::vector<float>
pt;
108 std::vector<float>
z0;
125 trueMatchIdx.clear();
126 truthMapMatchIdx.clear();
127 truthMapIsGenuine.clear();
128 truthMapIsLooselyGenuine.clear();
129 truthMapIsCombinatoric.clear();
130 truthMapIsUnknown.clear();
135 std::vector<float>
pt;
138 std::vector<float>
z0;
152 physCollision.clear();
155 useForAlgEff.clear();
156 useForVertexReco.clear();
162 void endJob()
override;
218 iConfig.getParameter<
edm::
InputTag>(
"l1TracksTPValueMapInputTags"))),
219 printResults_(iConfig.getParameter<
bool>(
"printResults")),
221 const std::vector<std::string> trackBranchNames(
222 iConfig.
getParameter<std::vector<std::string>>(
"l1TracksBranchNames"));
223 const std::vector<edm::InputTag> trackInputTags(
224 iConfig.
getParameter<std::vector<edm::InputTag>>(
"l1TracksInputTags"));
225 const std::vector<edm::InputTag> trackMapInputTags(
226 iConfig.
getParameter<std::vector<edm::InputTag>>(
"l1TracksTruthMapInputTags"));
228 if (trackBranchNames.size() != trackInputTags.size())
230 ") specified in the config does not match the number of input tags (" +
232 if (trackBranchNames.size() != trackMapInputTags.size())
234 ") specified in the config does not match the number of track map input tags (" +
237 const std::vector<std::string> vertexBranchNames(
238 iConfig.
getParameter<std::vector<std::string>>(
"l1VertexBranchNames"));
239 const std::vector<edm::InputTag> vertexInputTags(
240 iConfig.
getParameter<std::vector<edm::InputTag>>(
"l1VertexInputTags"));
241 const std::vector<std::string> vertexTrackNames(
242 iConfig.
getParameter<std::vector<std::string>>(
"l1VertexTrackInputs"));
244 if (vertexBranchNames.size() != vertexInputTags.size())
246 ") specified in the config does not match the number of input tags (" +
248 if (vertexBranchNames.size() != vertexTrackNames.size())
250 "The number of vertex branch names (" +
std::to_string(vertexBranchNames.size()) +
251 ") specified in the config does not match the number of associated input track collection names (" +
255 iConfig.
getParameter<std::vector<std::string>>(
"emulationVertexBranchNames"));
257 iConfig.
getParameter<std::vector<edm::InputTag>>(
"emulationVertexInputTags"));
259 const std::vector<edm::InputTag> extraVertexInputTags(
260 iConfig.
getParameter<std::vector<edm::InputTag>>(
"extraL1VertexInputTags"));
261 const std::vector<std::string> extraVertexDescriptions(
262 iConfig.
getParameter<std::vector<std::string>>(
"extraL1VertexDescriptions"));
266 outputTree_ =
fs->make<TTree>(
"l1VertexReco",
"L1 vertex-related info");
275 outputTree_->Branch((
"emulationVertices_" + *branchNameIt +
"_numTracks").c_str(), &branchData.
numTracks);
276 outputTree_->Branch((
"emulationVertices_" + *branchNameIt +
"_z0").c_str(), &branchData.
z0);
277 outputTree_->Branch((
"emulationVertices_" + *branchNameIt +
"_sumPt").c_str(), &branchData.
sumPt);
295 std::vector<std::string>::const_iterator trackBranchNameIt = trackBranchNames.begin();
296 std::vector<edm::InputTag>::const_iterator trackInputTagIt = trackInputTags.begin();
297 std::vector<edm::InputTag>::const_iterator trackMapInputTagIt = trackMapInputTags.begin();
298 for (; trackBranchNameIt != trackBranchNames.end(); trackBranchNameIt++, trackInputTagIt++, trackMapInputTagIt++) {
299 l1TracksTokenMap_[*trackBranchNameIt] = consumes<TTTrackCollectionView>(*trackInputTagIt);
301 consumes<TTTrackAssociationMap<Ref_Phase2TrackerDigi_>>(*trackMapInputTagIt);
305 outputTree_->Branch((
"recoTracks_" + *trackBranchNameIt +
"_pt").c_str(), &branchData.
pt);
306 outputTree_->Branch((
"recoTracks_" + *trackBranchNameIt +
"_eta").c_str(), &branchData.
eta);
307 outputTree_->Branch((
"recoTracks_" + *trackBranchNameIt +
"_phi").c_str(), &branchData.
phi);
308 outputTree_->Branch((
"recoTracks_" + *trackBranchNameIt +
"_z0").c_str(), &branchData.
z0);
309 outputTree_->Branch((
"recoTracks_" + *trackBranchNameIt +
"_numStubs").c_str(), &branchData.
numStubs);
310 outputTree_->Branch((
"recoTracks_" + *trackBranchNameIt +
"_chi2dof").c_str(), &branchData.
chi2dof);
312 outputTree_->Branch((
"recoTracks_" + *trackBranchNameIt +
"_truthMap_matchIdx").c_str(),
314 outputTree_->Branch((
"recoTracks_" + *trackBranchNameIt +
"_truthMap_isGenuine").c_str(),
316 outputTree_->Branch((
"recoTracks_" + *trackBranchNameIt +
"_truthMap_isLooselyGenuine").c_str(),
318 outputTree_->Branch((
"recoTracks_" + *trackBranchNameIt +
"_truthMap_isCombinatoric").c_str(),
320 outputTree_->Branch((
"recoTracks_" + *trackBranchNameIt +
"_truthMap_isUnknown").c_str(),
324 branchNameIt = vertexBranchNames.begin();
325 inputTagIt = vertexInputTags.begin();
326 std::vector<std::string>::const_iterator l1VertexTrackNameIt = vertexTrackNames.begin();
327 for (; branchNameIt != vertexBranchNames.end(); branchNameIt++, inputTagIt++, l1VertexTrackNameIt++) {
334 throw cms::Exception(
"Invalid track collection name '" + *l1VertexTrackNameIt +
335 "' specified as input to vertex collection '" + *branchNameIt +
"'");
337 outputTree_->Branch((
"recoVertices_" + *branchNameIt +
"_numTracks").c_str(), &branchData.
numTracks);
338 outputTree_->Branch((
"recoVertices_" + *branchNameIt +
"_trackIdxs").c_str(), &branchData.
trackIdxs);
339 outputTree_->Branch((
"recoVertices_" + *branchNameIt +
"_z0").c_str(), &branchData.
z0);
340 outputTree_->Branch((
"recoVertices_" + *branchNameIt +
"_sumPt").c_str(), &branchData.
sumPt);
355 for (
const auto&
inputTag : extraVertexInputTags)
357 TObjArray* descriptionArray =
new TObjArray();
358 for (
const auto&
description : extraVertexDescriptions)
359 descriptionArray->Add(
new TObjString(
description.c_str()));
370 const bool positive = (particle.
pdgId() < 0);
371 const size_t absId =
abs(particle.
pdgId());
374 return (
out << (positive ?
"d" :
"anti-d"));
376 return (
out << (positive ?
"u" :
"anti-u"));
378 return (
out << (positive ?
"s" :
"anti-s"));
380 return (
out << (positive ?
"c" :
"anti-c"));
382 return (
out << (positive ?
"b" :
"anti-b"));
384 return (
out << (positive ?
"t" :
"anti-t"));
386 return (
out << (positive ?
"e+" :
"e-"));
388 return (
out << (positive ?
"nu_e" :
"anti-nu_e"));
390 return (
out << (positive ?
"mu+" :
"mu-"));
392 return (
out << (positive ?
"nu_mu" :
"anti-nu_mu"));
394 return (
out << (positive ?
"tau+" :
"tau-"));
396 return (
out << (positive ?
"nu_tau" :
"anti-nu_tau"));
400 return (
out <<
"photon");
404 return (
out << (positive ?
"W-" :
"W+"));
406 if ((((absId / 1000) % 10) != 0) and (((absId / 10) % 10) == 0))
407 return (
out <<
"diquark<" << particle.
pdgId() <<
">");
409 return (
out <<
"unknown<" << particle.
pdgId() <<
">");
424 std::map<std::string, std::vector<L1TrackTruthMatched>> l1TrackCollections;
425 std::map<std::string, edm::Handle<TTTrackAssMap>> truthAssocMapHandles;
432 for (; (tokenMapEntry != tokenMapEntryEnd) && (mapTokenMapEntry != mapTokenMapEntryEnd);
433 ++tokenMapEntry, ++mapTokenMapEntry) {
436 iEvent.getByToken(tokenMapEntry->second, l1TracksHandle);
439 std::vector<L1TrackTruthMatched>&
l1Tracks = l1TrackCollections[tokenMapEntry->first];
441 for (
const auto&
track : l1TracksHandle->
ptrs()) {
448 std::map<std::string, std::map<const edm::Ptr<TTTrack<Ref_Phase2TrackerDigi_>>,
const L1TrackTruthMatched*>>
452 for (
const auto&
entry : l1TrackCollections) {
453 auto& edmL1Map = edmL1TrackMaps[
entry.first];
466 for (
auto bxIt = pileupHandle->begin(); bxIt != pileupHandle->end(); bxIt++) {
467 if (bxIt->getBunchCrossing() == 0) {
478 for (
const auto&
tp : *allMatchedTPsHandle) {
517 for (
const auto& genJet : *genJetsHandle) {
524 for (
const auto&
entry : l1TrackCollections) {
533 branchData.
pt.push_back(
track.pt());
534 branchData.
eta.push_back(
track.eta());
535 branchData.
phi.push_back(
track.phi0());
536 branchData.
z0.push_back(
track.z0());
545 auto it = std::find_if(allMatchedTPsHandle->begin(),
546 allMatchedTPsHandle->end(),
547 [&matchedTP](
auto const&
tp) {
return tp.getTrackingParticle() == matchedTP; });
548 assert(it != allMatchedTPsHandle->end());
565 std::vector<std::shared_ptr<const RecoVertexWithTP>> recoVertices;
566 recoVertices.reserve(
handle->size());
567 for (
unsigned int i = 0;
i <
handle->size(); ++
i) {
568 recoVertices.push_back(std::shared_ptr<const RecoVertexWithTP>(
574 for (
const std::shared_ptr<const RecoVertexWithTP>&
vtx : recoVertices) {
576 branchData.
trackIdxs.push_back(std::vector<unsigned>());
579 branchData.
z0.push_back(
vtx->z0());
580 branchData.
sumPt.push_back(
vtx->pt());
584 edm::LogInfo(
"VertexNTupler") <<
"analyze::" << recoVertices.size() <<
" '" << tokenMapEntry.first
585 <<
"' vertices were found ... ";
586 for (
const auto&
vtx : recoVertices) {
588 <<
" * z0 = " <<
vtx->z0() <<
"; contains " <<
vtx->numTracks()
590 for (
const auto& trackPtr :
vtx->tracks())
592 <<
" - z0 = " << trackPtr->z0() <<
"; pt = " << trackPtr->pt()
593 <<
", eta = " << trackPtr->eta() <<
", phi = " << trackPtr->phi0();
607 branchData.
z0.push_back(
vtx.z0());
608 branchData.
sumPt.push_back(
vtx.pt());
612 edm::LogInfo(
"VertexNTupler") <<
"analyze::" <<
handle->size() <<
" '" << tokenMapEntry.first
613 <<
"' vertices were found ... ";
616 <<
" * z0 = " <<
vtx.z0() <<
"; contains " <<
vtx.multiplicity()
632 const std::vector<l1t::Vertex>&
vertices = *vertexHandle;
644 float etaWeightedSumZ0 = 0.0;
645 float etaWeightSum = 0.0;
649 const float zRes = 0.223074 *
track->momentum().eta() *
track->momentum().eta() -
650 0.050231 *
abs(
track->momentum().eta()) + 0.209719;
651 etaWeightedSumZ0 +=
track->POCA().z() / (zRes * zRes);
652 etaWeightSum += 1.0 / (zRes * zRes);
664 edm::LogInfo(
"VertexNTupler") <<
"analyze::================ End of Event ==============";
const TrackingParticlePtr & findTrackingParticlePtr(TTTrackPtrT< T > aTrack) const
~VertexNTupler() override
static const std::string kSharedResource
std::vector< float > sumPt
std::vector< float > physCollision
T getParameter(std::string const &) const
const edm::EDGetTokenT< edm::View< reco::GenParticle > > genParticlesToken_
std::vector< std::vector< unsigned > > l1Vertices_extra_numTracks_
std::vector< edm::EDGetTokenT< std::vector< l1t::Vertex > > > l1VerticesExtraTokens_
std::vector< std::vector< float > > l1Vertices_extra_z0_
std::vector< Ptr< value_type > > const & ptrs() const
std::vector< float > energy
double vz() const
Vertex z position [cm].
std::vector< std::vector< float > > l1Vertices_extra_sumPt_
bool isUnknown(TTTrackPtrT< T > aTrack) const
More than one stub on track is "unknown".
AnalysisSettings settings_
std::vector< float > chi2dof
#define DEFINE_FWK_MODULE(type)
std::vector< float > truthMapIsUnknown
std::map< std::string, edm::EDGetTokenT< TTTrackCollectionView > > l1TracksTokenMap_
std::vector< float > truthMapIsGenuine
std::string to_string(const V &value)
std::map< std::string, edm::EDGetTokenT< TTTrackAssociationMap< Ref_Phase2TrackerDigi_ > > > l1TracksMapTokenMap_
std::map< std::string, edm::EDGetTokenT< std::vector< l1t::Vertex > > > l1VerticesTokenMap_
bool isCombinatoric(TTTrackPtrT< T > aTrack) const
Both isLooselyGenuine() & isUnknown() are false.
std::map< std::string, edm::EDGetTokenT< std::vector< l1t::VertexWord > > > l1VerticesEmulationTokenMap_
std::vector< std::vector< float > > l1Vertices_extra_z0_etaWeighted_
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
std::map< std::string, RecoTracksBranchData > l1TracksBranchData_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Stores association of Truth Particles (TP) to L1 Track-Trigger Tracks.
int pdgId() const final
PDG identifier.
std::vector< float > energy
RecoVertex< L1TrackTruthMatched > RecoVertexWithTP
unsigned int debug() const
std::vector< float > truthMapIsLooselyGenuine
bool isNull() const
Checks for null.
std::vector< float > truePileUpVtxZ0_
Simple wrapper class for TTTrack, with match to a tracking particle.
bool isGenuine(TTTrackPtrT< T > aTrack) const
std::vector< int > trueMatchIdx
const edm::EDGetTokenT< std::vector< PileupSummaryInfo > > pileupSummaryToken_
std::vector< float > truthMapIsCombinatoric
Abs< T >::type abs(const T &t)
float numTrueInteractions_
TTTrackAssociationMap< Ref_Phase2TrackerDigi_ > TTTrackAssMap
const edm::EDGetTokenT< edm::ValueMap< l1tVertexFinder::TP > > vTPsToken_
bool isLooselyGenuine(TTTrackPtrT< T > aTrack) const
std::map< std::string, EmulationVerticesBranchData > l1VerticesEmulationBranchData_
edm::View< TTTrack< Ref_Phase2TrackerDigi_ > > TTTrackCollectionView
Log< level::Info, false > LogInfo
std::ostream & operator<<(std::ostream &out, const reco::GenParticle &particle)
std::vector< float > useForVertexReco
Class to store the L1 Track Trigger tracks.
std::vector< unsigned > numStubs
std::vector< unsigned > numTracks
std::vector< float > useForAlgEff
GenJetsBranchData genJetsBranchData_
std::vector< float > useForEff
std::vector< int > status
void analyze(const edm::Event &evt, const edm::EventSetup &setup) override
TrueTracksBranchData trueTracksBranchData_
std::map< std::string, RecoVerticesBranchData > l1VerticesBranchData_
emulationVertexBranchNames
const edm::EDGetTokenT< std::vector< reco::GenJet > > genJetsToken_
const edm::EDGetTokenT< l1tVertexFinder::InputData > inputDataToken_
std::vector< int > truthMapMatchIdx
std::map< std::string, std::string > l1VerticesInputMap_
std::vector< std::vector< unsigned > > trackIdxs
GenParticlesBranchData genParticlesHardOutgoingBranchData_
const edm::EDGetTokenT< std::vector< l1tVertexFinder::TP > > allMatchedTPsToken_