Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "Alignment/CommonAlignmentMonitor/interface/AlignmentMonitorPluginFactory.h"
00016 #include "TH1.h"
00017 #include "TObject.h"
00018
00019 #include "Alignment/CommonAlignmentMonitor/interface/AlignmentMonitorBase.h"
00020 #include "TrackingTools/TrackFitters/interface/TrajectoryStateCombiner.h"
00021
00022
00023
00024
00025
00026
00027
00028 class AlignmentMonitorTemplate: public AlignmentMonitorBase {
00029 public:
00030 AlignmentMonitorTemplate(const edm::ParameterSet& cfg): AlignmentMonitorBase(cfg, "AlignmentMonitorTemplate") { };
00031 ~AlignmentMonitorTemplate() {};
00032
00033 void book();
00034 void event(const edm::Event &iEvent, const edm::EventSetup &iSetup, const ConstTrajTrackPairCollection& iTrajTracks);
00035 void afterAlignment(const edm::EventSetup &iSetup);
00036
00037 private:
00038 TH1F *m_hist, *m_ihist, *m_otherdir, *m_otherdir2;
00039 std::map<Alignable*, TH1F*> m_residuals;
00040 };
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 void AlignmentMonitorTemplate::book() {
00055 m_hist = book1D("/", "hist", "hist", 10, 0.5, 10.5);
00056 m_ihist = book1D("/iterN/", "ihist", "ihist", 10, 0, 1);
00057
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
00063
00064
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
00075
00076
00077
00078
00079
00080 }
00081
00082 void AlignmentMonitorTemplate::event(const edm::Event &iEvent, const edm::EventSetup &iSetup, const ConstTrajTrackPairCollection& tracks) {
00083 m_hist->Fill(iteration());
00084 m_ihist->Fill(0.5);
00085
00086 TrajectoryStateCombiner tsoscomb;
00087
00088
00089 for (ConstTrajTrackPairCollection::const_iterator it = tracks.begin(); it != tracks.end(); ++it) {
00090 const Trajectory* traj = it->first;
00091
00092
00093
00094
00095
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
00105
00106 TrajectoryStateOnSurface tsosc = tsoscomb.combine(meas.forwardPredictedState(), meas.backwardPredictedState());
00107
00108
00109
00110
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 }
00119 }
00120 }
00121 }
00122
00123 void AlignmentMonitorTemplate::afterAlignment(const edm::EventSetup &iSetup) {
00124 m_otherdir->Fill(iteration());
00125 }
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162 DEFINE_EDM_PLUGIN(AlignmentMonitorPluginFactory, AlignmentMonitorTemplate, "AlignmentMonitorTemplate");