File indexing completed on 2024-04-06 12:29:01
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include <memory>
0021
0022
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
0039 #define COUT(x) std::cout << x << ' '
0040
0041
0042
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
0054 edm::EDGetTokenT<std::vector<Trajectory>> trajTag;
0055 };
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068 TrajectoryAnalyzer::TrajectoryAnalyzer(const edm::ParameterSet& iConfig)
0069 : trajTag(consumes<std::vector<Trajectory>>(iConfig.getParameter<edm::InputTag>("trajectoryInput"))) {}
0070
0071 TrajectoryAnalyzer::~TrajectoryAnalyzer() {
0072
0073
0074 }
0075
0076
0077
0078
0079
0080
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
0110
0111 DEFINE_FWK_MODULE(TrajectoryAnalyzer);