48 theSimTracksToken = consumes<edm::SimTrackContainer>(theSimTracksLabel);
51 theTracksToken = consumes<reco::TrackCollection>(theTracksLabel);
57 theSeedsToken = consumes<TrajectorySeedCollection>(theSeedsLabel);
59 theSeedPropagatorName = updatorPar.
getParameter<
string>(
"Propagator");
67 theCSCSimHitToken = consumes<std::vector<PSimHit> >(theCSCSimHitLabel);
68 theDTSimHitToken = consumes<std::vector<PSimHit> >(theDTSimHitLabel);
69 theRPCSimHitToken = consumes<std::vector<PSimHit> >(theRPCSimHitLabel);
86 if (theService)
delete theService;
102 dirName+=algo.
label()+
"_";
105 if (dirName.find(
"Tracks")<dirName.length()){
106 dirName.replace(dirName.find(
"Tracks"),6,
"");
113 simName+=
"/SimTracks";
125 hRecoSeedInner =
new HTrack(dirName.c_str(),
"RecoSeed",
"Inner");
126 hRecoSeedPCA =
new HTrack(dirName.c_str(),
"RecoSeed",
"PCA");
129 if(doTracksAnalysis){
132 hRecoTracksPCA =
new HTrack(dirName.c_str(),
"RecoTracks",
"PCA");
133 hRecoTracksInner =
new HTrack(dirName.c_str(),
"RecoTracks",
"Inner");
134 hRecoTracksOuter =
new HTrack(dirName.c_str(),
"RecoTracks",
"Outer");
143 hChi2VsEta =
dbe_->
book2D(
"chi2VsEta",
"#chi^2 VS #eta",120,-3.,3.,200,0,200);
145 hChi2Norm =
dbe_->
book1D(
"chi2Norm",
"Normalized #chi^2",400,0,100);
146 hChi2NormVsEta =
dbe_->
book2D(
"chi2NormVsEta",
"Normalized #chi^2 VS #eta",120,-3.,3.,400,0,100);
148 hHitsPerTrack =
dbe_->
book1D(
"HitsPerTrack",
"Number of hits per track",55,0,55);
149 hHitsPerTrackVsEta =
dbe_->
book2D(
"HitsPerTrackVsEta",
"Number of hits per track VS #eta",
152 hDof =
dbe_->
book1D(
"dof",
"Number of Degree of Freedom",55,0,55);
153 hDofVsEta =
dbe_->
book2D(
"dofVsEta",
"Number of Degree of Freedom VS #eta",120,-3.,3.,55,0,55);
155 hChi2Prob =
dbe_->
book1D(
"chi2Prob",
"#chi^2 probability",200,0,1);
156 hChi2ProbVsEta =
dbe_->
book2D(
"chi2ProbVsEta",
"#chi^2 probability VS #eta",120,-3.,3.,200,0,1);
158 hNumberOfTracks =
dbe_->
book1D(
"NumberOfTracks",
"Number of reconstructed tracks per event",200,0,200);
159 hNumberOfTracksVsEta =
dbe_->
book2D(
"NumberOfTracksVsEta",
160 "Number of reconstructed tracks per event VS #eta",
163 hChargeVsEta =
dbe_->
book2D(
"ChargeVsEta",
"Charge vs #eta gen",120,-3.,3.,4,-2.,2.);
164 hChargeVsPt =
dbe_->
book2D(
"ChargeVsPt",
"Charge vs P_{T} gen",250,0,200,4,-2.,2.);
165 hPtRecVsPtGen =
dbe_->
book2D(
"PtRecVsPtGen",
"P_{T} rec vs P_{T} gen",250,0,200,250,0,200);
167 hDeltaPtVsEta =
dbe_->
book2D(
"DeltaPtVsEta",
"#Delta P_{t} vs #eta gen",120,-3.,3.,500,-250.,250.);
168 hDeltaPt_In_Out_VsEta =
dbe_->
book2D(
"DeltaPt_In_Out_VsEta_",
"P^{in}_{t} - P^{out}_{t} vs #eta gen",120,-3.,3.,500,-250.,250.);
177 LogInfo(
"MuonTrackAnalyzer")<<
"Number of Sim tracks: " << numberOfSimTracks;
179 LogInfo(
"MuonTrackAnalyzer") <<
"Number of Reco tracks: " << numberOfRecTracks;
182 if(doTracksAnalysis){
183 double eff = hRecoTracksPCA->computeEfficiency(hSimTracks);
184 LogInfo(
"MuonTrackAnalyzer") <<
" *Track Efficiency* = "<< eff <<
"%";
188 double eff = hRecoSeedInner->computeEfficiency(hSimTracks);
189 LogInfo(
"MuonTrackAnalyzer")<<
" *Seed Efficiency* = "<< eff <<
"%";
195 LogDebug(
"MuonTrackAnalyzer") <<
"Run: " <<
event.id().run() <<
" Event: " <<
event.id().event();
198 theService->update(eventSetup);
201 event.getByToken(theSimTracksToken,simTracks);
202 fillPlots(event,simTracks);
206 tracksAnalysis(event,eventSetup,simTracks);
209 seedsAnalysis(event,eventSetup,simTracks);
221 event.getByToken(theSeedsToken, seeds);
223 LogTrace(
"MuonTrackAnalyzer")<<
"Number of reconstructed seeds: " << seeds->size()<<endl;
225 for(TrajectorySeedCollection::const_iterator seed = seeds->begin();
226 seed != seeds->end(); ++seed){
228 pair<SimTrack,double>
sim = getSimTrack(seedTSOS,simTracks);
229 fillPlots(seedTSOS, sim.first,
230 hRecoSeedInner, debug);
232 std::pair<bool,FreeTrajectoryState> propSeed =
233 theUpdator->propagateToNominalLine(seedTSOS);
235 fillPlots(propSeed.second, sim.first,
236 hRecoSeedPCA, debug);
238 LogTrace(
"MuonTrackAnalyzer")<<
"Error in seed propagation"<<endl;
251 event.getByToken(theTracksToken, tracks);
253 LogTrace(
"MuonTrackAnalyzer")<<
"Reconstructed tracks: " << tracks->size() << endl;
254 hNumberOfTracks->Fill(tracks->size());
256 if(tracks->size()) numberOfRecTracks++;
259 for(reco::TrackCollection::const_iterator
t = tracks->begin();
t != tracks->end(); ++
t) {
267 pair<SimTrack,double>
sim = getSimTrack(pcaTSOS,simTracks);
269 hNumberOfTracksVsEta->Fill(simTrack.
momentum().eta(), tracks->size());
270 fillPlots(track,simTrack);
272 LogTrace(
"MuonTrackAnalyzer") <<
"State at the outer surface: " << endl;
273 fillPlots(outerTSOS,simTrack,hRecoTracksOuter,debug);
275 LogTrace(
"MuonTrackAnalyzer") <<
"State at the inner surface: " << endl;
276 fillPlots(innerTSOS,simTrack,hRecoTracksInner,debug);
278 LogTrace(
"MuonTrackAnalyzer") <<
"State at PCA: " << endl;
279 fillPlots(pcaTSOS,simTrack,hRecoTracksPCA,debug);
281 double deltaPt_in_out = innerTSOS.
globalMomentum().
perp()-outerTSOS.globalMomentum().perp();
282 hDeltaPt_In_Out_VsEta->Fill(simTrack.
momentum().eta(),deltaPt_in_out);
285 hDeltaPtVsEta->Fill(simTrack.
momentum().eta(),deltaPt_pca_sim);
293 LogTrace(
"MuonTrackAnalyzer")<<
"--------------------------------------------"<<endl;
301 if(!checkMuonSimHitPresence(event,simTracks))
return;
304 SimTrackContainer::const_iterator simTrack;
305 LogTrace(
"MuonTrackAnalyzer")<<
"Simulated tracks: "<<simTracks->size()<<endl;
307 for (simTrack = simTracks->begin(); simTrack != simTracks->end(); ++simTrack)
308 if (
abs((*simTrack).type()) == 13) {
310 if( !isInTheAcceptance( (*simTrack).momentum().eta()) )
continue;
314 LogTrace(
"MuonTrackAnalyzer")<<
"Simualted muon:"<<endl;
315 LogTrace(
"MuonTrackAnalyzer")<<
"Sim pT: "<<
sqrt((*simTrack).momentum().perp2())<<endl;
316 LogTrace(
"MuonTrackAnalyzer")<<
"Sim Eta: "<<(*simTrack).momentum().eta()<<endl;
318 hSimTracks->Fill((*simTrack).momentum().mag(),
319 sqrt((*simTrack).momentum().perp2()),
320 (*simTrack).momentum().eta(),
321 (*simTrack).momentum().phi(),
322 -(*simTrack).type()/
abs((*simTrack).type()) );
323 LogTrace(
"MuonTrackAnalyzer") <<
"hSimTracks filled" << endl;
326 LogTrace(
"MuonTrackAnalyzer") << endl;
332 LogTrace(
"MuonTrackAnalyzer")<<
"Analizer: New track, chi2: "<<track.
chi2()<<
" dof: "<<track.
ndof()<<endl;
334 hDof->Fill(track.
ndof());
340 hChi2VsEta->Fill(simTrack.
momentum().eta(),track.
chi2());
344 hDofVsEta->Fill(simTrack.
momentum().eta(),track.
ndof());
352 histo->
Fill(recoTSOS);
356 double deltaRVal = deltaR<double>(
reco.eta(),
reco.phi(),
368 histo->
Fill(recoFTS);
372 double deltaRVal = deltaR<double>(
reco.eta(),
reco.phi(),
398 SimTrackContainer::const_iterator simTrack;
402 double bestDeltaR = 10e5;
403 for (simTrack = simTracks->begin(); simTrack != simTracks->end(); ++simTrack){
404 if (
abs((*simTrack).type()) != 13)
continue;
409 double newDeltaR = deltaR<double>(vect.eta(),vect.phi(),
410 simTrack->momentum().eta(),simTrack->momentum().phi());
412 if ( newDeltaR < bestDeltaR ) {
413 LogTrace(
"MuonTrackAnalyzer") <<
"Matching Track with DeltaR = " << newDeltaR<<endl;
414 bestDeltaR = newDeltaR;
418 return pair<SimTrack,double>(
result,bestDeltaR);
425 return (
abs(eta) <= 2.4 ) ?
true :
false;
427 return (
abs(eta) < 1.1 ) ?
true :
false;
429 return (
abs(eta) >= 1.1 &&
abs(eta) <= 2.4 ) ?
true :
false;
431 {
LogTrace(
"MuonTrackAnalyzer")<<
"No correct Eta range selected!! "<<endl;
return false;}
440 event.getByToken(theDTSimHitToken, dtSimHits);
444 event.getByToken(theCSCSimHitToken, cscSimHits);
447 event.getByToken(theRPCSimHitToken, rpcSimHits);
449 map<unsigned int, vector<const PSimHit*> > mapOfMuonSimHits;
451 for(PSimHitContainer::const_iterator simhit = dtSimHits->begin();
452 simhit != dtSimHits->end(); ++simhit) {
453 if (
abs(simhit->particleType()) != 13)
continue;
454 mapOfMuonSimHits[simhit->trackId()].push_back(&*simhit);
457 for(PSimHitContainer::const_iterator simhit = cscSimHits->begin();
458 simhit != cscSimHits->end(); ++simhit) {
459 if (
abs(simhit->particleType()) != 13)
continue;
460 mapOfMuonSimHits[simhit->trackId()].push_back(&*simhit);
463 for(PSimHitContainer::const_iterator simhit = rpcSimHits->begin();
464 simhit != rpcSimHits->end(); ++simhit) {
465 if (
abs(simhit->particleType()) != 13)
continue;
466 mapOfMuonSimHits[simhit->trackId()].push_back(&*simhit);
469 bool presence =
false;
471 for (SimTrackContainer::const_iterator simTrack = simTracks->begin();
472 simTrack != simTracks->end(); ++simTrack){
474 if (
abs(simTrack->type()) != 13)
continue;
476 map<unsigned int, vector<const PSimHit*> >::const_iterator mapIterator =
477 mapOfMuonSimHits.find(simTrack->trackId());
479 if (mapIterator != mapOfMuonSimHits.end())
496 const GeomDet* gdet = theService->trackingGeometry()->idToDet( seedDetId );
501 const DetLayer *initialLayer = theService->detLayerGeometry()->idToLayer( seedDetId );
506 vector<const DetLayer*> detLayers;
507 detLayers = initialLayer->compatibleLayers( *initialState.
freeState(),detLayerOrder);
510 if(detLayers.size()){
511 const DetLayer* finalLayer = detLayers.back();
514 result = propagatedState;
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T 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)
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
bool checkMuonSimHitPresence(const edm::Event &event, edm::Handle< edm::SimTrackContainer > simTracks)
void cd(void)
go to top directory (ie. root)
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
bool isInTheAcceptance(double eta)
FreeTrajectoryState const * freeState(bool withErrors=true) const
tuple MuonUpdatorAtVertex
Abs< T >::type abs(const T &t)
float ChiSquaredProbability(double chiSquared, double nrDOF)
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
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
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
particle info...
void showDirStructure(void) const
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
void fillPlots(const edm::Event &event, edm::Handle< edm::SimTrackContainer > &simTracks)
void setCurrentFolder(const std::string &fullpath)