CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
AlignmentProducer Class Reference

#include <AlignmentProducer.h>

Inheritance diagram for AlignmentProducer:
edm::ESProducerLooper edm::ESProducer edm::EventSetupRecordIntervalFinder edm::EDLooper edm::ESProxyFactoryProducer edm::EDLooperBase edm::eventsetup::DataProxyProvider

Public Types

typedef std::vector< Alignable * > Alignables
 
typedef std::pair< const
Trajectory *, const
reco::Track * > 
ConstTrajTrackPair
 
typedef std::vector
< ConstTrajTrackPair
ConstTrajTrackPairCollection
 
- Public Types inherited from edm::eventsetup::DataProxyProvider
typedef std::vector< std::pair
< DataKey, boost::shared_ptr
< DataProxy > > > 
KeyedProxies
 
typedef std::vector
< EventSetupRecordKey
Keys
 
typedef std::map
< EventSetupRecordKey,
KeyedProxies
RecordProxies
 
- Public Types inherited from edm::EDLooperBase
enum  Status { kContinue, kStop }
 

Public Member Functions

 AlignmentProducer (const edm::ParameterSet &iConfig)
 Constructor. More...
 
virtual void beginLuminosityBlock (const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &setup)
 Called at lumi block start, calling algorithm's beginLuminosityBlock. More...
 
virtual void beginOfJob (const edm::EventSetup &)
 Called at beginning of job. More...
 
virtual void beginRun (const edm::Run &run, const edm::EventSetup &setup)
 Called at run start and calling algorithms beginRun. More...
 
virtual Status duringLoop (const edm::Event &event, const edm::EventSetup &setup)
 Called at each event. More...
 
virtual void endLuminosityBlock (const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &setup)
 Called at lumi block end, calling algorithm's endLuminosityBlock. More...
 
virtual void endOfJob ()
 Called at end of job. More...
 
virtual Status endOfLoop (const edm::EventSetup &, unsigned int iLoop)
 Called at end of loop. More...
 
virtual void endRun (const edm::Run &run, const edm::EventSetup &setup)
 Called at run end - currently reading TkFittedLasBeam if an InpuTag is given for that. More...
 
virtual boost::shared_ptr
< CSCGeometry
produceCSC (const MuonGeometryRecord &iRecord)
 Produce the muon CSC geometry. More...
 
virtual boost::shared_ptr
< DTGeometry
produceDT (const MuonGeometryRecord &iRecord)
 Produce the muon DT geometry. More...
 
virtual boost::shared_ptr
< TrackerGeometry
produceTracker (const TrackerDigiGeometryRecord &iRecord)
 Produce the tracker geometry. More...
 
virtual void startingNewLoop (unsigned int iLoop)
 Called at beginning of loop. More...
 
 ~AlignmentProducer ()
 Destructor. More...
 
- Public Member Functions inherited from edm::ESProducerLooper
 ESProducerLooper ()
 
virtual std::set
< eventsetup::EventSetupRecordKey
modifyingRecords () const
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
virtual ~ESProducer ()
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
virtual void newInterval (const eventsetup::EventSetupRecordKey &iRecordType, const ValidityInterval &iInterval)
 overrides DataProxyProvider method More...
 
virtual ~ESProxyFactoryProducer ()
 
- Public Member Functions inherited from edm::eventsetup::DataProxyProvider
 DataProxyProvider ()
 
const ComponentDescriptiondescription () const
 
bool isUsingRecord (const EventSetupRecordKey &) const
 
const KeyedProxieskeyedProxies (const EventSetupRecordKey &iRecordKey) const
 
void resetProxies (const EventSetupRecordKey &iRecordType)
 
void resetProxiesIfTransient (const EventSetupRecordKey &iRecordType)
 
void setAppendToDataLabel (const edm::ParameterSet &)
 
void setDescription (const ComponentDescription &iDescription)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~DataProxyProvider ()
 
- Public Member Functions inherited from edm::EventSetupRecordIntervalFinder
const
eventsetup::ComponentDescription
descriptionForFinder () const
 
 EventSetupRecordIntervalFinder ()
 
std::set
< eventsetup::EventSetupRecordKey
findingForRecords () const
 
const ValidityIntervalfindIntervalFor (const eventsetup::EventSetupRecordKey &, const IOVSyncValue &)
 
void setDescriptionForFinder (const eventsetup::ComponentDescription &iDescription)
 
virtual ~EventSetupRecordIntervalFinder ()
 
- Public Member Functions inherited from edm::EDLooper
 EDLooper ()
 
virtual ~EDLooper ()
 
- Public Member Functions inherited from edm::EDLooperBase
virtual void attachTo (ActivityRegistry &)
 Override this method if you need to monitor the state of the processing. More...
 
virtual void beginOfJob ()
 
void copyInfo (ScheduleInfo const &)
 
void doBeginLuminosityBlock (LuminosityBlockPrincipal &, EventSetup const &)
 
void doBeginRun (RunPrincipal &, EventSetup const &)
 
Status doDuringLoop (EventPrincipal &eventPrincipal, EventSetup const &es, ProcessingController &)
 
void doEndLuminosityBlock (LuminosityBlockPrincipal &, EventSetup const &)
 
Status doEndOfLoop (EventSetup const &es)
 
void doEndRun (RunPrincipal &, EventSetup const &)
 
void doStartingNewLoop ()
 
 EDLooperBase ()
 
void prepareForNextLoop (eventsetup::EventSetupProvider *esp)
 
void setActionTable (ActionTable const *actionTable)
 
void setModuleChanger (ModuleChanger const *)
 
virtual ~EDLooperBase ()
 

Private Member Functions

void addSurveyInfo_ (Alignable *)
 Add survey info to an alignable. More...
 
template<class G , class Rcd , class ErrRcd >
void applyDB (G *geometry, const edm::EventSetup &iSetup, const AlignTransform &globalPosition) const
 
template<class G , class DeformationRcd >
void applyDB (G *geometry, const edm::EventSetup &iSetup) const
 Apply DB constants for surface deformations. More...
 
void createGeometries_ (const edm::EventSetup &)
 Create tracker and muon geometries. More...
 
void readInSurveyRcds (const edm::EventSetup &)
 read in survey records More...
 
void simpleMisalignment_ (const Alignables &alivec, const std::string &selection, float shift, float rot, bool local)
 Apply random shifts and rotations to selected alignables, according to configuration. More...
 
void writeDB (Alignments *alignments, const std::string &alignRcd, AlignmentErrors *alignmentErrors, const std::string &errRcd, const AlignTransform *globalCoordinates) const
 
void writeDB (AlignmentSurfaceDeformations *alignmentSurfaceDeformations, const std::string &surfaceDeformationRcd) const
 

Private Attributes

const bool applyDbAlignment_
 
const bool applyDbDeformations_
 
const edm::InputTag beamSpotTag_
 
const edm::InputTag clusterValueMapTag_
 
const bool doMisalignmentScenario_
 
const bool doMuon_
 
const bool doTracker_
 
const AlignmentsglobalPositions_
 GlobalPositions that might be read from DB, NULL otherwise. More...
 
int nevent_
 
const bool saveApeToDB_
 
const bool saveDeformationsToDB_
 
const bool saveToDB_
 
const int stNFixAlignables_
 
const double stRandomRotation_
 
const double stRandomShift_
 
AlignableExtrastheAlignableExtras
 
AlignableMuontheAlignableMuon
 
AlignableTrackertheAlignableTracker
 
AlignmentAlgorithmBasetheAlignmentAlgo
 
AlignmentParameterStoretheAlignmentParameterStore
 
const unsigned int theMaxLoops
 
std::vector
< AlignmentMonitorBase * > 
theMonitors
 
boost::shared_ptr< CSCGeometrytheMuonCSC
 
boost::shared_ptr< DTGeometrytheMuonDT
 
edm::ParameterSet theParameterSet
 
const SurveyErrorstheSurveyErrors
 
unsigned int theSurveyIndex
 
const AlignmentstheSurveyValues
 
boost::shared_ptr
< TrackerGeometry
theTracker
 
const edm::InputTag tjTkAssociationMapTag_
 
const edm::InputTag tkLasBeamTag_
 
const bool useExtras_
 
const bool useSurvey_
 
edm::ESWatcher< CSCSurveyErrorRcdwatchCSCSurveyErrRcd_
 
edm::ESWatcher< CSCSurveyRcdwatchCSCSurveyRcd_
 
edm::ESWatcher< DTSurveyErrorRcdwatchDTSurveyErrRcd_
 
edm::ESWatcher< DTSurveyRcdwatchDTSurveyRcd_
 
edm::ESWatcher
< TrackerSurveyErrorRcd
watchTkSurveyErrRcd_
 
edm::ESWatcher< TrackerSurveyRcdwatchTkSurveyRcd_
 

Additional Inherited Members

- Protected Member Functions inherited from edm::ESProducerLooper
virtual void registerFactoryWithKey (const eventsetup::EventSetupRecordKey &iRecord, std::auto_ptr< eventsetup::ProxyFactoryBase > &iFactory, const std::string &iLabel=std::string())
 
void setIntervalFor (const eventsetup::EventSetupRecordKey &iKey, const IOVSyncValue &iTime, ValidityInterval &oInterval)
 
- Protected Member Functions inherited from edm::ESProducer
template<typename T >
void setWhatProduced (T *iThis, const es::Label &iLabel=es::Label())
 
template<typename T >
void setWhatProduced (T *iThis, const char *iLabel)
 
template<typename T >
void setWhatProduced (T *iThis, const std::string &iLabel)
 
template<typename T , typename TDecorator >
void setWhatProduced (T *iThis, const TDecorator &iDec, const es::Label &iLabel=es::Label())
 
template<typename T , typename TReturn , typename TRecord >
void setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const es::Label &iLabel=es::Label())
 
template<typename T , typename TReturn , typename TRecord , typename TArg >
void setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const TArg &iDec, const es::Label &iLabel=es::Label())
 
- Protected Member Functions inherited from edm::ESProxyFactoryProducer
template<class TFactory >
void registerFactory (std::auto_ptr< TFactory > iFactory, const std::string &iLabel=std::string())
 
virtual void registerProxies (const eventsetup::EventSetupRecordKey &iRecord, KeyedProxies &aProxyList)
 override DataProxyProvider method More...
 
- Protected Member Functions inherited from edm::eventsetup::DataProxyProvider
void eraseAll (const EventSetupRecordKey &iRecordKey)
 deletes all the Proxies in aStream More...
 
void invalidateProxies (const EventSetupRecordKey &iRecordKey)
 
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &)
 
- Protected Member Functions inherited from edm::EventSetupRecordIntervalFinder
template<class T >
void findingRecord ()
 
void findingRecordWithKey (const eventsetup::EventSetupRecordKey &)
 
- Protected Member Functions inherited from edm::EDLooperBase
ModuleChanger const * moduleChanger () const
 This only returns a non-zero value during the call to endOfLoop. More...
 
ScheduleInfo const * scheduleInfo () const
 This returns a non-zero value after the constructor has been called. More...
 

Detailed Description

Package : Alignment/CommonAlignmentProducer Description : calls alignment algorithms

Author
: Frederic Ronga Revision :
Revision:
1.18

last update:

Date:
2010/09/10 11:46:17

by :

Author:
mussgill

Definition at line 54 of file AlignmentProducer.h.

Member Typedef Documentation

Definition at line 58 of file AlignmentProducer.h.

Definition at line 59 of file AlignmentProducer.h.

Definition at line 60 of file AlignmentProducer.h.

Constructor & Destructor Documentation

AlignmentProducer::AlignmentProducer ( const edm::ParameterSet iConfig)

Constructor.

Definition at line 73 of file AlignmentProducer.cc.

References doMuon_, doTracker_, edm::hlt::Exception, reco::get(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), produceCSC(), produceDT(), produceTracker(), edm::ESProducer::setWhatProduced(), theAlignmentAlgo, and theMonitors.

73  :
77  nevent_(0), theParameterSet(iConfig),
78  theMaxLoops( iConfig.getUntrackedParameter<unsigned int>("maxLoops") ),
79  stNFixAlignables_(iConfig.getParameter<int>("nFixAlignables") ),
80  stRandomShift_(iConfig.getParameter<double>("randomShift")),
81  stRandomRotation_(iConfig.getParameter<double>("randomRotation")),
82  applyDbAlignment_( iConfig.getUntrackedParameter<bool>("applyDbAlignment")),
83  applyDbDeformations_( iConfig.getUntrackedParameter<bool>("applyDbDeformations")),
84  doMisalignmentScenario_(iConfig.getParameter<bool>("doMisalignmentScenario")),
85  saveToDB_(iConfig.getParameter<bool>("saveToDB")),
86  saveApeToDB_(iConfig.getParameter<bool>("saveApeToDB")),
87  saveDeformationsToDB_(iConfig.getParameter<bool>("saveDeformationsToDB")),
88  doTracker_( iConfig.getUntrackedParameter<bool>("doTracker") ),
89  doMuon_( iConfig.getUntrackedParameter<bool>("doMuon") ),
90  useExtras_( iConfig.getUntrackedParameter<bool>("useExtras") ),
91  useSurvey_( iConfig.getParameter<bool>("useSurvey") ),
92  tjTkAssociationMapTag_(iConfig.getParameter<edm::InputTag>("tjTkAssociationMapTag")),
93  beamSpotTag_(iConfig.getParameter<edm::InputTag>("beamSpotTag")),
94  tkLasBeamTag_(iConfig.getParameter<edm::InputTag>("tkLasBeamTag")),
95  clusterValueMapTag_(iConfig.getParameter<edm::InputTag>("hitPrescaleMapTag"))
96 {
97  edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::AlignmentProducer";
98 
99  // Tell the framework what data is being produced
100  if (doTracker_) {
102  }
103  if (doMuon_) {
106  }
107 
108  // Create the alignment algorithm
109  edm::ParameterSet algoConfig = iConfig.getParameter<edm::ParameterSet>( "algoConfig" );
110  std::string algoName = algoConfig.getParameter<std::string>("algoName");
111  theAlignmentAlgo = AlignmentAlgorithmPluginFactory::get( )->create( algoName, algoConfig );
112 
113  // Check if found
114  if ( !theAlignmentAlgo )
115  throw cms::Exception("BadConfig") << "Couldn't find algorithm called " << algoName;
116 
117  edm::ParameterSet monitorConfig = iConfig.getParameter<edm::ParameterSet>( "monitorConfig" );
118  std::vector<std::string> monitors = monitorConfig.getUntrackedParameter<std::vector<std::string> >( "monitors" );
119 
120  for (std::vector<std::string>::const_iterator miter = monitors.begin(); miter != monitors.end(); ++miter) {
121  AlignmentMonitorBase* newMonitor = AlignmentMonitorPluginFactory::get()->create(*miter, monitorConfig.getUntrackedParameter<edm::ParameterSet>(*miter));
122 
123  if (!newMonitor) throw cms::Exception("BadConfig") << "Couldn't find monitor named " << *miter;
124 
125  theMonitors.push_back(newMonitor);
126  }
127 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
const bool applyDbDeformations_
const bool doMisalignmentScenario_
AlignmentAlgorithmBase * theAlignmentAlgo
virtual boost::shared_ptr< TrackerGeometry > produceTracker(const TrackerDigiGeometryRecord &iRecord)
Produce the tracker geometry.
virtual boost::shared_ptr< DTGeometry > produceDT(const MuonGeometryRecord &iRecord)
Produce the muon DT geometry.
edm::ParameterSet theParameterSet
const edm::InputTag tkLasBeamTag_
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
const bool applyDbAlignment_
const unsigned int theMaxLoops
AlignableExtras * theAlignableExtras
const edm::InputTag clusterValueMapTag_
std::vector< AlignmentMonitorBase * > theMonitors
AlignmentParameterStore * theAlignmentParameterStore
const edm::InputTag beamSpotTag_
const edm::InputTag tjTkAssociationMapTag_
AlignableMuon * theAlignableMuon
const bool saveDeformationsToDB_
const double stRandomShift_
virtual boost::shared_ptr< CSCGeometry > produceCSC(const MuonGeometryRecord &iRecord)
Produce the muon CSC geometry.
AlignableTracker * theAlignableTracker
const Alignments * globalPositions_
GlobalPositions that might be read from DB, NULL otherwise.
T get(const Candidate &c)
Definition: component.h:56
const double stRandomRotation_
AlignmentProducer::~AlignmentProducer ( )

Destructor.

Definition at line 132 of file AlignmentProducer.cc.

References globalPositions_, theAlignableExtras, theAlignableMuon, theAlignableTracker, and theAlignmentParameterStore.

133 {
135  delete theAlignableExtras;
136  delete theAlignableTracker;
137  delete theAlignableMuon;
138 
139  delete globalPositions_;
140 }
AlignableExtras * theAlignableExtras
AlignmentParameterStore * theAlignmentParameterStore
AlignableMuon * theAlignableMuon
AlignableTracker * theAlignableTracker
const Alignments * globalPositions_
GlobalPositions that might be read from DB, NULL otherwise.

Member Function Documentation

void AlignmentProducer::addSurveyInfo_ ( Alignable ali)
private

Add survey info to an alignable.

Definition at line 614 of file AlignmentProducer.cc.

References Alignable::alignableObjectId(), Alignable::components(), error, edm::hlt::Exception, i, Alignable::id(), AlignableSurface::length(), Alignments::m_align, SurveyErrors::m_surveyErrors, SurveyError::matrix(), pos, SurveyError::rawId(), AlignableSurface::setLength(), Alignable::setSurvey(), AlignableSurface::setWidth(), SurveyError::structureType(), Alignable::surface(), theSurveyErrors, theSurveyIndex, theSurveyValues, and AlignableSurface::width().

Referenced by readInSurveyRcds().

615 {
616  const std::vector<Alignable*>& comp = ali->components();
617 
618  unsigned int nComp = comp.size();
619 
620  for (unsigned int i = 0; i < nComp; ++i) addSurveyInfo_(comp[i]);
621 
623 
624  if ( ali->id() != error.rawId() ||
625  ali->alignableObjectId() != error.structureType() )
626  {
627  throw cms::Exception("DatabaseError")
628  << "Error reading survey info from DB. Mismatched id!";
629  }
630 
631  const CLHEP::Hep3Vector& pos = theSurveyValues->m_align[theSurveyIndex].translation();
632  const CLHEP::HepRotation& rot = theSurveyValues->m_align[theSurveyIndex].rotation();
633 
634  AlignableSurface surf( align::PositionType( pos.x(), pos.y(), pos.z() ),
635  align::RotationType( rot.xx(), rot.xy(), rot.xz(),
636  rot.yx(), rot.yy(), rot.yz(),
637  rot.zx(), rot.zy(), rot.zz() ) );
638 
639  surf.setWidth( ali->surface().width() );
640  surf.setLength( ali->surface().length() );
641 
642  ali->setSurvey( new SurveyDet( surf, error.matrix() ) );
643 
644  ++theSurveyIndex;
645 }
align::Scalar width() const
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:180
int i
Definition: DBlmapReader.cc:9
ErrorMatrix matrix() const
Definition: SurveyError.h:72
const Alignments * theSurveyValues
void addSurveyInfo_(Alignable *)
Add survey info to an alignable.
uint8_t structureType() const
Definition: SurveyError.h:62
virtual Alignables components() const =0
Return vector of all direct components.
std::vector< AlignTransform > m_align
Definition: Alignments.h:14
unsigned int theSurveyIndex
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
align::ID rawId() const
Definition: SurveyError.h:67
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:126
const SurveyErrors * theSurveyErrors
align::Scalar length() const
void setSurvey(const SurveyDet *)
Set survey info.
Definition: Alignable.cc:243
std::vector< SurveyError > m_surveyErrors
Definition: SurveyErrors.h:21
template<class G , class Rcd , class ErrRcd >
void AlignmentProducer::applyDB ( G *  geometry,
const edm::EventSetup iSetup,
const AlignTransform globalPosition 
) const
private

Apply DB constants belonging to (Err)Rcd to geometry, taking into account 'globalPosition' correction.

Definition at line 713 of file AlignmentProducer.cc.

References GeometryAligner::applyAlignments(), geometry, and edm::EventSetup::get().

715 {
716  // 'G' is the geometry class for that DB should be applied,
717  // 'Rcd' is the record class for its Alignments
718  // 'ErrRcd' is the record class for its AlignmentErrors
719  // 'globalCoordinates' are global transformation for this geometry
720  edm::ESHandle<Alignments> alignments;
721  iSetup.get<Rcd>().get(alignments);
722 
723  edm::ESHandle<AlignmentErrors> alignmentErrors;
724  iSetup.get<ErrRcd>().get(alignmentErrors);
725 
726  GeometryAligner aligner;
727  aligner.applyAlignments<G>(geometry, &(*alignments), &(*alignmentErrors),
728  globalCoordinates);
729 }
Class to update a given geometry with a set of alignments.
void applyAlignments(C *geometry, const Alignments *alignments, const AlignmentErrors *alignmentErrors, const AlignTransform &globalCoordinates)
const T & get() const
Definition: EventSetup.h:55
ESHandle< TrackerGeometry > geometry
template<class G , class DeformationRcd >
void AlignmentProducer::applyDB ( G *  geometry,
const edm::EventSetup iSetup 
) const
private

Apply DB constants for surface deformations.

Definition at line 736 of file AlignmentProducer.cc.

References GeometryAligner::attachSurfaceDeformations(), geometry, and edm::EventSetup::get().

737 {
738  // 'G' is the geometry class for that DB should be applied,
739  // 'DeformationRcd' is the record class for its surface deformations
741  iSetup.get<DeformationRcd>().get(surfaceDeformations);
742 
743  GeometryAligner aligner;
744  aligner.attachSurfaceDeformations<G>(geometry, &(*surfaceDeformations));
745 }
Class to update a given geometry with a set of alignments.
void attachSurfaceDeformations(C *geometry, const AlignmentSurfaceDeformations *surfaceDeformations)
const T & get() const
Definition: EventSetup.h:55
ESHandle< TrackerGeometry > geometry
void AlignmentProducer::beginLuminosityBlock ( const edm::LuminosityBlock lumiBlock,
const edm::EventSetup setup 
)
virtual

Called at lumi block start, calling algorithm's beginLuminosityBlock.

Reimplemented from edm::EDLooperBase.

Definition at line 506 of file AlignmentProducer.cc.

References AlignmentAlgorithmBase::beginLuminosityBlock(), and theAlignmentAlgo.

508 {
509  theAlignmentAlgo->beginLuminosityBlock(setup); // do not forward edm::LuminosityBlock
510 }
virtual void beginLuminosityBlock(const edm::EventSetup &setup)
called at begin of luminosity block (no lumi block info passed yet)
AlignmentAlgorithmBase * theAlignmentAlgo
void AlignmentProducer::beginOfJob ( const edm::EventSetup iSetup)
virtual

Called at beginning of job.

Reimplemented from edm::EDLooperBase.

Definition at line 173 of file AlignmentProducer.cc.

References align::AlignableMuon, AlignmentParameterStore_cfi::AlignmentParameterStore, applyDbAlignment_, applyDbDeformations_, MuonScenarioBuilder::applyScenario(), TrackerScenarioBuilder::applyScenario(), createGeometries_(), align::DetectorGlobalPosition(), doMisalignmentScenario_, doMuon_, doTracker_, edm::EventSetup::get(), edm::ParameterSet::getParameter(), globalPositions_, AlignmentAlgorithmBase::initialize(), DetId::Muon, simpleMisalignment_(), stNFixAlignables_, stRandomRotation_, stRandomShift_, theAlignableExtras, theAlignableMuon, theAlignableTracker, theAlignmentAlgo, theAlignmentParameterStore, theMonitors, theMuonCSC, theMuonDT, theParameterSet, theTracker, DetId::Tracker, and useExtras_.

174 {
175  edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::beginOfJob";
176 
177  // Create the geometries from the ideal geometries (first time only)
178  this->createGeometries_( iSetup );
179 
180  // Retrieve and apply alignments, if requested (requires DB setup)
181  if ( applyDbAlignment_ ) {
182  // we need GlobalPositionRcd - and have to keep track for later removal
183  // before writing again to DB...
184  edm::ESHandle<Alignments> globalPositionRcd;
185  iSetup.get<GlobalPositionRcd>().get(globalPositionRcd);
186  globalPositions_ = new Alignments(*globalPositionRcd);
187 
188  if ( doTracker_ ) { // apply to tracker
189  this->applyDB<TrackerGeometry,TrackerAlignmentRcd,TrackerAlignmentErrorRcd>
190  (&(*theTracker), iSetup,
192  }
193 
194  if ( doMuon_ ) { // apply to tracker
195  this->applyDB<DTGeometry,DTAlignmentRcd,DTAlignmentErrorRcd>
196  (&(*theMuonDT), iSetup,
198  this->applyDB<CSCGeometry,CSCAlignmentRcd,CSCAlignmentErrorRcd>
199  (&(*theMuonCSC), iSetup,
201  }
202  }
203 
204  if ( applyDbDeformations_ && doTracker_ ) {
205  this->applyDB<TrackerGeometry,TrackerSurfaceDeformationRcd>(&(*theTracker), iSetup);
206  }
207 
208  // Create alignable tracker and muon
209  if (doTracker_) {
210  theAlignableTracker = new AlignableTracker( &(*theTracker) );
211  }
212 
213  if (doMuon_) {
214  theAlignableMuon = new AlignableMuon( &(*theMuonDT), &(*theMuonCSC) );
215  }
216 
217  if (useExtras_) {
219  }
220 
221  // Create alignment parameter builder
222  edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::beginOfJob"
223  << "Creating AlignmentParameterBuilder";
224  edm::ParameterSet aliParamBuildCfg =
225  theParameterSet.getParameter<edm::ParameterSet>("ParameterBuilder");
226  AlignmentParameterBuilder alignmentParameterBuilder(theAlignableTracker,
229  aliParamBuildCfg );
230  // Fix alignables if requested
231  if (stNFixAlignables_>0) alignmentParameterBuilder.fixAlignables(stNFixAlignables_);
232 
233  // Get list of alignables
234  Alignables theAlignables = alignmentParameterBuilder.alignables();
235  edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::beginOfJob"
236  << "got " << theAlignables.size() << " alignables";
237 
238  // Create AlignmentParameterStore
239  edm::ParameterSet aliParamStoreCfg =
241  theAlignmentParameterStore = new AlignmentParameterStore(theAlignables, aliParamStoreCfg);
242  edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::beginOfJob"
243  << "AlignmentParameterStore created!";
244 
245  // Apply misalignment scenario to alignable tracker and muon if requested
246  // WARNING: this assumes scenarioConfig can be passed to both muon and tracker
248  edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::beginOfJob"
249  << "Applying misalignment scenario to "
250  << (doTracker_ ? "tracker" : "")
251  << (doMuon_ ? (doTracker_ ? " and muon" : "muon") : ".");
252  edm::ParameterSet scenarioConfig
253  = theParameterSet.getParameter<edm::ParameterSet>( "MisalignmentScenario" );
254  if (doTracker_) {
255  TrackerScenarioBuilder scenarioBuilder( theAlignableTracker );
256  scenarioBuilder.applyScenario( scenarioConfig );
257  }
258  if (doMuon_) {
259  MuonScenarioBuilder muonScenarioBuilder( theAlignableMuon );
260  muonScenarioBuilder.applyScenario( scenarioConfig );
261  }
262  } else {
263  edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::beginOfJob"
264  << "NOT applying misalignment scenario!";
265  }
266 
267  // Apply simple misalignment
268  const std::string sParSel(theParameterSet.getParameter<std::string>("parameterSelectorSimple"));
269  this->simpleMisalignment_(theAlignables, sParSel, stRandomShift_, stRandomRotation_, true);
270 
271  // Initialize alignment algorithm
272  theAlignmentAlgo->initialize( iSetup,
274  theAlignmentParameterStore );
275 
276  for (std::vector<AlignmentMonitorBase*>::const_iterator monitor = theMonitors.begin();
277  monitor != theMonitors.end(); ++monitor) {
278  (*monitor)->beginOfJob(theAlignableTracker, theAlignableMuon, theAlignmentParameterStore);
279  }
280 }
std::vector< Alignable * > Alignables
T getParameter(std::string const &) const
const bool applyDbDeformations_
const bool doMisalignmentScenario_
Builds a scenario from configuration and applies it to the alignable Muon.
AlignmentAlgorithmBase * theAlignmentAlgo
void simpleMisalignment_(const Alignables &alivec, const std::string &selection, float shift, float rot, bool local)
Apply random shifts and rotations to selected alignables, according to configuration.
edm::ParameterSet theParameterSet
void createGeometries_(const edm::EventSetup &)
Create tracker and muon geometries.
const bool applyDbAlignment_
AlignableExtras * theAlignableExtras
boost::shared_ptr< CSCGeometry > theMuonCSC
std::vector< AlignmentMonitorBase * > theMonitors
AlignmentParameterStore * theAlignmentParameterStore
virtual void initialize(const edm::EventSetup &setup, AlignableTracker *tracker, AlignableMuon *muon, AlignableExtras *extras, AlignmentParameterStore *store)=0
Call at beginning of job (must be implemented in derived class)
Definition: DetId.h:20
AlignableMuon * theAlignableMuon
const double stRandomShift_
const T & get() const
Definition: EventSetup.h:55
AlignableTracker * theAlignableTracker
const AlignTransform & DetectorGlobalPosition(const Alignments &allGlobals, const DetId &id)
Builds a scenario from configuration and applies it to the alignable tracker.
const Alignments * globalPositions_
GlobalPositions that might be read from DB, NULL otherwise.
const double stRandomRotation_
void AlignmentProducer::beginRun ( const edm::Run run,
const edm::EventSetup setup 
)
virtual

Called at run start and calling algorithms beginRun.

Reimplemented from edm::EDLooperBase.

Definition at line 481 of file AlignmentProducer.cc.

References AlignmentAlgorithmBase::beginRun(), and theAlignmentAlgo.

482 {
483  theAlignmentAlgo->beginRun(setup); // do not forward edm::Run...
484 }
virtual void beginRun(const edm::EventSetup &setup)
called at begin of run
AlignmentAlgorithmBase * theAlignmentAlgo
void AlignmentProducer::createGeometries_ ( const edm::EventSetup iSetup)
private

Create tracker and muon geometries.

Definition at line 590 of file AlignmentProducer.cc.

References TrackerGeomBuilderFromGeometricDet::build(), CSCGeometryBuilderFromDDD::build(), DTGeometryBuilderFromDDD::build(), doMuon_, doTracker_, edm::EventSetup::get(), theMuonCSC, theMuonDT, and theTracker.

Referenced by beginOfJob().

591 {
593  iSetup.get<IdealGeometryRecord>().get( cpv );
594 
595  if (doTracker_) {
596  edm::ESHandle<GeometricDet> geometricDet;
597  iSetup.get<IdealGeometryRecord>().get( geometricDet );
598  TrackerGeomBuilderFromGeometricDet trackerBuilder;
599  theTracker = boost::shared_ptr<TrackerGeometry>( trackerBuilder.build(&(*geometricDet)) );
600  }
601 
602  if (doMuon_) {
604  iSetup.get<MuonNumberingRecord>().get(mdc);
605  DTGeometryBuilderFromDDD DTGeometryBuilder;
607  theMuonDT = boost::shared_ptr<DTGeometry>(new DTGeometry );
608  DTGeometryBuilder.build( theMuonDT, &(*cpv), *mdc);
609  theMuonCSC = boost::shared_ptr<CSCGeometry>( new CSCGeometry );
610  CSCGeometryBuilder.build( theMuonCSC, &(*cpv), *mdc );
611  }
612 }
boost::shared_ptr< TrackerGeometry > theTracker
void build(boost::shared_ptr< CSCGeometry > geom, const DDCompactView *fv, const MuonDDDConstants &muonConstants)
Build the geometry.
boost::shared_ptr< CSCGeometry > theMuonCSC
boost::shared_ptr< DTGeometry > theMuonDT
void build(boost::shared_ptr< DTGeometry > theGeometry, const DDCompactView *cview, const MuonDDDConstants &muonConstants)
const T & get() const
Definition: EventSetup.h:55
TrackerGeometry * build(const GeometricDet *gd)
edm::EDLooper::Status AlignmentProducer::duringLoop ( const edm::Event event,
const edm::EventSetup setup 
)
virtual

Called at each event.

Implements edm::EDLooper.

Definition at line 419 of file AlignmentProducer.cc.

References ExpressReco_HICollisions_FallBack::beamSpot, beamSpotTag_, clusterValueMapTag_, edm::InputTag::encode(), ZMuMuCategoriesSequences_cff::eventInfo, edm::Event::getByLabel(), i, edm::EventBase::id(), AlignableExtras::initializeBeamSpot(), edm::EDLooperBase::kContinue, nevent_, readInSurveyRcds(), AlignmentAlgorithmBase::run(), theAlignableExtras, theAlignmentAlgo, theMonitors, and tjTkAssociationMapTag_.

421 {
422  ++nevent_;
423 
424  // reading in survey records
425  this->readInSurveyRcds(setup);
426 
427  // Printout event number
428  for ( int i=10; i<10000000; i*=10 )
429  if ( nevent_<10*i && (nevent_%i)==0 )
430  edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::duringLoop"
431  << "Events processed: " << nevent_;
432 
433  // Retrieve trajectories and tracks from the event
434  // -> merely skip if collection is empty
436  if (event.getByLabel(tjTkAssociationMapTag_, m_TrajTracksMap)) {
437 
438  // Form pairs of trajectories and tracks
439  ConstTrajTrackPairCollection trajTracks;
440  for ( TrajTrackAssociationCollection::const_iterator iPair = m_TrajTracksMap->begin();
441  iPair != m_TrajTracksMap->end(); ++iPair) {
442  trajTracks.push_back( ConstTrajTrackPair( &(*(*iPair).key), &(*(*iPair).val) ) );
443  }
445  event.getByLabel(beamSpotTag_, beamSpot);
446 
447  if (nevent_==1 && theAlignableExtras) {
448  edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::duringLoop"
449  << "initializing AlignableBeamSpot" << std::endl;
450  theAlignableExtras->initializeBeamSpot(beamSpot->x0(), beamSpot->y0(), beamSpot->z0(),
451  beamSpot->dxdz(), beamSpot->dydz());
452  }
453 
454  // Run the alignment algorithm with its input
455  const AliClusterValueMap *clusterValueMapPtr = 0;
456  if(clusterValueMapTag_.encode().size()){//check that the input tag is not empty
457  edm::Handle<AliClusterValueMap> clusterValueMap;
458  event.getByLabel(clusterValueMapTag_, clusterValueMap);
459  clusterValueMapPtr = &(*clusterValueMap);
460  }
461 
462  const AlignmentAlgorithmBase::EventInfo eventInfo(event.id(), trajTracks, *beamSpot,
463  clusterValueMapPtr);
464  theAlignmentAlgo->run(setup, eventInfo);
465 
466 
467  for (std::vector<AlignmentMonitorBase*>::const_iterator monitor = theMonitors.begin();
468  monitor != theMonitors.end(); ++monitor) {
469  (*monitor)->duringLoop(event, setup, trajTracks); // forward eventInfo?
470  }
471  } else {
472  edm::LogError("Alignment") << "@SUB=AlignmentProducer::duringLoop"
473  << "No track collection found: skipping event";
474  }
475 
476 
477  return kContinue;
478 }
int i
Definition: DBlmapReader.cc:9
virtual void run(const edm::EventSetup &setup, const EventInfo &eventInfo)=0
Run the algorithm (must be implemented in derived class)
AlignmentAlgorithmBase * theAlignmentAlgo
void readInSurveyRcds(const edm::EventSetup &)
read in survey records
std::string encode() const
Definition: InputTag.cc:72
AlignableExtras * theAlignableExtras
const edm::InputTag clusterValueMapTag_
std::vector< AlignmentMonitorBase * > theMonitors
void initializeBeamSpot(double x, double y, double z, double dxdz, double dydz)
Initialize the alignable beam spot with the given parameters.
const edm::InputTag beamSpotTag_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
const edm::InputTag tjTkAssociationMapTag_
std::vector< ConstTrajTrackPair > ConstTrajTrackPairCollection
edm::EventID id() const
Definition: EventBase.h:56
std::pair< const Trajectory *, const reco::Track * > ConstTrajTrackPair
define event information passed to algorithms
void AlignmentProducer::endLuminosityBlock ( const edm::LuminosityBlock lumiBlock,
const edm::EventSetup setup 
)
virtual

Called at lumi block end, calling algorithm's endLuminosityBlock.

Reimplemented from edm::EDLooperBase.

Definition at line 513 of file AlignmentProducer.cc.

References AlignmentAlgorithmBase::endLuminosityBlock(), and theAlignmentAlgo.

515 {
516  theAlignmentAlgo->endLuminosityBlock(setup); // do not forward edm::LuminosityBlock
517 }
AlignmentAlgorithmBase * theAlignmentAlgo
virtual void endLuminosityBlock(const edm::EventSetup &setup)
called at end of luminosity block (no lumi block info passed yet)
void AlignmentProducer::endOfJob ( )
virtual

Called at end of job.

Reimplemented from edm::EDLooperBase.

Definition at line 284 of file AlignmentProducer.cc.

References AlignableTracker::alignmentErrors(), AlignableTracker::alignments(), AlignableMuon::cscAlignmentErrors(), AlignableMuon::cscAlignments(), align::DetectorGlobalPosition(), doMuon_, doTracker_, AlignableMuon::dtAlignmentErrors(), AlignableMuon::dtAlignments(), AlignableExtras::dump(), globalPositions_, DetId::Muon, nevent_, saveApeToDB_, saveDeformationsToDB_, saveToDB_, Alignable::surfaceDeformations(), theAlignableExtras, theAlignableMuon, theAlignableTracker, theMonitors, DetId::Tracker, and writeDB().

285 {
286  edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::endOfJob";
287 
288  for (std::vector<AlignmentMonitorBase*>::const_iterator monitor = theMonitors.begin(); monitor != theMonitors.end(); ++monitor) {
289  (*monitor)->endOfJob();
290  }
291 
292  if (0 == nevent_) {
293  edm::LogError("Alignment") << "@SUB=AlignmentProducer::endOfJob" << "Did not process any "
294  << "events in last loop, do not dare to store to DB.";
295  } else {
296 
297  // Save alignments to database
298  if (saveToDB_ || saveApeToDB_) {
299 
300  if ( doTracker_ ) { // first tracker
301  const AlignTransform *trackerGlobal = 0; // will be 'removed' from constants
302  if (globalPositions_) { // i.e. applied before in applyDB
305  }
306  // Get alignments+errors - ownership taken over by writeDB(..), so no delete
307  Alignments *alignments = theAlignableTracker->alignments();
309  this->writeDB(alignments, "TrackerAlignmentRcd",
310  alignmentErrors, "TrackerAlignmentErrorRcd", trackerGlobal);
311  }
312 
313  if ( doMuon_ ) { // now muon
314  const AlignTransform *muonGlobal = 0; // will be 'removed' from constants
315  if (globalPositions_) { // i.e. applied before in applyDB
317  DetId(DetId::Muon));
318  }
319  // Get alignments+errors, first DT - ownership taken over by writeDB(..), so no delete
320  Alignments *alignments = theAlignableMuon->dtAlignments();
321  AlignmentErrors *alignmentErrors = theAlignableMuon->dtAlignmentErrors();
322  this->writeDB(alignments, "DTAlignmentRcd",
323  alignmentErrors, "DTAlignmentErrorRcd", muonGlobal);
324 
325  // Get alignments+errors, now CSC - ownership taken over by writeDB(..), so no delete
326  alignments = theAlignableMuon->cscAlignments();
327  alignmentErrors = theAlignableMuon->cscAlignmentErrors();
328  this->writeDB(alignments, "CSCAlignmentRcd",
329  alignmentErrors, "CSCAlignmentErrorRcd", muonGlobal);
330  }
331 
332  // Save surface deformations to database
334  AlignmentSurfaceDeformations *alignmentSurfaceDeformations = theAlignableTracker->surfaceDeformations();
335  this->writeDB(alignmentSurfaceDeformations, "TrackerSurfaceDeformationRcd");
336  }
337 
338  }
339  }
340 
342 }
AlignmentErrors * dtAlignmentErrors()
AlignableExtras * theAlignableExtras
Alignments * dtAlignments()
AlignmentErrors * alignmentErrors() const
Return alignment errors, sorted by DetId.
AlignmentErrors * cscAlignmentErrors()
std::vector< AlignmentMonitorBase * > theMonitors
AlignmentSurfaceDeformations * surfaceDeformations() const
Return surface deformations, sorted by DetId.
Definition: Alignable.cc:214
Definition: DetId.h:20
AlignableMuon * theAlignableMuon
const bool saveDeformationsToDB_
Alignments * cscAlignments()
void dump(void) const
void writeDB(Alignments *alignments, const std::string &alignRcd, AlignmentErrors *alignmentErrors, const std::string &errRcd, const AlignTransform *globalCoordinates) const
AlignableTracker * theAlignableTracker
const AlignTransform & DetectorGlobalPosition(const Alignments &allGlobals, const DetId &id)
Alignments * alignments() const
Return alignments, sorted by DetId.
const Alignments * globalPositions_
GlobalPositions that might be read from DB, NULL otherwise.
edm::EDLooper::Status AlignmentProducer::endOfLoop ( const edm::EventSetup iSetup,
unsigned int  iLoop 
)
virtual

Called at end of loop.

Implements edm::EDLooperBase.

Definition at line 388 of file AlignmentProducer.cc.

References edm::EDLooperBase::kContinue, edm::EDLooperBase::kStop, nevent_, AlignmentAlgorithmBase::terminate(), theAlignmentAlgo, theMaxLoops, and theMonitors.

389 {
390 
391  if (0 == nevent_) {
392  // beginOfJob is usually called by the framework in the first event of the first loop
393  // (a hack: beginOfJob needs the EventSetup that is not well defined without an event)
394  // and the algorithms rely on the initialisations done in beginOfJob. We cannot call
395  // this->beginOfJob(iSetup); here either since that will access the EventSetup to get
396  // some geometry information that is not defined either without having seen an event.
397  edm::LogError("Alignment") << "@SUB=AlignmentProducer::endOfLoop"
398  << "Did not process any events in loop " << iLoop
399  << ", stop processing without terminating algorithm.";
400  return kStop;
401  }
402 
403  edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::endOfLoop"
404  << "Ending loop " << iLoop << ", terminating algorithm.";
405 
407 
408  for (std::vector<AlignmentMonitorBase*>::const_iterator monitor = theMonitors.begin(); monitor != theMonitors.end(); ++monitor) {
409  (*monitor)->endOfLoop(iSetup);
410  }
411 
412  if ( iLoop == theMaxLoops-1 || iLoop >= theMaxLoops ) return kStop;
413  else return kContinue;
414 }
virtual void terminate()=0
Call at end of job (must be implemented in derived class)
AlignmentAlgorithmBase * theAlignmentAlgo
const unsigned int theMaxLoops
std::vector< AlignmentMonitorBase * > theMonitors
void AlignmentProducer::endRun ( const edm::Run run,
const edm::EventSetup setup 
)
virtual

Called at run end - currently reading TkFittedLasBeam if an InpuTag is given for that.

Reimplemented from edm::EDLooperBase.

Definition at line 487 of file AlignmentProducer.cc.

References edm::InputTag::encode(), AlignmentAlgorithmBase::endRun(), edm::Run::getByLabel(), edm::RunBase::id(), theAlignmentAlgo, and tkLasBeamTag_.

488 {
489  // call with or without las beam info...
490  typedef AlignmentAlgorithmBase::EndRunInfo EndRunInfo;
491  if (tkLasBeamTag_.encode().size()) { // non-empty InputTag
494  run.getByLabel(tkLasBeamTag_, lasBeams);
495  run.getByLabel(tkLasBeamTag_, tsoses);
496 
497  theAlignmentAlgo->endRun(EndRunInfo(run.id(), &(*lasBeams), &(*tsoses)), setup);
498  } else {
499  edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::endRun"
500  << "No Tk LAS beams to forward to algorithm.";
501  theAlignmentAlgo->endRun(EndRunInfo(run.id(), 0, 0), setup);
502  }
503 }
bool getByLabel(std::string const &label, Handle< PROD > &result) const
Definition: Run.h:174
RunID const & id() const
Definition: RunBase.h:43
AlignmentAlgorithmBase * theAlignmentAlgo
const edm::InputTag tkLasBeamTag_
std::string encode() const
Definition: InputTag.cc:72
virtual void endRun(const EndRunInfo &runInfo, const edm::EventSetup &setup)
called at end of run - order of arguments like in EDProducer etc.
define run information passed to algorithms (in endRun)
boost::shared_ptr< CSCGeometry > AlignmentProducer::produceCSC ( const MuonGeometryRecord iRecord)
virtual

Produce the muon CSC geometry.

Definition at line 164 of file AlignmentProducer.cc.

References theMuonCSC.

Referenced by AlignmentProducer().

165 {
166  edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::produceCSC";
167  return theMuonCSC;
168 }
boost::shared_ptr< CSCGeometry > theMuonCSC
boost::shared_ptr< DTGeometry > AlignmentProducer::produceDT ( const MuonGeometryRecord iRecord)
virtual

Produce the muon DT geometry.

Definition at line 155 of file AlignmentProducer.cc.

References theMuonDT.

Referenced by AlignmentProducer().

156 {
157  edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::produceDT";
158  return theMuonDT;
159 }
boost::shared_ptr< DTGeometry > theMuonDT
boost::shared_ptr< TrackerGeometry > AlignmentProducer::produceTracker ( const TrackerDigiGeometryRecord iRecord)
virtual

Produce the tracker geometry.

Definition at line 146 of file AlignmentProducer.cc.

References theTracker.

Referenced by AlignmentProducer().

147 {
148  edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::produceTracker";
149  return theTracker;
150 }
boost::shared_ptr< TrackerGeometry > theTracker
void AlignmentProducer::readInSurveyRcds ( const edm::EventSetup iSetup)
private

read in survey records

Definition at line 647 of file AlignmentProducer.cc.

References addSurveyInfo_(), edm::ESWatcher< T >::check(), AlignableMuon::CSCEndcaps(), doMuon_, doTracker_, AlignableMuon::DTBarrel(), edm::EventSetup::get(), theAlignableMuon, theAlignableTracker, theSurveyErrors, theSurveyIndex, theSurveyValues, useSurvey_, watchTkSurveyErrRcd_, and watchTkSurveyRcd_.

Referenced by duringLoop().

647  {
648 
649  // Get Survey Rcds and add Survey Info
650  if ( doTracker_ && useSurvey_ ){
651  bool tkSurveyBool = watchTkSurveyRcd_.check(iSetup);
652  bool tkSurveyErrBool = watchTkSurveyErrRcd_.check(iSetup);
653  edm::LogInfo("Alignment") << "watcher tksurveyrcd: " << tkSurveyBool;
654  edm::LogInfo("Alignment") << "watcher tksurveyerrrcd: " << tkSurveyErrBool;
655  if ( tkSurveyBool || tkSurveyErrBool){
656 
657  edm::LogInfo("Alignment") << "ADDING THE SURVEY INFORMATION";
659  edm::ESHandle<SurveyErrors> surveyErrors;
660 
661  iSetup.get<TrackerSurveyRcd>().get(surveys);
662  iSetup.get<TrackerSurveyErrorRcd>().get(surveyErrors);
663 
664  theSurveyIndex = 0;
665  theSurveyValues = &*surveys;
666  theSurveyErrors = &*surveyErrors;
668  }
669  }
670 
671  if ( doMuon_ && useSurvey_) {
672  bool DTSurveyBool = watchTkSurveyRcd_.check(iSetup);
673  bool DTSurveyErrBool = watchTkSurveyErrRcd_.check(iSetup);
674  bool CSCSurveyBool = watchTkSurveyRcd_.check(iSetup);
675  bool CSCSurveyErrBool = watchTkSurveyErrRcd_.check(iSetup);
676 
677  if ( DTSurveyBool || DTSurveyErrBool || CSCSurveyBool || CSCSurveyErrBool ){
678  edm::ESHandle<Alignments> dtSurveys;
679  edm::ESHandle<SurveyErrors> dtSurveyErrors;
680  edm::ESHandle<Alignments> cscSurveys;
681  edm::ESHandle<SurveyErrors> cscSurveyErrors;
682 
683  iSetup.get<DTSurveyRcd>().get(dtSurveys);
684  iSetup.get<DTSurveyErrorRcd>().get(dtSurveyErrors);
685  iSetup.get<CSCSurveyRcd>().get(cscSurveys);
686  iSetup.get<CSCSurveyErrorRcd>().get(cscSurveyErrors);
687 
688  theSurveyIndex = 0;
689  theSurveyValues = &*dtSurveys;
690  theSurveyErrors = &*dtSurveyErrors;
691  std::vector<Alignable*> barrels = theAlignableMuon->DTBarrel();
692  for (std::vector<Alignable*>::const_iterator iter = barrels.begin(); iter != barrels.end(); ++iter) {
693  addSurveyInfo_(*iter);
694  }
695 
696  theSurveyIndex = 0;
697  theSurveyValues = &*cscSurveys;
698  theSurveyErrors = &*cscSurveyErrors;
699  std::vector<Alignable*> endcaps = theAlignableMuon->CSCEndcaps();
700  for (std::vector<Alignable*>::const_iterator iter = endcaps.begin(); iter != endcaps.end(); ++iter) {
701  addSurveyInfo_(*iter);
702  }
703  }
704  }
705 
706 }
const Alignments * theSurveyValues
void addSurveyInfo_(Alignable *)
Add survey info to an alignable.
std::vector< Alignable * > CSCEndcaps()
unsigned int theSurveyIndex
const SurveyErrors * theSurveyErrors
edm::ESWatcher< TrackerSurveyErrorRcd > watchTkSurveyErrRcd_
std::vector< Alignable * > DTBarrel()
AlignableMuon * theAlignableMuon
const T & get() const
Definition: EventSetup.h:55
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:59
edm::ESWatcher< TrackerSurveyRcd > watchTkSurveyRcd_
AlignableTracker * theAlignableTracker
void AlignmentProducer::simpleMisalignment_ ( const Alignables alivec,
const std::string &  selection,
float  shift,
float  rot,
bool  local 
)
private

Apply random shifts and rotations to selected alignables, according to configuration.

Definition at line 521 of file AlignmentProducer.cc.

References abs, Alignable::alignmentParameters(), AlignmentParameterSelector::convertParamSel(), RigidBodyAlignmentParameters::dalpha, RigidBodyAlignmentParameters::dbeta, RigidBodyAlignmentParameters::dgamma, RigidBodyAlignmentParameters::dx, RigidBodyAlignmentParameters::dy, RigidBodyAlignmentParameters::dz, edm::hlt::Exception, Alignable::move(), RigidBodyAlignmentParameters::N_PARAM, convertSQLitetoXML_cfg::output, csvReporter::r, random, Alignable::rotateInGlobalFrame(), Alignable::rotateInLocalFrame(), indexGen::s2, AlignmentParameters::selector(), Alignable::surface(), AlignableSurface::toGlobal(), and align::toMatrix().

Referenced by beginOfJob().

523 {
524 
525  std::ostringstream output; // collecting output
526 
527  if (shift > 0. || rot > 0.) {
528  output << "Adding random flat shift of max size " << shift
529  << " and adding random flat rotation of max size " << rot <<" to ";
530 
531  std::vector<bool> commSel(0);
532  if (selection != "-1") {
533  AlignmentParameterSelector aSelector(0,0); // no alignable needed here...
534  const std::vector<char> cSel(aSelector.convertParamSel(selection));
535  if (cSel.size() < RigidBodyAlignmentParameters::N_PARAM) {
536  throw cms::Exception("BadConfig")
537  << "[AlignmentProducer::simpleMisalignment_]\n"
538  << "Expect selection string '" << selection << "' to be at least of length "
539  << RigidBodyAlignmentParameters::N_PARAM << " or to be '-1'.\n"
540  << "(Most probably you have to adjust the parameter 'parameterSelectorSimple'.)";
541  }
542  for (std::vector<char>::const_iterator cIter = cSel.begin(); cIter != cSel.end(); ++cIter) {
543  commSel.push_back(*cIter == '0' ? false : true);
544  }
545  output << "parameters defined by (" << selection
546  << "), representing (x,y,z,alpha,beta,gamma),";
547  } else {
548  output << "the active parameters of each alignable,";
549  }
550  output << " in " << (local ? "local" : "global") << " frame.";
551 
552  for (std::vector<Alignable*>::const_iterator it = alivec.begin(); it != alivec.end(); ++it) {
553  Alignable* ali=(*it);
554  std::vector<bool> mysel(commSel.empty() ? ali->alignmentParameters()->selector() : commSel);
555 
556  if (std::abs(shift)>0.00001) {
557  double s0 = 0., s1 = 0., s2 = 0.;
558  if (mysel[RigidBodyAlignmentParameters::dx]) s0 = shift * double(random()%1000-500)/500.;
559  if (mysel[RigidBodyAlignmentParameters::dy]) s1 = shift * double(random()%1000-500)/500.;
560  if (mysel[RigidBodyAlignmentParameters::dz]) s2 = shift * double(random()%1000-500)/500.;
561 
562  if (local) ali->move( ali->surface().toGlobal(align::LocalVector(s0,s1,s2)) );
563  else ali->move( align::GlobalVector(s0,s1,s2) );
564 
565  //AlignmentPositionError ape(dx,dy,dz);
566  //ali->addAlignmentPositionError(ape);
567  }
568 
569  if (std::abs(rot)>0.00001) {
571  if (mysel[RigidBodyAlignmentParameters::dalpha]) r(1)=rot*double(random()%1000-500)/500.;
572  if (mysel[RigidBodyAlignmentParameters::dbeta]) r(2)=rot*double(random()%1000-500)/500.;
573  if (mysel[RigidBodyAlignmentParameters::dgamma]) r(3)=rot*double(random()%1000-500)/500.;
574 
575  const align::RotationType mrot = align::toMatrix(r);
576  if (local) ali->rotateInLocalFrame(mrot);
577  else ali->rotateInGlobalFrame(mrot);
578 
579  //ali->addAlignmentPositionErrorFromRotation(mrot);
580  }
581  } // end loop on alignables
582  } else {
583  output << "No simple misalignment added!";
584  }
585  edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::simpleMisalignment_" << output.str();
586 }
virtual void rotateInLocalFrame(const RotationType &rotation)
Rotation intepreted in the local reference frame.
Definition: Alignable.cc:89
#define abs(x)
Definition: mlp_lapack.h:159
virtual void move(const GlobalVector &displacement)=0
Movement with respect to the global reference frame.
const std::vector< bool > & selector(void) const
Get alignment parameter selector vector.
TRandom random
Definition: MVATrainer.cc:138
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:57
tuple s2
Definition: indexGen.py:106
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:126
AlgebraicVector EulerAngles
Definition: Definitions.h:36
virtual void rotateInGlobalFrame(const RotationType &rotation)=0
align::GlobalPoints toGlobal(const align::LocalPoints &) const
Return in global coord given a set of local points.
RotationType toMatrix(const EulerAngles &)
Convert rotation angles about x-, y-, z-axes to matrix.
Definition: Utilities.cc:40
static unsigned int const shift
void AlignmentProducer::startingNewLoop ( unsigned int  iLoop)
virtual

Called at beginning of loop.

Implements edm::EDLooperBase.

Definition at line 346 of file AlignmentProducer.cc.

References AlignableTracker::alignmentErrors(), AlignableTracker::alignments(), GeometryAligner::applyAlignments(), GeometryAligner::attachSurfaceDeformations(), AlignableMuon::cscAlignmentErrors(), AlignableMuon::cscAlignments(), doMuon_, doTracker_, AlignableMuon::dtAlignmentErrors(), AlignableMuon::dtAlignments(), nevent_, AlignmentAlgorithmBase::startNewLoop(), Alignable::surfaceDeformations(), theAlignableMuon, theAlignableTracker, theAlignmentAlgo, and theMonitors.

347 {
348  edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::startingNewLoop"
349  << "Starting loop number " << iLoop;
350 
351  nevent_ = 0;
352 
354 
355  for (std::vector<AlignmentMonitorBase*>::const_iterator monitor = theMonitors.begin(); monitor != theMonitors.end(); ++monitor) {
356  (*monitor)->startingNewLoop();
357  }
358 
359  edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::startingNewLoop"
360  << "Now physically apply alignments to geometry...";
361 
362 
363  // Propagate changes to reconstruction geometry (from initialisation or iteration)
364  GeometryAligner aligner;
365  if ( doTracker_ ) {
366  std::auto_ptr<Alignments> alignments(theAlignableTracker->alignments());
367  std::auto_ptr<AlignmentErrors> alignmentErrors(theAlignableTracker->alignmentErrors());
368  aligner.applyAlignments<TrackerGeometry>( &(*theTracker),&(*alignments),&(*alignmentErrors), AlignTransform() ); // don't apply global a second time!
369  std::auto_ptr<AlignmentSurfaceDeformations> aliDeforms(theAlignableTracker->surfaceDeformations());
370  aligner.attachSurfaceDeformations<TrackerGeometry>(&(*theTracker), &(*aliDeforms));
371 
372  }
373  if ( doMuon_ ) {
374  std::auto_ptr<Alignments> dtAlignments( theAlignableMuon->dtAlignments());
375  std::auto_ptr<AlignmentErrors> dtAlignmentErrors( theAlignableMuon->dtAlignmentErrors());
376  std::auto_ptr<Alignments> cscAlignments( theAlignableMuon->cscAlignments());
377  std::auto_ptr<AlignmentErrors> cscAlignmentErrors( theAlignableMuon->cscAlignmentErrors());
378 
379  aligner.applyAlignments<DTGeometry>( &(*theMuonDT), &(*dtAlignments), &(*dtAlignmentErrors), AlignTransform() ); // don't apply global a second time!
380  aligner.applyAlignments<CSCGeometry>( &(*theMuonCSC), &(*cscAlignments), &(*cscAlignmentErrors), AlignTransform() ); // nope!
381  }
382 }
AlignmentErrors * dtAlignmentErrors()
AlignmentAlgorithmBase * theAlignmentAlgo
Class to update a given geometry with a set of alignments.
Alignments * dtAlignments()
void attachSurfaceDeformations(C *geometry, const AlignmentSurfaceDeformations *surfaceDeformations)
AlignmentErrors * alignmentErrors() const
Return alignment errors, sorted by DetId.
AlignmentErrors * cscAlignmentErrors()
std::vector< AlignmentMonitorBase * > theMonitors
void applyAlignments(C *geometry, const Alignments *alignments, const AlignmentErrors *alignmentErrors, const AlignTransform &globalCoordinates)
AlignmentSurfaceDeformations * surfaceDeformations() const
Return surface deformations, sorted by DetId.
Definition: Alignable.cc:214
AlignableMuon * theAlignableMuon
Alignments * cscAlignments()
AlignableTracker * theAlignableTracker
Alignments * alignments() const
Return alignments, sorted by DetId.
void AlignmentProducer::writeDB ( Alignments alignments,
const std::string &  alignRcd,
AlignmentErrors alignmentErrors,
const std::string &  errRcd,
const AlignTransform globalCoordinates 
) const
private

Write alignment and/or errors to DB for record names (removes *globalCoordinates before writing if non-null...). Takes over ownership of alignments and alignmentErrrors.

Definition at line 749 of file AlignmentProducer.cc.

References cond::service::PoolDBOutputService::beginOfTime(), edm::hlt::Exception, edm::Service< T >::isAvailable(), GeometryAligner::removeGlobalTransform(), saveApeToDB_, saveToDB_, AlignTransform::transform(), and cond::service::PoolDBOutputService::writeOne().

Referenced by endOfJob().

754 {
755  Alignments * tempAlignments = alignments;
756  AlignmentErrors * tempAlignmentErrors = alignmentErrors;
757 
758  // Call service
760  if (!poolDb.isAvailable()) { // Die if not available
761  delete tempAlignments; // promised to take over ownership...
762  delete tempAlignmentErrors; // dito
763  throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
764  }
765 
766  if (globalCoordinates // happens only if (applyDbAlignment_ == true)
767  && globalCoordinates->transform() != AlignTransform::Transform::Identity) {
768 
769  tempAlignments = new Alignments(); // temporary storage for
770  tempAlignmentErrors = new AlignmentErrors(); // final alignments and errors
771 
772  GeometryAligner aligner;
773  aligner.removeGlobalTransform(alignments, alignmentErrors,
774  *globalCoordinates,
775  tempAlignments, tempAlignmentErrors);
776 
777  delete alignments; // have to delete original alignments
778  delete alignmentErrors; // same thing for the errors
779 
780  edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::writeDB"
781  << "globalCoordinates removed from alignments (" << alignRcd
782  << ") and errors (" << alignRcd << ").";
783  }
784 
785  if (saveToDB_) {
786  edm::LogInfo("Alignment") << "Writing Alignments to " << alignRcd << ".";
787  poolDb->writeOne<Alignments>(tempAlignments, poolDb->beginOfTime(), alignRcd);
788  } else { // poolDb->writeOne(..) takes over 'alignments' ownership,...
789  delete tempAlignments; // ...otherwise we have to delete, as promised!
790  }
791 
792  if (saveApeToDB_) {
793  edm::LogInfo("Alignment") << "Writing AlignmentErrors to " << errRcd << ".";
794  poolDb->writeOne<AlignmentErrors>(tempAlignmentErrors, poolDb->beginOfTime(), errRcd);
795  } else { // poolDb->writeOne(..) takes over 'alignmentErrors' ownership,...
796  delete tempAlignmentErrors; // ...otherwise we have to delete, as promised!
797  }
798 }
Class to update a given geometry with a set of alignments.
void removeGlobalTransform(const Alignments *alignments, const AlignmentErrors *alignmentErrors, const AlignTransform &globalCoordinates, Alignments *newAlignments, AlignmentErrors *newAlignmentErrors)
bool isAvailable() const
Definition: Service.h:47
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
Transform transform() const
void AlignmentProducer::writeDB ( AlignmentSurfaceDeformations alignmentSurfaceDeformations,
const std::string &  surfaceDeformationRcd 
) const
private

Write surface deformations (bows & kinks) to DB for given record name Takes over ownership of alignmentsurfaceDeformations.

Definition at line 802 of file AlignmentProducer.cc.

References cond::service::PoolDBOutputService::beginOfTime(), edm::hlt::Exception, edm::Service< T >::isAvailable(), saveDeformationsToDB_, and cond::service::PoolDBOutputService::writeOne().

804 {
805  // Call service
807  if (!poolDb.isAvailable()) { // Die if not available
808  delete alignmentSurfaceDeformations; // promised to take over ownership...
809  throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
810  }
811 
812  if (saveDeformationsToDB_) {
813  edm::LogInfo("Alignment") << "Writing AlignmentSurfaceDeformations to "
814  << surfaceDeformationRcd << ".";
815  poolDb->writeOne<AlignmentSurfaceDeformations>(alignmentSurfaceDeformations, poolDb->beginOfTime(),
816  surfaceDeformationRcd);
817  } else { // poolDb->writeOne(..) takes over 'surfaceDeformation' ownership,...
818  delete alignmentSurfaceDeformations; // ...otherwise we have to delete, as promised!
819  }
820 }
bool isAvailable() const
Definition: Service.h:47
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
const bool saveDeformationsToDB_

Member Data Documentation

const bool AlignmentProducer::applyDbAlignment_
private

Definition at line 167 of file AlignmentProducer.h.

Referenced by beginOfJob().

const bool AlignmentProducer::applyDbDeformations_
private

Definition at line 167 of file AlignmentProducer.h.

Referenced by beginOfJob().

const edm::InputTag AlignmentProducer::beamSpotTag_
private

Definition at line 174 of file AlignmentProducer.h.

Referenced by duringLoop().

const edm::InputTag AlignmentProducer::clusterValueMapTag_
private

Definition at line 176 of file AlignmentProducer.h.

Referenced by duringLoop().

const bool AlignmentProducer::doMisalignmentScenario_
private

Definition at line 167 of file AlignmentProducer.h.

Referenced by beginOfJob().

const bool AlignmentProducer::doMuon_
private
const bool AlignmentProducer::doTracker_
private
const Alignments* AlignmentProducer::globalPositions_
private

GlobalPositions that might be read from DB, NULL otherwise.

Definition at line 156 of file AlignmentProducer.h.

Referenced by beginOfJob(), endOfJob(), and ~AlignmentProducer().

int AlignmentProducer::nevent_
private

Definition at line 158 of file AlignmentProducer.h.

Referenced by duringLoop(), endOfJob(), endOfLoop(), and startingNewLoop().

const bool AlignmentProducer::saveApeToDB_
private

Definition at line 168 of file AlignmentProducer.h.

Referenced by endOfJob(), and writeDB().

const bool AlignmentProducer::saveDeformationsToDB_
private

Definition at line 168 of file AlignmentProducer.h.

Referenced by endOfJob(), and writeDB().

const bool AlignmentProducer::saveToDB_
private

Definition at line 168 of file AlignmentProducer.h.

Referenced by endOfJob(), and writeDB().

const int AlignmentProducer::stNFixAlignables_
private

Definition at line 165 of file AlignmentProducer.h.

Referenced by beginOfJob().

const double AlignmentProducer::stRandomRotation_
private

Definition at line 166 of file AlignmentProducer.h.

Referenced by beginOfJob().

const double AlignmentProducer::stRandomShift_
private

Definition at line 166 of file AlignmentProducer.h.

Referenced by beginOfJob().

AlignableExtras* AlignmentProducer::theAlignableExtras
private

Definition at line 148 of file AlignmentProducer.h.

Referenced by beginOfJob(), duringLoop(), endOfJob(), and ~AlignmentProducer().

AlignableMuon* AlignmentProducer::theAlignableMuon
private
AlignableTracker* AlignmentProducer::theAlignableTracker
private
AlignmentAlgorithmBase* AlignmentProducer::theAlignmentAlgo
private
AlignmentParameterStore* AlignmentProducer::theAlignmentParameterStore
private

Definition at line 146 of file AlignmentProducer.h.

Referenced by beginOfJob(), and ~AlignmentProducer().

const unsigned int AlignmentProducer::theMaxLoops
private

Definition at line 163 of file AlignmentProducer.h.

Referenced by endOfLoop().

std::vector<AlignmentMonitorBase*> AlignmentProducer::theMonitors
private
boost::shared_ptr<CSCGeometry> AlignmentProducer::theMuonCSC
private

Definition at line 154 of file AlignmentProducer.h.

Referenced by beginOfJob(), createGeometries_(), and produceCSC().

boost::shared_ptr<DTGeometry> AlignmentProducer::theMuonDT
private

Definition at line 153 of file AlignmentProducer.h.

Referenced by beginOfJob(), createGeometries_(), and produceDT().

edm::ParameterSet AlignmentProducer::theParameterSet
private

Definition at line 159 of file AlignmentProducer.h.

Referenced by beginOfJob().

const SurveyErrors* AlignmentProducer::theSurveyErrors
private

Definition at line 142 of file AlignmentProducer.h.

Referenced by addSurveyInfo_(), and readInSurveyRcds().

unsigned int AlignmentProducer::theSurveyIndex
private

Definition at line 140 of file AlignmentProducer.h.

Referenced by addSurveyInfo_(), and readInSurveyRcds().

const Alignments* AlignmentProducer::theSurveyValues
private

Definition at line 141 of file AlignmentProducer.h.

Referenced by addSurveyInfo_(), and readInSurveyRcds().

boost::shared_ptr<TrackerGeometry> AlignmentProducer::theTracker
private

Definition at line 152 of file AlignmentProducer.h.

Referenced by beginOfJob(), createGeometries_(), and produceTracker().

const edm::InputTag AlignmentProducer::tjTkAssociationMapTag_
private

Definition at line 173 of file AlignmentProducer.h.

Referenced by duringLoop().

const edm::InputTag AlignmentProducer::tkLasBeamTag_
private

Definition at line 175 of file AlignmentProducer.h.

Referenced by endRun().

const bool AlignmentProducer::useExtras_
private

Definition at line 169 of file AlignmentProducer.h.

Referenced by beginOfJob().

const bool AlignmentProducer::useSurvey_
private

Definition at line 170 of file AlignmentProducer.h.

Referenced by readInSurveyRcds().

edm::ESWatcher<CSCSurveyErrorRcd> AlignmentProducer::watchCSCSurveyErrRcd_
private

Definition at line 185 of file AlignmentProducer.h.

edm::ESWatcher<CSCSurveyRcd> AlignmentProducer::watchCSCSurveyRcd_
private

Definition at line 184 of file AlignmentProducer.h.

edm::ESWatcher<DTSurveyErrorRcd> AlignmentProducer::watchDTSurveyErrRcd_
private

Definition at line 183 of file AlignmentProducer.h.

edm::ESWatcher<DTSurveyRcd> AlignmentProducer::watchDTSurveyRcd_
private

Definition at line 182 of file AlignmentProducer.h.

edm::ESWatcher<TrackerSurveyErrorRcd> AlignmentProducer::watchTkSurveyErrRcd_
private

Definition at line 181 of file AlignmentProducer.h.

Referenced by readInSurveyRcds().

edm::ESWatcher<TrackerSurveyRcd> AlignmentProducer::watchTkSurveyRcd_
private

Definition at line 180 of file AlignmentProducer.h.

Referenced by readInSurveyRcds().