CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/Alignment/CommonAlignmentProducer/plugins/FakeAlignmentSource.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    FakeAlignmentSource
00004 // Class:      FakeAlignmentSource
00005 // 
00015 //
00016 // Original Author:  Gero Flucke (based on FakeAlignmentProducer written by Frederic Ronga)
00017 //         Created:  June 24, 2007
00018 // $Id: FakeAlignmentSource.cc,v 1.3 2010/11/23 13:24:32 mussgill Exp $
00019 //
00020 //
00021 
00022 
00023 // System
00024 #include <memory>
00025 #include <string>
00026 
00027 // Framework
00028 #include "FWCore/Framework/interface/SourceFactory.h"
00029 #include "FWCore/Framework/interface/ESProducer.h"
00030 #include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h"
00031 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00032 
00033 // Alignment
00034 #include "CondFormats/Alignment/interface/Alignments.h"
00035 #include "CondFormats/Alignment/interface/AlignmentErrors.h"
00036 #include "CondFormats/Alignment/interface/AlignmentSurfaceDeformations.h"
00037 #include "CondFormats/AlignmentRecord/interface/TrackerAlignmentRcd.h"
00038 #include "CondFormats/AlignmentRecord/interface/DTAlignmentRcd.h"
00039 #include "CondFormats/AlignmentRecord/interface/CSCAlignmentRcd.h"
00040 #include "CondFormats/AlignmentRecord/interface/TrackerAlignmentErrorRcd.h"
00041 #include "CondFormats/AlignmentRecord/interface/DTAlignmentErrorRcd.h"
00042 #include "CondFormats/AlignmentRecord/interface/CSCAlignmentErrorRcd.h"
00043 #include "CondFormats/AlignmentRecord/interface/GlobalPositionRcd.h"
00044 #include "CondFormats/AlignmentRecord/interface/TrackerSurfaceDeformationRcd.h"
00045 
00046 class FakeAlignmentSource : public edm::ESProducer, public edm::EventSetupRecordIntervalFinder  {
00047 public:
00048   FakeAlignmentSource(const edm::ParameterSet&);
00049   ~FakeAlignmentSource() {}
00050 
00052   std::auto_ptr<Alignments> produceTkAli(const TrackerAlignmentRcd&) {
00053     return std::auto_ptr<Alignments>(new Alignments);
00054   }
00055   std::auto_ptr<AlignmentErrors> produceTkAliErr(const TrackerAlignmentErrorRcd&) { 
00056     return std::auto_ptr<AlignmentErrors>(new AlignmentErrors);
00057   }
00058 
00060   std::auto_ptr<Alignments> produceDTAli(const DTAlignmentRcd&) {
00061     return std::auto_ptr<Alignments>(new Alignments);
00062   }
00063   std::auto_ptr<AlignmentErrors> produceDTAliErr(const DTAlignmentErrorRcd&) {
00064     return std::auto_ptr<AlignmentErrors>(new AlignmentErrors);
00065   }
00066 
00068   std::auto_ptr<Alignments> produceCSCAli(const CSCAlignmentRcd&) {
00069     return std::auto_ptr<Alignments>(new Alignments);
00070   }
00071   std::auto_ptr<AlignmentErrors> produceCSCAliErr(const CSCAlignmentErrorRcd&) {
00072     return std::auto_ptr<AlignmentErrors>(new AlignmentErrors);
00073   }
00074 
00076   std::auto_ptr<Alignments> produceGlobals(const GlobalPositionRcd&) {
00077     return std::auto_ptr<Alignments>(new Alignments);
00078   }
00079 
00081   std::auto_ptr<AlignmentSurfaceDeformations>
00082   produceTrackerSurfaceDeformation(const TrackerSurfaceDeformationRcd&) {
00083     return std::auto_ptr<AlignmentSurfaceDeformations>(new AlignmentSurfaceDeformations);
00084   }
00085 
00086  protected:
00088   virtual void setIntervalFor( const edm::eventsetup::EventSetupRecordKey& /*dummy*/,
00089                                const edm::IOVSyncValue& ioSyncVal, edm::ValidityInterval& iov);
00090 
00091  private:
00092 
00093   bool produceTracker_;
00094   bool produceDT_;
00095   bool produceCSC_;
00096   bool produceGlobalPosition_;
00097   bool produceTrackerSurfaceDeformation_;
00098 };
00099 
00100 //________________________________________________________________________________________
00101 //________________________________________________________________________________________
00102 //________________________________________________________________________________________
00103 
00104 FakeAlignmentSource::FakeAlignmentSource(const edm::ParameterSet& iConfig)
00105   :produceTracker_(iConfig.getParameter<bool>("produceTracker")),
00106    produceDT_(iConfig.getParameter<bool>("produceDT")),
00107    produceCSC_(iConfig.getParameter<bool>("produceCSC")),
00108    produceGlobalPosition_(iConfig.getParameter<bool>("produceGlobalPosition")),
00109    produceTrackerSurfaceDeformation_(iConfig.getParameter<bool>("produceTrackerSurfaceDeformation"))
00110 {
00111   // This 'appendToDataLabel' is used by the framework to distinguish providers
00112   // with different settings and to request a special one by e.g.
00113   // iSetup.get<TrackerDigiGeometryRecord>().get("theLabel", tkGeomHandle);
00114   
00115   edm::LogInfo("Alignments") 
00116     << "@SUB=FakeAlignmentSource" << "Providing data with label '" 
00117     << iConfig.getParameter<std::string>("appendToDataLabel") << "'.";
00118   
00119   // Tell framework what data is produced by which method:
00120   if (produceTracker_) {
00121     this->setWhatProduced(this, &FakeAlignmentSource::produceTkAli);
00122     this->setWhatProduced(this, &FakeAlignmentSource::produceTkAliErr);
00123   }
00124   if (produceDT_) {
00125     this->setWhatProduced(this, &FakeAlignmentSource::produceDTAli);
00126     this->setWhatProduced(this, &FakeAlignmentSource::produceDTAliErr);
00127   }
00128   if (produceCSC_) {
00129     this->setWhatProduced(this, &FakeAlignmentSource::produceCSCAli);
00130     this->setWhatProduced(this, &FakeAlignmentSource::produceCSCAliErr);
00131   }
00132   if (produceGlobalPosition_) {
00133     this->setWhatProduced(this, &FakeAlignmentSource::produceGlobals);
00134   }
00135   if (produceTrackerSurfaceDeformation_) {
00136     this->setWhatProduced(this, &FakeAlignmentSource::produceTrackerSurfaceDeformation);
00137   }
00138 
00139   // Tell framework to provide IOV for the above data:
00140   if (produceTracker_) {
00141     this->findingRecord<TrackerAlignmentRcd>();
00142     this->findingRecord<TrackerAlignmentErrorRcd>();
00143   }
00144   if (produceDT_) {
00145     this->findingRecord<DTAlignmentRcd>();
00146     this->findingRecord<DTAlignmentErrorRcd>();
00147   }
00148   if (produceCSC_) {
00149     this->findingRecord<CSCAlignmentRcd>();
00150     this->findingRecord<CSCAlignmentErrorRcd>();
00151   }
00152   if (produceGlobalPosition_) {
00153     this->findingRecord<GlobalPositionRcd>();
00154   }
00155   if (produceTrackerSurfaceDeformation_) {
00156     this->findingRecord<TrackerSurfaceDeformationRcd>();
00157   }
00158 }
00159 
00160 void FakeAlignmentSource::setIntervalFor( const edm::eventsetup::EventSetupRecordKey& /*dummy*/, 
00161                                             const edm::IOVSyncValue& ioSyncVal, 
00162                                             edm::ValidityInterval& outValidity )
00163 {
00164   // Implementation copied from SiStripGainFakeESSource: unlimited IOV
00165   outValidity = edm::ValidityInterval(ioSyncVal.beginOfTime(), ioSyncVal.endOfTime());
00166 }
00167 
00168 //define this as a plug-in
00169 DEFINE_FWK_EVENTSETUP_SOURCE(FakeAlignmentSource);