CMS 3D CMS Logo

StraightTrackAlignment.h
Go to the documentation of this file.
1 /****************************************************************************
2 * Authors:
3 * Jan Kašpar (jan.kaspar@gmail.com)
4 * Cristian Baldenegro (crisx.baldenegro@gmail.com)
5 ****************************************************************************/
6 
7 #ifndef CalibPPS_AlignmentRelative_StraightTrackAlignment_h
8 #define CalibPPS_AlignmentRelative_StraightTrackAlignment_h
9 
10 #include <set>
11 #include <vector>
12 #include <string>
13 
14 #include <TMatrixD.h>
15 #include <TVectorD.h>
16 #include <TFile.h>
17 
24 
26 
35 
36 namespace edm {
37  class ParameterSet;
38  class Event;
39  class EventSetup;
40 } // namespace edm
41 
42 class TH1D;
43 class TGraph;
44 
49 public:
51  virtual ~StraightTrackAlignment();
52 
53  virtual void begin(edm::ESHandle<CTPPSRPAlignmentCorrectionsData> hRealAlignment,
54  edm::ESHandle<CTPPSGeometry> hRealGeometry,
55  edm::ESHandle<CTPPSGeometry> hMisalignedGeometry);
56 
57  virtual void processEvent(const edm::EventID &eventId,
58  const edm::DetSetVector<TotemRPUVPattern> &uvPatternsStrip,
59  const edm::DetSetVector<CTPPSDiamondRecHit> &hitsDiamond,
60  const edm::DetSetVector<CTPPSPixelRecHit> &hitsPixel,
61  const edm::DetSetVector<CTPPSPixelLocalTrack> &tracksPixel);
62 
64  virtual void finish();
65 
66 protected:
67  // ---------- input parameters -----------
68 
70  unsigned int verbosity;
71 
73  std::vector<unsigned int> rpIds;
74 
76  std::vector<unsigned int> excludePlanes;
77 
80  double z0;
81 
83  std::vector<AlignmentAlgorithm *> algorithms;
84 
87 
90 
92  signed int maxEvents;
93 
94  // ---------- hit/track selection parameters ----------
95 
98 
100  unsigned int requireNumberOfUnits;
101 
104 
107 
110 
113 
115  double maxTrackAx;
116  double maxTrackAy;
117 
119  std::vector<std::set<unsigned int> > additionalAcceptedRPSets;
120 
121  // ---------- output parameters ----------
122 
125 
128 
131 
134 
137 
140 
143 
146 
148  TFile *taskDataFile;
149 
150  // ---------- internal data members ----------
151 
154 
157 
160 
161  // ---------- diagnostics parameters and plots ----------
162 
165 
168 
169  signed int eventsTotal;
170  signed int eventsFitted;
171  signed int eventsSelected;
172 
173  std::map<std::set<unsigned int>, unsigned long> fittedTracksPerRPSet;
174  std::map<std::set<unsigned int>, unsigned long>
176 
177  std::map<unsigned int, unsigned int> selectedHitsPerPlane;
178 
185 
186  struct RPSetPlots {
188 
190  TH1D *chisqn_lin_fitted = nullptr, *chisqn_lin_selected = nullptr, *chisqn_log_fitted = nullptr,
192 
194  TGraph *fitAxVsAyGraph_fitted = nullptr, *fitAxVsAyGraph_selected = nullptr;
195 
197  TGraph *fitBxVsByGraph_fitted = nullptr, *fitBxVsByGraph_selected = nullptr;
198 
200 
201  RPSetPlots(const std::string &_name);
202 
203  void free();
204 
205  void write() const;
206  };
207 
210 
212  std::map<std::set<unsigned int>, RPSetPlots> rpSetPlots;
213 
218  std::map<std::set<unsigned int>, TH1D *> perRPSet_fitted, perRPSet_selected;
219  };
220 
222  std::map<unsigned int, ResiduaHistogramSet> residuaHistograms;
223 
224  // ----------- methods ------------
225 
227  TH1D *newResiduaHist(const char *name);
228 
232  void fitLocalTrack(HitCollection &, LocalTrackFit &, bool &failed, bool &selectionChanged);
233 
235  void removeInsufficientPots(HitCollection &, bool &selectionChanged);
236 
238  void buildConstraints(std::vector<AlignmentConstraint> &);
239 
242  const std::set<unsigned int> &selectedRPs,
243  const LocalTrackFit &trackFit,
244  bool trackSelected);
245 
247  static std::string setToString(const std::set<unsigned int> &);
248 
250  void printN(const char *str, unsigned int N);
251  void printLineSeparator(const std::vector<std::map<unsigned int, AlignmentResult> > &);
252  void printQuantitiesLine(const std::vector<std::map<unsigned int, AlignmentResult> > &);
253  void printAlgorithmsLine(const std::vector<std::map<unsigned int, AlignmentResult> > &);
254 
256  void saveDiagnostics() const;
257 };
258 
259 #endif
StraightTrackAlignment::eventsFitted
signed int eventsFitted
counter of processed tracks
Definition: StraightTrackAlignment.h:170
StraightTrackAlignment::RPSetPlots::chisqn_log_selected
TH1D * chisqn_log_selected
Definition: StraightTrackAlignment.h:191
edm::DetSetVector
Definition: DetSetVector.h:61
StraightTrackAlignment::fitAxHist_fitted
TH1D * fitAxHist_fitted
Definition: StraightTrackAlignment.h:181
StraightTrackAlignment
Track-based alignment using straight tracks.
Definition: StraightTrackAlignment.h:48
CTPPSPixelLocalTrack.h
StraightTrackAlignment::ResiduaHistogramSet::perRPSet_fitted
std::map< std::set< unsigned int >, TH1D * > perRPSet_fitted
Definition: StraightTrackAlignment.h:218
StraightTrackAlignment::maxEvents
signed int maxEvents
stops after this event number has been reached
Definition: StraightTrackAlignment.h:92
AlignmentTask
Represents an alignment task.
Definition: AlignmentTask.h:19
StraightTrackAlignment::requireAtLeast3PotsInOverlap
bool requireAtLeast3PotsInOverlap
if a track goes through overlap, select it only if it leaves signal in at least 3 pots
Definition: StraightTrackAlignment.h:103
HitCollection.h
StraightTrackAlignment::fittedTracksPerRPSet
std::map< std::set< unsigned int >, unsigned long > fittedTracksPerRPSet
counter of fitted tracks in a certain RP set
Definition: StraightTrackAlignment.h:173
StraightTrackAlignment::RPSetPlots::write
void write() const
Definition: StraightTrackAlignment.cc:81
ESHandle.h
StraightTrackAlignment::fitBxHist_fitted
TH1D * fitBxHist_fitted
Definition: StraightTrackAlignment.h:183
StraightTrackAlignment::RPSetPlots::fitAxVsAyGraph_fitted
TGraph * fitAxVsAyGraph_fitted
plots ax vs. ay
Definition: StraightTrackAlignment.h:194
StraightTrackAlignment::selectedHitsPerPlane
std::map< unsigned int, unsigned int > selectedHitsPerPlane
counter of selected hits per plane
Definition: StraightTrackAlignment.h:177
StraightTrackAlignment::fitPHist_fitted
TH1D * fitPHist_fitted
Definition: StraightTrackAlignment.h:180
edm
HLT enums.
Definition: AlignableModifier.h:19
StraightTrackAlignment::eventsTotal
signed int eventsTotal
counter of events
Definition: StraightTrackAlignment.h:169
StraightTrackAlignment::taskDataFile
TFile * taskDataFile
the file with task data
Definition: StraightTrackAlignment.h:148
runEdmFileComparison.failed
failed
Definition: runEdmFileComparison.py:225
StraightTrackAlignment::diagnosticsFile
std::string diagnosticsFile
file name for some event selection statistics
Definition: StraightTrackAlignment.h:167
StraightTrackAlignment::saveIntermediateResults
bool saveIntermediateResults
whether itermediate results (S, CS matrices) of alignments shall be saved
Definition: StraightTrackAlignment.h:142
StraightTrackAlignment::residuaHistograms
std::map< unsigned int, ResiduaHistogramSet > residuaHistograms
residua histograms
Definition: StraightTrackAlignment.h:222
StraightTrackAlignment::factoredFileNamePrefix
std::string factoredFileNamePrefix
file name prefix for cumulative factored result files
Definition: StraightTrackAlignment.h:133
StraightTrackAlignment::RPSetPlots::fitBxVsByGraph_selected
TGraph * fitBxVsByGraph_selected
Definition: StraightTrackAlignment.h:197
StraightTrackAlignment::RPSetPlots::chisqn_lin_fitted
TH1D * chisqn_lin_fitted
normalised chi^2 histograms for all/selected tracks, in linear/logarithmic scale
Definition: StraightTrackAlignment.h:190
StraightTrackAlignment::fitBxHist_selected
TH1D * fitBxHist_selected
fit bx histograms for all/selected tracks
Definition: StraightTrackAlignment.h:183
StraightTrackAlignment::printAlgorithmsLine
void printAlgorithmsLine(const std::vector< std::map< unsigned int, AlignmentResult > > &)
Definition: StraightTrackAlignment.cc:1011
TotemRPRecHit.h
StraightTrackAlignment::ctStandard
Definition: StraightTrackAlignment.h:86
StraightTrackAlignment::eventsSelected
signed int eventsSelected
counter of processed tracks
Definition: StraightTrackAlignment.h:171
StraightTrackAlignment::fitter
LocalTrackFitter fitter
track fitter
Definition: StraightTrackAlignment.h:156
StraightTrackAlignment::cumulativeFileNamePrefix
std::string cumulativeFileNamePrefix
file name prefix for cumulative result files
Definition: StraightTrackAlignment.h:127
AlignmentConstraint.h
CTPPSPixelRecHit.h
StraightTrackAlignment::ctFixedDetectors
Definition: StraightTrackAlignment.h:86
StraightTrackAlignment::taskDataFileName
std::string taskDataFileName
the name task data file
Definition: StraightTrackAlignment.h:145
StraightTrackAlignment::finish
virtual void finish()
performs analyses and fill results variable
Definition: StraightTrackAlignment.cc:709
StraightTrackAlignment::globalPlots
RPSetPlots globalPlots
global (all RP sets) chi^2 histograms
Definition: StraightTrackAlignment.h:209
StraightTrackAlignment::ResiduaHistogramSet::total_selected
TH1D * total_selected
Definition: StraightTrackAlignment.h:216
LocalTrackFitter.h
LocalTrackFit.h
StraightTrackAlignment::fitNdfHist_selected
TH1D * fitNdfHist_selected
fit num. of degrees of freedom histograms for all/selected tracks
Definition: StraightTrackAlignment.h:179
StraightTrackAlignment::ResiduaHistogramSet::total_fitted
TH1D * total_fitted
Definition: StraightTrackAlignment.h:216
StraightTrackAlignment::initialAlignments
CTPPSRPAlignmentCorrectionsData initialAlignments
(real geometry) alignments before this alignment iteration
Definition: StraightTrackAlignment.h:159
StraightTrackAlignment::task
AlignmentTask task
the alignment task to be solved
Definition: StraightTrackAlignment.h:153
StraightTrackAlignment::verbosity
unsigned int verbosity
verbosity level
Definition: StraightTrackAlignment.h:70
CTPPSDiamondRecHit.h
corrVsCorr.selection
selection
main part
Definition: corrVsCorr.py:100
StraightTrackAlignment::updateDiagnosticHistograms
void updateDiagnosticHistograms(const HitCollection &selection, const std::set< unsigned int > &selectedRPs, const LocalTrackFit &trackFit, bool trackSelected)
fills diagnostic (chi^2, residua, ...) histograms
Definition: StraightTrackAlignment.cc:578
str
#define str(s)
Definition: TestProcessor.cc:52
edm::ESHandle
Definition: DTSurvey.h:22
N
#define N
Definition: blowfish.cc:9
StraightTrackAlignment::requireOverlap
bool requireOverlap
if true, only track through vertical-horizontal overlap are seleceted
Definition: StraightTrackAlignment.h:106
Event
StraightTrackAlignment::RPSetPlots::free
void free()
Definition: StraightTrackAlignment.cc:67
StraightTrackAlignment::fitAyHist_fitted
TH1D * fitAyHist_fitted
Definition: StraightTrackAlignment.h:182
StraightTrackAlignment::ConstraintsType
ConstraintsType
constraint types
Definition: StraightTrackAlignment.h:86
StraightTrackAlignment::fitPHist_selected
TH1D * fitPHist_selected
fit p-value histograms for all/selected tracks
Definition: StraightTrackAlignment.h:180
StraightTrackAlignment::cutOnChiSqPerNdf
bool cutOnChiSqPerNdf
whether to cut on chi^2/ndf
Definition: StraightTrackAlignment.h:109
AlignmentGeometry.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
StraightTrackAlignment::additionalAcceptedRPSets
std::vector< std::set< unsigned int > > additionalAcceptedRPSets
list of RP sets accepted irrespective of the other "require" settings
Definition: StraightTrackAlignment.h:119
edm::ParameterSet
Definition: ParameterSet.h:47
StraightTrackAlignment::StraightTrackAlignment
StraightTrackAlignment(const edm::ParameterSet &)
Definition: StraightTrackAlignment.cc:96
StraightTrackAlignment::excludePlanes
std::vector< unsigned int > excludePlanes
list of planes to be excluded from processing
Definition: StraightTrackAlignment.h:76
ParameterSet
Definition: Functions.h:16
StraightTrackAlignment::ResiduaHistogramSet::perRPSet_selected
std::map< std::set< unsigned int >, TH1D * > perRPSet_selected
Definition: StraightTrackAlignment.h:218
StraightTrackAlignment::removeImpossible
bool removeImpossible
remove events with impossible signatures (i.e. simultaneously top and bottom)
Definition: StraightTrackAlignment.h:97
StraightTrackAlignment::ResiduaHistogramSet
map: detector id --> residua histogram
Definition: StraightTrackAlignment.h:215
StraightTrackAlignment::buildDiagnosticPlots
bool buildDiagnosticPlots
whether to build and save diagnostic plots
Definition: StraightTrackAlignment.h:164
StraightTrackAlignment::newResiduaHist
TH1D * newResiduaHist(const char *name)
creates a new residua histogram
Definition: StraightTrackAlignment.cc:39
StraightTrackAlignment::processEvent
virtual void processEvent(const edm::EventID &eventId, const edm::DetSetVector< TotemRPUVPattern > &uvPatternsStrip, const edm::DetSetVector< CTPPSDiamondRecHit > &hitsDiamond, const edm::DetSetVector< CTPPSPixelRecHit > &hitsPixel, const edm::DetSetVector< CTPPSPixelLocalTrack > &tracksPixel)
Definition: StraightTrackAlignment.cc:288
StraightTrackAlignment::RPSetPlots::chisqn_lin_selected
TH1D * chisqn_lin_selected
Definition: StraightTrackAlignment.h:190
StraightTrackAlignment::fitLocalTrack
void fitLocalTrack(HitCollection &, LocalTrackFit &, bool &failed, bool &selectionChanged)
StraightTrackAlignment::fileNamePrefix
std::string fileNamePrefix
file name prefix for result files
Definition: StraightTrackAlignment.h:124
StraightTrackAlignment::preciseXMLFormat
bool preciseXMLFormat
whether to use long format (many decimal digits) when saving XML files
Definition: StraightTrackAlignment.h:136
StraightTrackAlignment::RPSetPlots::name
std::string name
Definition: StraightTrackAlignment.h:187
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
StraightTrackAlignment::rpSetPlots
std::map< std::set< unsigned int >, RPSetPlots > rpSetPlots
chi^2 histograms per RP set
Definition: StraightTrackAlignment.h:212
StraightTrackAlignment::printLineSeparator
void printLineSeparator(const std::vector< std::map< unsigned int, AlignmentResult > > &)
Definition: StraightTrackAlignment.cc:975
StraightTrackAlignment::buildConstraints
void buildConstraints(std::vector< AlignmentConstraint > &)
builds a selected set of constraints
Definition: StraightTrackAlignment.cc:693
DetSetVector.h
StraightTrackAlignment::saveDiagnostics
void saveDiagnostics() const
saves a ROOT file with diagnostic plots
Definition: StraightTrackAlignment.cc:1029
StraightTrackAlignment::RPSetPlots::fitBxVsByGraph_fitted
TGraph * fitBxVsByGraph_fitted
plots bx vs. by
Definition: StraightTrackAlignment.h:197
StraightTrackAlignment::constraintsType
ConstraintsType constraintsType
the chosen type of constraints
Definition: StraightTrackAlignment.h:89
AlignmentTask.h
StraightTrackAlignment::rpIds
std::vector< unsigned int > rpIds
list of RPs for which the alignment parameters shall be optimized
Definition: StraightTrackAlignment.h:73
StraightTrackAlignment::requireNumberOfUnits
unsigned int requireNumberOfUnits
select only tracks with activity in minimal number of units
Definition: StraightTrackAlignment.h:100
StraightTrackAlignment::setToString
static std::string setToString(const std::set< unsigned int > &)
converts a set to string
Definition: StraightTrackAlignment.cc:948
StraightTrackAlignment::maxTrackAx
double maxTrackAx
cuts on absolute values of the track angle
Definition: StraightTrackAlignment.h:115
StraightTrackAlignment::fitNdfHist_fitted
TH1D * fitNdfHist_fitted
Definition: StraightTrackAlignment.h:179
StraightTrackAlignment::selectedTracksPerRPSet
std::map< std::set< unsigned int >, unsigned long > selectedTracksPerRPSet
counter of selected tracks in a certain RP set
Definition: StraightTrackAlignment.h:175
StraightTrackAlignment::ResiduaHistogramSet::selected_vs_chiSq
TGraph * selected_vs_chiSq
Definition: StraightTrackAlignment.h:217
StraightTrackAlignment::RPSetPlots::chisqn_log_fitted
TH1D * chisqn_log_fitted
Definition: StraightTrackAlignment.h:190
AlignmentAlgorithm.h
HitCollection
std::vector< Hit > HitCollection
Definition: HitCollection.h:34
StraightTrackAlignment::printN
void printN(const char *str, unsigned int N)
result pretty printing routines
Definition: StraightTrackAlignment.cc:968
StraightTrackAlignment::chiSqPerNdfCut
double chiSqPerNdfCut
the value of chi^2/ndf cut threshold
Definition: StraightTrackAlignment.h:112
StraightTrackAlignment::fitByHist_fitted
TH1D * fitByHist_fitted
Definition: StraightTrackAlignment.h:184
LocalTrackFit
Local (linear) track description (or a fit result). Uses global reference system.
Definition: LocalTrackFit.h:14
CTPPSRPAlignmentCorrectionsData
Container for CTPPS RP alignment corrections. The corrections are stored on two levels - RP and senso...
Definition: CTPPSRPAlignmentCorrectionsData.h:24
StraightTrackAlignment::RPSetPlots::fitAxVsAyGraph_selected
TGraph * fitAxVsAyGraph_selected
Definition: StraightTrackAlignment.h:194
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
StraightTrackAlignment::printQuantitiesLine
void printQuantitiesLine(const std::vector< std::map< unsigned int, AlignmentResult > > &)
Definition: StraightTrackAlignment.cc:990
CTPPSRPAlignmentCorrectionsData.h
StraightTrackAlignment::z0
double z0
Definition: StraightTrackAlignment.h:80
StraightTrackAlignment::saveXMLUncertainties
bool saveXMLUncertainties
whether to save uncertainties in the result XML files
Definition: StraightTrackAlignment.h:139
TotemRPUVPattern.h
StraightTrackAlignment::fitAxHist_selected
TH1D * fitAxHist_selected
fit ax histograms for all/selected tracks
Definition: StraightTrackAlignment.h:181
StraightTrackAlignment::algorithms
std::vector< AlignmentAlgorithm * > algorithms
the collection of the alignment algorithms
Definition: StraightTrackAlignment.h:83
EventSetup
StraightTrackAlignment::fitAyHist_selected
TH1D * fitAyHist_selected
fit ay histograms for all/selected tracks
Definition: StraightTrackAlignment.h:182
StraightTrackAlignment::begin
virtual void begin(edm::ESHandle< CTPPSRPAlignmentCorrectionsData > hRealAlignment, edm::ESHandle< CTPPSGeometry > hRealGeometry, edm::ESHandle< CTPPSGeometry > hMisalignedGeometry)
Definition: StraightTrackAlignment.cc:251
edm::EventID
Definition: EventID.h:31
StraightTrackAlignment::~StraightTrackAlignment
virtual ~StraightTrackAlignment()
Definition: StraightTrackAlignment.cc:213
StraightTrackAlignment::maxTrackAy
double maxTrackAy
Definition: StraightTrackAlignment.h:116
StraightTrackAlignment::RPSetPlots::RPSetPlots
RPSetPlots()
Definition: StraightTrackAlignment.h:199
StraightTrackAlignment::fitByHist_selected
TH1D * fitByHist_selected
fit by histograms for all/selected tracks
Definition: StraightTrackAlignment.h:184
StraightTrackAlignment::RPSetPlots
Definition: StraightTrackAlignment.h:186
StraightTrackAlignment::removeInsufficientPots
void removeInsufficientPots(HitCollection &, bool &selectionChanged)
removes the hits of pots with too few planes active
StraightTrackAlignment::expandedFileNamePrefix
std::string expandedFileNamePrefix
file name prefix for cumulative expanded result files
Definition: StraightTrackAlignment.h:130
LocalTrackFitter
Performs straight-line fit and outlier rejection.
Definition: LocalTrackFitter.h:19