CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
std::string taskDataFileName
the name task data file
void saveDiagnostics() const
saves a ROOT file with diagnostic plots
TGraph * fitBxVsByGraph_fitted
plots bx vs. by
bool cutOnChiSqPerNdf
whether to cut on chi^2/ndf
TH1D * fitNdfHist_selected
fit num. of degrees of freedom histograms for all/selected tracks
std::map< std::set< unsigned int >, TH1D * > perRPSet_selected
std::vector< unsigned int > excludePlanes
list of planes to be excluded from processing
std::vector< unsigned int > rpIds
list of RPs for which the alignment parameters shall be optimized
TH1D * fitAyHist_selected
fit ay histograms for all/selected tracks
bool buildDiagnosticPlots
whether to build and save diagnostic plots
bool saveXMLUncertainties
whether to save uncertainties in the result XML files
signed int eventsSelected
counter of processed tracks
unsigned int requireNumberOfUnits
select only tracks with activity in minimal number of units
selection
main part
Definition: corrVsCorr.py:100
virtual void finish()
performs analyses and fill results variable
TFile * taskDataFile
the file with task data
map: detector id –&gt; residua histogram
CTPPSRPAlignmentCorrectionsData initialAlignments
(real geometry) alignments before this alignment iteration
TH1D * fitPHist_selected
fit p-value histograms for all/selected tracks
void buildConstraints(std::vector< AlignmentConstraint > &)
builds a selected set of constraints
void updateDiagnosticHistograms(const HitCollection &selection, const std::set< unsigned int > &selectedRPs, const LocalTrackFit &trackFit, bool trackSelected)
fills diagnostic (chi^2, residua, ...) histograms
TGraph * fitAxVsAyGraph_fitted
plots ax vs. ay
LocalTrackFitter fitter
track fitter
StraightTrackAlignment(const edm::ParameterSet &)
std::map< unsigned int, unsigned int > selectedHitsPerPlane
counter of selected hits per plane
std::string factoredFileNamePrefix
file name prefix for cumulative factored result files
signed int eventsTotal
counter of events
bool saveIntermediateResults
whether itermediate results (S, CS matrices) of alignments shall be saved
Local (linear) track description (or a fit result). Uses global reference system. ...
Definition: LocalTrackFit.h:15
Performs straight-line fit and outlier rejection.
Represents an alignment task.
Definition: AlignmentTask.h:20
bool preciseXMLFormat
whether to use long format (many decimal digits) when saving XML files
AlignmentTask task
the alignment task to be solved
Track-based alignment using straight tracks.
signed int maxEvents
stops after this event number has been reached
void printN(const char *str, unsigned int N)
result pretty printing routines
unsigned int verbosity
verbosity level
std::string fileNamePrefix
file name prefix for result files
bool removeImpossible
remove events with impossible signatures (i.e. simultaneously top and bottom)
void removeInsufficientPots(HitCollection &, bool &selectionChanged)
removes the hits of pots with too few planes active
void fitLocalTrack(HitCollection &, LocalTrackFit &, bool &failed, bool &selectionChanged)
bool requireOverlap
if true, only track through vertical-horizontal overlap are seleceted
RPSetPlots globalPlots
global (all RP sets) chi^2 histograms
ConstraintsType
constraint types
TH1D * newResiduaHist(const char *name)
creates a new residua histogram
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)
std::string cumulativeFileNamePrefix
file name prefix for cumulative result files
std::map< std::set< unsigned int >, unsigned long > selectedTracksPerRPSet
counter of selected tracks in a certain RP set
TH1D * chisqn_lin_fitted
normalised chi^2 histograms for all/selected tracks, in linear/logarithmic scale
virtual void begin(edm::ESHandle< CTPPSRPAlignmentCorrectionsData > hRealAlignment, edm::ESHandle< CTPPSGeometry > hRealGeometry, edm::ESHandle< CTPPSGeometry > hMisalignedGeometry)
TH1D * fitAxHist_selected
fit ax histograms for all/selected tracks
#define N
Definition: blowfish.cc:9
std::map< std::set< unsigned int >, TH1D * > perRPSet_fitted
void printQuantitiesLine(const std::vector< std::map< unsigned int, AlignmentResult > > &)
std::vector< std::set< unsigned int > > additionalAcceptedRPSets
list of RP sets accepted irrespective of the other &quot;require&quot; settings
double chiSqPerNdfCut
the value of chi^2/ndf cut threshold
std::vector< Hit > HitCollection
Definition: HitCollection.h:35
std::vector< AlignmentAlgorithm * > algorithms
the collection of the alignment algorithms
Container for CTPPS RP alignment corrections. The corrections are stored on two levels - RP and senso...
static std::string setToString(const std::set< unsigned int > &)
converts a set to string
ConstraintsType constraintsType
the chosen type of constraints
signed int eventsFitted
counter of processed tracks
std::string diagnosticsFile
file name for some event selection statistics
TH1D * fitByHist_selected
fit by histograms for all/selected tracks
bool requireAtLeast3PotsInOverlap
if a track goes through overlap, select it only if it leaves signal in at least 3 pots ...
TH1D * fitBxHist_selected
fit bx histograms for all/selected tracks
std::map< unsigned int, ResiduaHistogramSet > residuaHistograms
residua histograms
void printAlgorithmsLine(const std::vector< std::map< unsigned int, AlignmentResult > > &)
void printLineSeparator(const std::vector< std::map< unsigned int, AlignmentResult > > &)
#define str(s)
double maxTrackAx
cuts on absolute values of the track angle
std::string expandedFileNamePrefix
file name prefix for cumulative expanded result files
std::map< std::set< unsigned int >, unsigned long > fittedTracksPerRPSet
counter of fitted tracks in a certain RP set
std::map< std::set< unsigned int >, RPSetPlots > rpSetPlots
chi^2 histograms per RP set