File indexing completed on 2024-04-06 11:58:33
0001
0002
0003
0004
0005
0006
0007 #ifndef CalibPPS_AlignmentRelative_StraightTrackAlignment_h
0008 #define CalibPPS_AlignmentRelative_StraightTrackAlignment_h
0009
0010 #include <set>
0011 #include <vector>
0012 #include <string>
0013
0014 #include <TMatrixD.h>
0015 #include <TVectorD.h>
0016 #include <TFile.h>
0017
0018 #include "DataFormats/Common/interface/DetSetVector.h"
0019 #include "DataFormats/CTPPSReco/interface/TotemRPRecHit.h"
0020 #include "DataFormats/CTPPSReco/interface/TotemRPUVPattern.h"
0021 #include "DataFormats/CTPPSReco/interface/CTPPSDiamondRecHit.h"
0022 #include "DataFormats/CTPPSReco/interface/CTPPSPixelRecHit.h"
0023 #include "DataFormats/CTPPSReco/interface/CTPPSPixelLocalTrack.h"
0024
0025 #include "CondFormats/PPSObjects/interface/CTPPSRPAlignmentCorrectionsData.h"
0026
0027 #include "CalibPPS/AlignmentRelative/interface/AlignmentGeometry.h"
0028 #include "CalibPPS/AlignmentRelative/interface/HitCollection.h"
0029 #include "CalibPPS/AlignmentRelative/interface/AlignmentAlgorithm.h"
0030 #include "CalibPPS/AlignmentRelative/interface/AlignmentConstraint.h"
0031 #include "CalibPPS/AlignmentRelative/interface/AlignmentTask.h"
0032 #include "CalibPPS/AlignmentRelative/interface/LocalTrackFit.h"
0033 #include "CalibPPS/AlignmentRelative/interface/LocalTrackFitter.h"
0034 #include "FWCore/Framework/interface/ESHandle.h"
0035
0036 namespace edm {
0037 class ParameterSet;
0038 class Event;
0039 class EventSetup;
0040 }
0041
0042 class TH1D;
0043 class TGraph;
0044
0045
0046
0047
0048 class StraightTrackAlignment {
0049 public:
0050 StraightTrackAlignment(const edm::ParameterSet &);
0051 virtual ~StraightTrackAlignment();
0052
0053 virtual void begin(edm::ESHandle<CTPPSRPAlignmentCorrectionsData> hRealAlignment,
0054 edm::ESHandle<CTPPSGeometry> hRealGeometry,
0055 edm::ESHandle<CTPPSGeometry> hMisalignedGeometry);
0056
0057 virtual void processEvent(const edm::EventID &eventId,
0058 const edm::DetSetVector<TotemRPUVPattern> &uvPatternsStrip,
0059 const edm::DetSetVector<CTPPSDiamondRecHit> &hitsDiamond,
0060 const edm::DetSetVector<CTPPSPixelRecHit> &hitsPixel,
0061 const edm::DetSetVector<CTPPSPixelLocalTrack> &tracksPixel);
0062
0063
0064 virtual void finish();
0065
0066 protected:
0067
0068
0069
0070 unsigned int verbosity;
0071
0072
0073 std::vector<unsigned int> rpIds;
0074
0075
0076 std::vector<unsigned int> excludePlanes;
0077
0078
0079
0080 double z0;
0081
0082
0083 std::vector<AlignmentAlgorithm *> algorithms;
0084
0085
0086 enum ConstraintsType { ctFixedDetectors, ctStandard };
0087
0088
0089 ConstraintsType constraintsType;
0090
0091
0092 signed int maxEvents;
0093
0094
0095
0096
0097 bool removeImpossible;
0098
0099
0100 unsigned int requireNumberOfUnits;
0101
0102
0103 bool requireAtLeast3PotsInOverlap;
0104
0105
0106 bool requireOverlap;
0107
0108
0109 bool cutOnChiSqPerNdf;
0110
0111
0112 double chiSqPerNdfCut;
0113
0114
0115 double maxTrackAx;
0116 double maxTrackAy;
0117
0118
0119 std::vector<std::set<unsigned int> > additionalAcceptedRPSets;
0120
0121
0122
0123
0124 std::string fileNamePrefix;
0125
0126
0127 std::string cumulativeFileNamePrefix;
0128
0129
0130 std::string expandedFileNamePrefix;
0131
0132
0133 std::string factoredFileNamePrefix;
0134
0135
0136 bool preciseXMLFormat;
0137
0138
0139 bool saveXMLUncertainties;
0140
0141
0142 bool saveIntermediateResults;
0143
0144
0145 std::string taskDataFileName;
0146
0147
0148 TFile *taskDataFile;
0149
0150
0151
0152
0153 AlignmentTask task;
0154
0155
0156 LocalTrackFitter fitter;
0157
0158
0159 CTPPSRPAlignmentCorrectionsData initialAlignments;
0160
0161
0162
0163
0164 bool buildDiagnosticPlots;
0165
0166
0167 std::string diagnosticsFile;
0168
0169 signed int eventsTotal;
0170 signed int eventsFitted;
0171 signed int eventsSelected;
0172
0173 std::map<std::set<unsigned int>, unsigned long> fittedTracksPerRPSet;
0174 std::map<std::set<unsigned int>, unsigned long>
0175 selectedTracksPerRPSet;
0176
0177 std::map<unsigned int, unsigned int> selectedHitsPerPlane;
0178
0179 TH1D *fitNdfHist_fitted, *fitNdfHist_selected;
0180 TH1D *fitPHist_fitted, *fitPHist_selected;
0181 TH1D *fitAxHist_fitted, *fitAxHist_selected;
0182 TH1D *fitAyHist_fitted, *fitAyHist_selected;
0183 TH1D *fitBxHist_fitted, *fitBxHist_selected;
0184 TH1D *fitByHist_fitted, *fitByHist_selected;
0185
0186 struct RPSetPlots {
0187 std::string name;
0188
0189
0190 TH1D *chisqn_lin_fitted = nullptr, *chisqn_lin_selected = nullptr, *chisqn_log_fitted = nullptr,
0191 *chisqn_log_selected = nullptr;
0192
0193
0194 TGraph *fitAxVsAyGraph_fitted = nullptr, *fitAxVsAyGraph_selected = nullptr;
0195
0196
0197 TGraph *fitBxVsByGraph_fitted = nullptr, *fitBxVsByGraph_selected = nullptr;
0198
0199 RPSetPlots() {}
0200
0201 RPSetPlots(const std::string &_name);
0202
0203 void free();
0204
0205 void write() const;
0206 };
0207
0208
0209 RPSetPlots globalPlots;
0210
0211
0212 std::map<std::set<unsigned int>, RPSetPlots> rpSetPlots;
0213
0214
0215 struct ResiduaHistogramSet {
0216 TH1D *total_fitted, *total_selected;
0217 TGraph *selected_vs_chiSq;
0218 std::map<std::set<unsigned int>, TH1D *> perRPSet_fitted, perRPSet_selected;
0219 };
0220
0221
0222 std::map<unsigned int, ResiduaHistogramSet> residuaHistograms;
0223
0224
0225
0226
0227 TH1D *newResiduaHist(const char *name);
0228
0229
0230
0231
0232 void fitLocalTrack(HitCollection &, LocalTrackFit &, bool &failed, bool &selectionChanged);
0233
0234
0235 void removeInsufficientPots(HitCollection &, bool &selectionChanged);
0236
0237
0238 void buildConstraints(std::vector<AlignmentConstraint> &);
0239
0240
0241 void updateDiagnosticHistograms(const HitCollection &selection,
0242 const std::set<unsigned int> &selectedRPs,
0243 const LocalTrackFit &trackFit,
0244 bool trackSelected);
0245
0246
0247 static std::string setToString(const std::set<unsigned int> &);
0248
0249
0250 void printN(const char *str, unsigned int N);
0251 void printLineSeparator(const std::vector<std::map<unsigned int, AlignmentResult> > &);
0252 void printQuantitiesLine(const std::vector<std::map<unsigned int, AlignmentResult> > &);
0253 void printAlgorithmsLine(const std::vector<std::map<unsigned int, AlignmentResult> > &);
0254
0255
0256 void saveDiagnostics() const;
0257 };
0258
0259 #endif