File indexing completed on 2024-04-06 12:33:49
0001 #include "Validation/TrackingMCTruth/interface/TrackingTruthValid.h"
0002 #include "DataFormats/Common/interface/Handle.h"
0003 #include "FWCore/Framework/interface/Event.h"
0004 #include "FWCore/Framework/interface/EventSetup.h"
0005 #include "FWCore/Framework/interface/MakerMacros.h"
0006 #include "FWCore/PluginManager/interface/ModuleDef.h"
0007 #include "FWCore/ServiceRegistry/interface/Service.h"
0008 #include "DQMServices/Core/interface/DQMStore.h"
0009 #include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h"
0010 #include "SimDataFormats/CrossingFrame/interface/MixCollection.h"
0011 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
0012 #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h"
0013
0014 #include <cmath>
0015
0016 typedef edm::RefVector<std::vector<TrackingParticle>> TrackingParticleContainer;
0017
0018 typedef TrackingParticleRefVector::iterator tp_iterator;
0019 typedef TrackingParticle::g4t_iterator g4t_iterator;
0020 typedef TrackingParticle::genp_iterator genp_iterator;
0021 typedef TrackingVertex::genv_iterator genv_iterator;
0022 typedef TrackingVertex::g4v_iterator g4v_iterator;
0023
0024 TrackingTruthValid::TrackingTruthValid(const edm::ParameterSet &conf)
0025 : runStandalone(conf.getParameter<bool>("runStandalone")),
0026 outputFile(conf.getParameter<std::string>("outputFile")),
0027 dbe_(nullptr),
0028 vec_TrackingParticle_Token_(consumes<TrackingParticleCollection>(conf.getParameter<edm::InputTag>("src"))) {}
0029
0030 void TrackingTruthValid::bookHistograms(DQMStore::IBooker &ibooker, const edm::Run &run, const edm::EventSetup &es) {
0031 dbe_ = edm::Service<DQMStore>().operator->();
0032 ibooker.setCurrentFolder("Tracking/TrackingMCTruth/TrackingParticle");
0033
0034 meTPMass = ibooker.book1D("TPMass", "Tracking Particle Mass", 100, -1, +5.);
0035 meTPCharge = ibooker.book1D("TPCharge", "Tracking Particle Charge", 10, -5, 5);
0036 meTPId = ibooker.book1D("TPId", "Tracking Particle Id", 500, -5000, 5000);
0037 meTPProc = ibooker.book1D("TPProc", "Tracking Particle Proc", 20, -0.5, 19.5);
0038 meTPAllHits = ibooker.book1D("TPAllHits", "Tracking Particle All Hits", 200, -0.5, 199.5);
0039 meTPMatchedHits = ibooker.book1D("TPMatchedHits", "Tracking Particle Matched Hits", 100, -0.5, 99.5);
0040 meTPPt = ibooker.book1D("TPPt", "Tracking Particle Pt", 100, 0, 100.);
0041 meTPEta = ibooker.book1D("TPEta", "Tracking Particle Eta", 100, -7., 7.);
0042 meTPPhi = ibooker.book1D("TPPhi", "Tracking Particle Phi", 100, -4., 4);
0043 meTPVtxX = ibooker.book1D("TPVtxX", "Tracking Particle VtxX", 100, -100, 100.);
0044 meTPVtxY = ibooker.book1D("TPVtxY", "Tracking Particle VtxY", 100, -100, 100.);
0045 meTPVtxZ = ibooker.book1D("TPVtxZ", "Tracking Particle VtxZ", 100, -100, 100.);
0046 meTPtip = ibooker.book1D("TPtip", "Tracking Particle tip", 100, 0, 1000.);
0047 meTPlip = ibooker.book1D("TPlip", "Tracking Particle lip", 100, 0, 100.);
0048
0049
0050 meTPProc->setBinLabel(1, "Undefined");
0051 meTPProc->setBinLabel(2, "Unknown");
0052 meTPProc->setBinLabel(3, "Primary");
0053 meTPProc->setBinLabel(4, "Hadronic");
0054 meTPProc->setBinLabel(5, "Decay");
0055 meTPProc->setBinLabel(6, "Compton");
0056 meTPProc->setBinLabel(7, "Annihilation");
0057 meTPProc->setBinLabel(8, "EIoni");
0058 meTPProc->setBinLabel(9, "HIoni");
0059 meTPProc->setBinLabel(10, "MuIoni");
0060 meTPProc->setBinLabel(11, "Photon");
0061 meTPProc->setBinLabel(12, "MuPairProd");
0062 meTPProc->setBinLabel(13, "Conversions");
0063 meTPProc->setBinLabel(14, "EBrem");
0064 meTPProc->setBinLabel(15, "SynchrotronRadiation");
0065 meTPProc->setBinLabel(16, "MuBrem");
0066 meTPProc->setBinLabel(17, "MuNucl");
0067 meTPProc->setBinLabel(18, "");
0068 meTPProc->setBinLabel(19, "");
0069 meTPProc->setBinLabel(20, "");
0070 }
0071
0072 void TrackingTruthValid::analyze(const edm::Event &event, const edm::EventSetup &c) {
0073 edm::Handle<TrackingParticleCollection> TruthTrackContainer;
0074
0075
0076 event.getByToken(vec_TrackingParticle_Token_, TruthTrackContainer);
0077
0078 const TrackingParticleCollection *tPC = TruthTrackContainer.product();
0079
0080
0081 for (TrackingParticleCollection::const_iterator t = tPC->begin(); t != tPC->end(); ++t) {
0082
0083
0084
0085 meTPMass->Fill(t->mass());
0086 meTPCharge->Fill(t->charge());
0087 meTPId->Fill(t->pdgId());
0088 meTPPt->Fill(sqrt(t->momentum().perp2()));
0089 meTPEta->Fill(t->momentum().eta());
0090 meTPPhi->Fill(t->momentum().Phi());
0091
0092
0093
0094
0095
0096
0097 meTPAllHits->Fill(t->numberOfTrackerHits());
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111 meTPMatchedHits->Fill(t->numberOfTrackerLayers());
0112 meTPVtxX->Fill(t->vx());
0113 meTPVtxY->Fill(t->vy());
0114 meTPVtxZ->Fill(t->vz());
0115 meTPtip->Fill(sqrt(t->vertex().perp2()));
0116 meTPlip->Fill(t->vz());
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142 }
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182 }