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);
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");
80 out =
pset.getUntrackedParameter<
string>(
"rootFileName");
82 subsystemname_ =
pset.getUntrackedParameter<
std::string>(
"subSystemFolder",
"YourSubsystem") ;
87 if (theService)
delete theService;
106 dirName+=algo.
label()+
"_";
109 if (dirName.find(
"Tracks")<dirName.length()){
110 dirName.replace(dirName.find(
"Tracks"),6,
"");
117 simName+=
"/SimTracks";
129 hRecoSeedInner =
new HTrack(ibooker,dirName.c_str(),
"RecoSeed",
"Inner");
130 hRecoSeedPCA =
new HTrack(ibooker,dirName.c_str(),
"RecoSeed",
"PCA");
133 if(doTracksAnalysis){
136 hRecoTracksPCA =
new HTrack(ibooker,dirName.c_str(),
"RecoTracks",
"PCA");
137 hRecoTracksInner =
new HTrack(ibooker,dirName.c_str(),
"RecoTracks",
"Inner");
138 hRecoTracksOuter =
new HTrack(ibooker,dirName.c_str(),
"RecoTracks",
"Outer");
147 hChi2VsEta = ibooker.
book2D(
"chi2VsEta",
"#chi^2 VS #eta",120,-3.,3.,200,0,200);
149 hChi2Norm = ibooker.
book1D(
"chi2Norm",
"Normalized #chi^2",400,0,100);
150 hChi2NormVsEta = ibooker.
book2D(
"chi2NormVsEta",
"Normalized #chi^2 VS #eta",120,-3.,3.,400,0,100);
152 hHitsPerTrack = ibooker.
book1D(
"HitsPerTrack",
"Number of hits per track",55,0,55);
153 hHitsPerTrackVsEta = ibooker.
book2D(
"HitsPerTrackVsEta",
"Number of hits per track VS #eta",
156 hDof = ibooker.
book1D(
"dof",
"Number of Degree of Freedom",55,0,55);
157 hDofVsEta = ibooker.
book2D(
"dofVsEta",
"Number of Degree of Freedom VS #eta",120,-3.,3.,55,0,55);
159 hChi2Prob = ibooker.
book1D(
"chi2Prob",
"#chi^2 probability",200,0,1);
160 hChi2ProbVsEta = ibooker.
book2D(
"chi2ProbVsEta",
"#chi^2 probability VS #eta",120,-3.,3.,200,0,1);
162 hNumberOfTracks = ibooker.
book1D(
"NumberOfTracks",
"Number of reconstructed tracks per event",200,0,200);
163 hNumberOfTracksVsEta = ibooker.
book2D(
"NumberOfTracksVsEta",
164 "Number of reconstructed tracks per event VS #eta",
167 hChargeVsEta = ibooker.
book2D(
"ChargeVsEta",
"Charge vs #eta gen",120,-3.,3.,4,-2.,2.);
168 hChargeVsPt = ibooker.
book2D(
"ChargeVsPt",
"Charge vs P_{T} gen",250,0,200,4,-2.,2.);
169 hPtRecVsPtGen = ibooker.
book2D(
"PtRecVsPtGen",
"P_{T} rec vs P_{T} gen",250,0,200,250,0,200);
171 hDeltaPtVsEta = ibooker.
book2D(
"DeltaPtVsEta",
"#Delta P_{t} vs #eta gen",120,-3.,3.,500,-250.,250.);
172 hDeltaPt_In_Out_VsEta = ibooker.
book2D(
"DeltaPt_In_Out_VsEta_",
"P^{in}_{t} - P^{out}_{t} vs #eta gen",120,-3.,3.,500,-250.,250.);
178 LogInfo(
"MuonTrackAnalyzer")<<
"Number of Sim tracks: " << numberOfSimTracks;
180 LogInfo(
"MuonTrackAnalyzer") <<
"Number of Reco tracks: " << numberOfRecTracks;
183 if(doTracksAnalysis){
184 double eff = hRecoTracksPCA->computeEfficiency(hSimTracks,ibooker);
185 LogInfo(
"MuonTrackAnalyzer") <<
" *Track Efficiency* = "<< eff <<
"%";
189 double eff = hRecoSeedInner->computeEfficiency(hSimTracks,ibooker);
190 LogInfo(
"MuonTrackAnalyzer")<<
" *Seed Efficiency* = "<< eff <<
"%";
196 LogDebug(
"MuonTrackAnalyzer") <<
"Run: " <<
event.id().run() <<
" Event: " <<
event.id().event();
199 theService->update(eventSetup);
202 event.getByToken(theSimTracksToken,simTracks);
203 fillPlots(event,simTracks);
207 tracksAnalysis(event,eventSetup,simTracks);
210 seedsAnalysis(event,eventSetup,simTracks);
222 event.getByToken(theSeedsToken, seeds);
224 LogTrace(
"MuonTrackAnalyzer")<<
"Number of reconstructed seeds: " << seeds->size()<<endl;
226 for(TrajectorySeedCollection::const_iterator
seed = seeds->begin();
229 pair<SimTrack,double>
sim = getSimTrack(seedTSOS,simTracks);
230 fillPlots(seedTSOS, sim.first,
231 hRecoSeedInner, debug);
233 std::pair<bool,FreeTrajectoryState> propSeed =
234 theUpdator->propagateToNominalLine(seedTSOS);
236 fillPlots(propSeed.second, sim.first,
237 hRecoSeedPCA, debug);
239 LogTrace(
"MuonTrackAnalyzer")<<
"Error in seed propagation"<<endl;
252 event.getByToken(theTracksToken, tracks);
254 LogTrace(
"MuonTrackAnalyzer")<<
"Reconstructed tracks: " << tracks->size() << endl;
255 hNumberOfTracks->Fill(tracks->size());
257 if(tracks->size()) numberOfRecTracks++;
260 for(reco::TrackCollection::const_iterator
t = tracks->begin();
t != tracks->end(); ++
t) {
268 pair<SimTrack,double>
sim = getSimTrack(pcaTSOS,simTracks);
270 hNumberOfTracksVsEta->Fill(simTrack.
momentum().eta(), tracks->size());
271 fillPlots(track,simTrack);
273 LogTrace(
"MuonTrackAnalyzer") <<
"State at the outer surface: " << endl;
274 fillPlots(outerTSOS,simTrack,hRecoTracksOuter,debug);
276 LogTrace(
"MuonTrackAnalyzer") <<
"State at the inner surface: " << endl;
277 fillPlots(innerTSOS,simTrack,hRecoTracksInner,debug);
279 LogTrace(
"MuonTrackAnalyzer") <<
"State at PCA: " << endl;
280 fillPlots(pcaTSOS,simTrack,hRecoTracksPCA,debug);
282 double deltaPt_in_out = innerTSOS.
globalMomentum().
perp()-outerTSOS.globalMomentum().perp();
283 hDeltaPt_In_Out_VsEta->Fill(simTrack.
momentum().eta(),deltaPt_in_out);
286 hDeltaPtVsEta->Fill(simTrack.
momentum().eta(),deltaPt_pca_sim);
294 LogTrace(
"MuonTrackAnalyzer")<<
"--------------------------------------------"<<endl;
302 if(!checkMuonSimHitPresence(event,simTracks))
return;
305 SimTrackContainer::const_iterator simTrack;
306 LogTrace(
"MuonTrackAnalyzer")<<
"Simulated tracks: "<<simTracks->size()<<endl;
308 for (simTrack = simTracks->begin(); simTrack != simTracks->end(); ++simTrack)
309 if (
abs((*simTrack).type()) == 13) {
311 if( !isInTheAcceptance( (*simTrack).momentum().eta()) )
continue;
315 LogTrace(
"MuonTrackAnalyzer")<<
"Simualted muon:"<<endl;
316 LogTrace(
"MuonTrackAnalyzer")<<
"Sim pT: "<<
sqrt((*simTrack).momentum().perp2())<<endl;
317 LogTrace(
"MuonTrackAnalyzer")<<
"Sim Eta: "<<(*simTrack).momentum().eta()<<endl;
319 hSimTracks->Fill((*simTrack).momentum().mag(),
320 sqrt((*simTrack).momentum().perp2()),
321 (*simTrack).momentum().eta(),
322 (*simTrack).momentum().phi(),
323 -(*simTrack).type()/
abs((*simTrack).type()) );
324 LogTrace(
"MuonTrackAnalyzer") <<
"hSimTracks filled" << endl;
327 LogTrace(
"MuonTrackAnalyzer") << endl;
333 LogTrace(
"MuonTrackAnalyzer")<<
"Analizer: New track, chi2: "<<track.
chi2()<<
" dof: "<<track.
ndof()<<endl;
335 hDof->Fill(track.
ndof());
341 hChi2VsEta->Fill(simTrack.
momentum().eta(),track.
chi2());
345 hDofVsEta->Fill(simTrack.
momentum().eta(),track.
ndof());
353 histo->
Fill(recoTSOS);
357 double deltaRVal = deltaR<double>(
reco.eta(),
reco.phi(),
369 histo->
Fill(recoFTS);
373 double deltaRVal = deltaR<double>(
reco.eta(),
reco.phi(),
399 SimTrackContainer::const_iterator simTrack;
403 double bestDeltaR = 10e5;
404 for (simTrack = simTracks->begin(); simTrack != simTracks->end(); ++simTrack){
405 if (
abs((*simTrack).type()) != 13)
continue;
410 double newDeltaR = deltaR<double>(vect.eta(),vect.phi(),
411 simTrack->momentum().eta(),simTrack->momentum().phi());
413 if ( newDeltaR < bestDeltaR ) {
414 LogTrace(
"MuonTrackAnalyzer") <<
"Matching Track with DeltaR = " << newDeltaR<<endl;
415 bestDeltaR = newDeltaR;
419 return pair<SimTrack,double>(
result,bestDeltaR);
426 return (
abs(eta) <= 2.4 ) ?
true :
false;
428 return (
abs(eta) < 1.1 ) ?
true :
false;
430 return (
abs(eta) >= 1.1 &&
abs(eta) <= 2.4 ) ?
true :
false;
432 {
LogTrace(
"MuonTrackAnalyzer")<<
"No correct Eta range selected!! "<<endl;
return false;}
441 event.getByToken(theDTSimHitToken, dtSimHits);
445 event.getByToken(theCSCSimHitToken, cscSimHits);
448 event.getByToken(theRPCSimHitToken, rpcSimHits);
450 map<unsigned int, vector<const PSimHit*> > mapOfMuonSimHits;
452 for(PSimHitContainer::const_iterator simhit = dtSimHits->begin();
453 simhit != dtSimHits->end(); ++simhit) {
454 if (
abs(simhit->particleType()) != 13)
continue;
455 mapOfMuonSimHits[simhit->trackId()].push_back(&*simhit);
458 for(PSimHitContainer::const_iterator simhit = cscSimHits->begin();
459 simhit != cscSimHits->end(); ++simhit) {
460 if (
abs(simhit->particleType()) != 13)
continue;
461 mapOfMuonSimHits[simhit->trackId()].push_back(&*simhit);
464 for(PSimHitContainer::const_iterator simhit = rpcSimHits->begin();
465 simhit != rpcSimHits->end(); ++simhit) {
466 if (
abs(simhit->particleType()) != 13)
continue;
467 mapOfMuonSimHits[simhit->trackId()].push_back(&*simhit);
470 bool presence =
false;
472 for (SimTrackContainer::const_iterator simTrack = simTracks->begin();
473 simTrack != simTracks->end(); ++simTrack){
475 if (
abs(simTrack->type()) != 13)
continue;
477 map<unsigned int, vector<const PSimHit*> >::const_iterator mapIterator =
478 mapOfMuonSimHits.find(simTrack->trackId());
480 if (mapIterator != mapOfMuonSimHits.end())
497 const GeomDet* gdet = theService->trackingGeometry()->idToDet( seedDetId );
502 const DetLayer *initialLayer = theService->detLayerGeometry()->idToLayer( seedDetId );
507 vector<const DetLayer*> detLayers;
508 detLayers = theService->muonNavigationSchool()->compatibleLayers(*initialLayer, *initialState.
freeState(),detLayerOrder);
511 if(detLayers.size()){
512 const DetLayer* finalLayer = detLayers.back();
515 result = propagatedState;
T getParameter(std::string const &) const
virtual const BoundSurface & surface() const =0
The surface of the GeometricSearchDet.
void computeResolutionAndPull(TrajectoryStateOnSurface &vtx, SimTrack &simTrack)
TrackCharge charge() const
virtual ~MuonTrackAnalyzer()
Destructor.
std::pair< SimTrack, double > getSimTrack(TrajectoryStateOnSurface &tsos, edm::Handle< edm::SimTrackContainer > simTracks)
bool checkMuonSimHitPresence(const edm::Event &event, edm::Handle< edm::SimTrackContainer > simTracks)
size_t recHitsSize() const
number of RecHits
TrajectoryStateOnSurface getSeedTSOS(const TrajectorySeed &seed)
void seedsAnalysis(const edm::Event &event, const edm::EventSetup &eventSetup, edm::Handle< edm::SimTrackContainer > simTracks)
double chi2() const
chi-squared of the fit
MuonTrackAnalyzer(const edm::ParameterSet &pset)
Constructor.
std::string dumpFTS(const FreeTrajectoryState &fts) const
std::string dumpTSOS(const TrajectoryStateOnSurface &tsos) const
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > XYZVectorD
spatial vector with cartesian internal representation
virtual void endRun(DQMStore::IBooker &ibooker)
bool isInTheAcceptance(double eta)
FreeTrajectoryState const * freeState(bool withErrors=true) const
MonitorElement * book1D(Args &&...args)
tuple MuonUpdatorAtVertex
Abs< T >::type abs(const T &t)
float ChiSquaredProbability(double chiSquared, double nrDOF)
unsigned int detId() const
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
void Fill(TrajectoryStateOnSurface &)
GlobalVector momentum() const
PTrajectoryStateOnDet const & startingState() const
void setCurrentFolder(const std::string &fullpath)
MonitorElement * book2D(Args &&...args)
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
double normalizedChi2() const
chi-squared divided by n.d.o.f.
double ndof() const
number of degrees of freedom of the fit
void tracksAnalysis(const edm::Event &event, const edm::EventSetup &eventSetup, edm::Handle< edm::SimTrackContainer > simTracks)
GlobalVector globalMomentum() const
void analyze(const edm::Event &event, const edm::EventSetup &eventSetup)
const math::XYZTLorentzVectorD & momentum() const
void fillPlots(const edm::Event &event, edm::Handle< edm::SimTrackContainer > &simTracks)