CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MillePedeAlignmentAlgorithm.h
Go to the documentation of this file.
1 #ifndef Alignment_MillePedeAlignmentAlgorithm_MillePedeAlignmentAlgorithm_h
2 #define Alignment_MillePedeAlignmentAlgorithm_MillePedeAlignmentAlgorithm_h
3 
13 
15 
17 
20 
22 
23 #include <vector>
24 #include <string>
25 
26 #include <TMatrixDSym.h>
27 #include <TMatrixD.h>
28 #include <TMatrixF.h>
29 
30 class Alignable;
31 class AlignableTracker;
32 class AlignableMuon;
33 class AlignableExtras;
34 
36 class AlignableNavigator;
39 
41 
43 
44 class MillePedeMonitor;
45 class PedeSteerer;
46 class PedeLabelerBase;
47 class Mille;
49 
50 // already from base class - and forward declaration does not work since typedef!
51 /* class TkFittedLasBeamCollection; */
52 /* class TsosVectorCollection; */
53 
55 {
56  public:
59 
62 
64  virtual void initialize(const edm::EventSetup &setup,
67 
69  virtual bool supportsCalibrations() override;
71  virtual bool addCalibrations(const std::vector<IntegratedCalibrationBase*> &iCals);
72 
74  virtual void terminate(const edm::EventSetup& iSetup);
76  virtual void terminate();
77 
79  virtual bool processesEvents() override;
81  virtual void run(const edm::EventSetup &setup, const EventInfo &eventInfo);
82 
83  // TODO: This method does NOT match endRun() in base class! Nobody is
84  // calling this?
86  virtual void endRun(const EventInfo&, const EndRunInfo&,
87  const edm::EventSetup&); //override;
88 
89  // This one will be called since it matches the interface of the base class
90  virtual void endRun(const EndRunInfo &runInfo, const edm::EventSetup &setup);
91 
92 
93 /* virtual void beginLuminosityBlock(const edm::EventSetup &setup) {} */
94 /* virtual void endLuminosityBlock(const edm::EventSetup &setup) {} */
95 
98  virtual bool setParametersForRunRange(const RunRange &runrange);
99 
100  private:
102 
104  std::pair<unsigned int, unsigned int>
105  addReferenceTrajectory(const edm::EventSetup &setup, const EventInfo &eventInfo,
107 
111  int addMeasurementData(const edm::EventSetup &setup, const EventInfo &eventInfo,
113  unsigned int iHit, AlignmentParameters *&params);
114 
117  int addGlobalData(const edm::EventSetup &setup, const EventInfo &eventInfo,
119  unsigned int iHit, GblPoint &gblPoint);
120 
125  unsigned int addHitCount(const std::vector<AlignmentParameters*> &parVec,
126  const std::vector<bool> &validHitVecY) const;
127 
130  unsigned int iTrajHit, TMatrixDSym &aHitCovarianceM,
131  TMatrixF &aHitResidualsM, TMatrixF &aLocalDerivativesM);
132 
135  unsigned int iVirtualMeas);
136 
139  unsigned int iVirtualMeas,TMatrixDSym &aHitCovarianceM,
140  TMatrixF &aHitResidualsM, TMatrixF &aLocalDerivativesM);
141 
143  bool globalDerivativesHierarchy(const EventInfo &eventInfo,
144  const TrajectoryStateOnSurface &tsos,
145  Alignable *ali, const AlignableDetOrUnitPtr &alidet,
146  std::vector<float> &globalDerivativesX,
147  std::vector<float> &globalDerivativesY,
148  std::vector<int> &globalLabels,
149  AlignmentParameters *&lowestParams) const;
150 
152  bool globalDerivativesHierarchy(const EventInfo &eventInfo,
153  const TrajectoryStateOnSurface &tsos,
154  Alignable *ali, const AlignableDetOrUnitPtr &alidet,
155  std::vector<double> &globalDerivativesX,
156  std::vector<double> &globalDerivativesY,
157  std::vector<int> &globalLabels,
158  AlignmentParameters *&lowestParams) const;
159 
162  const TrajectoryStateOnSurface &tsos,
163  const edm::EventSetup &setup, const EventInfo &eventInfo,
164  std::vector<float> &globalDerivativesX,
165  std::vector<float> &globalDerivativesY,
166  std::vector<int> &globalLabels) const;
167 
170  unsigned int iTrajHit, const std::vector<int> &globalLabels,
171  const std::vector<float> &globalDerivativesX,
172  const std::vector<float> &globalDerivativesY);
173 
176  unsigned int iTrajHit, const std::vector<int> &globalLabels,
177  const std::vector<float> &globalDerivativesX);
178 
183  unsigned int iTrajHit, const std::vector<int> &globalLabels,
184  const std::vector<float> &globalDerivativesx,
185  const std::vector<float> &globalDerivativesy);
186  void diagonalize(TMatrixDSym &aHitCovarianceM, TMatrixF &aLocalDerivativesM,
187  TMatrixF &aHitResidualsM,TMatrixF &theGlobalDerivativesM) const;
188  // deals with the non matrix format of theFloatBufferX ...
189  void makeGlobDerivMatrix(const std::vector<float> &globalDerivativesx,
190  const std::vector<float> &globalDerivativesy,
191  TMatrixF &aGlobalDerivativesM);
192 
193 // void callMille(const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr,
194 // unsigned int iTrajHit, MeasurementDirection xOrY,
195 // const std::vector<float> &globalDerivatives, const std::vector<int> &globalLabels);
197  bool is2D(const TransientTrackingRecHit::ConstRecHitPointer &recHit) const;
198 
200  bool readFromPede(const edm::ParameterSet &mprespset, bool setUserVars,
201  const RunRange &runrange);
202  bool areEmptyParams(const std::vector<Alignable*> &alignables) const;
203  unsigned int doIO(int loop) const;
205  void buildUserVariables(const std::vector<Alignable*> &alignables) const;
206 
209  std::vector<std::string> getExistingFormattedFiles(const std::vector<std::string> plainFiles, std::string theDir);
210 
211  void addLaserData(const EventInfo &eventInfo,
212  const TkFittedLasBeamCollection &tkLasBeams,
213  const TsosVectorCollection &tkLasBeamTsoses);
214  void addLasBeam(const EventInfo &eventInfo,
215  const TkFittedLasBeam &lasBeam,
216  const std::vector<TrajectoryStateOnSurface> &tsoses);
217 
219  void addPxbSurvey(const edm::ParameterSet &pxbSurveyCfg);
220 
221  //--------------------------------------------------------
222  // Data members
223  //--------------------------------------------------------
224  enum EModeBit {myMilleBit = 1 << 0, myPedeRunBit = 1 << 1, myPedeSteerBit = 1 << 2,
225  myPedeReadBit = 1 << 3};
226  unsigned int decodeMode(const std::string &mode) const;
227  bool isMode(unsigned int testMode) const {return (theMode & testMode);}
228  bool addHitStatistics(int fromLoop, const std::string &outFile,
229  const std::vector<std::string> &inFiles) const;
230  bool addHits(const std::vector<Alignable*> &alis,
231  const std::vector<AlignmentUserVariables*> &mpVars) const;
232 
234  unsigned int theMode;
237  std::vector<Alignable*> theAlignables;
244  std::vector<IntegratedCalibrationBase*> theCalibrations;
245  unsigned int theMinNumHits;
247  int theLastWrittenIov; // keeping track for output trees...
249  std::vector<float> theFloatBufferX;
250  std::vector<float> theFloatBufferY;
251  std::vector<int> theIntBuffer;
253  // CHK for GBL
256 };
257 
258 #endif
virtual bool processesEvents() override
Returns whether MP should process events in the current configuration.
void globalDerivativesCalibration(const TransientTrackingRecHit::ConstRecHitPointer &recHit, const TrajectoryStateOnSurface &tsos, const edm::EventSetup &setup, const EventInfo &eventInfo, std::vector< float > &globalDerivativesX, std::vector< float > &globalDerivativesY, std::vector< int > &globalLabels) const
adding derivatives from integrated calibrations
virtual bool supportsCalibrations() override
Returns whether MP supports calibrations.
tuple cfg
Definition: looper.py:259
virtual void endRun(const EventInfo &, const EndRunInfo &, const edm::EventSetup &)
Run on run products, e.g. TkLAS.
std::vector< Alignable * > theAlignables
bool globalDerivativesHierarchy(const EventInfo &eventInfo, const TrajectoryStateOnSurface &tsos, Alignable *ali, const AlignableDetOrUnitPtr &alidet, std::vector< float > &globalDerivativesX, std::vector< float > &globalDerivativesY, std::vector< int > &globalLabels, AlignmentParameters *&lowestParams) const
recursively adding derivatives and labels, false if problems
unsigned int addHitCount(const std::vector< AlignmentParameters * > &parVec, const std::vector< bool > &validHitVecY) const
int loop
CMSSW
int callMille2D(const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr, unsigned int iTrajHit, const std::vector< int > &globalLabels, const std::vector< float > &globalDerivativesx, const std::vector< float > &globalDerivativesy)
std::pair< RunNumber, RunNumber > RunRange
Interface/Base class for alignment algorithms, each alignment algorithm has to be derived from this c...
virtual void initialize(const edm::EventSetup &setup, AlignableTracker *tracker, AlignableMuon *muon, AlignableExtras *extras, AlignmentParameterStore *store)
Called at beginning of job.
void addLasBeam(const EventInfo &eventInfo, const TkFittedLasBeam &lasBeam, const std::vector< TrajectoryStateOnSurface > &tsoses)
define event information passed to algorithms
unsigned int doIO(int loop) const
int callMille(const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr, unsigned int iTrajHit, const std::vector< int > &globalLabels, const std::vector< float > &globalDerivativesX, const std::vector< float > &globalDerivativesY)
calls callMille1D or callMille2D
int callMille1D(const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr, unsigned int iTrajHit, const std::vector< int > &globalLabels, const std::vector< float > &globalDerivativesX)
calls Mille for 1D hits
void addLaserData(const EventInfo &eventInfo, const TkFittedLasBeamCollection &tkLasBeams, const TsosVectorCollection &tkLasBeamTsoses)
int addMeasurementData(const edm::EventSetup &setup, const EventInfo &eventInfo, const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr, unsigned int iHit, AlignmentParameters *&params)
bool isMode(unsigned int testMode) const
std::pair< RunNumber, RunNumber > RunRange
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
virtual bool setParametersForRunRange(const RunRange &runrange)
AlignmentParameterStore * theAlignmentParameterStore
directory for all kind of files
bool is2D(const TransientTrackingRecHit::ConstRecHitPointer &recHit) const
true if hit belongs to 2D detector (currently tracker specific)
int addGlobalData(const edm::EventSetup &setup, const EventInfo &eventInfo, const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr, unsigned int iHit, GblPoint &gblPoint)
void diagonalize(TMatrixDSym &aHitCovarianceM, TMatrixF &aLocalDerivativesM, TMatrixF &aHitResidualsM, TMatrixF &theGlobalDerivativesM) const
(Abstract) Base class for alignment algorithm user variables
std::vector< std::string > getExistingFormattedFiles(const std::vector< std::string > plainFiles, std::string theDir)
bool addHits(const std::vector< Alignable * > &alis, const std::vector< AlignmentUserVariables * > &mpVars) const
bool addHitStatistics(int fromLoop, const std::string &outFile, const std::vector< std::string > &inFiles) const
bool areEmptyParams(const std::vector< Alignable * > &alignables) const
void addVirtualMeas(const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr, unsigned int iVirtualMeas)
adds data for virtual measurements from reference trajectory
bool readFromPede(const edm::ParameterSet &mprespset, bool setUserVars, const RunRange &runrange)
read pede input defined by &#39;psetName&#39;, flag to create/not create MillePedeVariables ...
std::pair< unsigned int, unsigned int > addReferenceTrajectory(const edm::EventSetup &setup, const EventInfo &eventInfo, const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr)
fill mille for a trajectory, returning number of x/y hits ([0,0] if &#39;bad&#39; trajectory) ...
void addRefTrackData2D(const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr, unsigned int iTrajHit, TMatrixDSym &aHitCovarianceM, TMatrixF &aHitResidualsM, TMatrixF &aLocalDerivativesM)
adds data from reference trajectory from a specific Hit
std::vector< IntegratedCalibrationBase * > theCalibrations
void makeGlobDerivMatrix(const std::vector< float > &globalDerivativesx, const std::vector< float > &globalDerivativesy, TMatrixF &aGlobalDerivativesM)
virtual bool addCalibrations(const std::vector< IntegratedCalibrationBase * > &iCals)
Pass integrated calibrations to Millepede (they are not owned by Millepede!)
virtual void run(const edm::EventSetup &setup, const EventInfo &eventInfo)
Run the algorithm on trajectories and tracks.
void buildUserVariables(const std::vector< Alignable * > &alignables) const
add MillePedeVariables for each AlignmentParameters (exception if no parameters...)
MillePedeAlignmentAlgorithm(const edm::ParameterSet &cfg)
Constructor.
TrajectoryFactoryBase * theTrajectoryFactory
virtual ~MillePedeAlignmentAlgorithm()
Destructor.
std::vector< TkFittedLasBeam > TkFittedLasBeamCollection
Definition: Mille.h:26
Millepede-II (binary) record.
Definition: MilleBinary.h:46
void addRefTrackVirtualMeas1D(const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr, unsigned int iVirtualMeas, TMatrixDSym &aHitCovarianceM, TMatrixF &aHitResidualsM, TMatrixF &aLocalDerivativesM)
adds data for a specific virtual measurement from reference trajectory
void addPxbSurvey(const edm::ParameterSet &pxbSurveyCfg)
add measurement data from PXB survey
unsigned int decodeMode(const std::string &mode) const
std::vector< std::vector< TrajectoryStateOnSurface > > TsosVectorCollection
define run information passed to algorithms (in endRun)
Constructor of the full muon geometry.
Definition: AlignableMuon.h:36
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
Point on trajectory.
Definition: GblPoint.h:46
virtual void terminate()
Called at end of job.