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;
98 };
99 
100 //
101 // constants, enums and typedefs
102 //
103 
104 //
105 // static data member definitions
106 //
107 
108 //
109 // constructors and destructor
110 //
112  : m_tjTag(iConfig.getParameter<edm::InputTag>("tjTkAssociationMapTag")),
113  m_aliParamStoreCfg(iConfig.getParameter<edm::ParameterSet>("ParameterStore")),
114  esTokenDT_(esConsumes(edm::ESInputTag("", "idealForAlignmentMonitorAsAnalyzer"))),
115  esTokenCSC_(esConsumes(edm::ESInputTag("", "idealForAlignmentMonitorAsAnalyzer"))),
116  esTokenGEM_(esConsumes(edm::ESInputTag("", "idealForAlignmentMonitorAsAnalyzer"))) {
117  std::vector<std::string> monitors = iConfig.getUntrackedParameter<std::vector<std::string>>("monitors");
118 
119  for (auto const& mon : monitors) {
120  m_monitors.emplace_back(
122  }
123 }
124 
125 //
126 // member functions
127 //
128 
129 // ------------ method called to for each event ------------
131  //Retrieve tracker topology from geometry
132  edm::ESHandle<TrackerTopology> tTopoHandle;
133  iSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
134  const TrackerTopology* const tTopo = tTopoHandle.product();
135 
136  if (m_firstEvent) {
137  GeometryAligner aligner;
138 
139  edm::ESHandle<GeometricDet> theGeometricDet;
140  iSetup.get<IdealGeometryRecord>().get(theGeometricDet);
142  iSetup.get<PTrackerParametersRcd>().get(ptp);
143  TrackerGeomBuilderFromGeometricDet trackerBuilder;
144  std::shared_ptr<TrackerGeometry> theTracker(trackerBuilder.build(&(*theGeometricDet), *ptp, tTopo));
145 
146  edm::ESHandle<DTGeometry> theMuonDT = iSetup.getHandle(esTokenDT_);
147  edm::ESHandle<CSCGeometry> theMuonCSC = iSetup.getHandle(esTokenCSC_);
148  edm::ESHandle<GEMGeometry> theMuonGEM = iSetup.getHandle(esTokenGEM_);
149 
150  edm::ESHandle<Alignments> globalPositionRcd = iSetup.getHandle(esTokenGPR_);
151 
152  edm::ESHandle<Alignments> alignments;
153  iSetup.get<TrackerAlignmentRcd>().get(alignments);
155  iSetup.get<TrackerAlignmentErrorExtendedRcd>().get(alignmentErrors);
156  aligner.applyAlignments<TrackerGeometry>(&(*theTracker),
157  &(*alignments),
158  &(*alignmentErrors),
159  align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Tracker)));
160 
161  edm::ESHandle<Alignments> dtAlignments = iSetup.getHandle(esTokenDTAl_);
162  ;
163  edm::ESHandle<AlignmentErrorsExtended> dtAlignmentErrorsExtended = iSetup.getHandle(esTokenDTAPE_);
164  aligner.applyAlignments<DTGeometry>(&(*theMuonDT),
165  &(*dtAlignments),
166  &(*dtAlignmentErrorsExtended),
167  align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Muon)));
168 
169  edm::ESHandle<Alignments> cscAlignments = iSetup.getHandle(esTokenCSCAl_);
170  edm::ESHandle<AlignmentErrorsExtended> cscAlignmentErrorsExtended = iSetup.getHandle(esTokenCSCAPE_);
171  aligner.applyAlignments<CSCGeometry>(&(*theMuonCSC),
172  &(*cscAlignments),
173  &(*cscAlignmentErrorsExtended),
174  align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Muon)));
175 
176  edm::ESHandle<Alignments> gemAlignments = iSetup.getHandle(esTokenGEMAl_);
177  edm::ESHandle<AlignmentErrorsExtended> gemAlignmentErrorsExtended = iSetup.getHandle(esTokenGEMAPE_);
178  aligner.applyAlignments<GEMGeometry>(&(*theMuonGEM),
179  &(*gemAlignments),
180  &(*gemAlignmentErrorsExtended),
181  align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Muon)));
182 
183  // within an analyzer, modules can't expect to see any selected alignables!
184  align::Alignables empty_alignables;
185 
186  m_alignableTracker = std::make_unique<AlignableTracker>(&(*theTracker), tTopo);
187  m_alignableMuon = std::make_unique<AlignableMuon>(&(*theMuonDT), &(*theMuonCSC), &(*theMuonGEM));
188  m_alignmentParameterStore = std::make_unique<AlignmentParameterStore>(empty_alignables, m_aliParamStoreCfg);
189 
190  for (auto const& monitor : m_monitors) {
191  monitor->beginOfJob(m_alignableTracker.get(), m_alignableMuon.get(), m_alignmentParameterStore.get());
192  }
193  for (auto const& monitor : m_monitors) {
194  monitor->startingNewLoop();
195  }
196 
197  m_firstEvent = false;
198  }
199 
200  // Retrieve trajectories and tracks from the event
202  iEvent.getByLabel(m_tjTag, trajTracksMap);
203 
204  // Form pairs of trajectories and tracks
205  ConstTrajTrackPairCollection trajTracks;
206  for (const auto& iPair : *trajTracksMap) {
207  trajTracks.push_back(ConstTrajTrackPair(&(*iPair.key), &(*iPair.val)));
208  }
209 
210  // Run the monitors
211  for (const auto& monitor : m_monitors) {
212  monitor->duringLoop(iEvent, iSetup, trajTracks);
213  }
214 }
215 
216 // ------------ method called once each job just before starting event loop ------------
218 
219 // ------------ method called once each job just after ending the event loop ------------
221  for (auto const& monitor : m_monitors) {
222  monitor->endOfLoop();
223  }
224  for (auto const& monitor : m_monitors) {
225  monitor->endOfJob();
226  }
227 }
228 
229 //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
ESInputTag
AlignmentMonitorAsAnalyzer::ConstTrajTrackPair
std::pair< const Trajectory *, const reco::Track * > ConstTrajTrackPair
Definition: AlignmentMonitorAsAnalyzer.cc:70
GEMAlignmentErrorExtendedRcd.h
DTAlignmentErrorExtendedRcd.h
edm
HLT enums.
Definition: AlignableModifier.h:19
TrackerTopology
Definition: TrackerTopology.h:16
AlignmentMonitorAsAnalyzer::esTokenCSCAl_
edm::ESGetToken< Alignments, CSCAlignmentRcd > esTokenCSCAl_
Definition: AlignmentMonitorAsAnalyzer.cc:93
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
DetectorGlobalPosition.h
TrackerGeomBuilderFromGeometricDet::build
TrackerGeometry * build(const GeometricDet *gd, const PTrackerParameters &ptp, const TrackerTopology *tTopo)
Definition: TrackerGeomBuilderFromGeometricDet.cc:43
AlignmentMonitorAsAnalyzer::esTokenGEMAPE_
edm::ESGetToken< AlignmentErrorsExtended, GEMAlignmentErrorExtendedRcd > esTokenGEMAPE_
Definition: AlignmentMonitorAsAnalyzer.cc:96
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
AlignmentMonitorAsAnalyzer::esTokenGEMAl_
edm::ESGetToken< Alignments, GEMAlignmentRcd > esTokenGEMAl_
Definition: AlignmentMonitorAsAnalyzer.cc:95
GeometryAligner::applyAlignments
void applyAlignments(const C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
Definition: GeometryAligner.h:52
PTrackerParametersRcd
Definition: PTrackerParametersRcd.h:9
AlignmentMonitorAsAnalyzer::m_tjTag
edm::InputTag m_tjTag
Definition: AlignmentMonitorAsAnalyzer.cc:79
edm::EDAnalyzer
Definition: EDAnalyzer.h:28
TrackerAlignmentErrorExtendedRcd.h
AlignmentMonitorAsAnalyzer::beginJob
void beginJob() override
Definition: AlignmentMonitorAsAnalyzer.cc:217
AlignmentMonitorAsAnalyzer::ConstTrajTrackPairCollection
std::vector< ConstTrajTrackPair > ConstTrajTrackPairCollection
Definition: AlignmentMonitorAsAnalyzer.cc:71
CSCGeometry
Definition: CSCGeometry.h:24
DetId
Definition: DetId.h:17
AlignmentMonitorAsAnalyzer::esTokenDT_
edm::ESGetToken< DTGeometry, MuonGeometryRecord > esTokenDT_
Definition: AlignmentMonitorAsAnalyzer.cc:87
MakerMacros.h
TrackerTopology.h
GEMAlignmentRcd.h
TrackerTopologyRcd.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
AlignmentMonitorAsAnalyzer::esTokenCSCAPE_
edm::ESGetToken< AlignmentErrorsExtended, CSCAlignmentErrorExtendedRcd > esTokenCSCAPE_
Definition: AlignmentMonitorAsAnalyzer.cc:94
CSCAlignmentErrorExtendedRcd.h
edm::ESHandle< TrackerTopology >
AlignmentMonitorAsAnalyzer::m_alignableMuon
std::unique_ptr< AlignableMuon > m_alignableMuon
Definition: AlignmentMonitorAsAnalyzer.cc:83
AlignmentMonitorAsAnalyzer::esTokenCSC_
edm::ESGetToken< CSCGeometry, MuonGeometryRecord > esTokenCSC_
Definition: AlignmentMonitorAsAnalyzer.cc:88
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
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:86
beam_dqm_sourceclient-live_cfg.monitor
monitor
Definition: beam_dqm_sourceclient-live_cfg.py:244
AlignmentMonitorBase.h
AlignmentMonitorAsAnalyzer::esTokenDTAl_
edm::ESGetToken< Alignments, DTAlignmentRcd > esTokenDTAl_
Definition: AlignmentMonitorAsAnalyzer.cc:91
PTrackerParametersRcd.h
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:155
Utilities.h
DTAlignmentRcd.h
TrackerAlignmentRcd.h
edm::EventSetup
Definition: EventSetup.h:58
get
#define get
edm::ESGetToken< DTGeometry, MuonGeometryRecord >
AlignmentMonitorAsAnalyzer::esTokenDTAPE_
edm::ESGetToken< AlignmentErrorsExtended, DTAlignmentErrorExtendedRcd > esTokenDTAPE_
Definition: AlignmentMonitorAsAnalyzer.cc:92
align::Alignables
std::vector< Alignable * > Alignables
Definition: Utilities.h:31
GEMGeometry.h
AlignmentMonitorAsAnalyzer::AlignmentMonitorAsAnalyzer
AlignmentMonitorAsAnalyzer(const edm::ParameterSet &)
Definition: AlignmentMonitorAsAnalyzer.cc:111
GeometryAligner.h
Frameworkfwd.h
AlignmentMonitorAsAnalyzer::esTokenGPR_
edm::ESGetToken< Alignments, GlobalPositionRcd > esTokenGPR_
Definition: AlignmentMonitorAsAnalyzer.cc:90
AlignmentMonitorAsAnalyzer::esTokenGEM_
edm::ESGetToken< GEMGeometry, MuonGeometryRecord > esTokenGEM_
Definition: AlignmentMonitorAsAnalyzer.cc:89
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:130
GEMGeometry
Definition: GEMGeometry.h:24
DetId::Muon
Definition: DetId.h:26
TrackerTopologyRcd
Definition: TrackerTopologyRcd.h:10
ParameterSet.h
AlignmentMonitorAsAnalyzer::endJob
void endJob() override
Definition: AlignmentMonitorAsAnalyzer.cc:220
MuonGeometryRecord.h
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
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
IdealGeometryRecord
Definition: IdealGeometryRecord.h:25
AlignmentMonitorAsAnalyzer::m_firstEvent
bool m_firstEvent
Definition: AlignmentMonitorAsAnalyzer.cc:97
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