CMS 3D CMS Logo

PPSStraightTrackAligner.cc
Go to the documentation of this file.
1 /****************************************************************************
2 * Authors:
3 * Jan Kašpar (jan.kaspar@gmail.com)
4 * Cristian Baldenegro (crisx.baldenegro@gmail.com)
5 ****************************************************************************/
6 
15 
17 
22 
29 
34 public:
37 
38 private:
39  unsigned int verbosity_;
40 
45 
50 
52 
56 
59 
60  void analyze(const edm::Event &e, const edm::EventSetup &es) override;
61 
62  void endJob() override;
63 };
64 
65 using namespace std;
66 using namespace edm;
67 
68 //----------------------------------------------------------------------------------------------------
69 
71  : verbosity_(ps.getUntrackedParameter<unsigned int>("verbosity", 0)),
72 
73  tagUVPatternsStrip_(ps.getParameter<edm::InputTag>("tagUVPatternsStrip")),
74  tagDiamondHits_(ps.getParameter<edm::InputTag>("tagDiamondHits")),
75  tagPixelHits_(ps.getParameter<edm::InputTag>("tagPixelHits")),
76  tagPixelLocalTracks_(ps.getParameter<edm::InputTag>("tagPixelLocalTracks")),
77 
78  tokenUVPatternsStrip_(consumes<DetSetVector<TotemRPUVPattern>>(tagUVPatternsStrip_)),
79  tokenDiamondHits_(consumes<DetSetVector<CTPPSDiamondRecHit>>(tagDiamondHits_)),
80  tokenPixelHits_(consumes<DetSetVector<CTPPSPixelRecHit>>(tagPixelHits_)),
81  tokenPixelLocalTracks_(consumes<DetSetVector<CTPPSPixelLocalTrack>>(tagPixelLocalTracks_)),
82 
83  esTokenRealGeometry_(esConsumes()),
84  esTokenMisalignedGeometry_(esConsumes()),
85  esTokenRealAlignment_(esConsumes()),
86 
87  worker_initialized_(false),
88  worker_(ps) {
89  if (!tagPixelHits_.label().empty() && !tagPixelLocalTracks_.label().empty())
90  LogWarning("PPS")
91  << "Both tagPixelHits and tagPixelLocalTracks are not empty - most likely this not what you want.";
92 }
93 
94 //----------------------------------------------------------------------------------------------------
95 
97  // check if geometry hasn't changed
98  if (geometryWatcher_.check(es)) {
100  throw cms::Exception("PPS") << "PPSStraightTrackAligner can't cope with changing geometry - change in event "
101  << event.id() << endl;
102  }
103 
104  // check if worker already initialised
105  if (!worker_initialized_) {
106  auto hRealGeometry = es.getHandle(esTokenRealGeometry_);
107  auto hMisalignedGeometry = es.getHandle(esTokenMisalignedGeometry_);
108  auto hRealAlignment = es.getHandle(esTokenRealAlignment_);
109 
110  worker_.begin(hRealAlignment, hRealGeometry, hMisalignedGeometry);
111  worker_initialized_ = true;
112  }
113 
114  // get input
115  DetSetVector<TotemRPUVPattern> defaultStripUVPatterns;
116  const DetSetVector<TotemRPUVPattern> *pStripUVPatterns = &defaultStripUVPatterns;
117  Handle<DetSetVector<TotemRPUVPattern>> inputStripUVPatterns;
118  if (!tagUVPatternsStrip_.label().empty()) {
119  event.getByToken(tokenUVPatternsStrip_, inputStripUVPatterns);
120  pStripUVPatterns = &(*inputStripUVPatterns);
121  }
122 
123  DetSetVector<CTPPSDiamondRecHit> defaultDiamondHits;
124  const DetSetVector<CTPPSDiamondRecHit> *pDiamondHits = &defaultDiamondHits;
125  Handle<DetSetVector<CTPPSDiamondRecHit>> inputDiamondHits;
126  if (!tagDiamondHits_.label().empty()) {
127  event.getByToken(tokenDiamondHits_, inputDiamondHits);
128  pDiamondHits = &(*inputDiamondHits);
129  }
130 
131  DetSetVector<CTPPSPixelRecHit> defaultPixelHits;
132  const DetSetVector<CTPPSPixelRecHit> *pPixelHits = &defaultPixelHits;
134  if (!tagPixelHits_.label().empty()) {
135  event.getByToken(tokenPixelHits_, inputPixelHits);
136  pPixelHits = &(*inputPixelHits);
137  }
138 
139  DetSetVector<CTPPSPixelLocalTrack> defaultPixelLocalTracks;
140  const DetSetVector<CTPPSPixelLocalTrack> *pPixelLocalTracks = &defaultPixelLocalTracks;
141  Handle<DetSetVector<CTPPSPixelLocalTrack>> inputPixelLocalTracks;
142  if (!tagPixelLocalTracks_.label().empty()) {
143  event.getByToken(tokenPixelLocalTracks_, inputPixelLocalTracks);
144  pPixelLocalTracks = &(*inputPixelLocalTracks);
145  }
146 
147  // feed worker
148  worker_.processEvent(event.id(), *pStripUVPatterns, *pDiamondHits, *pPixelHits, *pPixelLocalTracks);
149 }
150 
151 //----------------------------------------------------------------------------------------------------
152 
155  worker_.finish();
156  else
157  throw cms::Exception("PPS") << "worker not initialized." << endl;
158 }
159 
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
StraightTrackAlignment worker_
An EDAnalyzer that runs StraightTrackAlignment.
Reconstructed hit in diamond detectors.
virtual void finish()
performs analyses and fill results variable
std::string const & label() const
Definition: InputTag.h:36
edm::ESGetToken< CTPPSGeometry, VeryForwardMisalignedGeometryRecord > esTokenMisalignedGeometry_
edm::EDGetTokenT< edm::DetSetVector< CTPPSDiamondRecHit > > tokenDiamondHits_
edm::EDGetTokenT< edm::DetSetVector< TotemRPUVPattern > > tokenUVPatternsStrip_
Track-based alignment using straight tracks.
edm::EDGetTokenT< edm::DetSetVector< CTPPSPixelRecHit > > tokenPixelHits_
edm::ESGetToken< CTPPSGeometry, VeryForwardRealGeometryRecord > esTokenRealGeometry_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
virtual void processEvent(const edm::EventID &eventId, const edm::DetSetVector< TotemRPUVPattern > &uvPatternsStrip, const edm::DetSetVector< CTPPSDiamondRecHit > &hitsDiamond, const edm::DetSetVector< CTPPSPixelRecHit > &hitsPixel, const edm::DetSetVector< CTPPSPixelLocalTrack > &tracksPixel)
PPSStraightTrackAligner(const edm::ParameterSet &ps)
A linear pattern in U or V projection. The intercept b is taken at the middle of a RP: (geometry->Get...
virtual void begin(edm::ESHandle< CTPPSRPAlignmentCorrectionsData > hRealAlignment, edm::ESHandle< CTPPSGeometry > hRealGeometry, edm::ESHandle< CTPPSGeometry > hMisalignedGeometry)
void analyze(const edm::Event &e, const edm::EventSetup &es) override
edm::EDGetTokenT< edm::DetSetVector< CTPPSPixelLocalTrack > > tokenPixelLocalTracks_
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
edm::ESWatcher< VeryForwardRealGeometryRecord > geometryWatcher_
HLT enums.
Log< level::Warning, false > LogWarning
edm::ESGetToken< CTPPSRPAlignmentCorrectionsData, RPRealAlignmentRecord > esTokenRealAlignment_
Definition: event.py:1