diff --git a/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/IAlignModuleTool.h b/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/IAlignModuleTool.h new file mode 100644 index 0000000000000000000000000000000000000000..629c626742c6d0d624cb8eb001a35f97215c0316 --- /dev/null +++ b/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/IAlignModuleTool.h @@ -0,0 +1,154 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRKALIGNINTERFACES_ALIGNMODULETOOL_IH +#define TRKALIGNINTERFACES_ALIGNMODULETOOL_IH + +#include "GaudiKernel/IAlgTool.h" +#include "GaudiKernel/ToolHandle.h" +#include "DataModel/DataVector.h" + +#include "TrkAlignEvent/AlignModuleList.h" +#include "TrkAlignEvent/AlignModule.h" +#include "TrkAlignEvent/AlignPar.h" + +#include <fstream> + +/** + @file ITrkAlignDBTool.h + @class ITrkAlignDBTool + + @brief Interface for tool use for managing list of AlignModules, + detector elements in AlignModules, and AlignPar for both. + + To be implemented for each detector-type separately. + + @author Robert Harrington <roberth@bu.edu> + @author Daniel Kollar <daniel.kollar@cern.ch> + @date 1/5/08 +*/ + +namespace Trk { + class Track; + class AlignTrack; + class AlignTSOS; + class RIO_OnTrack; + + static const InterfaceID + IID_TRKALIGNINTERFACES_IAlignModuleTool("Trk::IAlignModuleTool",1,0); + + + class IAlignModuleTool: virtual public IAlgTool { + + public: + static const InterfaceID& interfaceID(); + + virtual ~IAlignModuleTool() {}; + + virtual StatusCode initialize() = 0; + virtual StatusCode finalize() = 0; + + /** returns type of AlignModuleList (see AlignModuleList.h for more info) */ + AlignModuleListType alignModuleListType() { return (AlignModuleListType)m_alignModuleListType; } + + /** gets detector type for a detector element */ + virtual AlignModule::DetectorType getDetectorType(const TrkDetElementBase* det) const = 0; + + // + // GeometryManagerTool methods + // + + /** sets AlignModules for a particular detector type */ + virtual void setAlignModules(AlignModuleList* alignmods, + std::vector<AlignModuleList*>* idHashToAlignModMap) = 0; + + /** sets AlignPar for AlignModules for a particular detector type*/ + virtual void setAlignParLists(DataVector<DataVector<AlignPar> >* fullAlignParList, + DataVector<DataVector<AlignPar> >* alignParList) = 0; + + /** set and retrieve flag whether or not the sub-TrkDetElementBase structures are aligned for a given detector type */ + virtual void setSubDetElement(AlignModule::DetectorType detType, bool status) = 0; + virtual bool subDetElement(AlignModule::DetectorType detType) const = 0; + + // + // AlignTrackCreator methods + // + + /** finds AlignModule for a detector element (used by AlignTrackCreator) */ + virtual AlignModule * findAlignModule(const RIO_OnTrack * rio, + AlignModule::DetectorType = AlignModule::NDetectorTypes) const = 0; + + /** finds AlignModule for a detector element */ + virtual AlignModule * findAlignModule(const TrkDetElementBase* det, + AlignModule::DetectorType = AlignModule::NDetectorTypes) const = 0; + + /** allows to set detector specific properties of AlignTSOS, like measurement direction (CSC) or fan-out angle (SCT) */ + virtual void setMeasurementProperties(AlignTSOS *) const {}; + + // + // MatrixTool methods + // + + /** number of alignment parameters for all detector types */ + virtual int nAlignParameters() const = 0; + + /** converts 2-D AlignParList and AlignModuleList for all detector types + to single 1-D vectors (used by MatrixTool) */ + virtual const AlignModuleList* alignModules1D() = 0; + virtual DataVector<AlignPar>* alignParList1D() = 0; + + + // DerivCalcTool methods + + /** returns alignment parameters for a single module */ + virtual DataVector<AlignPar>* getAlignPars(const AlignModule* alignModule) const = 0; + + /** shifts and restores tubes traversed by track in module (used by ShiftingDerivCalcTool) */ + virtual void shiftModule(const AlignModule*, const Track*, + AlignModule::TransformParameters, double) const {} + virtual void restoreModule(const AlignModule*) const {} + + + // + // AlignDBTool methods + // + + /** returns alignment parameters for a detector element, applying AlignModule + transforms if necessary */ + virtual void fillDetAlignmentParameters(const TrkDetElementBase* det, + DataVector<AlignPar>* apVec, + AlignModule::DetectorType detType= + AlignModule::NDetectorTypes) const = 0; + + /** gets all AlignModules for a particular detector type */ + virtual const AlignModuleList* getAlignModuleCollection() const = 0; + + + // + // FillNtuple methods + // + + /** returns vector of full AlignPars for an AlignModule */ + virtual DataVector<AlignPar>* getFullAlignPars(const AlignModule* alignModule) const = 0; + + // + // Other + // + + /** sets the output stream for the logfile */ + virtual void setLogStream(std::ostream * os) { m_logStream = os; } + + protected: + int m_alignModuleListType; //!< uses Trk enum AlignModuleListType (L1,L2,L3,L1_5,L2_5) + + std::ostream * m_logStream; //!< logfile output stream + + }; + + inline const InterfaceID& IAlignModuleTool::interfaceID() + { return IID_TRKALIGNINTERFACES_IAlignModuleTool; } + +} // end namespace + +#endif // TRKALIGNINTERFACES_ALIGNMODULETOOL_IH diff --git a/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/IAlignResidualCalculator.h b/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/IAlignResidualCalculator.h new file mode 100644 index 0000000000000000000000000000000000000000..596d3374a22bc6ba4900031352fd966097746676 --- /dev/null +++ b/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/IAlignResidualCalculator.h @@ -0,0 +1,63 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRKALIGNINTERFACES_ALIGNRESIDUALCALCULATOR_IH +#define TRKALIGNINTERFACES_ALIGNRESIDUALCALCULATOR_IH + +#include "GaudiKernel/IAlgTool.h" +#include "GaudiKernel/ToolHandle.h" +#include "DataModel/DataVector.h" + +#include <vector> + +/** + @file IAlignResidualCalculator.h + @class IAlignResidualCalculator + + @brief Interface for tool used to calculate residuals. + + @author Robert Harrington <roberth@bu.edu> + @date 8/28/09 +*/ + +namespace Trk { + + class AlignTrack; + class Track; + + class AlignTSOS; + + static const InterfaceID + IID_TRKALIGNINTERFACES_IAlignResidualCalculator("Trk::IAlignResidualCalculator",1,0); + + + class IAlignResidualCalculator: virtual public IAlgTool { + + public: + static const InterfaceID& interfaceID(); + + virtual ~IAlignResidualCalculator() {}; + + virtual StatusCode initialize() = 0; + virtual StatusCode finalize() = 0; + + virtual double setResiduals(DataVector<AlignTSOS>* alignTSOSColl, + const Track* track=0) = 0; + + virtual double setResiduals(const AlignTrack* alignTrack, + const Track* track=0) = 0; + + virtual double setResiduals(DataVector<AlignTSOS>::const_iterator firstAtsos, + DataVector<AlignTSOS>::const_iterator lastAtsos, + const Track* track, bool newTrack=false) = 0; + virtual double chi2ForMeasType(int measType) const = 0; + + }; + + inline const InterfaceID& IAlignResidualCalculator::interfaceID() + { return IID_TRKALIGNINTERFACES_IAlignResidualCalculator; } + +} // end namespace + +#endif // TRKALIGNINTERFACES_ALIGNRESIDUALCALCULATOR_IH diff --git a/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/IAlignTool.h b/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/IAlignTool.h new file mode 100644 index 0000000000000000000000000000000000000000..6ce92ade7b63780845edb04c826fe44d3b43b1af --- /dev/null +++ b/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/IAlignTool.h @@ -0,0 +1,65 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRKALIGNINTERFACES_ALIGNTOOL_IH +#define TRKALIGNINTERFACES_ALIGNTOOL_IH + +#include "GaudiKernel/IAlgTool.h" +#include <fstream> + +/** + @file IAlignTool.h + @class IAlignTool + + @brief Interface for tool used to accumulate information for each track, + and then to solve for the final alignment parameters. + + @author Robert Harrington <roberth@bu.edu> + @date 1/5/08 +*/ + +class TFile; + + +namespace Trk { + + class AlignTrack; + + static const InterfaceID + IID_TRK_IAlignTool("IAlignTool",1,0); + + class IAlignTool: virtual public IAlgTool { + public: + static const InterfaceID& interfaceID(); + + virtual StatusCode firstEventInitialize() = 0; + + virtual bool accumulate(const AlignTrack* alignTrack) = 0; + + virtual bool accumulateFromFiles() = 0; + + virtual StatusCode solve() = 0; + + /** sets the output stream for the logfile */ + virtual void setLogStream(std::ostream * os) { m_logStream = os; } + + /** sets ntuple */ + virtual void setNtuple(TFile*) {} + + /** writes tree to ntuple */ + virtual StatusCode fillNtuple() { return StatusCode::SUCCESS; } + + protected: + std::ostream * m_logStream; //!< logfile output stream + + }; // end of class definition + + inline const InterfaceID& IAlignTool::interfaceID() { + return IID_TRK_IAlignTool; + } + +} // end of namespace + + +#endif // TRKALIGNINTERFACES_ALIGNTOOL_IH diff --git a/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/IAlignTrackCreator.h b/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/IAlignTrackCreator.h new file mode 100644 index 0000000000000000000000000000000000000000..aa64f933752afc86289aaaf3eebde562eeeef7c7 --- /dev/null +++ b/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/IAlignTrackCreator.h @@ -0,0 +1,67 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRKALIGNINTERFACES_ALIGN_TRACK_CREATOR_IH +#define TRKALIGNINTERFACES_ALIGN_TRACK_CREATOR_IH + +#include "GaudiKernel/IAlgTool.h" + +/** + @file IAlignTrackCreator.h + @class IAlignTrackCreator + + @brief Interface for tool used to create an AlignTrack. + + @author Robert Harrington <roberth@bu.edu> + @date 1/5/08 +*/ + +#include <fstream> + +namespace Trk { + + class AlignTrack; + class Track; + + static const InterfaceID + IID_TRK_IAlignTrackCreator("IAlignTrackCreator",1,0); + + class IAlignTrackCreator: virtual public IAlgTool { + + public: + IAlignTrackCreator(); + virtual ~IAlignTrackCreator() {} + + static const InterfaceID& interfaceID(); + + /** creates AlignTrack from Trk::Track */ + virtual bool processAlignTrack(AlignTrack* alignTrack) const = 0; + + /** Sets flags to indicate whether hits from particular detector elements are to be stored on the AlignTrack. (Not used at the moment.) */ + void setDoPixel(bool doPixel) { m_doPixel = doPixel; } + void setDoSCT(bool doSCT) { m_doSCT = doSCT; } + void setDoTRT(bool doTRT) { m_doTRT = doTRT; } + void setDoMDT(bool doMDT) { m_doMDT = doMDT; } + + /** sets the output stream for the logfile */ + virtual void setLogStream(std::ostream * os) { m_logStream = os; } + + protected: + + bool m_doPixel; + bool m_doSCT; + bool m_doTRT; + bool m_doMDT; + + std::ostream * m_logStream; //!< logfile output stream + + }; // end class definition + + inline IAlignTrackCreator::IAlignTrackCreator() : m_doPixel(1), m_doSCT(1), m_doTRT(1), m_doMDT(1) {} + inline const InterfaceID& IAlignTrackCreator::interfaceID() + { return IID_TRK_IAlignTrackCreator; } + +} // end namespace + +#endif // TRKALIGNINTERFACES_ALIGN_TRACK_CREATOR_IH diff --git a/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/IAlignTrackDresser.h b/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/IAlignTrackDresser.h new file mode 100644 index 0000000000000000000000000000000000000000..8a67e006e7bfdd478dcf443ad601053e6e52a2fa --- /dev/null +++ b/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/IAlignTrackDresser.h @@ -0,0 +1,52 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRKALIGNINTERFACES_ALIGN_TRACK_DRESSER_IH +#define TRKALIGNINTERFACES_ALIGN_TRACK_DRESSER_IH + +#include "GaudiKernel/IAlgTool.h" + +/** + @file IAlignTrackDresser.h + @class IAlignTrackDresser + + @brief Interface for tool used to dress an AlignTrack with derivatives + and other quantities needed for alignment. + + @author Robert Harrington <roberth@bu.edu> + @date 1/5/08 +*/ + +#include <fstream> + +namespace Trk { + + class AlignTrack; + + static const InterfaceID + IID_TRK_IAlignTrackDresser("IAlignTrackDresser",1,0); + + class IAlignTrackDresser: virtual public IAlgTool { + + public: + static const InterfaceID& interfaceID(); + + /** Dresses AlignTrack with derivatives and any other information needed for alignment. */ + virtual bool dressAlignTrack(AlignTrack* alignTrack) const = 0; + + /** sets the output stream for the logfile */ + virtual void setLogStream(std::ostream * os) { m_logStream = os; } + + protected: + std::ostream * m_logStream; //!< logfile output stream + + }; // end class definition + + inline const InterfaceID& IAlignTrackDresser::interfaceID() + { return IID_TRK_IAlignTrackDresser; } + +} // end namespace + +#endif // TRKALIGNINTERFACES_ALIGN_TRACK_DRESSER_IH + diff --git a/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/IAlignTrackPreProcessor.h b/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/IAlignTrackPreProcessor.h new file mode 100644 index 0000000000000000000000000000000000000000..86aa1520787f91f54cce6b385c801f89ed2495d1 --- /dev/null +++ b/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/IAlignTrackPreProcessor.h @@ -0,0 +1,77 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRKALIGNMENT_ALIGNTRACKPREPROCESSOR_IH +#define TRKALIGNMENT_ALIGNTRACKPREPROCESSOR_IH + +/** + @file IAlignTrackPreProcessor.h + @class IAlignTrackPreProcessor + + @brief Generic interface for alignment algtools which process a track + collection and return a collection of AlignTracks + (e.g. refits, with or without vertexing, track selection ...) + + @author Robert Harrington <roberth@bu.edu> + @author Daniel Kollar <daniel.kollar@cern.ch> + @date 10/1/09 +*/ + +#include "GaudiKernel/IAlgTool.h" +#include "DataModel/DataVector.h" + +#include <fstream> + +class TFile; + +namespace Trk { + + class Track; + class AlignTrack; + + static const InterfaceID + IID_Trk_IAlignTrackPreProcessor("IAlignTrackPreProcessor",1,0); + + class IAlignTrackPreProcessor: virtual public IAlgTool { + + public: + static const InterfaceID& interfaceID(); + + /** Main processing of track collection. + The method should create AlignTracks but fill them into a collection of Tracks. + The reason is that AlignTracks are needed further in the alignment processing + but we want to store the newly created TrackCollection into StoreGate. */ + virtual DataVector<Trk::Track>* processTrackCollection(const DataVector<Trk::Track>* trks) = 0; + + /** sets the output stream for the logfile */ + virtual void setLogStream(std::ostream * os) { m_logStream = os; } + + /** Sets output ntuple file, to be implemented if needed for detector-specific implementation. */ + virtual void setNtuple(TFile*) {} + + /** writes tree and histogrms to ntuple */ + virtual StatusCode fillNtuple() { return StatusCode::SUCCESS; } + + /** methods added for the full VTX fit: */ + virtual void accumulateVTX(const AlignTrack* ) {} + + virtual void solveVTX() {} + + /** Print processing summary to logfile. */ + virtual void printSummary() {} + + protected: + + std::ostream * m_logStream; //!< logfile output stream + + }; + + inline const InterfaceID& IAlignTrackPreProcessor::interfaceID() + { + return IID_Trk_IAlignTrackPreProcessor; + } + +} // namespace Trk + +#endif // TRKALIGNMENT_ALIGNTRACKPREPROCESSOR_IH diff --git a/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/IDerivCalcTool.h b/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/IDerivCalcTool.h new file mode 100644 index 0000000000000000000000000000000000000000..d5bb42b75811f6f0c532f4f39220c763c9bc9713 --- /dev/null +++ b/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/IDerivCalcTool.h @@ -0,0 +1,91 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRKALIGNINTERFACES_IDERIVCALCTOOL_IH +#define TRKALIGNINTERFACES_IDERIVCALCTOOL_IH + +/** + @file IDerivCalcTool.h + @class IDerivCalcTool + + @brief Interface for tool used to select tracks, to determine detectors + (ID or MS) for which to perform alignment, and to calculate first and + second derivatives of track chi2 with respect to track and alignment + parameters. + + Based on InDetAlignAlgs/SiGlobalChi2AlignAlgs. + + @author Robert Harrington <roberth@bu.edu> + @date 1/5/08 +*/ + +#include "GaudiKernel/IAlgTool.h" + +#include <fstream> + +namespace Trk { + + class Track; + class AlignTSOS; + class AlignTrack; + + static const InterfaceID + IID_TRKALIGNINTERFACES_IDerivCalcTool("IDerivCalcTool",1,0); + + class IDerivCalcTool : virtual public IAlgTool { + + public: + + /** enum of different solving options */ + enum SolveOption { + NONE = 0, //!< not solve in any case (to be used when ipc) + SOLVE = 1, //!< solving after data accumulation (LAPACK) + SOLVE_FAST = 2, //!< Fast (***REMOVED*** method) solving after data accumulation + DIRECT_SOLVE = 3, //!< direct solving (LAPACK), already available matrix & vector + DIRECT_SOLVE_FAST = 4, //!< direct Fast (***REMOVED*** method) solving, already available matrix & vector + DIRECT_SOLVE_CLUSTER = 5 //!< computation of alignment parameters from SCALAPAK already solved matrix + }; // this is also defined in TrkGlobAlign class + + /** Virtual destructor */ + virtual ~IDerivCalcTool() {} + + /** Retrieve interface ID */ + static const InterfaceID& interfaceID(); + + /** solving option (see enum above) */ + void setSolveOption(int solveOption) { m_solveOption=solveOption; } + + /** sets partial derivatives of residuals w.r.t. alignment parameters for all AlignTSOS on alignTrack */ + virtual bool setDerivatives(AlignTrack* alignTrack) = 0; + + /** write statistics to log file */ + virtual void showStatistics() = 0; + + //bool storeSuperStructures() { return m_storeSuperStructures; } + + /** sets residual covariance matrix */ + virtual bool setResidualCovMatrix(AlignTrack* alignTrack) const = 0; + + /** sets the output stream for the logfile */ + virtual void setLogStream(std::ostream * os) { m_logStream = os; } + + protected: + //bool m_storeSuperStructures; //!< Store Super Structures information in txt file ? + + std::ostream * m_logStream; //!< logfile output stream + + private: + + int m_solveOption; + + }; // end of class + + inline const InterfaceID& IDerivCalcTool::interfaceID() { + return IID_TRKALIGNINTERFACES_IDerivCalcTool; + } + +} // end of namespace + + +#endif // TRKALIGNINTERFACES_IDERIVCALCTOOL_IH diff --git a/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/IFillNtupleTool.h b/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/IFillNtupleTool.h new file mode 100644 index 0000000000000000000000000000000000000000..e3fdbb663a8072a43016f7391bc6f0db3f3f887e --- /dev/null +++ b/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/IFillNtupleTool.h @@ -0,0 +1,86 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRKALIGNINTERFACES_IFILLNTUPLETOOL_IH +#define TRKALIGNINTERFACES_IFILLNTUPLETOOL_IH + +#include "GaudiKernel/IAlgTool.h" + +/** + @file IFillNtupleTool.h + @class IFillNtupleTool + + @brief Interface for tool used to fill an ntuple with useful information for + debugging, etc. Implementation is detector-specific and does not have to be + implemented if not needed. + + @author Robert Harrington <roberth@bu.edu> + @date 1/5/08 +*/ + +#include <fstream> + +static const InterfaceID +IID_TRKALIGNINTERFACES_IFillNtupleTool("IFillNtupleTool",1,0); + +class TFile; + +namespace Trk { + + class AlignTrack; + + class IFillNtupleTool: virtual public IAlgTool { + + public: + virtual ~IFillNtupleTool() {} + + static const InterfaceID& interfaceID(); + + virtual StatusCode initialize() = 0; + virtual StatusCode finalize() = 0; + + /** dumps track information to ntuple */ + virtual void dumpTrack(int itrk, const AlignTrack* alignTrack) = 0; + + /** stores hitmap for writing to ntuple */ + virtual void storeHitmap() = 0; + + /** fills ntuple with hit information */ + virtual void fillHitmap() = 0; + + /** fills ntuple with event and track summary information */ + virtual void fillSummary() = 0; + + /** write statistics out to log file */ + virtual void showStatistics() = 0; + + /** used for numerical derivatives to write chi2 vs. chamber positions */ + virtual void fillChi2VChamberShift(const int, const int, int*, + double**,double**,double**, + double**,double**,double** ) {} + + /** returns pointer to TFile containing ntuple */ + //virtual TFile* ntupleFile() { return 0; } + + /** sets the output stream for the logfile */ + virtual void setLogStream(std::ostream * os) { m_logStream = os; } + + /** sets the output stream for the logfile */ + virtual void setNtuple(TFile* ntuple) = 0; + + /** writes trees and histograms to ntuple */ + virtual StatusCode fillNtuple() = 0; + + protected: + std::ostream * m_logStream; //!< logfile output stream + + }; // end class definition + + inline const InterfaceID& IFillNtupleTool::interfaceID() + { return IID_TRKALIGNINTERFACES_IFillNtupleTool; } + +} // end namespace + +#endif // TRKALIGNINTERFACES_IFILLNTUPLETOOL_IH + diff --git a/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/IGeometryManagerTool.h b/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/IGeometryManagerTool.h new file mode 100644 index 0000000000000000000000000000000000000000..cc3f5cca5151c98cf62da688a74c202f969d5a48 --- /dev/null +++ b/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/IGeometryManagerTool.h @@ -0,0 +1,127 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRKALIGNINTERFACES_IGEOMETRYMANAGERTOOL_H +#define TRKALIGNINTERFACES_IGEOMETRYMANAGERTOOL_H + +#include "GaudiKernel/IAlgTool.h" + +#include "TrkAlignEvent/AlignModuleList.h" +#include "DataModel/DataVector.h" + +/** + @file IGeometryManagerTool.h + @class IGeometryManagerTool + + @brief Interface for tool used to build the AlignModules to be used for alignment. The implementation is specific to a detector type. + + @author Robert Harrington <roberth@bu.edu> + @date 1/5/08 +*/ + +#include <fstream> + +class TFile; + +static const InterfaceID +IID_TRKALIGNINTERFACES_IGeometryManagerTool("IGeometryManagerTool",1,0); + +namespace Trk { + + class AlignModule; + class AlignPar; + +class IGeometryManagerTool : virtual public IAlgTool { + + public: + virtual ~IGeometryManagerTool() {} + + static const InterfaceID& interfaceID(); + + virtual StatusCode initialize() = 0; + virtual StatusCode finalize() = 0; + + /** build collection of AlignModules for a particular detector type, return number of alignment parameters */ + virtual int ReadGeometry(int solvelevel) = 0; + + virtual void PrintModPositions() = 0; + virtual void StoreModPositions(std::string filename) = 0; + + /** Sets output ntuple file, to be implemented if needed for detector-specific implementation. */ + virtual void setNtuple(TFile*) {} + + /** sets the output stream for the logfile */ + virtual void setLogStream(std::ostream * os) { m_logStream = os; } + + /** create align modules and add them to the list */ + virtual void buildGeometry() {}; + + /** set alignment parameters for a given module and add them to the list + the arguments are AlignModule, fullParameterList, activeParameterList */ + virtual void addModuleParameters(Trk::AlignModule * , DataVector< DataVector<Trk::AlignPar> > * , DataVector< DataVector<Trk::AlignPar> > *) {}; + + /** get next free IDHash usable for new AlignModule */ + virtual int getNextIDHash() { return m_hashCounter++; }; + + /** set first free IDHash usable for new AlignModule */ + virtual void setFirstIDHash(unsigned int idhash) { m_hashCounter=idhash; }; + + /** set pointer to module list to which the modules should be added to */ + virtual void setModuleList(Trk::AlignModuleList * list) { m_alignModuleListPtr=list; } + + /** set pointer to vector of hashMaps to which the elements should be added to */ + virtual void setHashMaps(std::vector<Trk::AlignModuleList *> * maps) { m_idHashToAlignModuleMapsPtr=maps; } + + /** check whether the alignment level is allowed */ + virtual bool checkAlignLevel() { return true; } + + /** get alignment level */ + virtual int alignLevel() { return m_alignLevel; } + + /** set alignment level */ + virtual void setAlignLevel(int level) { m_alignLevel = level; } + + /** get alignment level */ + virtual int alignLevelBarrel() { return m_alignLevelBarrel; } + + /** set alignment level */ + virtual void setAlignLevelBarrel(int level) { m_alignLevelBarrel = level; } + + /** check whether the alignment level is allowed */ + virtual bool checkAlignLevelBarrel() { return true; } + + /** get alignment level */ + virtual int alignLevelEndcaps() { return m_alignLevelEndcaps; } + + /** set alignment level */ + virtual void setAlignLevelEndcaps(int level) { m_alignLevelEndcaps = level; } + + /** check whether the alignment level is allowed */ + virtual bool checkAlignLevelEndcaps() { return true; } + + protected: + + /** pointer to module list to which the modules are added */ + Trk::AlignModuleList * m_alignModuleListPtr; + + /** pointer to vector of hashMaps to which the elements are added */ + std::vector<Trk::AlignModuleList *> * m_idHashToAlignModuleMapsPtr; + + int m_hashCounter; //!< variable for setting the idHash of the AlignModules + + std::ostream * m_logStream; //!< logfile output stream + + int m_alignLevel; //!< alignment level + int m_alignLevelBarrel; //!< alignment level + int m_alignLevelEndcaps; //!< alignment level + +}; // end class definition + +inline const InterfaceID& IGeometryManagerTool::interfaceID() { + return IID_TRKALIGNINTERFACES_IGeometryManagerTool; +} + +} // end namespace + +#endif // TRKALIGNINTERFACES_IGEOMETRYMANAGERTOOL_H diff --git a/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/IJacobianManagerTool.h b/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/IJacobianManagerTool.h new file mode 100644 index 0000000000000000000000000000000000000000..76e8f9f220e37c8c79b0bee1e05ca30a0587a85b --- /dev/null +++ b/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/IJacobianManagerTool.h @@ -0,0 +1,69 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRKALIGNINTERFACES_IJACOBIANMANAGERTOOL_H +#define TRKALIGNINTERFACES_IJACOBIANMANAGERTOOL_H + +#include "GaudiKernel/IAlgTool.h" +#include "GaudiKernel/ToolHandle.h" + +#include <map> + +/** + @file IJacobianManagerTool.h + @class IJacobianManagerTool + + @brief Interface for tool used to calculate Jacobian terms. Not yet implemented. + + Based on InDetAlignAlgs/SiGlobalChi2AlignAlgs. + + @author Robert Harrington <roberth@bu.edu> + @date 1/5/08 +*/ + +class AlMat; + +namespace Trk { + class IGeometryManagerTool; +} + +namespace Trk { + static const InterfaceID + IID_TRKALIGNINTERFACES_IJacobianManagerTool("IJacobianManagerTool",1,0); + + class IJacobianManagerTool : virtual public IAlgTool { + + public: + static const InterfaceID& interfaceID(); + + typedef std::map<int,int> ModuleIndexMap; + + virtual StatusCode initialize() = 0; // must retrieve IGeometryManagerTool + + virtual StatusCode BuildJacobian(AlMat*, int, bool, ModuleIndexMap) = 0; + virtual StatusCode BuildJacobian(int, bool) = 0; + + virtual std::vector<HepVector3D> GetCenterOfGravity() const = 0; + virtual std::vector<int> GetNumberOfModsPerLayer() const = 0; + virtual std::vector<float> GetLayerRadius() const = 0; + + private: + virtual StatusCode DumpJacobian(AlMat*) const = 0; + virtual StatusCode TestJacobian(AlMat*, int, int) const = 0; + virtual StatusCode FillJacobian(AlMat*, int, int, ModuleIndexMap, ModuleIndexMap) = 0; + virtual StatusCode StoreTxt() = 0; + virtual StatusCode ShowHitmap(ModuleIndexMap, ModuleIndexMap, bool, bool) = 0; + virtual int FindModIndex(int, ModuleIndexMap) = 0; + + ToolHandle<IGeometryManagerTool> m_geometryManagerTool; + + }; // end class definition + + inline const InterfaceID& IJacobianManagerTool::interfaceID() { + return IID_TRKALIGNINTERFACES_IJacobianManagerTool; + } + +} // end namespace + +#endif // TRKALIGNINTERFACES_IJACOBIANMANAGERTOOL_H diff --git a/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/IMatrixTool.h b/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/IMatrixTool.h new file mode 100644 index 0000000000000000000000000000000000000000..7fb35b1dc4178db50ee7a1f67ad758e1c536bf28 --- /dev/null +++ b/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/IMatrixTool.h @@ -0,0 +1,122 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRKALIGNINTERFACES_IMATRIXTOOL_IH +#define TRKALIGNINTERFACES_IMATRIXTOOL_IH + +/** + @file IMatrixTool.h + @class IMatrixTool + + @brief Interface for tool used to manipulate matrix and vector entries and + to solve for alignment parameters. + + Based on InDetAlignAlgs/SiGlobalChi2AlignAlgs. + + @author Robert Harrington <roberth@bu.edu> + @date 1/5/08 +*/ + +#include "GaudiKernel/IAlgTool.h" + +#include <fstream> + +namespace Trk { + + class AlignModule; + + class AlVec; + class AlSymMatBase; + + static const InterfaceID + IID_TRKALIGNINTERFACES_IMatrixTool("IMatrixTool",1,0); + + class IMatrixTool : virtual public IAlgTool { + + public: + + /** constructor */ + IMatrixTool(); + + /** Virtual destructor */ + virtual ~IMatrixTool() {} + + /** Retrieve interface ID */ + static const InterfaceID& interfaceID(); + + /** allocates space in memory for the big matrix and vector */ + virtual StatusCode allocateMatrix(int nDoF) = 0; + + /** reads/writes matrix entries from/to binary files as necessary*/ + virtual void prepareBinaryFiles(int solveOption) = 0; + + /** adds first derivative to vector */ + virtual void addFirstDerivatives(AlVec* vector) = 0; + + /** adds first derivative to vector for only some entries */ + virtual void addFirstDerivatives(std::list<int,double>& derivatives) = 0; + + virtual void addFirstDerivative(int irow, double val) = 0; + + /** adds second derivatives to matrix */ + virtual void addSecondDerivatives(AlSymMatBase* matrix) = 0; + + /** adds first derivative to vector for only some entries */ + virtual void addSecondDerivatives(std::list<std::pair<int,int>,double >& derivatives) = 0; + virtual void addSecondDerivative(int irow, int icol, double val) = 0; + + /** accumulates first and second derivatives from files. File type to be specified by configuring the tool*/ + virtual bool accumulateFromFiles() = 0; + + /** solves for alignment parameters */ + virtual int solve() = 0; + + void addModule(int alignModuleIndex, int nAlignParam); + int entryNumber(int alignModuleIndex); + + /** set module identifier */ + //virtual void setAlignModule(int irow, const AlignModule* alignmodule, + // int ipar) = 0; + + /** set number of hits */ + void setNHits(int n) { m_nHits = n; } + int nHits() const { return m_nHits; } + + /** set number of tracks */ + void setNTracks(int n) { m_nTracks = n; } + int nTracks() const { return m_nTracks; } + + /** set number of measurements */ + void setNMeasurements(int n) { m_nMeasurements = n; } + int nMeasurements() const { return m_nMeasurements; } + + /** sets the output stream for the logfile */ + virtual void setLogStream(std::ostream * os) { m_logStream = os; } + + protected: + std::ostream * m_logStream; //!< logfile output stream + + int m_nHits; + int m_nTracks; + int m_nMeasurements; + + private: + std::map<int,int> m_alignModuleMap; + int m_nentries; + + }; // end of class + + inline const InterfaceID& IMatrixTool::interfaceID() { + return IID_TRKALIGNINTERFACES_IMatrixTool; + } + + inline IMatrixTool::IMatrixTool() : m_logStream(0), m_nHits(0), m_nTracks(0), m_nMeasurements(0), m_nentries(0) {} + + inline void IMatrixTool::addModule(int alignModuleIndex, int nAlignParam) { m_alignModuleMap[alignModuleIndex]=m_nentries; m_nentries += nAlignParam; } + + inline int IMatrixTool::entryNumber(int alignModuleIndex) { if ( m_alignModuleMap.find(alignModuleIndex) == m_alignModuleMap.end()) return -1; else return m_alignModuleMap[alignModuleIndex]; } + +} // end of namespace + +#endif // TRKALIGNINTERFACES_IMATRIXTOOL_IH diff --git a/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/ITrackCollectionProvider.h b/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/ITrackCollectionProvider.h new file mode 100644 index 0000000000000000000000000000000000000000..48089d81e263da75b4fffd9bd79d42fa77b4c675 --- /dev/null +++ b/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/ITrackCollectionProvider.h @@ -0,0 +1,64 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRKALIGNINTERFACES_TRACKCOLLECTIONPROVIDER_IH +#define TRKALIGNINTERFACES_TRACKCOLLECTIONPROVIDER_IH + +#include "GaudiKernel/IAlgTool.h" + +#include "TrkTrack/TrackCollection.h" + +#include <fstream> + +/** + @file ITrackCollectionProvider.h + @class ITrackCollectionProvider + + @brief Interface for tool used to get a collection of tracks. + + @author Robert Harrington <roberth@bu.edu> + @date 7/29/2010 +*/ + + +class TFile; + + +namespace Trk { + + static const InterfaceID + IID_TRK_ITrackCollectionProvider("ITrackCollectionProvider",1,0); + + class ITrackCollectionProvider: virtual public IAlgTool { + public: + static const InterfaceID& interfaceID(); + + virtual StatusCode trackCollection(const TrackCollection*& tracks) = 0; + + /** sets the output stream for the logfile */ + virtual void setLogStream(std::ostream * os) { m_logStream = os; } + + /** sets ntuple */ + virtual void setNtuple(TFile*) {} + + /** writes tree to ntuple */ + virtual StatusCode fillNtuple() { return StatusCode::SUCCESS; } + + + /** Print statistical summary to logfile. */ + virtual void printSummary() {} + + protected: + std::ostream * m_logStream; //!< logfile output stream + + }; // end of class definition + + inline const InterfaceID& ITrackCollectionProvider::interfaceID() { + return IID_TRK_ITrackCollectionProvider; + } + +} // end of namespace + + +#endif // TRKALIGNINTERFACES_TRACKCOLLECTIONPROVIDER_IH diff --git a/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/ITrkAlignDBTool.h b/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/ITrkAlignDBTool.h new file mode 100644 index 0000000000000000000000000000000000000000..5362cf8cf9682cb248cbfdf4bf2fd62fd43c79f7 --- /dev/null +++ b/Tracking/TrkAlignment/TrkAlignInterfaces/TrkAlignInterfaces/ITrkAlignDBTool.h @@ -0,0 +1,67 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRKALIGNINTERFACES_ALIGNDBTOOL_IH +#define TRKALIGNINTERFACES_ALIGNDBTOOL_IH + +#include "GaudiKernel/IAlgTool.h" +#include "GaudiKernel/ToolHandle.h" + +#include <fstream> + +/** + @file ITrkAlignDBTool.h + @class ITrkAlignDBTool + + @brief Interface for tool used to manage the retrieval of alignment + information from conditions data or other sources, such as temporary ASCII + files, and to write constants to same. + + To be implemented for each detector-type separately. + + @author Robert Harrington <roberth@bu.edu> + @date 1/5/08 +*/ + +class TFile; + +namespace Trk { + + static const InterfaceID + IID_TRKALIGNINTERFACES_ITrkAlignDBTool("ITrkAlignDBTool",1,0); + + class ITrkAlignDBTool: virtual public IAlgTool { + + public: + static const InterfaceID& interfaceID(); + + virtual StatusCode initialize() = 0; + virtual StatusCode finalize() = 0; + + /** writes alignment parameters to output */ + virtual void writeAlignPar() {} + + /** sets ntuple if needed */ + virtual void setNtuple(TFile*) {} + + /** sets the output stream for the logfile */ + virtual void setLogStream(std::ostream * os) { m_logStream = os; } + + /** sets up initial alignment constants before solving */ + virtual StatusCode preSolve() { return StatusCode::SUCCESS; } + + protected: + std::ostream * m_logStream; //!< logfile output stream + + private: + bool m_AlignDBToolFormat; //!< text file has AlignDBTool or the GlobalChi2 format + + }; + + inline const InterfaceID& ITrkAlignDBTool::interfaceID() + { return IID_TRKALIGNINTERFACES_ITrkAlignDBTool; } + +} // end namespace + +#endif // TRKALIGNINTERFACES_ALIGNDBTOOL_IH diff --git a/Tracking/TrkAlignment/TrkAlignInterfaces/cmt/requirements b/Tracking/TrkAlignment/TrkAlignInterfaces/cmt/requirements new file mode 100644 index 0000000000000000000000000000000000000000..a6b0ea2524a5a302d010124e9b190e2743a0f2bd --- /dev/null +++ b/Tracking/TrkAlignment/TrkAlignInterfaces/cmt/requirements @@ -0,0 +1,12 @@ +package TrkAlignInterfaces +author Robert Harrington + +public +use AtlasPolicy AtlasPolicy-01-* +use GaudiInterface GaudiInterface-01-* External +use DataModel DataModel-* Control + +use TrkAlignEvent TrkAlignEvent-* Tracking/TrkAlignment +use TrkTrack TrkTrack-* Tracking/TrkEvent + +private diff --git a/Tracking/TrkAlignment/TrkAlignInterfaces/doc/mainpage.h b/Tracking/TrkAlignment/TrkAlignInterfaces/doc/mainpage.h new file mode 100644 index 0000000000000000000000000000000000000000..d8245d4472e003798313f026cbe04fe3dcabcca0 --- /dev/null +++ b/Tracking/TrkAlignment/TrkAlignInterfaces/doc/mainpage.h @@ -0,0 +1,43 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/** +@mainpage TrkAlignInterfaces +@author roberth@bu.edu +@author Daniel Kollar <daniel.kollar@cern.ch> + +@section TrkAlignInterfacesIntro Introduction + +This package contains virtual interfaces for tools to be used for track-based alignment. + +@section TrkAlignInterfacesOverview Class Overview + The package contains the following classes: + + - IAlignTrackPreProcessor: processes the collection of Tracks and creates a vector of AlignTracks + - IAlignTrackCreator: processes AlignTrack and assigns a collection AlignTSOS to it + - IAlignTrackDresser: dresses AlignTrack with derivatives, residuals, etc. + - IAlignTool: accumulates information from tracks and solves for alignment parameters + - IAlignModuleTool: provides methods to handle AlignModules and AlignPars + - IFillNtupleTool: can be inherited by detector-specific tool to write output ntuple + - IGeometryManagerTool: inherited by detector-specific tool for building geometry of AlignModules to be aligned + - IMatrixTool: inherited by MatrixTool and IPCMatrixTool for dealing with large matrices + - IDerivCalcTool: inherited by tools that calculate derivatives + - IJacobianManagerTool: not yet used + - ITrkAlignDBTool: used to read constants from the database and write constants (to ASCII file for now) + +@ref used_TrkAlignInterfaces + +@ref requirements_TrkAlignInterfaces + +*/ + +/** +@page used_TrkAlignInterfaces Used Packages +@htmlinclude used_packages.html +*/ + +/** +@page requirements_TrkAlignInterfaces Requirements +@include requirements +*/