CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/Alignment/CommonAlignmentProducer/plugins/AlignmentProducer.h

Go to the documentation of this file.
00001 #ifndef Alignment_CommonAlignmentAlgorithm_TrackerAlignmentProducer_h
00002 #define Alignment_CommonAlignmentAlgorithm_TrackerAlignmentProducer_h
00003 
00013 
00014 #include <vector>
00015 
00016 // Framework
00017 #include "FWCore/Framework/interface/ESProducerLooper.h"
00018 #include "FWCore/Framework/interface/ESHandle.h"
00019 #include "FWCore/Framework/interface/ESWatcher.h"
00020 
00021 #include "DataFormats/Provenance/interface/RunID.h"
00022 
00023 // Geometry
00024 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00025 
00026 // Alignment
00027 #include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmBase.h"
00028 #include "Alignment/CommonAlignmentMonitor/interface/AlignmentMonitorBase.h"
00029 #include "FWCore/ParameterSet/interface/ParameterSet.h" 
00030 #include <Geometry/Records/interface/MuonGeometryRecord.h> 
00031 #include "Alignment/CommonAlignment/interface/AlignableExtras.h"
00032 #include "Alignment/TrackerAlignment/interface/AlignableTracker.h"
00033 #include "Alignment/MuonAlignment/interface/AlignableMuon.h"
00034 #include <FWCore/Framework/interface/Frameworkfwd.h>
00035 #include "CondCore/DBCommon/interface/Time.h"
00036 #include "CondFormats/Alignment/interface/Alignments.h"
00037 #include "CondFormats/Alignment/interface/AlignmentSurfaceDeformations.h"
00038 
00039 // for watcher
00040 #include "CondFormats/AlignmentRecord/interface/TrackerSurveyRcd.h"
00041 #include "CondFormats/AlignmentRecord/interface/TrackerSurveyErrorRcd.h"
00042 #include "CondFormats/AlignmentRecord/interface/DTSurveyRcd.h"
00043 #include "CondFormats/AlignmentRecord/interface/DTSurveyErrorRcd.h"
00044 #include "CondFormats/AlignmentRecord/interface/CSCSurveyRcd.h"
00045 #include "CondFormats/AlignmentRecord/interface/CSCSurveyErrorRcd.h"
00046 
00047 
00048 class Alignments;
00049 class IntegratedCalibrationBase;
00050 class SurveyErrors;
00051 namespace edm {
00052   class Run;
00053   class LuminosityBlock;
00054 }
00055 
00056 class AlignmentProducer : public edm::ESProducerLooper
00057 {
00058 
00059  public:
00060   typedef std::vector<Alignable*> Alignables;
00061   typedef std::pair<const Trajectory*, const reco::Track*> ConstTrajTrackPair; 
00062   typedef std::vector<ConstTrajTrackPair>  ConstTrajTrackPairCollection;
00063 
00064   typedef AlignmentAlgorithmBase::RunNumber            RunNumber;
00065   typedef AlignmentAlgorithmBase::RunRange             RunRange;
00066   typedef std::vector<RunRange>                        RunRanges;
00067 
00069   AlignmentProducer( const edm::ParameterSet& iConfig );
00070   
00072   ~AlignmentProducer();
00073 
00075   virtual boost::shared_ptr<TrackerGeometry> produceTracker( const TrackerDigiGeometryRecord& iRecord );
00077   virtual boost::shared_ptr<DTGeometry>      produceDT( const MuonGeometryRecord& iRecord );
00079   virtual boost::shared_ptr<CSCGeometry>     produceCSC( const MuonGeometryRecord& iRecord );
00080 
00082   virtual void beginOfJob(const edm::EventSetup&);
00083 
00085   virtual void endOfJob();
00086 
00088   virtual void startingNewLoop( unsigned int iLoop );
00089 
00091   virtual Status endOfLoop( const edm::EventSetup&, unsigned int iLoop );
00092 
00094   virtual void beginRun(const edm::Run &run, const edm::EventSetup &setup);
00096   virtual void endRun(const edm::Run &run, const edm::EventSetup &setup);
00097 
00099   virtual void beginLuminosityBlock(const edm::LuminosityBlock &lumiBlock,
00100                                     const edm::EventSetup &setup);
00102   virtual void endLuminosityBlock(const edm::LuminosityBlock &lumiBlock,
00103                                   const edm::EventSetup &setup);
00105   virtual Status duringLoop(const edm::Event &event, const edm::EventSetup &setup);
00106 
00107  private:
00108 
00109   // private member functions
00110 
00112   void simpleMisalignment_(const Alignables &alivec, const std::string &selection,
00113                           float shift, float rot, bool local);
00114 
00116   void createGeometries_( const edm::EventSetup& );
00117 
00120   template<class G, class Rcd, class ErrRcd>
00121     void applyDB(G *geometry, const edm::EventSetup &iSetup,
00122                  const AlignTransform &globalPosition) const;
00124   template<class G, class DeformationRcd>
00125     void applyDB(G *geometry, const edm::EventSetup &iSetup) const;
00126 
00127   // write alignments and alignment errors for all sub detectors and
00128   // the given run number
00129   void writeForRunRange(cond::Time_t time);
00130 
00134   void writeDB(Alignments *alignments, const std::string &alignRcd,
00135                AlignmentErrors *alignmentErrors, const std::string &errRcd,
00136                const AlignTransform *globalCoordinates,
00137                cond::Time_t time) const;
00140   void writeDB(AlignmentSurfaceDeformations *alignmentSurfaceDeformations,
00141                const std::string &surfaceDeformationRcd,
00142                cond::Time_t time) const;
00143 
00145   void addSurveyInfo_(Alignable*);
00146         
00148   void readInSurveyRcds( const edm::EventSetup& );
00149 
00150   RunRanges makeNonOverlappingRunRanges(const edm::VParameterSet& RunRangeSelectionVPSet);
00151 
00152   // private data members
00153 
00154   unsigned int        theSurveyIndex;
00155   const Alignments*   theSurveyValues;
00156   const SurveyErrors* theSurveyErrors;
00157 
00158   AlignmentAlgorithmBase* theAlignmentAlgo;
00159   AlignmentParameterStore* theAlignmentParameterStore;
00160   std::vector<AlignmentMonitorBase*> theMonitors;
00161   std::vector<IntegratedCalibrationBase*> theCalibrations;
00162 
00163   AlignableExtras* theAlignableExtras;
00164   AlignableTracker* theAlignableTracker;
00165   AlignableMuon* theAlignableMuon;
00166 
00167   boost::shared_ptr<TrackerGeometry> theTracker;
00168   boost::shared_ptr<DTGeometry> theMuonDT;
00169   boost::shared_ptr<CSCGeometry> theMuonCSC;
00171   const Alignments *globalPositions_;
00172 
00173   int nevent_;
00174   edm::ParameterSet theParameterSet;
00175 
00176   // steering parameters
00177 
00178   const unsigned int theMaxLoops;     // Number of loops to loop
00179 
00180   const int stNFixAlignables_;
00181   const double stRandomShift_,stRandomRotation_;
00182   const bool applyDbAlignment_,checkDbAlignmentValidity_;
00183   const bool doMisalignmentScenario_;
00184   const bool saveToDB_, saveApeToDB_,saveDeformationsToDB_;
00185   const bool doTracker_,doMuon_,useExtras_;
00186   const bool useSurvey_; // true to read survey info from DB
00187 
00188   // event input tags
00189   const edm::InputTag tjTkAssociationMapTag_; // map with tracks/trajectories
00190   const edm::InputTag beamSpotTag_;           // beam spot
00191   const edm::InputTag tkLasBeamTag_;          // LAS beams in edm::Run (ignore if empty)
00192   const edm::InputTag clusterValueMapTag_;              // ValueMap containing associtaion cluster - flag
00193 
00194   // ESWatcher
00195   edm::ESWatcher<TrackerSurveyRcd> watchTkSurveyRcd_;
00196   edm::ESWatcher<TrackerSurveyErrorRcd> watchTkSurveyErrRcd_;
00197   edm::ESWatcher<DTSurveyRcd> watchDTSurveyRcd_;
00198   edm::ESWatcher<DTSurveyErrorRcd> watchDTSurveyErrRcd_;
00199   edm::ESWatcher<CSCSurveyRcd> watchCSCSurveyRcd_;
00200   edm::ESWatcher<CSCSurveyErrorRcd> watchCSCSurveyErrRcd_;      
00201 
00202 };
00203 
00204 #endif