File indexing completed on 2024-09-07 04:34:28
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include "Alignment/CommonAlignmentMonitor/interface/AlignmentMonitorPluginFactory.h"
0016 #include "TH1.h"
0017 #include "TObject.h"
0018
0019 #include "Alignment/CommonAlignmentMonitor/interface/AlignmentMonitorBase.h"
0020 #include "TrackingTools/TrackFitters/interface/TrajectoryStateCombiner.h"
0021
0022
0023
0024
0025
0026
0027
0028 class AlignmentMonitorTemplate : public AlignmentMonitorBase {
0029 public:
0030 AlignmentMonitorTemplate(const edm::ParameterSet& cfg, edm::ConsumesCollector iC)
0031 : AlignmentMonitorBase(cfg, iC, "AlignmentMonitorTemplate") {}
0032 ~AlignmentMonitorTemplate() override {}
0033
0034 void book() override;
0035 void event(const edm::Event& iEvent,
0036 const edm::EventSetup& iSetup,
0037 const ConstTrajTrackPairCollection& iTrajTracks) override;
0038 void afterAlignment() override;
0039
0040 private:
0041 TH1F *m_hist, *m_ihist, *m_otherdir, *m_otherdir2;
0042 std::map<Alignable*, TH1F*> m_residuals;
0043 };
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057 void AlignmentMonitorTemplate::book() {
0058 m_hist = book1D("/", "hist", "hist", 10, 0.5, 10.5);
0059 m_ihist = book1D("/iterN/", "ihist", "ihist", 10, 0, 1);
0060
0061
0062 m_otherdir = book1D("/otherdir/", "hist", "this is a histogram in another directory", 10, 0.5, 10.5);
0063 m_otherdir2 =
0064 book1D("/iterN/otherdir/", "hist", "here's one in another directory inside the iterN directories", 10, 0.5, 10.5);
0065
0066
0067
0068
0069 const auto& alignables = pStore()->alignables();
0070 for (const auto& it : alignables) {
0071 char name[256], title[256];
0072 snprintf(name, sizeof(name), "xresid%d", it->geomDetId().rawId());
0073 snprintf(title, sizeof(title), "x track-hit for DetId %d", it->geomDetId().rawId());
0074
0075 m_residuals[it] = book1D("/iterN/", name, title, 100, -5., 5.);
0076 }
0077
0078
0079
0080
0081
0082
0083
0084 }
0085
0086 void AlignmentMonitorTemplate::event(const edm::Event& iEvent,
0087 const edm::EventSetup& iSetup,
0088 const ConstTrajTrackPairCollection& tracks) {
0089 m_hist->Fill(iteration());
0090 m_ihist->Fill(0.5);
0091
0092 TrajectoryStateCombiner tsoscomb;
0093
0094
0095 for (ConstTrajTrackPairCollection::const_iterator it = tracks.begin(); it != tracks.end(); ++it) {
0096 const Trajectory* traj = it->first;
0097
0098
0099
0100
0101
0102
0103 std::vector<TrajectoryMeasurement> measurements = traj->measurements();
0104 for (std::vector<TrajectoryMeasurement>::const_iterator im = measurements.begin(); im != measurements.end(); ++im) {
0105 const TrajectoryMeasurement& meas = *im;
0106 const TransientTrackingRecHit* hit = &(*meas.recHit());
0107 const DetId id = hit->geographicalId();
0108
0109 if (hit->isValid() && pNavigator()->detAndSubdetInMap(id)) {
0110
0111
0112 TrajectoryStateOnSurface tsosc = tsoscomb.combine(meas.forwardPredictedState(), meas.backwardPredictedState());
0113
0114
0115
0116
0117 Alignable* alignable = pNavigator()->alignableFromDetId(id);
0118 std::map<Alignable*, TH1F*>::const_iterator search = m_residuals.find(alignable);
0119 while (search == m_residuals.end() && (alignable = alignable->mother()))
0120 search = m_residuals.find(alignable);
0121
0122 if (search != m_residuals.end()) {
0123 search->second->Fill(tsosc.localPosition().x() - hit->localPosition().x());
0124 }
0125 }
0126 }
0127 }
0128 }
0129
0130 void AlignmentMonitorTemplate::afterAlignment() {
0131 m_otherdir->Fill(
0132 iteration());
0133 }
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170 DEFINE_EDM_PLUGIN(AlignmentMonitorPluginFactory, AlignmentMonitorTemplate, "AlignmentMonitorTemplate");