CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_4/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 SurveyErrors;
00050 namespace edm {
00051   class Run;
00052   class LuminosityBlock;
00053 }
00054 
00055 class AlignmentProducer : public edm::ESProducerLooper
00056 {
00057 
00058  public:
00059   typedef std::vector<Alignable*> Alignables;
00060   typedef std::pair<const Trajectory*, const reco::Track*> ConstTrajTrackPair; 
00061   typedef std::vector<ConstTrajTrackPair>  ConstTrajTrackPairCollection;
00062 
00063   typedef AlignmentAlgorithmBase::RunNumber            RunNumber;
00064   typedef AlignmentAlgorithmBase::RunRange             RunRange;
00065   typedef std::vector<RunRange>                        RunRanges;
00066 
00068   AlignmentProducer( const edm::ParameterSet& iConfig );
00069   
00071   ~AlignmentProducer();
00072 
00074   virtual boost::shared_ptr<TrackerGeometry> produceTracker( const TrackerDigiGeometryRecord& iRecord );
00076   virtual boost::shared_ptr<DTGeometry>      produceDT( const MuonGeometryRecord& iRecord );
00078   virtual boost::shared_ptr<CSCGeometry>     produceCSC( const MuonGeometryRecord& iRecord );
00079 
00081   virtual void beginOfJob(const edm::EventSetup&);
00082 
00084   virtual void endOfJob();
00085 
00087   virtual void startingNewLoop( unsigned int iLoop );
00088 
00090   virtual Status endOfLoop( const edm::EventSetup&, unsigned int iLoop );
00091 
00093   virtual void beginRun(const edm::Run &run, const edm::EventSetup &setup);
00095   virtual void endRun(const edm::Run &run, const edm::EventSetup &setup);
00096 
00098   virtual void beginLuminosityBlock(const edm::LuminosityBlock &lumiBlock,
00099                                     const edm::EventSetup &setup);
00101   virtual void endLuminosityBlock(const edm::LuminosityBlock &lumiBlock,
00102                                   const edm::EventSetup &setup);
00104   virtual Status duringLoop(const edm::Event &event, const edm::EventSetup &setup);
00105 
00106  private:
00107 
00108   // private member functions
00109 
00111   void simpleMisalignment_(const Alignables &alivec, const std::string &selection,
00112                           float shift, float rot, bool local);
00113 
00115   void createGeometries_( const edm::EventSetup& );
00116 
00119   template<class G, class Rcd, class ErrRcd>
00120     void applyDB(G *geometry, const edm::EventSetup &iSetup,
00121                  const AlignTransform &globalPosition) const;
00123   template<class G, class DeformationRcd>
00124     void applyDB(G *geometry, const edm::EventSetup &iSetup) const;
00125 
00126   // write alignments and alignment errors for all sub detectors and
00127   // the given run number
00128   void writeForRunRange(cond::Time_t time);
00129 
00133   void writeDB(Alignments *alignments, const std::string &alignRcd,
00134                AlignmentErrors *alignmentErrors, const std::string &errRcd,
00135                const AlignTransform *globalCoordinates,
00136                cond::Time_t time) const;
00139   void writeDB(AlignmentSurfaceDeformations *alignmentSurfaceDeformations,
00140                const std::string &surfaceDeformationRcd,
00141                cond::Time_t time) const;
00142 
00144   void addSurveyInfo_(Alignable*);
00145         
00147   void readInSurveyRcds( const edm::EventSetup& );
00148 
00149   RunRanges makeNonOverlappingRunRanges(const edm::VParameterSet& RunRangeSelectionVPSet);
00150 
00151   // private data members
00152 
00153   unsigned int        theSurveyIndex;
00154   const Alignments*   theSurveyValues;
00155   const SurveyErrors* theSurveyErrors;
00156 
00157   AlignmentAlgorithmBase* theAlignmentAlgo;
00158   std::vector<AlignmentMonitorBase*> theMonitors;
00159   AlignmentParameterStore* theAlignmentParameterStore;
00160 
00161   AlignableExtras* theAlignableExtras;
00162   AlignableTracker* theAlignableTracker;
00163   AlignableMuon* theAlignableMuon;
00164 
00165   boost::shared_ptr<TrackerGeometry> theTracker;
00166   boost::shared_ptr<DTGeometry> theMuonDT;
00167   boost::shared_ptr<CSCGeometry> theMuonCSC;
00169   const Alignments *globalPositions_;
00170 
00171   int nevent_;
00172   edm::ParameterSet theParameterSet;
00173 
00174   // steering parameters
00175 
00176   const unsigned int theMaxLoops;     // Number of loops to loop
00177 
00178   const int stNFixAlignables_;
00179   const double stRandomShift_,stRandomRotation_;
00180   const bool applyDbAlignment_,checkDbAlignmentValidity_;
00181   const bool doMisalignmentScenario_;
00182   const bool saveToDB_, saveApeToDB_,saveDeformationsToDB_;
00183   const bool doTracker_,doMuon_,useExtras_;
00184   const bool useSurvey_; // true to read survey info from DB
00185 
00186   // event input tags
00187   const edm::InputTag tjTkAssociationMapTag_; // map with tracks/trajectories
00188   const edm::InputTag beamSpotTag_;           // beam spot
00189   const edm::InputTag tkLasBeamTag_;          // LAS beams in edm::Run (ignore if empty)
00190   const edm::InputTag clusterValueMapTag_;              // ValueMap containing associtaion cluster - flag
00191 
00192 
00193   // ESWatcher
00194   edm::ESWatcher<TrackerSurveyRcd> watchTkSurveyRcd_;
00195   edm::ESWatcher<TrackerSurveyErrorRcd> watchTkSurveyErrRcd_;
00196   edm::ESWatcher<DTSurveyRcd> watchDTSurveyRcd_;
00197   edm::ESWatcher<DTSurveyErrorRcd> watchDTSurveyErrRcd_;
00198   edm::ESWatcher<CSCSurveyRcd> watchCSCSurveyRcd_;
00199   edm::ESWatcher<CSCSurveyErrorRcd> watchCSCSurveyErrRcd_;      
00200   
00201 };
00202 
00203 #endif