CMS 3D CMS Logo

AlignmentMonitorTemplate Class Reference

Inheritance diagram for AlignmentMonitorTemplate:

AlignmentMonitorBase

List of all members.

Public Member Functions

void afterAlignment (const edm::EventSetup &iSetup)
 Called after updating AlignableTracker and AlignableMuon (by "endOfLoop()"): may be reimplemented.
 AlignmentMonitorTemplate (const edm::ParameterSet &cfg)
void book ()
 Book or retrieve histograms; MUST be reimplemented.
void event (const edm::EventSetup &iSetup, const ConstTrajTrackPairCollection &iTrajTracks)
 ~AlignmentMonitorTemplate ()

Private Attributes

TH1F * m_hist
TH1F * m_ihist
TH1F * m_otherdir
TH1F * m_otherdir2
std::map< Alignable *, TH1F * > m_residuals


Detailed Description

Definition at line 28 of file AlignmentMonitorTemplate.cc.


Constructor & Destructor Documentation

AlignmentMonitorTemplate::AlignmentMonitorTemplate ( const edm::ParameterSet cfg  )  [inline]

Definition at line 30 of file AlignmentMonitorTemplate.cc.

00030 : AlignmentMonitorBase(cfg, "AlignmentMonitorTemplate") { };

AlignmentMonitorTemplate::~AlignmentMonitorTemplate (  )  [inline]

Definition at line 31 of file AlignmentMonitorTemplate.cc.

00031 {};


Member Function Documentation

void AlignmentMonitorTemplate::afterAlignment ( const edm::EventSetup iSetup  )  [virtual]

Called after updating AlignableTracker and AlignableMuon (by "endOfLoop()"): may be reimplemented.

Reimplemented from AlignmentMonitorBase.

Definition at line 123 of file AlignmentMonitorTemplate.cc.

References AlignmentMonitorBase::iteration(), and m_otherdir.

00123                                                                          {
00124    m_otherdir->Fill(iteration());  // this one will only get one fill per iteration, because it's called in afterAlignment()
00125 }

void AlignmentMonitorTemplate::book (  )  [virtual]

Book or retrieve histograms; MUST be reimplemented.

Implements AlignmentMonitorBase.

Definition at line 54 of file AlignmentMonitorTemplate.cc.

References AlignmentParameterStore::alignables(), AlignmentMonitorBase::book1D(), it, m_hist, m_ihist, m_otherdir, m_otherdir2, m_residuals, name, AlignmentMonitorBase::pStore(), and indexGen::title.

00054                                     {
00055    m_hist = book1D("/", "hist", "hist", 10, 0.5, 10.5);      // there's only one of these per job
00056    m_ihist = book1D("/iterN/", "ihist", "ihist", 10, 0, 1);  // there's a new one of these for each iteration
00057    // "/iterN/" is a special directory name, in which the "N" gets replaced by the current iteration number.
00058 
00059    m_otherdir = book1D("/otherdir/", "hist", "this is a histogram in another directory", 10, 0.5, 10.5);
00060    m_otherdir2 = book1D("/iterN/otherdir/", "hist", "here's one in another directory inside the iterN directories", 10, 0.5, 10.5);
00061 
00062    // This is a procedure that makes one histogram for each selected alignable, and puts them in the iterN directory.
00063    // This is not a constant-time lookup.  If you need something faster, see AlignmentMonitorMuonHIP, which has a
00064    // dynamically-allocated array of TH1F*s.
00065    std::vector<Alignable*> alignables = pStore()->alignables();
00066    for (std::vector<Alignable*>::const_iterator it = alignables.begin();  it != alignables.end();  ++it) {
00067       char name[256], title[256];
00068       sprintf(name,  "xresid%d", (*it)->geomDetId().rawId());
00069       sprintf(title, "x track-hit for DetId %d", (*it)->geomDetId().rawId());
00070 
00071       m_residuals[*it] = book1D("/iterN/", name, title, 100, -5., 5.);
00072    }
00073 
00074    // Important: you create TObject pointers with the "new" operator, but YOU don't delete them.  They're deleted by the
00075    // base class, which knows when they are no longer needed (based on whether they are in the /iterN/ directory or not).
00076 
00077    // For more detail, see the twiki page:
00078    // httpss://twiki.cern.ch/twiki/bin/view/CMS/SWGuideAlignmentMonitors    for creating a plugin like this one
00079    // httpss://twiki.cern.ch/twiki/bin/view/CMS/SWGuideAlignmentAlgorithms#Monitoring    for configuring it
00080 }

void AlignmentMonitorTemplate::event ( const edm::EventSetup iSetup,
const ConstTrajTrackPairCollection iTrajTracks 
)

Definition at line 82 of file AlignmentMonitorTemplate.cc.

References AlignableNavigator::alignableFromDetId(), TrajectoryMeasurement::backwardPredictedState(), TrajectoryStateCombiner::combine(), AlignableNavigator::detAndSubdetInMap(), TrajectoryMeasurement::forwardPredictedState(), TrackingRecHit::geographicalId(), TrackingRecHit::isValid(), it, AlignmentMonitorBase::iteration(), TrackingRecHit::localPosition(), TrajectoryStateOnSurface::localPosition(), m_hist, m_ihist, m_residuals, Trajectory::measurements(), Alignable::mother(), AlignmentMonitorBase::pNavigator(), TrajectoryMeasurement::recHit(), and PV3DBase< T, PVType, FrameType >::x().

00082                                                                                                             {
00083    m_hist->Fill(iteration());  // get the number of events per iteration
00084    m_ihist->Fill(0.5);         // get the number of events in this iteration in the central bin
00085 
00086   TrajectoryStateCombiner tsoscomb;
00087 
00088   // This is a procedure that loops over tracks/hits, calculates residuals, and fills the appropriate histogram.
00089    for (ConstTrajTrackPairCollection::const_iterator it = tracks.begin();  it != tracks.end();  ++it) {
00090       const Trajectory* traj = it->first;
00091 //      const reco::Track* track = it->second;
00092       // If your tracks are refit using the producer in RecoTracker, you'll get updated reco::Track objects with
00093       // each iteration, and it makes sense to make plots using these.
00094       // If your tracks are refit using TrackingTools/TrackRefitter, only the Trajectories will be updated.
00095       // We're working on that.  I'll try to remember to change this comment when the update is ready.
00096 
00097       std::vector<TrajectoryMeasurement> measurements = traj->measurements();
00098       for (std::vector<TrajectoryMeasurement>::const_iterator im = measurements.begin();  im != measurements.end();  ++im) {
00099          const TrajectoryMeasurement meas = *im;
00100          const TransientTrackingRecHit* hit = &(*meas.recHit());
00101          const DetId id = hit->geographicalId();
00102 
00103          if (hit->isValid()  &&  pNavigator()->detAndSubdetInMap(id)) {
00104             // Combine the forward-propagated state with the backward-propagated state to get a minimally-biased residual.
00105             // This is the same procedure that is used to calculate residuals in the HIP algorithm
00106             TrajectoryStateOnSurface tsosc = tsoscomb.combine(meas.forwardPredictedState(), meas.backwardPredictedState());
00107 
00108             // Search for our histogram using the Alignable* -> TH1F* map
00109             // The "alignable = alignable->mother()" part ascends the alignable tree, because hits are on the lowest-level
00110             // while our histograms may be associated with higher-level Alignables.
00111             Alignable *alignable = pNavigator()->alignableFromDetId(id);
00112             std::map<Alignable*, TH1F*>::const_iterator search = m_residuals.find(alignable);
00113             while (search == m_residuals.end()  &&  (alignable = alignable->mother())) search = m_residuals.find(alignable);
00114 
00115             if (search != m_residuals.end()) {
00116                search->second->Fill(tsosc.localPosition().x() - hit->localPosition().x());
00117             }
00118          } // end if hit is valid
00119       } // end loop over hits
00120    } // end loop over tracks/trajectories
00121 }


Member Data Documentation

TH1F* AlignmentMonitorTemplate::m_hist [private]

Definition at line 38 of file AlignmentMonitorTemplate.cc.

Referenced by book(), and event().

TH1F * AlignmentMonitorTemplate::m_ihist [private]

Definition at line 38 of file AlignmentMonitorTemplate.cc.

Referenced by book(), and event().

TH1F * AlignmentMonitorTemplate::m_otherdir [private]

Definition at line 38 of file AlignmentMonitorTemplate.cc.

Referenced by afterAlignment(), and book().

TH1F * AlignmentMonitorTemplate::m_otherdir2 [private]

Definition at line 38 of file AlignmentMonitorTemplate.cc.

Referenced by book().

std::map<Alignable*, TH1F*> AlignmentMonitorTemplate::m_residuals [private]

Definition at line 39 of file AlignmentMonitorTemplate.cc.

Referenced by book(), and event().


The documentation for this class was generated from the following file:
Generated on Tue Jun 9 18:14:31 2009 for CMSSW by  doxygen 1.5.4