Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:29:01

0001 // -*- C++ -*-
0002 //
0003 // Package:    TrajectoryAnalyzer
0004 // Class:      TrajectoryAnalyzer
0005 //
0006 /**\class TrajectoryAnalyzer TrajectoryAnalyzer.cc RecoTracker/TrackProducer/test/TrajectoryAnalyzer.cc
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Boris Mangano
0015 //         Created:  Mon Oct 16 10:38:20 CEST 2006
0016 //
0017 //
0018 
0019 // system include files
0020 #include <memory>
0021 
0022 // user include files
0023 #include "FWCore/Framework/interface/Frameworkfwd.h"
0024 #include "FWCore/Framework/interface/stream/EDAnalyzer.h"
0025 
0026 #include "FWCore/Framework/interface/Event.h"
0027 #include "FWCore/Framework/interface/EventSetup.h"
0028 #include "FWCore/Framework/interface/MakerMacros.h"
0029 
0030 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0031 
0032 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0033 
0034 #include "TrackingTools/PatternTools/interface/Trajectory.h"
0035 #include "TrackingTools/PatternTools/interface/TrajectoryMeasurement.h"
0036 
0037 #include <iostream>
0038 // #define COUT(x) edm::LogVerbatim(x)
0039 #define COUT(x) std::cout << x << ' '
0040 
0041 //
0042 // class decleration
0043 //
0044 
0045 class TrajectoryAnalyzer : public edm::stream::EDAnalyzer<> {
0046 public:
0047   explicit TrajectoryAnalyzer(const edm::ParameterSet&);
0048   ~TrajectoryAnalyzer();
0049 
0050 private:
0051   virtual void analyze(const edm::Event&, const edm::EventSetup&) override;
0052 
0053   // ----------member data ---------------------------
0054   edm::EDGetTokenT<std::vector<Trajectory>> trajTag;
0055 };
0056 
0057 //
0058 // constants, enums and typedefs
0059 //
0060 
0061 //
0062 // static data member definitions
0063 //
0064 
0065 //
0066 // constructors and destructor
0067 //
0068 TrajectoryAnalyzer::TrajectoryAnalyzer(const edm::ParameterSet& iConfig)
0069     : trajTag(consumes<std::vector<Trajectory>>(iConfig.getParameter<edm::InputTag>("trajectoryInput"))) {}
0070 
0071 TrajectoryAnalyzer::~TrajectoryAnalyzer() {
0072   // do anything here that needs to be done at desctruction time
0073   // (e.g. close files, deallocate resources etc.)
0074 }
0075 
0076 //
0077 // member functions
0078 //
0079 
0080 // ------------ method called to for each event  ------------
0081 void TrajectoryAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0082   using namespace edm;
0083 
0084   Handle<std::vector<Trajectory>> trajCollectionHandle;
0085   iEvent.getByToken(trajTag, trajCollectionHandle);
0086 
0087   COUT("TrajectoryAnalyzer") << "trajColl->size(): " << trajCollectionHandle->size() << std::endl;
0088   for (auto it = trajCollectionHandle->begin(); it != trajCollectionHandle->end(); it++) {
0089     COUT("TrajectoryAnalyzer") << "this traj has " << it->foundHits() << " valid hits"
0090                                << " , "
0091                                << "isValid: " << it->isValid() << std::endl;
0092 
0093     auto const& tmColl = it->measurements();
0094     for (auto itTraj = tmColl.begin(); itTraj != tmColl.end(); itTraj++) {
0095       if (!itTraj->updatedState().isValid())
0096         continue;
0097       COUT("TrajectoryAnalyzer") << "tm number: " << (itTraj - tmColl.begin()) + 1 << " , "
0098                                  << "tm.backwardState.pt: " << itTraj->backwardPredictedState().globalMomentum().perp()
0099                                  << " , "
0100                                  << "tm.forwardState.pt:  " << itTraj->forwardPredictedState().globalMomentum().perp()
0101                                  << " , "
0102                                  << "tm.updatedState.pt:  " << itTraj->updatedState().globalMomentum().perp() << " , "
0103                                  << "tm.globalPos.perp: " << itTraj->updatedState().globalPosition().perp()
0104                                  << std::endl;
0105     }
0106   }
0107 }
0108 
0109 //define this as a plug-in
0110 
0111 DEFINE_FWK_MODULE(TrajectoryAnalyzer);