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 #include <memory>
26 
27 #include <TMatrixDSym.h>
28 #include <TMatrixD.h>
29 #include <TMatrixF.h>
30 
31 class Alignable;
32 class AlignableTracker;
33 class AlignableMuon;
34 class AlignableExtras;
35 
37 class AlignableNavigator;
40 
42 
44 
45 class MillePedeMonitor;
46 class PedeSteerer;
47 class PedeLabelerBase;
48 class Mille;
50 
51 // already from base class - and forward declaration does not work since typedef!
52 /* class TkFittedLasBeamCollection; */
53 /* class TsosVectorCollection; */
54 
56 {
57  public:
60 
63 
65  virtual void initialize(const edm::EventSetup &setup,
68 
70  virtual bool supportsCalibrations() override;
72  virtual bool addCalibrations(const std::vector<IntegratedCalibrationBase*> &iCals);
73 
75  virtual void terminate(const edm::EventSetup& iSetup);
77  virtual void terminate();
78 
80  virtual bool processesEvents() override;
82  virtual void run(const edm::EventSetup &setup, const EventInfo &eventInfo);
83 
84  // TODO: This method does NOT match endRun() in base class! Nobody is
85  // calling this?
87  virtual void endRun(const EventInfo&, const EndRunInfo&,
88  const edm::EventSetup&); //override;
89 
90  // This one will be called since it matches the interface of the base class
91  virtual void endRun(const EndRunInfo &runInfo, const edm::EventSetup &setup);
92 
94  virtual void beginLuminosityBlock(const edm::EventSetup&) override;
95 
97  virtual void endLuminosityBlock(const edm::EventSetup&) override;
98 
99 
100 /* virtual void beginLuminosityBlock(const edm::EventSetup &setup) {} */
101 /* virtual void endLuminosityBlock(const edm::EventSetup &setup) {} */
102 
105  virtual bool setParametersForRunRange(const RunRange &runrange);
106 
107  private:
109 
111  std::pair<unsigned int, unsigned int>
112  addReferenceTrajectory(const edm::EventSetup &setup, const EventInfo &eventInfo,
114 
118  int addMeasurementData(const edm::EventSetup &setup, const EventInfo &eventInfo,
120  unsigned int iHit, AlignmentParameters *&params);
121 
124  int addGlobalData(const edm::EventSetup &setup, const EventInfo &eventInfo,
126  unsigned int iHit, gbl::GblPoint &gblPoint);
127 
132  unsigned int addHitCount(const std::vector<AlignmentParameters*> &parVec,
133  const std::vector<bool> &validHitVecY) const;
134 
137  unsigned int iTrajHit, TMatrixDSym &aHitCovarianceM,
138  TMatrixF &aHitResidualsM, TMatrixF &aLocalDerivativesM);
139 
142  unsigned int iVirtualMeas);
143 
146  unsigned int iVirtualMeas,TMatrixDSym &aHitCovarianceM,
147  TMatrixF &aHitResidualsM, TMatrixF &aLocalDerivativesM);
148 
150  bool globalDerivativesHierarchy(const EventInfo &eventInfo,
151  const TrajectoryStateOnSurface &tsos,
152  Alignable *ali, const AlignableDetOrUnitPtr &alidet,
153  std::vector<float> &globalDerivativesX,
154  std::vector<float> &globalDerivativesY,
155  std::vector<int> &globalLabels,
156  AlignmentParameters *&lowestParams) const;
157 
159  bool globalDerivativesHierarchy(const EventInfo &eventInfo,
160  const TrajectoryStateOnSurface &tsos,
161  Alignable *ali, const AlignableDetOrUnitPtr &alidet,
162  std::vector<double> &globalDerivativesX,
163  std::vector<double> &globalDerivativesY,
164  std::vector<int> &globalLabels,
165  AlignmentParameters *&lowestParams) const;
166 
169  const TrajectoryStateOnSurface &tsos,
170  const edm::EventSetup &setup, const EventInfo &eventInfo,
171  std::vector<float> &globalDerivativesX,
172  std::vector<float> &globalDerivativesY,
173  std::vector<int> &globalLabels) const;
174 
177  unsigned int iTrajHit, const std::vector<int> &globalLabels,
178  const std::vector<float> &globalDerivativesX,
179  const std::vector<float> &globalDerivativesY);
180 
183  unsigned int iTrajHit, const std::vector<int> &globalLabels,
184  const std::vector<float> &globalDerivativesX);
185 
190  unsigned int iTrajHit, const std::vector<int> &globalLabels,
191  const std::vector<float> &globalDerivativesx,
192  const std::vector<float> &globalDerivativesy);
193  void diagonalize(TMatrixDSym &aHitCovarianceM, TMatrixF &aLocalDerivativesM,
194  TMatrixF &aHitResidualsM,TMatrixF &theGlobalDerivativesM) const;
195  // deals with the non matrix format of theFloatBufferX ...
196  void makeGlobDerivMatrix(const std::vector<float> &globalDerivativesx,
197  const std::vector<float> &globalDerivativesy,
198  TMatrixF &aGlobalDerivativesM);
199 
200 // void callMille(const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr,
201 // unsigned int iTrajHit, MeasurementDirection xOrY,
202 // const std::vector<float> &globalDerivatives, const std::vector<int> &globalLabels);
204  bool is2D(const TransientTrackingRecHit::ConstRecHitPointer &recHit) const;
205 
207  bool readFromPede(const edm::ParameterSet &mprespset, bool setUserVars,
208  const RunRange &runrange);
209  bool areEmptyParams(const std::vector<Alignable*> &alignables) const;
210  unsigned int doIO(int loop) const;
212  void buildUserVariables(const std::vector<Alignable*> &alignables) const;
213 
216  std::vector<std::string> getExistingFormattedFiles(const std::vector<std::string>& plainFiles, const std::string& theDir);
217 
218  void addLaserData(const EventInfo &eventInfo,
219  const TkFittedLasBeamCollection &tkLasBeams,
220  const TsosVectorCollection &tkLasBeamTsoses);
221  void addLasBeam(const EventInfo &eventInfo,
222  const TkFittedLasBeam &lasBeam,
223  const std::vector<TrajectoryStateOnSurface> &tsoses);
224 
226  void addPxbSurvey(const edm::ParameterSet &pxbSurveyCfg);
227 
228  //--------------------------------------------------------
229  // Data members
230  //--------------------------------------------------------
231  enum EModeBit {myMilleBit = 1 << 0, myPedeRunBit = 1 << 1, myPedeSteerBit = 1 << 2,
232  myPedeReadBit = 1 << 3};
233  unsigned int decodeMode(const std::string &mode) const;
234  bool isMode(unsigned int testMode) const {return (theMode & testMode);}
235  bool addHitStatistics(int fromLoop, const std::string &outFile,
236  const std::vector<std::string> &inFiles) const;
237  bool addHits(const std::vector<Alignable*> &alis,
238  const std::vector<AlignmentUserVariables*> &mpVars) const;
239 
241  unsigned int theMode;
244  std::vector<Alignable*> theAlignables;
245  std::unique_ptr<AlignableNavigator> theAlignableNavigator;
246  std::unique_ptr<MillePedeMonitor> theMonitor;
247  std::unique_ptr<Mille> theMille;
248  std::unique_ptr<PedeLabelerBase> thePedeLabels;
249  std::unique_ptr<PedeSteerer> thePedeSteer;
250  std::unique_ptr<TrajectoryFactoryBase> theTrajectoryFactory;
251  std::vector<IntegratedCalibrationBase*> theCalibrations;
252  unsigned int theMinNumHits;
254  int theLastWrittenIov; // keeping track for output trees...
256  std::vector<float> theFloatBufferX;
257  std::vector<float> theFloatBufferY;
258  std::vector<int> theIntBuffer;
260  // CHK for GBL
261  std::unique_ptr<gbl::MilleBinary> theBinary;
263 
264  const bool runAtPCL_;
265 };
266 
267 #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 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
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
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
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)
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
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.
virtual ~MillePedeAlignmentAlgorithm()
Destructor.
std::vector< TkFittedLasBeam > TkFittedLasBeamCollection
Definition: Mille.h:26
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
virtual void terminate()
Called at end of job.