CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions | Private Attributes

AlignmentMonitorAsAnalyzer Class Reference

#include <Dummy/AlignmentMonitorAsAnalyzer/src/AlignmentMonitorAsAnalyzer.cc>

Inheritance diagram for AlignmentMonitorAsAnalyzer:
edm::EDAnalyzer edm::EDConsumerBase

List of all members.

Public Types

typedef std::pair< const
Trajectory *, const
reco::Track * > 
ConstTrajTrackPair
typedef std::vector
< ConstTrajTrackPair
ConstTrajTrackPairCollection

Public Member Functions

 AlignmentMonitorAsAnalyzer (const edm::ParameterSet &)
 ~AlignmentMonitorAsAnalyzer ()

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
virtual void beginJob ()
virtual void endJob ()

Private Attributes

AlignableMuonm_alignableMuon
AlignableTrackerm_alignableTracker
AlignmentParameterStorem_alignmentParameterStore
edm::ParameterSet m_aliParamStoreCfg
bool m_firstEvent
const edm::EventSetupm_lastSetup
std::vector
< AlignmentMonitorBase * > 
m_monitors
const edm::ParameterSet m_pSet
edm::InputTag m_tjTag

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 60 of file AlignmentMonitorAsAnalyzer.cc.


Member Typedef Documentation

Definition at line 65 of file AlignmentMonitorAsAnalyzer.cc.

Definition at line 66 of file AlignmentMonitorAsAnalyzer.cc.


Constructor & Destructor Documentation

AlignmentMonitorAsAnalyzer::AlignmentMonitorAsAnalyzer ( const edm::ParameterSet iConfig) [explicit]

Definition at line 99 of file AlignmentMonitorAsAnalyzer.cc.

References Exception, reco::get(), edm::ParameterSet::getUntrackedParameter(), and m_monitors.

   : m_tjTag(iConfig.getParameter<edm::InputTag>("tjTkAssociationMapTag"))
     , m_aliParamStoreCfg(iConfig.getParameter<edm::ParameterSet>("ParameterStore")),
     m_pSet(iConfig)
   , m_alignableTracker(NULL)
   , m_alignableMuon(NULL)
   , m_alignmentParameterStore(NULL)
{
   std::vector<std::string> monitors = iConfig.getUntrackedParameter<std::vector<std::string> >( "monitors" );

   for (std::vector<std::string>::const_iterator miter = monitors.begin();  miter != monitors.end();  ++miter) {
      AlignmentMonitorBase* newMonitor = AlignmentMonitorPluginFactory::get()->create(*miter, iConfig.getUntrackedParameter<edm::ParameterSet>(*miter));

      if (!newMonitor) throw cms::Exception("BadConfig") << "Couldn't find monitor named " << *miter;

      m_monitors.push_back(newMonitor);
   }
}
AlignmentMonitorAsAnalyzer::~AlignmentMonitorAsAnalyzer ( )

Member Function Documentation

void AlignmentMonitorAsAnalyzer::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Implements edm::EDAnalyzer.

Definition at line 133 of file AlignmentMonitorAsAnalyzer.cc.

References align::AlignableMuon, AlignmentParameterStore_cfi::AlignmentParameterStore, GeometryAligner::applyAlignments(), DTGeometryBuilderFromDDD::build(), CSCGeometryBuilderFromDDD::build(), TrackerGeomBuilderFromGeometricDet::build(), align::DetectorGlobalPosition(), edm::EventSetup::get(), edm::Event::getByLabel(), m_alignableMuon, m_alignableTracker, m_alignmentParameterStore, m_aliParamStoreCfg, m_firstEvent, m_lastSetup, m_monitors, m_pSet, m_tjTag, DetId::Muon, edm::ESHandle< T >::product(), and DetId::Tracker.

{
   //Retrieve tracker topology from geometry
   edm::ESHandle<TrackerTopology> tTopoHandle;
   iSetup.get<IdealGeometryRecord>().get(tTopoHandle);
   const TrackerTopology* const tTopo = tTopoHandle.product();

   if (m_firstEvent) {
      GeometryAligner aligner;
    
      edm::ESTransientHandle<DDCompactView> cpv;
      iSetup.get<IdealGeometryRecord>().get( cpv );
      
      edm::ESHandle<GeometricDet> theGeometricDet;
      iSetup.get<IdealGeometryRecord>().get( theGeometricDet );
      TrackerGeomBuilderFromGeometricDet trackerBuilder;
      boost::shared_ptr<TrackerGeometry> theTracker(trackerBuilder.build(&(*theGeometricDet), m_pSet ));
      
      edm::ESHandle<MuonDDDConstants> mdc;
      iSetup.get<MuonNumberingRecord>().get(mdc);
      DTGeometryBuilderFromDDD DTGeometryBuilder;
      CSCGeometryBuilderFromDDD CSCGeometryBuilder;
      boost::shared_ptr<DTGeometry> theMuonDT(new DTGeometry);
      DTGeometryBuilder.build(theMuonDT, &(*cpv), *mdc);
      boost::shared_ptr<CSCGeometry> theMuonCSC(new CSCGeometry);
      CSCGeometryBuilder.build(theMuonCSC, &(*cpv), *mdc);
      
      edm::ESHandle<Alignments> globalPositionRcd;
      iSetup.get<GlobalPositionRcd>().get(globalPositionRcd);
      
      edm::ESHandle<Alignments> alignments;
      iSetup.get<TrackerAlignmentRcd>().get( alignments );
      edm::ESHandle<AlignmentErrors> alignmentErrors;
      iSetup.get<TrackerAlignmentErrorRcd>().get( alignmentErrors );
      aligner.applyAlignments<TrackerGeometry>( &(*theTracker), &(*alignments), &(*alignmentErrors),
                                                align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Tracker)) );
      
      edm::ESHandle<Alignments> dtAlignments;
      iSetup.get<DTAlignmentRcd>().get( dtAlignments );
      edm::ESHandle<AlignmentErrors> dtAlignmentErrors;
      iSetup.get<DTAlignmentErrorRcd>().get( dtAlignmentErrors );
      aligner.applyAlignments<DTGeometry>( &(*theMuonDT), &(*dtAlignments), &(*dtAlignmentErrors),
                                           align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Muon)) );
      
      edm::ESHandle<Alignments> cscAlignments;
      iSetup.get<CSCAlignmentRcd>().get( cscAlignments );
      edm::ESHandle<AlignmentErrors> cscAlignmentErrors;
      iSetup.get<CSCAlignmentErrorRcd>().get( cscAlignmentErrors );
      aligner.applyAlignments<CSCGeometry>( &(*theMuonCSC), &(*cscAlignments), &(*cscAlignmentErrors),
                                            align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Muon)) );
      
      // within an analyzer, modules can't expect to see any selected alignables!
      std::vector<Alignable*> empty_alignables;
      
      m_alignableTracker = new AlignableTracker( &(*theTracker), tTopo );
      m_alignableMuon = new AlignableMuon( &(*theMuonDT), &(*theMuonCSC) );
      m_alignmentParameterStore = new AlignmentParameterStore(empty_alignables, m_aliParamStoreCfg);
      
      for (std::vector<AlignmentMonitorBase*>::const_iterator monitor = m_monitors.begin();  monitor != m_monitors.end();  ++monitor) {
        (*monitor)->beginOfJob(m_alignableTracker, m_alignableMuon, m_alignmentParameterStore);
      }
      for (std::vector<AlignmentMonitorBase*>::const_iterator monitor = m_monitors.begin();  monitor != m_monitors.end();  ++monitor) {
        (*monitor)->startingNewLoop();
      }
      
      m_firstEvent = false;
   }

   // Retrieve trajectories and tracks from the event
   edm::Handle<TrajTrackAssociationCollection> trajTracksMap;
   iEvent.getByLabel(m_tjTag, trajTracksMap);
   
   // Form pairs of trajectories and tracks
   ConstTrajTrackPairCollection trajTracks;
   for (TrajTrackAssociationCollection::const_iterator iPair = trajTracksMap->begin();  iPair != trajTracksMap->end();  ++iPair) {
      trajTracks.push_back(ConstTrajTrackPair(&(*(*iPair).key), &(*(*iPair).val)));
   }
   
   // Run the monitors
   for (std::vector<AlignmentMonitorBase*>::const_iterator monitor = m_monitors.begin();  monitor != m_monitors.end();  ++monitor) {
      (*monitor)->duringLoop(iEvent, iSetup, trajTracks);
   }

   // Keep this for endOfLoop (why does endOfLoop want iSetup???)
   m_lastSetup = &iSetup;
}
void AlignmentMonitorAsAnalyzer::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 223 of file AlignmentMonitorAsAnalyzer.cc.

References m_firstEvent.

{
   m_firstEvent = true;
}
void AlignmentMonitorAsAnalyzer::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 230 of file AlignmentMonitorAsAnalyzer.cc.

References m_lastSetup, and m_monitors.

{
   for (std::vector<AlignmentMonitorBase*>::const_iterator monitor = m_monitors.begin();  monitor != m_monitors.end();  ++monitor) {
      (*monitor)->endOfLoop(*m_lastSetup);
   }
   for (std::vector<AlignmentMonitorBase*>::const_iterator monitor = m_monitors.begin();  monitor != m_monitors.end();  ++monitor) {
      (*monitor)->endOfJob();
   }
}

Member Data Documentation

Definition at line 79 of file AlignmentMonitorAsAnalyzer.cc.

Referenced by analyze(), and ~AlignmentMonitorAsAnalyzer().

Definition at line 78 of file AlignmentMonitorAsAnalyzer.cc.

Referenced by analyze(), and ~AlignmentMonitorAsAnalyzer().

Definition at line 80 of file AlignmentMonitorAsAnalyzer.cc.

Referenced by analyze(), and ~AlignmentMonitorAsAnalyzer().

Definition at line 75 of file AlignmentMonitorAsAnalyzer.cc.

Referenced by analyze().

Definition at line 85 of file AlignmentMonitorAsAnalyzer.cc.

Referenced by analyze(), and beginJob().

Definition at line 83 of file AlignmentMonitorAsAnalyzer.cc.

Referenced by analyze(), and endJob().

Definition at line 82 of file AlignmentMonitorAsAnalyzer.cc.

Referenced by AlignmentMonitorAsAnalyzer(), analyze(), and endJob().

Definition at line 76 of file AlignmentMonitorAsAnalyzer.cc.

Referenced by analyze().

Definition at line 74 of file AlignmentMonitorAsAnalyzer.cc.

Referenced by analyze().