Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-15 05:17:37

0001 /** \class TrackReader
0002  *  No description available.
0003  *
0004  *  \author R. Bellan - INFN Torino <riccardo.bellan@cern.ch>
0005  */
0006 
0007 // Base Class Headers
0008 #include "DataFormats/Common/interface/Handle.h"
0009 #include "DataFormats/DetId/interface/DetId.h"
0010 #include "DataFormats/TrackReco/interface/Track.h"
0011 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0012 #include "FWCore/Framework/interface/ESHandle.h"
0013 #include "FWCore/Framework/interface/Event.h"
0014 #include "FWCore/Framework/interface/EventSetup.h"
0015 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0016 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0017 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0018 #include "FWCore/Utilities/interface/InputTag.h"
0019 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
0020 #include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h"
0021 #include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h"
0022 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0023 #include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h"
0024 #include "TrackingTools/PatternTools/interface/Trajectory.h"
0025 #include "TrackingTools/Records/interface/TransientRecHitRecord.h"
0026 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
0027 #include "TrackingTools/TransientTrack/interface/TransientTrack.h"
0028 #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHit.h"
0029 #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHitBuilder.h"
0030 
0031 #include "TFile.h"
0032 #include "TH1F.h"
0033 
0034 #include <vector>
0035 
0036 class TrackReader : public edm::one::EDAnalyzer<> {
0037 public:
0038   typedef std::vector<Trajectory> Trajectories;
0039 
0040 public:
0041   /// Constructor
0042   TrackReader(const edm::ParameterSet& pset);
0043 
0044   /// Destructor
0045   virtual ~TrackReader();
0046 
0047   void analyze(const edm::Event& event, const edm::EventSetup& eventSetup);
0048 
0049 protected:
0050   //  void printTrackRecHits(const reco::Track &, edm::ESHandle<GlobalTrackingGeometry>) const;
0051 
0052 private:
0053   const edm::ESGetToken<TransientTrackingRecHitBuilder, TransientRecHitRecord> trackerBuilderToken_;
0054   const edm::ESGetToken<TransientTrackingRecHitBuilder, TransientRecHitRecord> muonBuilderToken_;
0055   edm::InputTag theInputLabel;
0056 };
0057 
0058 /// Constructor
0059 TrackReader::TrackReader(const edm::ParameterSet& parameterSet)
0060     : trackerBuilderToken_(
0061           esConsumes(edm::ESInputTag("", parameterSet.getParameter<std::string>("TrackerRecHitBuilder")))),
0062       muonBuilderToken_(esConsumes(edm::ESInputTag("", parameterSet.getParameter<std::string>("MuonRecHitBuilder")))) {
0063   theInputLabel = parameterSet.getParameter<edm::InputTag>("InputLabel");
0064 }
0065 
0066 /// Destructor
0067 TrackReader::~TrackReader() = default;
0068 
0069 void TrackReader::analyze(const edm::Event& event, const edm::EventSetup& setup) {
0070   const TransientTrackingRecHitBuilder* theTrackerRecHitBuilder = &setup.getData(trackerBuilderToken_);
0071   const TransientTrackingRecHitBuilder* theMuonRecHitBuilder = &setup.getData(muonBuilderToken_);
0072 
0073   const std::string metname = "Reco|TrackingTools|TrackReader";
0074 
0075   // Get the RecTrack collection from the event
0076   edm::Handle<reco::TrackCollection> tracks;
0077   event.getByLabel(theInputLabel, tracks);
0078 
0079   for (reco::TrackCollection::const_iterator track = tracks->begin(); track != tracks->end(); ++track) {
0080     for (trackingRecHit_iterator hit = track->recHitsBegin(); hit != track->recHitsEnd(); ++hit) {
0081       if ((*hit)->isValid()) {
0082         if ((*hit)->geographicalId().det() == DetId::Tracker) {
0083           LogDebug("TrackReader") << "Tracker hit";
0084           TransientTrackingRecHit::RecHitPointer tthit = theTrackerRecHitBuilder->build(&**hit);
0085           //      TransientTrackingRecHit::RecHitPointer preciseHit = tthit.clone(predTsos);
0086           LogTrace("TrackReader") << "Position: " << tthit->globalPosition();
0087         } else if ((*hit)->geographicalId().det() == DetId::Muon) {
0088           LogDebug("TrackReader") << "Muon hit";
0089           TransientTrackingRecHit::RecHitPointer tthit = theMuonRecHitBuilder->build(&**hit);
0090           LogTrace("TrackReader") << "Position: " << tthit->globalPosition();
0091         }
0092       }
0093     }
0094   }
0095 }
0096 
0097 #include "FWCore/PluginManager/interface/ModuleDef.h"
0098 #include "FWCore/Framework/interface/MakerMacros.h"
0099 
0100 DEFINE_FWK_MODULE(TrackReader);