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 
55 
57 
58 //
59 // class decleration
60 //
61 
63 public:
65  ~AlignmentMonitorAsAnalyzer() override = default;
66 
67  typedef std::pair<const Trajectory*, const reco::Track*> ConstTrajTrackPair;
68  typedef std::vector<ConstTrajTrackPair> ConstTrajTrackPairCollection;
69 
70 private:
71  void beginJob() override;
72  void analyze(const edm::Event&, const edm::EventSetup&) override;
73  void endJob() override;
74 
75  // ----------member data ---------------------------
78 
79  std::unique_ptr<AlignableTracker> m_alignableTracker;
80  std::unique_ptr<AlignableMuon> m_alignableMuon;
81  std::unique_ptr<AlignmentParameterStore> m_alignmentParameterStore;
82 
83  std::vector<std::unique_ptr<AlignmentMonitorBase>> m_monitors;
86 };
87 
88 //
89 // constants, enums and typedefs
90 //
91 
92 //
93 // static data member definitions
94 //
95 
96 //
97 // constructors and destructor
98 //
100  : m_tjTag(iConfig.getParameter<edm::InputTag>("tjTkAssociationMapTag")),
101  m_aliParamStoreCfg(iConfig.getParameter<edm::ParameterSet>("ParameterStore")),
102  idealGeometryLabel("idealForAlignmentMonitorAsAnalyzer") {
103  std::vector<std::string> monitors = iConfig.getUntrackedParameter<std::vector<std::string>>("monitors");
104 
105  for (auto const& mon : monitors) {
106  m_monitors.emplace_back(
108  }
109 }
110 
111 //
112 // member functions
113 //
114 
115 // ------------ method called to for each event ------------
117  //Retrieve tracker topology from geometry
118  edm::ESHandle<TrackerTopology> tTopoHandle;
119  iSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
120  const TrackerTopology* const tTopo = tTopoHandle.product();
121 
122  if (m_firstEvent) {
123  GeometryAligner aligner;
124 
125  edm::ESHandle<GeometricDet> theGeometricDet;
126  iSetup.get<IdealGeometryRecord>().get(theGeometricDet);
128  iSetup.get<PTrackerParametersRcd>().get(ptp);
129  TrackerGeomBuilderFromGeometricDet trackerBuilder;
130  std::shared_ptr<TrackerGeometry> theTracker(trackerBuilder.build(&(*theGeometricDet), *ptp, tTopo));
131 
132  edm::ESHandle<DTGeometry> theMuonDT;
133  edm::ESHandle<CSCGeometry> theMuonCSC;
134  iSetup.get<MuonGeometryRecord>().get(idealGeometryLabel, theMuonDT);
135  iSetup.get<MuonGeometryRecord>().get(idealGeometryLabel, theMuonCSC);
136 
137  edm::ESHandle<Alignments> globalPositionRcd;
138  iSetup.get<GlobalPositionRcd>().get(globalPositionRcd);
139 
140  edm::ESHandle<Alignments> alignments;
141  iSetup.get<TrackerAlignmentRcd>().get(alignments);
143  iSetup.get<TrackerAlignmentErrorExtendedRcd>().get(alignmentErrors);
144  aligner.applyAlignments<TrackerGeometry>(&(*theTracker),
145  &(*alignments),
146  &(*alignmentErrors),
147  align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Tracker)));
148 
149  edm::ESHandle<Alignments> dtAlignments;
150  iSetup.get<DTAlignmentRcd>().get(dtAlignments);
151  edm::ESHandle<AlignmentErrorsExtended> dtAlignmentErrorsExtended;
152  iSetup.get<DTAlignmentErrorExtendedRcd>().get(dtAlignmentErrorsExtended);
153  aligner.applyAlignments<DTGeometry>(&(*theMuonDT),
154  &(*dtAlignments),
155  &(*dtAlignmentErrorsExtended),
156  align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Muon)));
157 
158  edm::ESHandle<Alignments> cscAlignments;
159  iSetup.get<CSCAlignmentRcd>().get(cscAlignments);
160  edm::ESHandle<AlignmentErrorsExtended> cscAlignmentErrorsExtended;
161  iSetup.get<CSCAlignmentErrorExtendedRcd>().get(cscAlignmentErrorsExtended);
162  aligner.applyAlignments<CSCGeometry>(&(*theMuonCSC),
163  &(*cscAlignments),
164  &(*cscAlignmentErrorsExtended),
165  align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Muon)));
166 
167  // within an analyzer, modules can't expect to see any selected alignables!
168  align::Alignables empty_alignables;
169 
170  m_alignableTracker = std::make_unique<AlignableTracker>(&(*theTracker), tTopo);
171  m_alignableMuon = std::make_unique<AlignableMuon>(&(*theMuonDT), &(*theMuonCSC));
172  m_alignmentParameterStore = std::make_unique<AlignmentParameterStore>(empty_alignables, m_aliParamStoreCfg);
173 
174  for (auto const& monitor : m_monitors) {
175  monitor->beginOfJob(m_alignableTracker.get(), m_alignableMuon.get(), m_alignmentParameterStore.get());
176  }
177  for (auto const& monitor : m_monitors) {
178  monitor->startingNewLoop();
179  }
180 
181  m_firstEvent = false;
182  }
183 
184  // Retrieve trajectories and tracks from the event
186  iEvent.getByLabel(m_tjTag, trajTracksMap);
187 
188  // Form pairs of trajectories and tracks
189  ConstTrajTrackPairCollection trajTracks;
190  for (const auto& iPair : *trajTracksMap) {
191  trajTracks.push_back(ConstTrajTrackPair(&(*iPair.key), &(*iPair.val)));
192  }
193 
194  // Run the monitors
195  for (const auto& monitor : m_monitors) {
196  monitor->duringLoop(iEvent, iSetup, trajTracks);
197  }
198 }
199 
200 // ------------ method called once each job just before starting event loop ------------
202 
203 // ------------ method called once each job just after ending the event loop ------------
205  for (auto const& monitor : m_monitors) {
206  monitor->endOfLoop();
207  }
208  for (auto const& monitor : m_monitors) {
209  monitor->endOfJob();
210  }
211 }
212 
213 //define this as a plug-in
DTGeometry
Definition: DTGeometry.h:28
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
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:67
DTAlignmentErrorExtendedRcd.h
edm
HLT enums.
Definition: AlignableModifier.h:19
TrackerTopology
Definition: TrackerTopology.h:16
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
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
GeometryAligner::applyAlignments
void applyAlignments(const C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
Definition: GeometryAligner.h:52
GlobalPositionRcd
Definition: GlobalPositionRcd.h:6
PTrackerParametersRcd
Definition: PTrackerParametersRcd.h:9
AlignmentMonitorAsAnalyzer::m_tjTag
edm::InputTag m_tjTag
Definition: AlignmentMonitorAsAnalyzer.cc:76
edm::EDAnalyzer
Definition: EDAnalyzer.h:28
TrackerAlignmentErrorExtendedRcd.h
AlignmentMonitorAsAnalyzer::beginJob
void beginJob() override
Definition: AlignmentMonitorAsAnalyzer.cc:201
AlignmentMonitorAsAnalyzer::ConstTrajTrackPairCollection
std::vector< ConstTrajTrackPair > ConstTrajTrackPairCollection
Definition: AlignmentMonitorAsAnalyzer.cc:68
CSCGeometry
Definition: CSCGeometry.h:24
DetId
Definition: DetId.h:17
AlignmentMonitorAsAnalyzer::idealGeometryLabel
std::string idealGeometryLabel
Definition: AlignmentMonitorAsAnalyzer.cc:84
MakerMacros.h
TrackerTopology.h
TrackerTopologyRcd.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
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:80
DTAlignmentErrorExtendedRcd
Definition: DTAlignmentErrorExtendedRcd.h:6
TrajTrackAssociation.h
AlignmentParameterStore.h
LaserDQM_cfi.mon
mon
Definition: LaserDQM_cfi.py:3
AlignmentMonitorPluginFactory.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DTGeometry.h
AlignmentMonitorAsAnalyzer::m_aliParamStoreCfg
edm::ParameterSet m_aliParamStoreCfg
Definition: AlignmentMonitorAsAnalyzer.cc:77
gather_cfg.monitors
monitors
Definition: gather_cfg.py:173
CSCAlignmentErrorExtendedRcd
Definition: CSCAlignmentErrorExtendedRcd.h:6
edm::ParameterSet
Definition: ParameterSet.h:47
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:83
beam_dqm_sourceclient-live_cfg.monitor
monitor
Definition: beam_dqm_sourceclient-live_cfg.py:242
AlignmentMonitorBase.h
PTrackerParametersRcd.h
iEvent
int iEvent
Definition: GenABIO.cc:224
Utilities.h
DTAlignmentRcd.h
TrackerAlignmentRcd.h
edm::EventSetup
Definition: EventSetup.h:57
get
#define get
align::Alignables
std::vector< Alignable * > Alignables
Definition: Utilities.h:31
AlignmentMonitorAsAnalyzer::AlignmentMonitorAsAnalyzer
AlignmentMonitorAsAnalyzer(const edm::ParameterSet &)
Definition: AlignmentMonitorAsAnalyzer.cc:99
GeometryAligner.h
Frameworkfwd.h
AlignmentMonitorAsAnalyzer::m_alignableTracker
std::unique_ptr< AlignableTracker > m_alignableTracker
Definition: AlignmentMonitorAsAnalyzer.cc:79
TrackerGeomBuilderFromGeometricDet.h
TrackerGeomBuilderFromGeometricDet
Definition: TrackerGeomBuilderFromGeometricDet.h:17
AlignmentMonitorAsAnalyzer::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: AlignmentMonitorAsAnalyzer.cc:116
DetId::Muon
Definition: DetId.h:26
TrackerTopologyRcd
Definition: TrackerTopologyRcd.h:10
ParameterSet.h
AlignmentMonitorAsAnalyzer::endJob
void endJob() override
Definition: AlignmentMonitorAsAnalyzer.cc:204
MuonGeometryRecord.h
edm::Event
Definition: Event.h:73
TrackerAlignmentErrorExtendedRcd
Definition: TrackerAlignmentErrorExtendedRcd.h:6
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
AlignmentMonitorAsAnalyzer::m_alignmentParameterStore
std::unique_ptr< AlignmentParameterStore > m_alignmentParameterStore
Definition: AlignmentMonitorAsAnalyzer.cc:81
edm::InputTag
Definition: InputTag.h:15
IdealGeometryRecord
Definition: IdealGeometryRecord.h:25
CSCAlignmentRcd
Definition: CSCAlignmentRcd.h:6
AlignmentMonitorAsAnalyzer::m_firstEvent
bool m_firstEvent
Definition: AlignmentMonitorAsAnalyzer.cc:85
GeometryAligner
Class to update a given geometry with a set of alignments.
Definition: GeometryAligner.h:33
CSCAlignmentRcd.h
CSCGeometry.h
AlignmentMonitorAsAnalyzer
Definition: AlignmentMonitorAsAnalyzer.cc:62
TrackerGeometry
Definition: TrackerGeometry.h:14