CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/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 "CondFormats/Alignment/interface/Alignments.h"
00036 #include "CondFormats/Alignment/interface/AlignmentSurfaceDeformations.h"
00037 
00038 // for watcher
00039 #include "CondFormats/AlignmentRecord/interface/TrackerSurveyRcd.h"
00040 #include "CondFormats/AlignmentRecord/interface/TrackerSurveyErrorRcd.h"
00041 #include "CondFormats/AlignmentRecord/interface/DTSurveyRcd.h"
00042 #include "CondFormats/AlignmentRecord/interface/DTSurveyErrorRcd.h"
00043 #include "CondFormats/AlignmentRecord/interface/CSCSurveyRcd.h"
00044 #include "CondFormats/AlignmentRecord/interface/CSCSurveyErrorRcd.h"
00045 
00046 
00047 class Alignments;
00048 class SurveyErrors;
00049 namespace edm {
00050   class Run;
00051   class LuminosityBlock;
00052 }
00053 
00054 class AlignmentProducer : public edm::ESProducerLooper
00055 {
00056 
00057  public:
00058   typedef std::vector<Alignable*> Alignables;
00059   typedef std::pair<const Trajectory*, const reco::Track*> ConstTrajTrackPair; 
00060   typedef std::vector<ConstTrajTrackPair>  ConstTrajTrackPairCollection;
00061   
00063   AlignmentProducer( const edm::ParameterSet& iConfig );
00064   
00066   ~AlignmentProducer();
00067 
00069   virtual boost::shared_ptr<TrackerGeometry> produceTracker( const TrackerDigiGeometryRecord& iRecord );
00071   virtual boost::shared_ptr<DTGeometry>      produceDT( const MuonGeometryRecord& iRecord );
00073   virtual boost::shared_ptr<CSCGeometry>     produceCSC( const MuonGeometryRecord& iRecord );
00074 
00076   virtual void beginOfJob(const edm::EventSetup&);
00077 
00079   virtual void endOfJob();
00080 
00082   virtual void startingNewLoop( unsigned int iLoop );
00083 
00085   virtual Status endOfLoop( const edm::EventSetup&, unsigned int iLoop );
00086 
00088   virtual void beginRun(const edm::Run &run, const edm::EventSetup &setup);
00090   virtual void endRun(const edm::Run &run, const edm::EventSetup &setup);
00091 
00093   virtual void beginLuminosityBlock(const edm::LuminosityBlock &lumiBlock,
00094                                     const edm::EventSetup &setup);
00096   virtual void endLuminosityBlock(const edm::LuminosityBlock &lumiBlock,
00097                                   const edm::EventSetup &setup);
00099   virtual Status duringLoop(const edm::Event &event, const edm::EventSetup &setup);
00100 
00101  private:
00102 
00103   // private member functions
00104 
00106   void simpleMisalignment_(const Alignables &alivec, const std::string &selection,
00107                           float shift, float rot, bool local);
00108 
00110   void createGeometries_( const edm::EventSetup& );
00111 
00114   template<class G, class Rcd, class ErrRcd>
00115     void applyDB(G *geometry, const edm::EventSetup &iSetup,
00116                  const AlignTransform &globalPosition) const;
00118   template<class G, class DeformationRcd>
00119     void applyDB(G *geometry, const edm::EventSetup &iSetup) const;
00120 
00124   void writeDB(Alignments *alignments, const std::string &alignRcd,
00125                AlignmentErrors *alignmentErrors, const std::string &errRcd,
00126                const AlignTransform *globalCoordinates) const;
00129   void writeDB(AlignmentSurfaceDeformations *alignmentSurfaceDeformations,
00130                const std::string &surfaceDeformationRcd) const;
00131 
00133   void addSurveyInfo_(Alignable*);
00134         
00136   void readInSurveyRcds( const edm::EventSetup& );
00137 
00138   // private data members
00139 
00140   unsigned int        theSurveyIndex;
00141   const Alignments*   theSurveyValues;
00142   const SurveyErrors* theSurveyErrors;
00143 
00144   AlignmentAlgorithmBase* theAlignmentAlgo;
00145   std::vector<AlignmentMonitorBase*> theMonitors;
00146   AlignmentParameterStore* theAlignmentParameterStore;
00147 
00148   AlignableExtras* theAlignableExtras;
00149   AlignableTracker* theAlignableTracker;
00150   AlignableMuon* theAlignableMuon;
00151 
00152   boost::shared_ptr<TrackerGeometry> theTracker;
00153   boost::shared_ptr<DTGeometry> theMuonDT;
00154   boost::shared_ptr<CSCGeometry> theMuonCSC;
00156   const Alignments *globalPositions_;
00157 
00158   int nevent_;
00159   edm::ParameterSet theParameterSet;
00160 
00161   // steering parameters
00162 
00163   const unsigned int theMaxLoops;     // Number of loops to loop
00164 
00165   const int stNFixAlignables_;
00166   const double stRandomShift_,stRandomRotation_;
00167   const bool applyDbAlignment_,applyDbDeformations_,doMisalignmentScenario_;
00168   const bool saveToDB_, saveApeToDB_,saveDeformationsToDB_;
00169   const bool doTracker_,doMuon_,useExtras_;
00170   const bool useSurvey_; // true to read survey info from DB
00171 
00172   // event input tags
00173   const edm::InputTag tjTkAssociationMapTag_; // map with tracks/trajectories
00174   const edm::InputTag beamSpotTag_;           // beam spot
00175   const edm::InputTag tkLasBeamTag_;          // LAS beams in edm::Run (ignore if empty)
00176   const edm::InputTag clusterValueMapTag_;              // ValueMap containing associtaion cluster - flag
00177 
00178 
00179   // ESWatcher
00180   edm::ESWatcher<TrackerSurveyRcd> watchTkSurveyRcd_;
00181   edm::ESWatcher<TrackerSurveyErrorRcd> watchTkSurveyErrRcd_;
00182   edm::ESWatcher<DTSurveyRcd> watchDTSurveyRcd_;
00183   edm::ESWatcher<DTSurveyErrorRcd> watchDTSurveyErrRcd_;
00184   edm::ESWatcher<CSCSurveyRcd> watchCSCSurveyRcd_;
00185   edm::ESWatcher<CSCSurveyErrorRcd> watchCSCSurveyErrRcd_;      
00186   
00187 };
00188 
00189 #endif