49 theSimTracksToken = consumes<edm::SimTrackContainer>(theSimTracksLabel);
52 theTracksToken = consumes<reco::TrackCollection>(theTracksLabel);
53 doTracksAnalysis =
pset.getUntrackedParameter<
bool>(
"DoTracksAnalysis",
true);
55 doSeedsAnalysis =
pset.getUntrackedParameter<
bool>(
"DoSeedsAnalysis",
false);
56 if (doSeedsAnalysis) {
58 theSeedsToken = consumes<TrajectorySeedCollection>(theSeedsLabel);
60 theSeedPropagatorName = updatorPar.
getParameter<
string>(
"Propagator");
65 theCSCSimHitLabel =
pset.getParameter<
InputTag>(
"CSCSimHit");
66 theDTSimHitLabel =
pset.getParameter<
InputTag>(
"DTSimHit");
67 theRPCSimHitLabel =
pset.getParameter<
InputTag>(
"RPCSimHit");
68 theCSCSimHitToken = consumes<std::vector<PSimHit> >(theCSCSimHitLabel);
69 theDTSimHitToken = consumes<std::vector<PSimHit> >(theDTSimHitLabel);
70 theRPCSimHitToken = consumes<std::vector<PSimHit> >(theRPCSimHitLabel);
72 theEtaRange = (
EtaRange)
pset.getParameter<
int>(
"EtaRange");
75 numberOfSimTracks = 0;
77 numberOfRecTracks = 0;
80 out =
pset.getUntrackedParameter<
string>(
"rootFileName");
82 subsystemname_ =
pset.getUntrackedParameter<
std::string>(
"subSystemFolder",
"YourSubsystem");
98 if (!
algo.process().empty())
100 if (!
algo.label().empty())
102 if (!
algo.instance().empty())
112 simName +=
"/SimTracks";
121 if (doSeedsAnalysis) {
124 hRecoSeedInner =
new HTrack(ibooker,
dirName,
"RecoSeed",
"Inner");
125 hRecoSeedPCA =
new HTrack(ibooker,
dirName,
"RecoSeed",
"PCA");
128 if (doTracksAnalysis) {
131 hRecoTracksPCA =
new HTrack(ibooker,
dirName,
"RecoTracks",
"PCA");
132 hRecoTracksInner =
new HTrack(ibooker,
dirName,
"RecoTracks",
"Inner");
133 hRecoTracksOuter =
new HTrack(ibooker,
dirName,
"RecoTracks",
"Outer");
140 hChi2 = ibooker.
book1D(
"chi2",
"#chi^2", 200, 0, 200);
141 hChi2VsEta = ibooker.
book2D(
"chi2VsEta",
"#chi^2 VS #eta", 120, -3., 3., 200, 0, 200);
143 hChi2Norm = ibooker.
book1D(
"chi2Norm",
"Normalized #chi^2", 400, 0, 100);
144 hChi2NormVsEta = ibooker.
book2D(
"chi2NormVsEta",
"Normalized #chi^2 VS #eta", 120, -3., 3., 400, 0, 100);
146 hHitsPerTrack = ibooker.
book1D(
"HitsPerTrack",
"Number of hits per track", 55, 0, 55);
148 ibooker.
book2D(
"HitsPerTrackVsEta",
"Number of hits per track VS #eta", 120, -3., 3., 55, 0, 55);
150 hDof = ibooker.
book1D(
"dof",
"Number of Degree of Freedom", 55, 0, 55);
151 hDofVsEta = ibooker.
book2D(
"dofVsEta",
"Number of Degree of Freedom VS #eta", 120, -3., 3., 55, 0, 55);
153 hChi2Prob = ibooker.
book1D(
"chi2Prob",
"#chi^2 probability", 200, 0, 1);
154 hChi2ProbVsEta = ibooker.
book2D(
"chi2ProbVsEta",
"#chi^2 probability VS #eta", 120, -3., 3., 200, 0, 1);
156 hNumberOfTracks = ibooker.
book1D(
"NumberOfTracks",
"Number of reconstructed tracks per event", 200, 0, 200);
157 hNumberOfTracksVsEta = ibooker.
book2D(
158 "NumberOfTracksVsEta",
"Number of reconstructed tracks per event VS #eta", 120, -3., 3., 10, 0, 10);
160 hChargeVsEta = ibooker.
book2D(
"ChargeVsEta",
"Charge vs #eta gen", 120, -3., 3., 4, -2., 2.);
161 hChargeVsPt = ibooker.
book2D(
"ChargeVsPt",
"Charge vs P_{T} gen", 250, 0, 200, 4, -2., 2.);
162 hPtRecVsPtGen = ibooker.
book2D(
"PtRecVsPtGen",
"P_{T} rec vs P_{T} gen", 250, 0, 200, 250, 0, 200);
164 hDeltaPtVsEta = ibooker.
book2D(
"DeltaPtVsEta",
"#Delta P_{t} vs #eta gen", 120, -3., 3., 500, -250., 250.);
165 hDeltaPt_In_Out_VsEta =
166 ibooker.
book2D(
"DeltaPt_In_Out_VsEta_",
"P^{in}_{t} - P^{out}_{t} vs #eta gen", 120, -3., 3., 500, -250., 250.);
171 LogDebug(
"MuonTrackAnalyzer") <<
"Run: " <<
event.id().run() <<
" Event: " <<
event.id().event();
177 event.getByToken(theSimTracksToken,
simTracks);
180 if (doTracksAnalysis)
194 event.getByToken(theSeedsToken,
seeds);
196 LogTrace(
"MuonTrackAnalyzer") <<
"Number of reconstructed seeds: " <<
seeds->size() << endl;
200 pair<SimTrack, double>
sim = getSimTrack(seedTSOS,
simTracks);
201 fillPlots(seedTSOS,
sim.first, hRecoSeedInner,
debug);
203 std::pair<bool, FreeTrajectoryState> propSeed = theUpdator->propagateToNominalLine(seedTSOS);
205 fillPlots(propSeed.second,
sim.first, hRecoSeedPCA,
debug);
207 LogTrace(
"MuonTrackAnalyzer") <<
"Error in seed propagation" << endl;
218 event.getByToken(theTracksToken,
tracks);
220 LogTrace(
"MuonTrackAnalyzer") <<
"Reconstructed tracks: " <<
tracks->size() << endl;
221 hNumberOfTracks->Fill(
tracks->size());
227 for (reco::TrackCollection::const_iterator
t =
tracks->begin();
t !=
tracks->end(); ++
t) {
234 pair<SimTrack, double>
sim = getSimTrack(pcaTSOS,
simTracks);
236 hNumberOfTracksVsEta->Fill(
simTrack.momentum().eta(),
tracks->size());
239 LogTrace(
"MuonTrackAnalyzer") <<
"State at the outer surface: " << endl;
242 LogTrace(
"MuonTrackAnalyzer") <<
"State at the inner surface: " << endl;
245 LogTrace(
"MuonTrackAnalyzer") <<
"State at PCA: " << endl;
248 double deltaPt_in_out = innerTSOS.
globalMomentum().
perp() - outerTSOS.globalMomentum().perp();
249 hDeltaPt_In_Out_VsEta->Fill(
simTrack.momentum().eta(), deltaPt_in_out);
252 hDeltaPtVsEta->Fill(
simTrack.momentum().eta(), deltaPt_pca_sim);
260 LogTrace(
"MuonTrackAnalyzer") <<
"--------------------------------------------" << endl;
268 SimTrackContainer::const_iterator
simTrack;
269 LogTrace(
"MuonTrackAnalyzer") <<
"Simulated tracks: " <<
simTracks->size() << endl;
272 if (
abs((*simTrack).type()) == 13) {
273 if (!isInTheAcceptance((*simTrack).momentum().eta()))
278 LogTrace(
"MuonTrackAnalyzer") <<
"Simualted muon:" << endl;
279 LogTrace(
"MuonTrackAnalyzer") <<
"Sim pT: " <<
sqrt((*simTrack).momentum().perp2()) << endl;
280 LogTrace(
"MuonTrackAnalyzer") <<
"Sim Eta: " << (*simTrack).momentum().eta() << endl;
282 hSimTracks->Fill((*simTrack).momentum().mag(),
283 sqrt((*simTrack).momentum().perp2()),
284 (*simTrack).momentum().eta(),
285 (*simTrack).momentum().phi(),
286 -(*simTrack).type() /
abs((*simTrack).type()));
287 LogTrace(
"MuonTrackAnalyzer") <<
"hSimTracks filled" << endl;
290 LogTrace(
"MuonTrackAnalyzer") << endl;
294 LogTrace(
"MuonTrackAnalyzer") <<
"Analizer: New track, chi2: " <<
track.chi2() <<
" dof: " <<
track.ndof() << endl;
295 hChi2->Fill(
track.chi2());
296 hDof->Fill(
track.ndof());
297 hChi2Norm->Fill(
track.normalizedChi2());
298 hHitsPerTrack->Fill(
track.recHitsSize());
303 hChi2NormVsEta->Fill(
simTrack.momentum().eta(),
track.normalizedChi2());
305 hHitsPerTrackVsEta->Fill(
simTrack.momentum().eta(),
track.recHitsSize());
313 LogTrace(
"MuonTrackAnalyzer") <<
debug.dumpTSOS(recoTSOS) << endl;
314 histo->Fill(recoTSOS);
319 histo->FillDeltaR(deltaRVal);
328 LogTrace(
"MuonTrackAnalyzer") <<
debug.dumpFTS(recoFTS) << endl;
329 histo->Fill(recoFTS);
334 histo->FillDeltaR(deltaRVal);
356 SimTrackContainer::const_iterator
simTrack;
360 double bestDeltaR = 10
e5;
362 if (
abs((*simTrack).type()) != 13)
368 double newDeltaR = deltaR<double>(vect.eta(), vect.phi(),
simTrack->momentum().eta(),
simTrack->momentum().phi());
370 if (newDeltaR < bestDeltaR) {
371 LogTrace(
"MuonTrackAnalyzer") <<
"Matching Track with DeltaR = " << newDeltaR << endl;
372 bestDeltaR = newDeltaR;
376 return pair<SimTrack, double>(
result, bestDeltaR);
380 switch (theEtaRange) {
388 LogTrace(
"MuonTrackAnalyzer") <<
"No correct Eta range selected!! " << endl;
397 event.getByToken(theDTSimHitToken, dtSimHits);
400 event.getByToken(theCSCSimHitToken, cscSimHits);
403 event.getByToken(theRPCSimHitToken, rpcSimHits);
405 map<unsigned int, vector<const PSimHit *> > mapOfMuonSimHits;
407 for (PSimHitContainer::const_iterator simhit = dtSimHits->begin(); simhit != dtSimHits->end(); ++simhit) {
408 if (
abs(simhit->particleType()) != 13)
410 mapOfMuonSimHits[simhit->trackId()].push_back(&*simhit);
413 for (PSimHitContainer::const_iterator simhit = cscSimHits->begin(); simhit != cscSimHits->end(); ++simhit) {
414 if (
abs(simhit->particleType()) != 13)
416 mapOfMuonSimHits[simhit->trackId()].push_back(&*simhit);
419 for (PSimHitContainer::const_iterator simhit = rpcSimHits->begin(); simhit != rpcSimHits->end(); ++simhit) {
420 if (
abs(simhit->particleType()) != 13)
422 mapOfMuonSimHits[simhit->trackId()].push_back(&*simhit);
425 bool presence =
false;
431 map<unsigned int, vector<const PSimHit *> >::const_iterator mapIterator =
432 mapOfMuonSimHits.find(
simTrack->trackId());
434 if (mapIterator != mapOfMuonSimHits.end())
449 const GeomDet *gdet = theService->trackingGeometry()->idToDet(seedDetId);
455 const DetLayer *initialLayer = theService->detLayerGeometry()->idToLayer(seedDetId);
460 vector<const DetLayer *> detLayers;
462 theService->muonNavigationSchool()->compatibleLayers(*initialLayer, *initialState.
freeState(), detLayerOrder);
465 if (!detLayers.empty()) {
466 const DetLayer *finalLayer = detLayers.back();
468 theService->propagator(theSeedPropagatorName)->propagate(initialState, finalLayer->
surface());
virtual const BoundSurface & surface() const =0
The surface of the GeometricSearchDet.
T getParameter(std::string const &) const
std::pair< SimTrack, double > getSimTrack(TrajectoryStateOnSurface &tsos, edm::Handle< edm::SimTrackContainer > simTracks)
virtual void setCurrentFolder(std::string const &fullpath)
bool checkMuonSimHitPresence(const edm::Event &event, edm::Handle< edm::SimTrackContainer > simTracks)
def replace(string, replacements)
TrajectoryStateOnSurface getSeedTSOS(const TrajectorySeed &seed)
void seedsAnalysis(const edm::Event &event, const edm::EventSetup &eventSetup, edm::Handle< edm::SimTrackContainer > simTracks)
MuonTrackAnalyzer(const edm::ParameterSet &pset)
Constructor.
unsigned int detId() const
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > XYZVectorD
spatial vector with cartesian internal representation
bool isInTheAcceptance(double eta)
GlobalVector momentum() const
Abs< T >::type abs(const T &t)
float ChiSquaredProbability(double chiSquared, double nrDOF)
TrackCharge charge() const
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
GlobalVector globalMomentum() const
void tracksAnalysis(const edm::Event &event, const edm::EventSetup &eventSetup, edm::Handle< edm::SimTrackContainer > simTracks)
FreeTrajectoryState const * freeState(bool withErrors=true) const
~MuonTrackAnalyzer() override
Destructor.
void analyze(const edm::Event &event, const edm::EventSetup &eventSetup) override
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
void fillPlots(const edm::Event &event, edm::Handle< edm::SimTrackContainer > &simTracks)