CMS 3D CMS Logo

AlignmentMonitorAsAnalyzer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: AlignmentMonitorAsAnalyzer
4 // Class: AlignmentMonitorAsAnalyzer
5 //
13 //
14 // Original Author: Jim Pivarski
15 // Created: Sat Apr 26 12:36:13 CDT 2008
16 // $Id: AlignmentMonitorAsAnalyzer.cc,v 1.9 2012/07/13 09:18:40 yana Exp $
17 //
18 //
19 
20 // system include files
21 #include <memory>
22 
23 // user include files
31 
37 
58 
60 
61 //
62 // class decleration
63 //
64 
66 public:
68  ~AlignmentMonitorAsAnalyzer() override = default;
69 
70  typedef std::pair<const Trajectory*, const reco::Track*> ConstTrajTrackPair;
71  typedef std::vector<ConstTrajTrackPair> ConstTrajTrackPairCollection;
72 
73 private:
74  void beginJob() override;
75  void analyze(const edm::Event&, const edm::EventSetup&) override;
76  void endJob() override;
77 
78  // ----------member data ---------------------------
81 
82  std::unique_ptr<AlignableTracker> m_alignableTracker;
83  std::unique_ptr<AlignableMuon> m_alignableMuon;
84  std::unique_ptr<AlignmentParameterStore> m_alignmentParameterStore;
85 
86  std::vector<std::unique_ptr<AlignmentMonitorBase>> m_monitors;
87 
89 };
90 
91 //
92 // constants, enums and typedefs
93 //
94 
95 //
96 // static data member definitions
97 //
98 
99 //
100 // constructors and destructor
101 //
103  : m_tjTag(iConfig.getParameter<edm::InputTag>("tjTkAssociationMapTag")),
104  m_aliParamStoreCfg(iConfig.getParameter<edm::ParameterSet>("ParameterStore")) {
105  std::vector<std::string> monitors = iConfig.getUntrackedParameter<std::vector<std::string>>("monitors");
106 
107  for (auto const& mon : monitors) {
108  m_monitors.emplace_back(
110  }
111 }
112 
113 //
114 // member functions
115 //
116 
117 // ------------ method called to for each event ------------
119  //Retrieve tracker topology from geometry
120  edm::ESHandle<TrackerTopology> tTopoHandle;
121  iSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
122  const TrackerTopology* const tTopo = tTopoHandle.product();
123 
124  if (m_firstEvent) {
125  GeometryAligner aligner;
126 
128  iSetup.get<IdealGeometryRecord>().get(cpv);
129 
130  edm::ESHandle<GeometricDet> theGeometricDet;
131  iSetup.get<IdealGeometryRecord>().get(theGeometricDet);
133  iSetup.get<PTrackerParametersRcd>().get(ptp);
134  TrackerGeomBuilderFromGeometricDet trackerBuilder;
135  std::shared_ptr<TrackerGeometry> theTracker(trackerBuilder.build(&(*theGeometricDet), *ptp, tTopo));
136 
138  iSetup.get<IdealGeometryRecord>().get(mdc);
141  auto theMuonDT = std::make_shared<DTGeometry>();
142  DTGeometryBuilder.build(*theMuonDT, &(*cpv), *mdc);
143  auto theMuonCSC = std::make_shared<CSCGeometry>();
144  CSCGeometryBuilder.build(*theMuonCSC, &(*cpv), *mdc);
145 
146  edm::ESHandle<Alignments> globalPositionRcd;
147  iSetup.get<GlobalPositionRcd>().get(globalPositionRcd);
148 
149  edm::ESHandle<Alignments> alignments;
150  iSetup.get<TrackerAlignmentRcd>().get(alignments);
152  iSetup.get<TrackerAlignmentErrorExtendedRcd>().get(alignmentErrors);
153  aligner.applyAlignments<TrackerGeometry>(&(*theTracker),
154  &(*alignments),
155  &(*alignmentErrors),
156  align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Tracker)));
157 
158  edm::ESHandle<Alignments> dtAlignments;
159  iSetup.get<DTAlignmentRcd>().get(dtAlignments);
160  edm::ESHandle<AlignmentErrorsExtended> dtAlignmentErrorsExtended;
161  iSetup.get<DTAlignmentErrorExtendedRcd>().get(dtAlignmentErrorsExtended);
162  aligner.applyAlignments<DTGeometry>(&(*theMuonDT),
163  &(*dtAlignments),
164  &(*dtAlignmentErrorsExtended),
165  align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Muon)));
166 
167  edm::ESHandle<Alignments> cscAlignments;
168  iSetup.get<CSCAlignmentRcd>().get(cscAlignments);
169  edm::ESHandle<AlignmentErrorsExtended> cscAlignmentErrorsExtended;
170  iSetup.get<CSCAlignmentErrorExtendedRcd>().get(cscAlignmentErrorsExtended);
171  aligner.applyAlignments<CSCGeometry>(&(*theMuonCSC),
172  &(*cscAlignments),
173  &(*cscAlignmentErrorsExtended),
174  align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Muon)));
175 
176  // within an analyzer, modules can't expect to see any selected alignables!
177  align::Alignables empty_alignables;
178 
179  m_alignableTracker = std::make_unique<AlignableTracker>(&(*theTracker), tTopo);
180  m_alignableMuon = std::make_unique<AlignableMuon>(&(*theMuonDT), &(*theMuonCSC));
181  m_alignmentParameterStore = std::make_unique<AlignmentParameterStore>(empty_alignables, m_aliParamStoreCfg);
182 
183  for (auto const& monitor : m_monitors) {
184  monitor->beginOfJob(m_alignableTracker.get(), m_alignableMuon.get(), m_alignmentParameterStore.get());
185  }
186  for (auto const& monitor : m_monitors) {
187  monitor->startingNewLoop();
188  }
189 
190  m_firstEvent = false;
191  }
192 
193  // Retrieve trajectories and tracks from the event
195  iEvent.getByLabel(m_tjTag, trajTracksMap);
196 
197  // Form pairs of trajectories and tracks
198  ConstTrajTrackPairCollection trajTracks;
199  for (const auto& iPair : *trajTracksMap) {
200  trajTracks.push_back(ConstTrajTrackPair(&(*iPair.key), &(*iPair.val)));
201  }
202 
203  // Run the monitors
204  for (const auto& monitor : m_monitors) {
205  monitor->duringLoop(iEvent, iSetup, trajTracks);
206  }
207 }
208 
209 // ------------ method called once each job just before starting event loop ------------
211 
212 // ------------ method called once each job just after ending the event loop ------------
214  for (auto const& monitor : m_monitors) {
215  monitor->endOfLoop();
216  }
217  for (auto const& monitor : m_monitors) {
218  monitor->endOfJob();
219  }
220 }
221 
222 //define this as a plug-in
DTGeometry
Definition: DTGeometry.h:28
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
DTGeometryBuilder
GlobalPositionRcd.h
ESTransientHandle.h
AlignmentMonitorAsAnalyzer::~AlignmentMonitorAsAnalyzer
~AlignmentMonitorAsAnalyzer() override=default
TrackerGeometry.h
ESHandle.h
AlignmentMonitorAsAnalyzer::ConstTrajTrackPair
std::pair< const Trajectory *, const reco::Track * > ConstTrajTrackPair
Definition: AlignmentMonitorAsAnalyzer.cc:70
DTAlignmentErrorExtendedRcd.h
edm
HLT enums.
Definition: AlignableModifier.h:19
DTGeometryBuilderFromDDD
Definition: DTGeometryBuilderFromDDD.h:31
TrackerTopology
Definition: TrackerTopology.h:16
MuonGeometryConstants.h
DetectorGlobalPosition.h
TrackerGeomBuilderFromGeometricDet::build
TrackerGeometry * build(const GeometricDet *gd, const PTrackerParameters &ptp, const TrackerTopology *tTopo)
Definition: TrackerGeomBuilderFromGeometricDet.cc:43
TrackerAlignmentRcd
Definition: TrackerAlignmentRcd.h:6
PTrackerParameters.h
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
EDAnalyzer.h
beamerCreator.create
def create(alignables, pedeDump, additionalData, outputFile, config)
Definition: beamerCreator.py:44
edm::Handle
Definition: AssociativeIterator.h:50
MuonNumberingRecord.h
GlobalPositionRcd
Definition: GlobalPositionRcd.h:6
PTrackerParametersRcd
Definition: PTrackerParametersRcd.h:9
AlignmentMonitorAsAnalyzer::m_tjTag
edm::InputTag m_tjTag
Definition: AlignmentMonitorAsAnalyzer.cc:79
edm::EDAnalyzer
Definition: EDAnalyzer.h:29
TrackerAlignmentErrorExtendedRcd.h
AlignmentMonitorAsAnalyzer::beginJob
void beginJob() override
Definition: AlignmentMonitorAsAnalyzer.cc:210
AlignmentMonitorAsAnalyzer::ConstTrajTrackPairCollection
std::vector< ConstTrajTrackPair > ConstTrajTrackPairCollection
Definition: AlignmentMonitorAsAnalyzer.cc:71
DTGeometryBuilderFromDDD.h
CSCGeometry
Definition: CSCGeometry.h:24
DetId
Definition: DetId.h:17
CSCGeometryBuilder
Definition: CSCGeometryBuilder.h:20
MakerMacros.h
TrackerTopology.h
TrackerTopologyRcd.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
DTAlignmentRcd
Definition: DTAlignmentRcd.h:6
CSCAlignmentErrorExtendedRcd.h
edm::ESHandle< TrackerTopology >
AlignmentMonitorAsAnalyzer::m_alignableMuon
std::unique_ptr< AlignableMuon > m_alignableMuon
Definition: AlignmentMonitorAsAnalyzer.cc:83
DTAlignmentErrorExtendedRcd
Definition: DTAlignmentErrorExtendedRcd.h:6
CSCGeometryBuilder::build
void build(CSCGeometry &theGeometry, const RecoIdealGeometry &rig, const CSCRecoDigiParameters &cscpars)
Build the geometry.
Definition: CSCGeometryBuilder.cc:17
TrajTrackAssociation.h
AlignmentParameterStore.h
LaserDQM_cfi.mon
mon
Definition: LaserDQM_cfi.py:3
AlignmentMonitorPluginFactory.h
DTGeometry.h
AlignmentMonitorAsAnalyzer::m_aliParamStoreCfg
edm::ParameterSet m_aliParamStoreCfg
Definition: AlignmentMonitorAsAnalyzer.cc:80
gather_cfg.monitors
monitors
Definition: gather_cfg.py:173
CSCAlignmentErrorExtendedRcd
Definition: CSCAlignmentErrorExtendedRcd.h:6
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
DetId::Tracker
Definition: DetId.h:25
align::DetectorGlobalPosition
const AlignTransform & DetectorGlobalPosition(const Alignments &allGlobals, const DetId &id)
Definition: DetectorGlobalPosition.cc:10
Event.h
ParameterSet
Definition: Functions.h:16
AlignmentMonitorAsAnalyzer::m_monitors
std::vector< std::unique_ptr< AlignmentMonitorBase > > m_monitors
Definition: AlignmentMonitorAsAnalyzer.cc:86
beam_dqm_sourceclient-live_cfg.monitor
monitor
Definition: beam_dqm_sourceclient-live_cfg.py:234
AlignmentMonitorBase.h
PTrackerParametersRcd.h
iEvent
int iEvent
Definition: GenABIO.cc:224
Utilities.h
DTAlignmentRcd.h
TrackerAlignmentRcd.h
edm::EventSetup
Definition: EventSetup.h:57
CSCGeometryBuilderFromDDD.h
get
#define get
edm::ESTransientHandle
Definition: ESTransientHandle.h:41
align::Alignables
std::vector< Alignable * > Alignables
Definition: Utilities.h:31
AlignmentMonitorAsAnalyzer::AlignmentMonitorAsAnalyzer
AlignmentMonitorAsAnalyzer(const edm::ParameterSet &)
Definition: AlignmentMonitorAsAnalyzer.cc:102
GeometryAligner.h
Frameworkfwd.h
CSCGeometryBuilderFromDDD
Definition: CSCGeometryBuilderFromDDD.h:30
AlignmentMonitorAsAnalyzer::m_alignableTracker
std::unique_ptr< AlignableTracker > m_alignableTracker
Definition: AlignmentMonitorAsAnalyzer.cc:82
TrackerGeomBuilderFromGeometricDet.h
TrackerGeomBuilderFromGeometricDet
Definition: TrackerGeomBuilderFromGeometricDet.h:17
AlignmentMonitorAsAnalyzer::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: AlignmentMonitorAsAnalyzer.cc:118
DetId::Muon
Definition: DetId.h:26
TrackerTopologyRcd
Definition: TrackerTopologyRcd.h:10
ParameterSet.h
AlignmentMonitorAsAnalyzer::endJob
void endJob() override
Definition: AlignmentMonitorAsAnalyzer.cc:213
edm::Event
Definition: Event.h:73
TrackerAlignmentErrorExtendedRcd
Definition: TrackerAlignmentErrorExtendedRcd.h:6
AlignmentMonitorAsAnalyzer::m_alignmentParameterStore
std::unique_ptr< AlignmentParameterStore > m_alignmentParameterStore
Definition: AlignmentMonitorAsAnalyzer.cc:84
edm::InputTag
Definition: InputTag.h:15
GeometryAligner::applyAlignments
void applyAlignments(C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
Definition: GeometryAligner.h:52
IdealGeometryRecord
Definition: IdealGeometryRecord.h:27
CSCAlignmentRcd
Definition: CSCAlignmentRcd.h:6
AlignmentMonitorAsAnalyzer::m_firstEvent
bool m_firstEvent
Definition: AlignmentMonitorAsAnalyzer.cc:88
GeometryAligner
Class to update a given geometry with a set of alignments.
Definition: GeometryAligner.h:33
CSCAlignmentRcd.h
CSCGeometry.h
AlignmentMonitorAsAnalyzer
Definition: AlignmentMonitorAsAnalyzer.cc:65
TrackerGeometry
Definition: TrackerGeometry.h:14