test
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;
83  virtual void run(const edm::EventSetup &setup, const EventInfo &eventInfo) override;
84 
85  // TODO: This method does NOT match endRun() in base class! Nobody is
86  // calling this?
88  virtual void endRun(const EventInfo&, const EndRunInfo&,
89  const edm::EventSetup&); //override;
90 
91  // This one will be called since it matches the interface of the base class
92  virtual void endRun(const EndRunInfo &runInfo, const edm::EventSetup &setup) override;
93 
95  virtual void beginLuminosityBlock(const edm::EventSetup&) override;
96 
98  virtual void endLuminosityBlock(const edm::EventSetup&) override;
99 
100 
101 /* virtual void beginLuminosityBlock(const edm::EventSetup &setup) {} */
102 /* virtual void endLuminosityBlock(const edm::EventSetup &setup) {} */
103 
106  virtual bool setParametersForRunRange(const RunRange &runrange) override;
107 
108  private:
110 
112  std::pair<unsigned int, unsigned int>
113  addReferenceTrajectory(const edm::EventSetup &setup, const EventInfo &eventInfo,
115 
119  int addMeasurementData(const edm::EventSetup &setup, const EventInfo &eventInfo,
121  unsigned int iHit, AlignmentParameters *&params);
122 
125  int addGlobalData(const edm::EventSetup &setup, const EventInfo &eventInfo,
127  unsigned int iHit, gbl::GblPoint &gblPoint);
128 
133  unsigned int addHitCount(const std::vector<AlignmentParameters*> &parVec,
134  const std::vector<bool> &validHitVecY) const;
135 
138  unsigned int iTrajHit, TMatrixDSym &aHitCovarianceM,
139  TMatrixF &aHitResidualsM, TMatrixF &aLocalDerivativesM);
140 
143  unsigned int iVirtualMeas);
144 
147  unsigned int iVirtualMeas,TMatrixDSym &aHitCovarianceM,
148  TMatrixF &aHitResidualsM, TMatrixF &aLocalDerivativesM);
149 
151  bool globalDerivativesHierarchy(const EventInfo &eventInfo,
152  const TrajectoryStateOnSurface &tsos,
153  Alignable *ali, const AlignableDetOrUnitPtr &alidet,
154  std::vector<float> &globalDerivativesX,
155  std::vector<float> &globalDerivativesY,
156  std::vector<int> &globalLabels,
157  AlignmentParameters *&lowestParams) const;
158 
160  bool globalDerivativesHierarchy(const EventInfo &eventInfo,
161  const TrajectoryStateOnSurface &tsos,
162  Alignable *ali, const AlignableDetOrUnitPtr &alidet,
163  std::vector<double> &globalDerivativesX,
164  std::vector<double> &globalDerivativesY,
165  std::vector<int> &globalLabels,
166  AlignmentParameters *&lowestParams) const;
167 
170  const TrajectoryStateOnSurface &tsos,
171  const edm::EventSetup &setup, const EventInfo &eventInfo,
172  std::vector<float> &globalDerivativesX,
173  std::vector<float> &globalDerivativesY,
174  std::vector<int> &globalLabels) const;
175 
178  unsigned int iTrajHit, const std::vector<int> &globalLabels,
179  const std::vector<float> &globalDerivativesX,
180  const std::vector<float> &globalDerivativesY);
181 
184  unsigned int iTrajHit, const std::vector<int> &globalLabels,
185  const std::vector<float> &globalDerivativesX);
186 
191  unsigned int iTrajHit, const std::vector<int> &globalLabels,
192  const std::vector<float> &globalDerivativesx,
193  const std::vector<float> &globalDerivativesy);
194  void diagonalize(TMatrixDSym &aHitCovarianceM, TMatrixF &aLocalDerivativesM,
195  TMatrixF &aHitResidualsM,TMatrixF &theGlobalDerivativesM) const;
196  // deals with the non matrix format of theFloatBufferX ...
197  void makeGlobDerivMatrix(const std::vector<float> &globalDerivativesx,
198  const std::vector<float> &globalDerivativesy,
199  TMatrixF &aGlobalDerivativesM);
200 
201 // void callMille(const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr,
202 // unsigned int iTrajHit, MeasurementDirection xOrY,
203 // const std::vector<float> &globalDerivatives, const std::vector<int> &globalLabels);
205  bool is2D(const TransientTrackingRecHit::ConstRecHitPointer &recHit) const;
206 
208  bool readFromPede(const edm::ParameterSet &mprespset, bool setUserVars,
209  const RunRange &runrange);
210  bool areEmptyParams(const std::vector<Alignable*> &alignables) const;
211  unsigned int doIO(int loop) const;
213  void buildUserVariables(const std::vector<Alignable*> &alignables) const;
214 
217  std::vector<std::string> getExistingFormattedFiles(const std::vector<std::string>& plainFiles, const std::string& theDir);
218 
219  void addLaserData(const EventInfo &eventInfo,
220  const TkFittedLasBeamCollection &tkLasBeams,
221  const TsosVectorCollection &tkLasBeamTsoses);
222  void addLasBeam(const EventInfo &eventInfo,
223  const TkFittedLasBeam &lasBeam,
224  const std::vector<TrajectoryStateOnSurface> &tsoses);
225 
227  void addPxbSurvey(const edm::ParameterSet &pxbSurveyCfg);
228 
229  //--------------------------------------------------------
230  // Data members
231  //--------------------------------------------------------
232  enum EModeBit {myMilleBit = 1 << 0, myPedeRunBit = 1 << 1, myPedeSteerBit = 1 << 2,
233  myPedeReadBit = 1 << 3};
234  unsigned int decodeMode(const std::string &mode) const;
235  bool isMode(unsigned int testMode) const {return (theMode & testMode);}
236  bool addHitStatistics(int fromLoop, const std::string &outFile,
237  const std::vector<std::string> &inFiles) const;
238  bool addHits(const std::vector<Alignable*> &alis,
239  const std::vector<AlignmentUserVariables*> &mpVars) const;
240 
242  unsigned int theMode;
245  std::vector<Alignable*> theAlignables;
246  std::unique_ptr<AlignableNavigator> theAlignableNavigator;
247  std::unique_ptr<MillePedeMonitor> theMonitor;
248  std::unique_ptr<Mille> theMille;
249  std::unique_ptr<PedeLabelerBase> thePedeLabels;
250  std::unique_ptr<PedeSteerer> thePedeSteer;
251  std::unique_ptr<TrajectoryFactoryBase> theTrajectoryFactory;
252  std::vector<IntegratedCalibrationBase*> theCalibrations;
253  unsigned int theMinNumHits;
255  int theLastWrittenIov; // keeping track for output trees...
257  std::vector<float> theFloatBufferX;
258  std::vector<float> theFloatBufferY;
259  std::vector<int> theIntBuffer;
261  // CHK for GBL
262  std::unique_ptr<gbl::MilleBinary> theBinary;
264 
265  const bool runAtPCL_;
267 };
268 
270  MillePedeAlignmentAlgorithm, "MillePedeAlignmentAlgorithm");
271 #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::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
std::unique_ptr< PedeLabelerBase > thePedeLabels
(Abstract) Base class for alignment algorithm user variables
std::unique_ptr< PedeSteerer > thePedeSteer
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:36
Point on trajectory.
Definition: GblPoint.h:46