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 
16 
18 
21 
23 
24 #include <vector>
25 #include <string>
26 #include <memory>
27 
28 #include <TMatrixDSym.h>
29 #include <TMatrixD.h>
30 #include <TMatrixF.h>
31 
32 class Alignable;
33 class AlignableTracker;
34 class AlignableMuon;
35 class AlignableExtras;
36 
38 class AlignableNavigator;
41 
43 
45 
46 class MillePedeMonitor;
47 class PedeSteerer;
48 class PedeLabelerBase;
49 class Mille;
51 
52 // already from base class - and forward declaration does not work since typedef!
53 /* class TkFittedLasBeamCollection; */
54 /* class TsosVectorCollection; */
55 
57 {
58  public:
61 
64 
66  virtual void initialize(const edm::EventSetup &setup,
68  AlignmentParameterStore *store) override;
69 
71  virtual bool supportsCalibrations() override;
73  virtual bool addCalibrations(const std::vector<IntegratedCalibrationBase*> &iCals) override;
74 
76  virtual void terminate(const edm::EventSetup& iSetup) override;
78  virtual void terminate() override;
79 
81  virtual bool processesEvents() override;
82 
84  virtual bool storeAlignments() override;
85 
87  virtual void run(const edm::EventSetup &setup, const EventInfo &eventInfo) override;
88 
89  // TODO: This method does NOT match endRun() in base class! Nobody is
90  // calling this?
92  virtual void endRun(const EventInfo&, const EndRunInfo&,
93  const edm::EventSetup&); //override;
94 
95  // This one will be called since it matches the interface of the base class
96  virtual void endRun(const EndRunInfo &runInfo, const edm::EventSetup &setup) override;
97 
99  virtual void beginLuminosityBlock(const edm::EventSetup&) override;
100 
102  virtual void endLuminosityBlock(const edm::EventSetup&) override;
103 
104 
105 /* virtual void beginLuminosityBlock(const edm::EventSetup &setup) {} */
106 /* virtual void endLuminosityBlock(const edm::EventSetup &setup) {} */
107 
110  virtual bool setParametersForRunRange(const RunRange &runrange) override;
111 
112  private:
114 
116  std::pair<unsigned int, unsigned int>
117  addReferenceTrajectory(const edm::EventSetup &setup, const EventInfo &eventInfo,
119 
123  int addMeasurementData(const edm::EventSetup &setup, const EventInfo &eventInfo,
125  unsigned int iHit, AlignmentParameters *&params);
126 
129  int addGlobalData(const edm::EventSetup &setup, const EventInfo &eventInfo,
131  unsigned int iHit, gbl::GblPoint &gblPoint);
132 
137  unsigned int addHitCount(const std::vector<AlignmentParameters*> &parVec,
138  const std::vector<bool> &validHitVecY) const;
139 
142  unsigned int iTrajHit, TMatrixDSym &aHitCovarianceM,
143  TMatrixF &aHitResidualsM, TMatrixF &aLocalDerivativesM);
144 
147  unsigned int iVirtualMeas);
148 
151  unsigned int iVirtualMeas,TMatrixDSym &aHitCovarianceM,
152  TMatrixF &aHitResidualsM, TMatrixF &aLocalDerivativesM);
153 
155  bool globalDerivativesHierarchy(const EventInfo &eventInfo,
156  const TrajectoryStateOnSurface &tsos,
157  Alignable *ali, const AlignableDetOrUnitPtr &alidet,
158  std::vector<float> &globalDerivativesX,
159  std::vector<float> &globalDerivativesY,
160  std::vector<int> &globalLabels,
161  AlignmentParameters *&lowestParams) const;
162 
164  bool globalDerivativesHierarchy(const EventInfo &eventInfo,
165  const TrajectoryStateOnSurface &tsos,
166  Alignable *ali, const AlignableDetOrUnitPtr &alidet,
167  std::vector<double> &globalDerivativesX,
168  std::vector<double> &globalDerivativesY,
169  std::vector<int> &globalLabels,
170  AlignmentParameters *&lowestParams) const;
171 
174  const TrajectoryStateOnSurface &tsos,
175  const edm::EventSetup &setup, const EventInfo &eventInfo,
176  std::vector<float> &globalDerivativesX,
177  std::vector<float> &globalDerivativesY,
178  std::vector<int> &globalLabels) const;
179 
182  unsigned int iTrajHit, const std::vector<int> &globalLabels,
183  const std::vector<float> &globalDerivativesX,
184  const std::vector<float> &globalDerivativesY);
185 
188  unsigned int iTrajHit, const std::vector<int> &globalLabels,
189  const std::vector<float> &globalDerivativesX);
190 
195  unsigned int iTrajHit, const std::vector<int> &globalLabels,
196  const std::vector<float> &globalDerivativesx,
197  const std::vector<float> &globalDerivativesy);
198  void diagonalize(TMatrixDSym &aHitCovarianceM, TMatrixF &aLocalDerivativesM,
199  TMatrixF &aHitResidualsM,TMatrixF &theGlobalDerivativesM) const;
200  // deals with the non matrix format of theFloatBufferX ...
201  void makeGlobDerivMatrix(const std::vector<float> &globalDerivativesx,
202  const std::vector<float> &globalDerivativesy,
203  TMatrixF &aGlobalDerivativesM);
204 
205 // void callMille(const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr,
206 // unsigned int iTrajHit, MeasurementDirection xOrY,
207 // const std::vector<float> &globalDerivatives, const std::vector<int> &globalLabels);
209  bool is2D(const TransientTrackingRecHit::ConstRecHitPointer &recHit) const;
210 
212  bool readFromPede(const edm::ParameterSet &mprespset, bool setUserVars,
213  const RunRange &runrange);
214  bool areEmptyParams(const std::vector<Alignable*> &alignables) const;
215  unsigned int doIO(int loop) const;
217  void buildUserVariables(const std::vector<Alignable*> &alignables) const;
218 
221  std::vector<std::string> getExistingFormattedFiles(const std::vector<std::string>& plainFiles, const std::string& theDir);
222 
223  void addLaserData(const EventInfo &eventInfo,
224  const TkFittedLasBeamCollection &tkLasBeams,
225  const TsosVectorCollection &tkLasBeamTsoses);
226  void addLasBeam(const EventInfo &eventInfo,
227  const TkFittedLasBeam &lasBeam,
228  const std::vector<TrajectoryStateOnSurface> &tsoses);
229 
231  void addPxbSurvey(const edm::ParameterSet &pxbSurveyCfg);
232 
233  //--------------------------------------------------------
234  // Data members
235  //--------------------------------------------------------
236  enum EModeBit {myMilleBit = 1 << 0, myPedeRunBit = 1 << 1, myPedeSteerBit = 1 << 2,
237  myPedeReadBit = 1 << 3};
238  unsigned int decodeMode(const std::string &mode) const;
239  bool isMode(unsigned int testMode) const {return (theMode & testMode);}
240  bool addHitStatistics(int fromLoop, const std::string &outFile,
241  const std::vector<std::string> &inFiles) const;
242  bool addHits(const std::vector<Alignable*> &alis,
243  const std::vector<AlignmentUserVariables*> &mpVars) const;
244 
246  unsigned int theMode;
249  std::vector<Alignable*> theAlignables;
250  std::unique_ptr<AlignableNavigator> theAlignableNavigator;
251  std::unique_ptr<MillePedeMonitor> theMonitor;
252  std::unique_ptr<Mille> theMille;
253  std::shared_ptr<PedeLabelerBase> thePedeLabels;
254  std::unique_ptr<PedeSteerer> thePedeSteer;
255  std::unique_ptr<TrajectoryFactoryBase> theTrajectoryFactory;
256  std::vector<IntegratedCalibrationBase*> theCalibrations;
257  unsigned int theMinNumHits;
259  int theLastWrittenIov; // keeping track for output trees...
261  std::vector<float> theFloatBufferX;
262  std::vector<float> theFloatBufferY;
263  std::vector<int> theIntBuffer;
265  // CHK for GBL
266  std::unique_ptr<gbl::MilleBinary> theBinary;
268 
269  const bool runAtPCL_;
271 };
272 
274  MillePedeAlignmentAlgorithm, "MillePedeAlignmentAlgorithm");
275 #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.
std::unique_ptr< MillePedeMonitor > theMonitor
tuple cfg
Definition: looper.py:293
virtual bool setParametersForRunRange(const RunRange &runrange) override
virtual void endRun(const EventInfo &, const EndRunInfo &, const edm::EventSetup &)
Run on run products, e.g. TkLAS.
std::vector< Alignable * > theAlignables
virtual void endLuminosityBlock(const edm::EventSetup &) override
called at end of luminosity block
std::unique_ptr< TrajectoryFactoryBase > theTrajectoryFactory
std::unique_ptr< gbl::MilleBinary > theBinary
int addGlobalData(const edm::EventSetup &setup, const EventInfo &eventInfo, const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr, unsigned int iHit, gbl::GblPoint &gblPoint)
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
std::shared_ptr< PedeLabelerBase > thePedeLabels
std::vector< std::string > getExistingFormattedFiles(const std::vector< std::string > &plainFiles, const std::string &theDir)
unsigned int addHitCount(const std::vector< AlignmentParameters * > &parVec, const std::vector< bool > &validHitVecY) const
int loop
CMSSW
virtual bool addCalibrations(const std::vector< IntegratedCalibrationBase * > &iCals) override
Pass integrated calibrations to Millepede (they are not owned by Millepede!)
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...
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
virtual void beginLuminosityBlock(const edm::EventSetup &) override
called at begin of luminosity block (resets Mille binary in mille mode)
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
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)
void diagonalize(TMatrixDSym &aHitCovarianceM, TMatrixF &aLocalDerivativesM, TMatrixF &aHitResidualsM, TMatrixF &theGlobalDerivativesM) const
(Abstract) Base class for alignment algorithm user variables
std::unique_ptr< PedeSteerer > thePedeSteer
virtual bool storeAlignments() override
Returns whether MP produced results to be stored.
virtual void terminate() override
Called at end of job.
virtual void initialize(const edm::EventSetup &setup, AlignableTracker *tracker, AlignableMuon *muon, AlignableExtras *extras, AlignmentParameterStore *store) override
Called at beginning of job.
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 void run(const edm::EventSetup &setup, const EventInfo &eventInfo) override
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.
virtual ~MillePedeAlignmentAlgorithm()
Destructor.
std::vector< TkFittedLasBeam > TkFittedLasBeamCollection
Definition: Mille.h:26
#define DEFINE_EDM_PLUGIN(factory, type, name)
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::unique_ptr< AlignableNavigator > theAlignableNavigator
std::vector< std::vector< TrajectoryStateOnSurface > > TsosVectorCollection
define run information passed to algorithms (in endRun)
Constructor of the full muon geometry.
Definition: AlignableMuon.h:37
Point on trajectory.
Definition: GblPoint.h:46