CMS 3D CMS Logo

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

List of all members.

Public Types

typedef std::vector< Alignable * > Alignables
typedef std::pair< const
Trajectory *, const
reco::Track * > 
ConstTrajTrackPair
typedef std::vector
< ConstTrajTrackPair
ConstTrajTrackPairCollection
typedef
AlignmentAlgorithmBase::RunNumber 
RunNumber
typedef
AlignmentAlgorithmBase::RunRange 
RunRange
typedef std::vector< RunRangeRunRanges

Public Member Functions

 AlignmentProducer (const edm::ParameterSet &iConfig)
 Constructor.
virtual void beginLuminosityBlock (const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &setup)
 Called at lumi block start, calling algorithm's beginLuminosityBlock.
virtual void beginOfJob (const edm::EventSetup &)
 Called at beginning of job.
virtual void beginRun (const edm::Run &run, const edm::EventSetup &setup)
 Called at run start and calling algorithms beginRun.
virtual Status duringLoop (const edm::Event &event, const edm::EventSetup &setup)
 Called at each event.
virtual void endLuminosityBlock (const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &setup)
 Called at lumi block end, calling algorithm's endLuminosityBlock.
virtual void endOfJob ()
 Called at end of job.
virtual Status endOfLoop (const edm::EventSetup &, unsigned int iLoop)
 Called at end of loop.
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.
virtual boost::shared_ptr
< CSCGeometry
produceCSC (const MuonGeometryRecord &iRecord)
 Produce the muon CSC geometry.
virtual boost::shared_ptr
< DTGeometry
produceDT (const MuonGeometryRecord &iRecord)
 Produce the muon DT geometry.
virtual boost::shared_ptr
< TrackerGeometry
produceTracker (const TrackerDigiGeometryRecord &iRecord)
 Produce the tracker geometry.
virtual void startingNewLoop (unsigned int iLoop)
 Called at beginning of loop.
 ~AlignmentProducer ()
 Destructor.

Private Member Functions

void addSurveyInfo_ (Alignable *)
 Add survey info to an alignable.
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.
void createGeometries_ (const edm::EventSetup &)
 Create tracker and muon geometries.
RunRanges makeNonOverlappingRunRanges (const edm::VParameterSet &RunRangeSelectionVPSet)
void readInSurveyRcds (const edm::EventSetup &)
 read in survey records
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.
void writeDB (AlignmentSurfaceDeformations *alignmentSurfaceDeformations, const std::string &surfaceDeformationRcd, cond::Time_t time) const
void writeDB (Alignments *alignments, const std::string &alignRcd, AlignmentErrors *alignmentErrors, const std::string &errRcd, const AlignTransform *globalCoordinates, cond::Time_t time) const
void writeForRunRange (cond::Time_t time)

Private Attributes

const bool applyDbAlignment_
const edm::InputTag beamSpotTag_
const bool checkDbAlignmentValidity_
const edm::InputTag clusterValueMapTag_
const bool doMisalignmentScenario_
const bool doMuon_
const bool doTracker_
const AlignmentsglobalPositions_
 GlobalPositions that might be read from DB, NULL otherwise.
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_

Detailed Description

Package : Alignment/CommonAlignmentProducer Description : calls alignment algorithms

Author:
: Frederic Ronga Revision :
Revision:
1.25

last update:

Date:
2012/02/01 13:55:23

by :

Author:
mussgill

Definition at line 55 of file AlignmentProducer.h.


Member Typedef Documentation

Definition at line 59 of file AlignmentProducer.h.

Definition at line 60 of file AlignmentProducer.h.

Definition at line 61 of file AlignmentProducer.h.

Definition at line 63 of file AlignmentProducer.h.

Definition at line 64 of file AlignmentProducer.h.

typedef std::vector<RunRange> AlignmentProducer::RunRanges

Definition at line 65 of file AlignmentProducer.h.


Constructor & Destructor Documentation

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

Constructor.

Definition at line 76 of file AlignmentProducer.cc.

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

                                                                   :
  theAlignmentAlgo(0), theAlignmentParameterStore(0),
  theAlignableExtras(0), theAlignableTracker(0), theAlignableMuon(0), 
  globalPositions_(0),
  nevent_(0), theParameterSet(iConfig),
  theMaxLoops( iConfig.getUntrackedParameter<unsigned int>("maxLoops") ),
  stNFixAlignables_(iConfig.getParameter<int>("nFixAlignables") ),
  stRandomShift_(iConfig.getParameter<double>("randomShift")),
  stRandomRotation_(iConfig.getParameter<double>("randomRotation")),
  applyDbAlignment_( iConfig.getUntrackedParameter<bool>("applyDbAlignment")),
  checkDbAlignmentValidity_( iConfig.getUntrackedParameter<bool>("checkDbAlignmentValidity")),
  doMisalignmentScenario_(iConfig.getParameter<bool>("doMisalignmentScenario")),
  saveToDB_(iConfig.getParameter<bool>("saveToDB")),
  saveApeToDB_(iConfig.getParameter<bool>("saveApeToDB")),
  saveDeformationsToDB_(iConfig.getParameter<bool>("saveDeformationsToDB")),
  doTracker_( iConfig.getUntrackedParameter<bool>("doTracker") ),
  doMuon_( iConfig.getUntrackedParameter<bool>("doMuon") ),
  useExtras_( iConfig.getUntrackedParameter<bool>("useExtras") ),
  useSurvey_( iConfig.getParameter<bool>("useSurvey") ),
  tjTkAssociationMapTag_(iConfig.getParameter<edm::InputTag>("tjTkAssociationMapTag")),
  beamSpotTag_(iConfig.getParameter<edm::InputTag>("beamSpotTag")),
  tkLasBeamTag_(iConfig.getParameter<edm::InputTag>("tkLasBeamTag")),
  clusterValueMapTag_(iConfig.getParameter<edm::InputTag>("hitPrescaleMapTag"))
{
  edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::AlignmentProducer";

  // Tell the framework what data is being produced
  if (doTracker_) {
     setWhatProduced(this, &AlignmentProducer::produceTracker);
  }
  if (doMuon_) {
     setWhatProduced(this, &AlignmentProducer::produceDT);
     setWhatProduced(this, &AlignmentProducer::produceCSC);
  }

  // Create the alignment algorithm
  edm::ParameterSet algoConfig = iConfig.getParameter<edm::ParameterSet>( "algoConfig" );
  edm::VParameterSet iovSelection = iConfig.getParameter<edm::VParameterSet>( "RunRangeSelection" );
  algoConfig.addUntrackedParameter<edm::VParameterSet>( "RunRangeSelection", iovSelection );
  std::string algoName = algoConfig.getParameter<std::string>( "algoName" );
  theAlignmentAlgo = AlignmentAlgorithmPluginFactory::get( )->create( algoName, algoConfig  );

  // Check if found
  if ( !theAlignmentAlgo )
        throw cms::Exception("BadConfig") << "Couldn't find algorithm called " << algoName;

  edm::ParameterSet monitorConfig = iConfig.getParameter<edm::ParameterSet>( "monitorConfig" );
  std::vector<std::string> monitors = monitorConfig.getUntrackedParameter<std::vector<std::string> >( "monitors" );

  for (std::vector<std::string>::const_iterator miter = monitors.begin();  miter != monitors.end();  ++miter) {
    AlignmentMonitorBase* newMonitor = AlignmentMonitorPluginFactory::get()->create(*miter, monitorConfig.getUntrackedParameter<edm::ParameterSet>(*miter));

    if (!newMonitor) throw cms::Exception("BadConfig") << "Couldn't find monitor named " << *miter;

    theMonitors.push_back(newMonitor);
  }
}
AlignmentProducer::~AlignmentProducer ( )

Member Function Documentation

void AlignmentProducer::addSurveyInfo_ ( Alignable ali) [private]

Add survey info to an alignable.

Definition at line 622 of file AlignmentProducer.cc.

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

Referenced by readInSurveyRcds().

{
  const std::vector<Alignable*>& comp = ali->components();

  unsigned int nComp = comp.size();

  for (unsigned int i = 0; i < nComp; ++i) addSurveyInfo_(comp[i]);

  const SurveyError& error = theSurveyErrors->m_surveyErrors[theSurveyIndex];

  if ( ali->id() != error.rawId() ||
       ali->alignableObjectId() != error.structureType() )
  {
    throw cms::Exception("DatabaseError")
      << "Error reading survey info from DB. Mismatched id!";
  }

  const CLHEP::Hep3Vector&  pos = theSurveyValues->m_align[theSurveyIndex].translation();
  const CLHEP::HepRotation& rot = theSurveyValues->m_align[theSurveyIndex].rotation();

  AlignableSurface surf( align::PositionType( pos.x(), pos.y(), pos.z() ),
                         align::RotationType( rot.xx(), rot.xy(), rot.xz(),
                                              rot.yx(), rot.yy(), rot.yz(),
                                              rot.zx(), rot.zy(), rot.zz() ) );

  surf.setWidth( ali->surface().width() );
  surf.setLength( ali->surface().length() );

  ali->setSurvey( new SurveyDet( surf, error.matrix() ) );

  ++theSurveyIndex;
}
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 721 of file AlignmentProducer.cc.

References GeometryAligner::applyAlignments(), edm::IOVSyncValue::beginOfTime(), checkDbAlignmentValidity_, edm::IOVSyncValue::endOfTime(), edm::IOVSyncValue::eventID(), Exception, first, edm::ValidityInterval::first(), geometry, edm::EventSetup::get(), edm::ValidityInterval::last(), prof2calltree::last, and record.

{
  // 'G' is the geometry class for that DB should be applied,
  // 'Rcd' is the record class for its Alignments 
  // 'ErrRcd' is the record class for its AlignmentErrors
  // 'globalCoordinates' are global transformation for this geometry

  const Rcd & record = iSetup.get<Rcd>();
  if (checkDbAlignmentValidity_) {
    const edm::ValidityInterval & validity = record.validityInterval();
    const edm::IOVSyncValue first = validity.first();
    const edm::IOVSyncValue last = validity.last();
    if (first!=edm::IOVSyncValue::beginOfTime() ||
        last!=edm::IOVSyncValue::endOfTime()) {
      throw cms::Exception("DatabaseError")
        << "@SUB=AlignmentProducer::applyDB"
        << "\nTrying to apply "
        << record.key().name()
        << " with multiple IOVs in tag.\n"
        << "Validity range is "
        << first.eventID().run() << " - " << last.eventID().run();
    }
  }

  edm::ESHandle<Alignments> alignments;
  record.get(alignments);

  edm::ESHandle<AlignmentErrors> alignmentErrors;
  iSetup.get<ErrRcd>().get(alignmentErrors);

  GeometryAligner aligner;
  aligner.applyAlignments<G>(geometry, &(*alignments), &(*alignmentErrors),
                             globalCoordinates);
}
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 762 of file AlignmentProducer.cc.

References GeometryAligner::attachSurfaceDeformations(), edm::IOVSyncValue::beginOfTime(), checkDbAlignmentValidity_, edm::IOVSyncValue::endOfTime(), edm::IOVSyncValue::eventID(), Exception, first, edm::ValidityInterval::first(), geometry, edm::EventSetup::get(), edm::ValidityInterval::last(), prof2calltree::last, and record.

{
  // 'G' is the geometry class for that DB should be applied,
  // 'DeformationRcd' is the record class for its surface deformations 

  const DeformationRcd & record = iSetup.get<DeformationRcd>();
  if (checkDbAlignmentValidity_) {
    const edm::ValidityInterval & validity = record.validityInterval();
    const edm::IOVSyncValue first = validity.first();
    const edm::IOVSyncValue last = validity.last();
    if (first!=edm::IOVSyncValue::beginOfTime() ||
        last!=edm::IOVSyncValue::endOfTime()) {
      throw cms::Exception("DatabaseError")
        << "@SUB=AlignmentProducer::applyDB"
        << "\nTrying to apply "
        << record.key().name()
        << " with multiple IOVs in tag.\n"
        << "Validity range is "
        << first.eventID().run() << " - " << last.eventID().run();
    }
  }
  edm::ESHandle<AlignmentSurfaceDeformations> surfaceDeformations;
  record.get(surfaceDeformations);

  GeometryAligner aligner;
  aligner.attachSurfaceDeformations<G>(geometry, &(*surfaceDeformations));
}
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 514 of file AlignmentProducer.cc.

References AlignmentAlgorithmBase::beginLuminosityBlock(), and theAlignmentAlgo.

{
  theAlignmentAlgo->beginLuminosityBlock(setup); // do not forward edm::LuminosityBlock
}
void AlignmentProducer::beginOfJob ( const edm::EventSetup iSetup) [virtual]

Called at beginning of job.

Reimplemented from edm::EDLooperBase.

Definition at line 180 of file AlignmentProducer.cc.

References align::AlignableMuon, AlignmentParameterStore_cfi::AlignmentParameterStore, applyDbAlignment_, TrackerScenarioBuilder::applyScenario(), MuonScenarioBuilder::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_.

{
  edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::beginOfJob";

  // Create the geometries from the ideal geometries (first time only)
  this->createGeometries_( iSetup );
  
  // Retrieve and apply alignments, if requested (requires DB setup)
  if ( applyDbAlignment_ ) {
    // we need GlobalPositionRcd - and have to keep track for later removal
    // before writing again to DB...
    edm::ESHandle<Alignments> globalPositionRcd;
    iSetup.get<GlobalPositionRcd>().get(globalPositionRcd);
    globalPositions_ = new Alignments(*globalPositionRcd);

    if ( doTracker_ ) {     // apply to tracker
      this->applyDB<TrackerGeometry,TrackerAlignmentRcd,TrackerAlignmentErrorRcd>
        (&(*theTracker), iSetup,  
         align::DetectorGlobalPosition(*globalPositions_, DetId(DetId::Tracker)));
      this->applyDB<TrackerGeometry,TrackerSurfaceDeformationRcd>(&(*theTracker), iSetup);
    }
    
    if ( doMuon_ ) { // apply to tracker
      this->applyDB<DTGeometry,DTAlignmentRcd,DTAlignmentErrorRcd>
        (&(*theMuonDT), iSetup,
         align::DetectorGlobalPosition(*globalPositions_, DetId(DetId::Muon)));
      this->applyDB<CSCGeometry,CSCAlignmentRcd,CSCAlignmentErrorRcd>
        (&(*theMuonCSC), iSetup,
         align::DetectorGlobalPosition(*globalPositions_, DetId(DetId::Muon)));
    }
  }

  // Create alignable tracker and muon 
  if (doTracker_) {
    theAlignableTracker = new AlignableTracker( &(*theTracker) );
  }

  if (doMuon_) {
     theAlignableMuon = new AlignableMuon( &(*theMuonDT), &(*theMuonCSC) );
  }

  if (useExtras_) {
    theAlignableExtras = new AlignableExtras();
  }

  // Create alignment parameter builder
  edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::beginOfJob" 
                            << "Creating AlignmentParameterBuilder";
  edm::ParameterSet aliParamBuildCfg = 
    theParameterSet.getParameter<edm::ParameterSet>("ParameterBuilder");
  AlignmentParameterBuilder alignmentParameterBuilder(theAlignableTracker,
                                                      theAlignableMuon,
                                                      theAlignableExtras,
                                                      aliParamBuildCfg );
  // Fix alignables if requested
  if (stNFixAlignables_>0) alignmentParameterBuilder.fixAlignables(stNFixAlignables_);

  // Get list of alignables
  Alignables theAlignables = alignmentParameterBuilder.alignables();
  edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::beginOfJob" 
                            << "got " << theAlignables.size() << " alignables";

  // Create AlignmentParameterStore 
  edm::ParameterSet aliParamStoreCfg = 
    theParameterSet.getParameter<edm::ParameterSet>("ParameterStore");
  theAlignmentParameterStore = new AlignmentParameterStore(theAlignables, aliParamStoreCfg);
  edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::beginOfJob" 
                            << "AlignmentParameterStore created!";

  // Apply misalignment scenario to alignable tracker and muon if requested
  // WARNING: this assumes scenarioConfig can be passed to both muon and tracker
  if (doMisalignmentScenario_ && (doTracker_ || doMuon_)) {
    edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::beginOfJob" 
                              << "Applying misalignment scenario to "
                              << (doTracker_ ? "tracker" : "")
                              << (doMuon_    ? (doTracker_ ? " and muon" : "muon") : ".");
    edm::ParameterSet scenarioConfig 
      = theParameterSet.getParameter<edm::ParameterSet>( "MisalignmentScenario" );
    if (doTracker_) {
      TrackerScenarioBuilder scenarioBuilder( theAlignableTracker );
      scenarioBuilder.applyScenario( scenarioConfig );
    }
    if (doMuon_) {
      MuonScenarioBuilder muonScenarioBuilder( theAlignableMuon );
      muonScenarioBuilder.applyScenario( scenarioConfig );
    }
  } else {
    edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::beginOfJob" 
                              << "NOT applying misalignment scenario!";
  }

  // Apply simple misalignment
  const std::string sParSel(theParameterSet.getParameter<std::string>("parameterSelectorSimple"));
  this->simpleMisalignment_(theAlignables, sParSel, stRandomShift_, stRandomRotation_, true);

  // Initialize alignment algorithm
  theAlignmentAlgo->initialize( iSetup, 
                                theAlignableTracker, theAlignableMuon, theAlignableExtras,
                                theAlignmentParameterStore );

  for (std::vector<AlignmentMonitorBase*>::const_iterator monitor = theMonitors.begin();
       monitor != theMonitors.end();  ++monitor) {
     (*monitor)->beginOfJob(theAlignableTracker, theAlignableMuon, theAlignmentParameterStore);
  }
}
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 489 of file AlignmentProducer.cc.

References AlignmentAlgorithmBase::beginRun(), and theAlignmentAlgo.

{
  theAlignmentAlgo->beginRun(setup); // do not forward edm::Run...
}
void AlignmentProducer::createGeometries_ ( const edm::EventSetup iSetup) [private]

Create tracker and muon geometries.

Definition at line 598 of file AlignmentProducer.cc.

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

Referenced by beginOfJob().

{
   edm::ESTransientHandle<DDCompactView> cpv;
   iSetup.get<IdealGeometryRecord>().get( cpv );

   if (doTracker_) {
     edm::ESHandle<GeometricDet> geometricDet;
     iSetup.get<IdealGeometryRecord>().get( geometricDet );
     TrackerGeomBuilderFromGeometricDet trackerBuilder;
     theTracker = boost::shared_ptr<TrackerGeometry>( trackerBuilder.build(&(*geometricDet)) );
   }

   if (doMuon_) {
     edm::ESHandle<MuonDDDConstants> mdc;
     iSetup.get<MuonNumberingRecord>().get(mdc);
     DTGeometryBuilderFromDDD DTGeometryBuilder;
     CSCGeometryBuilderFromDDD CSCGeometryBuilder;
     theMuonDT = boost::shared_ptr<DTGeometry>(new DTGeometry );
     DTGeometryBuilder.build( theMuonDT, &(*cpv), *mdc);
     theMuonCSC = boost::shared_ptr<CSCGeometry>( new CSCGeometry );
     CSCGeometryBuilder.build( theMuonCSC, &(*cpv), *mdc );
   }
}
edm::EDLooper::Status AlignmentProducer::duringLoop ( const edm::Event event,
const edm::EventSetup setup 
) [virtual]

Called at each event.

Implements edm::EDLooper.

Definition at line 427 of file AlignmentProducer.cc.

References SiPixelRawToDigiRegional_cfi::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_.

{
  ++nevent_;

  // reading in survey records
  this->readInSurveyRcds(setup);
        
  // Printout event number
  for ( int i=10; i<10000000; i*=10 )
    if ( nevent_<10*i && (nevent_%i)==0 )
      edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::duringLoop" 
                                << "Events processed: " << nevent_;
  
  // Retrieve trajectories and tracks from the event
  // -> merely skip if collection is empty
  edm::Handle<TrajTrackAssociationCollection> m_TrajTracksMap;
  if (event.getByLabel(tjTkAssociationMapTag_, m_TrajTracksMap)) {
    
    // Form pairs of trajectories and tracks
    ConstTrajTrackPairCollection trajTracks;
    for ( TrajTrackAssociationCollection::const_iterator iPair = m_TrajTracksMap->begin();
          iPair != m_TrajTracksMap->end(); ++iPair) {
      trajTracks.push_back( ConstTrajTrackPair( &(*(*iPair).key), &(*(*iPair).val) ) );
    }
    edm::Handle<reco::BeamSpot> beamSpot;
    event.getByLabel(beamSpotTag_, beamSpot);

    if (nevent_==1 && theAlignableExtras) {
      edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::duringLoop"
                                << "initializing AlignableBeamSpot" << std::endl;
      theAlignableExtras->initializeBeamSpot(beamSpot->x0(), beamSpot->y0(), beamSpot->z0(),
                                             beamSpot->dxdz(), beamSpot->dydz());
    }

    // Run the alignment algorithm with its input
    const AliClusterValueMap *clusterValueMapPtr = 0;
    if(clusterValueMapTag_.encode().size()){//check that the input tag is not empty
      edm::Handle<AliClusterValueMap> clusterValueMap;
      event.getByLabel(clusterValueMapTag_, clusterValueMap);
      clusterValueMapPtr = &(*clusterValueMap);
    }

    const AlignmentAlgorithmBase::EventInfo eventInfo(event.id(), trajTracks, *beamSpot,
                                                      clusterValueMapPtr);
    theAlignmentAlgo->run(setup, eventInfo);


    for (std::vector<AlignmentMonitorBase*>::const_iterator monitor = theMonitors.begin();
         monitor != theMonitors.end();  ++monitor) {
      (*monitor)->duringLoop(event, setup, trajTracks); // forward eventInfo?
    }
  } else {
    edm::LogError("Alignment") << "@SUB=AlignmentProducer::duringLoop" 
                               << "No track collection found: skipping event";
  }
  

  return kContinue;
}
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 521 of file AlignmentProducer.cc.

References AlignmentAlgorithmBase::endLuminosityBlock(), and theAlignmentAlgo.

{
  theAlignmentAlgo->endLuminosityBlock(setup); // do not forward edm::LuminosityBlock
}
void AlignmentProducer::endOfJob ( ) [virtual]

Called at end of job.

Reimplemented from edm::EDLooperBase.

Definition at line 288 of file AlignmentProducer.cc.

References AlignableExtras::beamSpot(), edm::ParameterSet::getParameter(), makeNonOverlappingRunRanges(), nevent_, AlignmentParameters::parameters(), cond::runnumber, saveApeToDB_, saveDeformationsToDB_, saveToDB_, AlignmentAlgorithmBase::setParametersForRunRange(), theAlignableExtras, theAlignmentAlgo, theMonitors, theParameterSet, cond::timeTypeSpecs, and writeForRunRange().

{
  edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::endOfJob";

  for (std::vector<AlignmentMonitorBase*>::const_iterator monitor = theMonitors.begin();  monitor != theMonitors.end();  ++monitor) {
     (*monitor)->endOfJob();
  }

  if (0 == nevent_) {
    edm::LogError("Alignment") << "@SUB=AlignmentProducer::endOfJob" << "Did not process any "
                               << "events in last loop, do not dare to store to DB.";
  } else {
    
    // Expand run ranges and make them unique
    edm::VParameterSet runRangeSelectionVPSet(theParameterSet.getParameter<edm::VParameterSet>("RunRangeSelection"));
    RunRanges uniqueRunRanges(this->makeNonOverlappingRunRanges(runRangeSelectionVPSet));
    if (uniqueRunRanges.empty()) { // create dummy IOV
      const RunRange runRange(cond::timeTypeSpecs[cond::runnumber].beginValue,
                              cond::timeTypeSpecs[cond::runnumber].endValue);
      uniqueRunRanges.push_back(runRange);
    }

    std::vector<AlgebraicVector> beamSpotParameters;

    for (RunRanges::const_iterator iRunRange = uniqueRunRanges.begin();
         iRunRange != uniqueRunRanges.end();
         ++iRunRange) {

      theAlignmentAlgo->setParametersForRunRange(*iRunRange);

      // Save alignments to database
      if (saveToDB_ || saveApeToDB_ || saveDeformationsToDB_)
        this->writeForRunRange((*iRunRange).first);
      
      // Deal with extra alignables, e.g. beam spot
      if (theAlignableExtras) {
        Alignables &alis = theAlignableExtras->beamSpot();
        if (!alis.empty()) {
          BeamSpotAlignmentParameters *beamSpotAliPars = dynamic_cast<BeamSpotAlignmentParameters*>(alis[0]->alignmentParameters());
          beamSpotParameters.push_back(beamSpotAliPars->parameters());
        }
      }
    }
    
    if (theAlignableExtras) {
      std::ostringstream bsOutput;
      
      std::vector<AlgebraicVector>::const_iterator itPar = beamSpotParameters.begin();
      for (RunRanges::const_iterator iRunRange = uniqueRunRanges.begin();
           iRunRange != uniqueRunRanges.end();
           ++iRunRange, ++itPar) {
        bsOutput << "Run range: " << (*iRunRange).first << " - " << (*iRunRange).second << "\n";
        bsOutput << "  Displacement: x=" << (*itPar)[0] << ", y=" << (*itPar)[1] << "\n"; 
        bsOutput << "  Slope: dx/dz=" << (*itPar)[2] << ", dy/dz=" << (*itPar)[3] << "\n"; 
      }
      
      edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::endOfJob"
                                << "Parameters for alignable beamspot:\n"
                                << bsOutput.str();
    }

  }
}
edm::EDLooper::Status AlignmentProducer::endOfLoop ( const edm::EventSetup iSetup,
unsigned int  iLoop 
) [virtual]

Called at end of loop.

Implements edm::EDLooperBase.

Definition at line 396 of file AlignmentProducer.cc.

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

{

  if (0 == nevent_) {
    // beginOfJob is usually called by the framework in the first event of the first loop
    // (a hack: beginOfJob needs the EventSetup that is not well defined without an event)
    // and the algorithms rely on the initialisations done in beginOfJob. We cannot call 
    // this->beginOfJob(iSetup); here either since that will access the EventSetup to get
    // some geometry information that is not defined either without having seen an event.
    edm::LogError("Alignment") << "@SUB=AlignmentProducer::endOfLoop" 
                               << "Did not process any events in loop " << iLoop
                               << ", stop processing without terminating algorithm.";
    return kStop;
  }

  edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::endOfLoop" 
                            << "Ending loop " << iLoop << ", terminating algorithm.";

  theAlignmentAlgo->terminate();

  for (std::vector<AlignmentMonitorBase*>::const_iterator monitor = theMonitors.begin();  monitor != theMonitors.end();  ++monitor) {
     (*monitor)->endOfLoop(iSetup);
  }

  if ( iLoop == theMaxLoops-1 || iLoop >= theMaxLoops ) return kStop;
  else return kContinue;
}
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 495 of file AlignmentProducer.cc.

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

{
  // call with or without las beam info...
  typedef AlignmentAlgorithmBase::EndRunInfo EndRunInfo;
  if (tkLasBeamTag_.encode().size()) { // non-empty InputTag
    edm::Handle<TkFittedLasBeamCollection> lasBeams;
    edm::Handle<TsosVectorCollection> tsoses;
    run.getByLabel(tkLasBeamTag_, lasBeams);
    run.getByLabel(tkLasBeamTag_, tsoses);
    
    theAlignmentAlgo->endRun(EndRunInfo(run.id(), &(*lasBeams), &(*tsoses)), setup);
  } else {
    edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::endRun"
                              << "No Tk LAS beams to forward to algorithm.";
    theAlignmentAlgo->endRun(EndRunInfo(run.id(), 0, 0), setup);
  }
}
AlignmentProducer::RunRanges AlignmentProducer::makeNonOverlappingRunRanges ( const edm::VParameterSet RunRangeSelectionVPSet) [private]

Definition at line 912 of file AlignmentProducer.cc.

References first, i, cond::runnumber, groupFilesInBlocks::temp, cond::timeTypeSpecs, and edm::tokenize().

Referenced by endOfJob().

{
  static bool oldRunRangeSelectionWarning = false;

  const RunNumber beginValue = cond::timeTypeSpecs[cond::runnumber].beginValue;
  const RunNumber endValue = cond::timeTypeSpecs[cond::runnumber].endValue;
  
  RunRanges uniqueRunRanges;
  if (!RunRangeSelectionVPSet.empty()) {

    std::map<RunNumber,RunNumber> uniqueFirstRunNumbers;
    
    for (std::vector<edm::ParameterSet>::const_iterator ipset = RunRangeSelectionVPSet.begin();
         ipset != RunRangeSelectionVPSet.end();
         ++ipset) {
      const std::vector<std::string> RunRangeStrings = (*ipset).getParameter<std::vector<std::string> >("RunRanges");
      for (std::vector<std::string>::const_iterator irange = RunRangeStrings.begin();
           irange != RunRangeStrings.end();
           ++irange) {
        
        if ((*irange).find(':')==std::string::npos) {
          
          RunNumber first = beginValue;
          long int temp = strtol((*irange).c_str(), 0, 0);
          if (temp!=-1) first = temp;
          uniqueFirstRunNumbers[first] = first;
          
        } else {
          
          if (!oldRunRangeSelectionWarning) {
            edm::LogWarning("BadConfig") << "@SUB=AlignmentProducer::makeNonOverlappingRunRanges"
                                         << "Config file contains old format for 'RunRangeSelection'. Only the start run\n"
                                         << "number is used internally. The number of the last run is ignored and can be\n"
                                         << "safely removed from the config file.\n";
            oldRunRangeSelectionWarning = true;
          }
          
          std::vector<std::string> tokens = edm::tokenize(*irange, ":");
          long int temp;
          RunNumber first = beginValue;
          temp = strtol(tokens[0].c_str(), 0, 0);
          if (temp!=-1) first = temp;
          uniqueFirstRunNumbers[first] = first;
        }
      }
    }

    for (std::map<RunNumber,RunNumber>::iterator iFirst = uniqueFirstRunNumbers.begin();
         iFirst!=uniqueFirstRunNumbers.end();
         ++iFirst) {
      uniqueRunRanges.push_back(std::pair<RunNumber,RunNumber>((*iFirst).first, endValue));
    }
    for (unsigned int i = 0;i<uniqueRunRanges.size()-1;++i) {
      uniqueRunRanges[i].second = uniqueRunRanges[i+1].first - 1;
    }
    
  } else {
        
    uniqueRunRanges.push_back(std::pair<RunNumber,RunNumber>(beginValue, endValue));
    
  }
  
  return uniqueRunRanges;
}
boost::shared_ptr< CSCGeometry > AlignmentProducer::produceCSC ( const MuonGeometryRecord iRecord) [virtual]

Produce the muon CSC geometry.

Definition at line 171 of file AlignmentProducer.cc.

References theMuonCSC.

Referenced by AlignmentProducer().

{
  edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::produceCSC";
  return theMuonCSC;  
}
boost::shared_ptr< DTGeometry > AlignmentProducer::produceDT ( const MuonGeometryRecord iRecord) [virtual]

Produce the muon DT geometry.

Definition at line 162 of file AlignmentProducer.cc.

References theMuonDT.

Referenced by AlignmentProducer().

{
  edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::produceDT";
  return theMuonDT;
}
boost::shared_ptr< TrackerGeometry > AlignmentProducer::produceTracker ( const TrackerDigiGeometryRecord iRecord) [virtual]

Produce the tracker geometry.

Definition at line 153 of file AlignmentProducer.cc.

References theTracker.

Referenced by AlignmentProducer().

{
  edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::produceTracker";
  return theTracker;
}
void AlignmentProducer::readInSurveyRcds ( const edm::EventSetup iSetup) [private]

read in survey records

Definition at line 655 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().

                                                                     {
        
  // Get Survey Rcds and add Survey Info
  if ( doTracker_ && useSurvey_ ){
    bool tkSurveyBool = watchTkSurveyRcd_.check(iSetup);
    bool tkSurveyErrBool = watchTkSurveyErrRcd_.check(iSetup);
    edm::LogInfo("Alignment") << "watcher tksurveyrcd: " << tkSurveyBool;
    edm::LogInfo("Alignment") << "watcher tksurveyerrrcd: " << tkSurveyErrBool;
    if ( tkSurveyBool || tkSurveyErrBool){
      
      edm::LogInfo("Alignment") << "ADDING THE SURVEY INFORMATION";
      edm::ESHandle<Alignments> surveys;
      edm::ESHandle<SurveyErrors> surveyErrors;
      
      iSetup.get<TrackerSurveyRcd>().get(surveys);
      iSetup.get<TrackerSurveyErrorRcd>().get(surveyErrors);
      
      theSurveyIndex  = 0;
      theSurveyValues = &*surveys;
      theSurveyErrors = &*surveyErrors;
      addSurveyInfo_(theAlignableTracker);
    }
  }
  
  if ( doMuon_ && useSurvey_) {
    bool DTSurveyBool = watchTkSurveyRcd_.check(iSetup);
    bool DTSurveyErrBool = watchTkSurveyErrRcd_.check(iSetup);
    bool CSCSurveyBool = watchTkSurveyRcd_.check(iSetup);
    bool CSCSurveyErrBool = watchTkSurveyErrRcd_.check(iSetup);
    
    if ( DTSurveyBool || DTSurveyErrBool || CSCSurveyBool || CSCSurveyErrBool ){
      edm::ESHandle<Alignments> dtSurveys;
      edm::ESHandle<SurveyErrors> dtSurveyErrors;
      edm::ESHandle<Alignments> cscSurveys;
      edm::ESHandle<SurveyErrors> cscSurveyErrors;
      
      iSetup.get<DTSurveyRcd>().get(dtSurveys);
      iSetup.get<DTSurveyErrorRcd>().get(dtSurveyErrors);
      iSetup.get<CSCSurveyRcd>().get(cscSurveys);
      iSetup.get<CSCSurveyErrorRcd>().get(cscSurveyErrors);
      
      theSurveyIndex  = 0;
      theSurveyValues = &*dtSurveys;
      theSurveyErrors = &*dtSurveyErrors;
      std::vector<Alignable*> barrels = theAlignableMuon->DTBarrel();
      for (std::vector<Alignable*>::const_iterator iter = barrels.begin();  iter != barrels.end();  ++iter) {
        addSurveyInfo_(*iter);
      }
      
      theSurveyIndex  = 0;
      theSurveyValues = &*cscSurveys;
      theSurveyErrors = &*cscSurveyErrors;
      std::vector<Alignable*> endcaps = theAlignableMuon->CSCEndcaps();
      for (std::vector<Alignable*>::const_iterator iter = endcaps.begin();  iter != endcaps.end();  ++iter) {
        addSurveyInfo_(*iter);
      }
    }
  }

}
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 529 of file AlignmentProducer.cc.

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

Referenced by beginOfJob().

{

  std::ostringstream output; // collecting output

  if (shift > 0. || rot > 0.) {
    output << "Adding random flat shift of max size " << shift
           << " and adding random flat rotation of max size " << rot <<" to ";

    std::vector<bool> commSel(0);
    if (selection != "-1") {
      AlignmentParameterSelector aSelector(0,0); // no alignable needed here...
      const std::vector<char> cSel(aSelector.convertParamSel(selection));
      if (cSel.size() < RigidBodyAlignmentParameters::N_PARAM) {
        throw cms::Exception("BadConfig") 
          << "[AlignmentProducer::simpleMisalignment_]\n"
          << "Expect selection string '" << selection << "' to be at least of length " 
          << RigidBodyAlignmentParameters::N_PARAM << " or to be '-1'.\n"
          << "(Most probably you have to adjust the parameter 'parameterSelectorSimple'.)";
      }
      for (std::vector<char>::const_iterator cIter = cSel.begin(); cIter != cSel.end(); ++cIter) {
        commSel.push_back(*cIter == '0' ? false : true);
      }
      output << "parameters defined by (" << selection 
             << "), representing (x,y,z,alpha,beta,gamma),";
    } else {
      output << "the active parameters of each alignable,";
    }
    output << " in " << (local ? "local" : "global") << " frame.";

    for (std::vector<Alignable*>::const_iterator it = alivec.begin(); it != alivec.end(); ++it) {
      Alignable* ali=(*it);
      std::vector<bool> mysel(commSel.empty() ? ali->alignmentParameters()->selector() : commSel);
      
      if (std::abs(shift)>0.00001) {
        double s0 = 0., s1 = 0., s2 = 0.;
        if (mysel[RigidBodyAlignmentParameters::dx]) s0 = shift * double(random()%1000-500)/500.;
        if (mysel[RigidBodyAlignmentParameters::dy]) s1 = shift * double(random()%1000-500)/500.;
        if (mysel[RigidBodyAlignmentParameters::dz]) s2 = shift * double(random()%1000-500)/500.;
        
        if (local) ali->move( ali->surface().toGlobal(align::LocalVector(s0,s1,s2)) );
        else       ali->move( align::GlobalVector(s0,s1,s2) );

      //AlignmentPositionError ape(dx,dy,dz);
      //ali->addAlignmentPositionError(ape);
      }

      if (std::abs(rot)>0.00001) {
        align::EulerAngles r(3);
        if (mysel[RigidBodyAlignmentParameters::dalpha]) r(1)=rot*double(random()%1000-500)/500.;
        if (mysel[RigidBodyAlignmentParameters::dbeta])  r(2)=rot*double(random()%1000-500)/500.;
        if (mysel[RigidBodyAlignmentParameters::dgamma]) r(3)=rot*double(random()%1000-500)/500.;

        const align::RotationType mrot = align::toMatrix(r);
        if (local) ali->rotateInLocalFrame(mrot);
        else       ali->rotateInGlobalFrame(mrot);
        
      //ali->addAlignmentPositionErrorFromRotation(mrot);
      }
    } // end loop on alignables
  } else {
    output << "No simple misalignment added!";
  }
  edm::LogInfo("Alignment")  << "@SUB=AlignmentProducer::simpleMisalignment_" << output.str();
}
void AlignmentProducer::startingNewLoop ( unsigned int  iLoop) [virtual]

Called at beginning of loop.

Implements edm::EDLooperBase.

Definition at line 354 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.

{
  edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::startingNewLoop" 
                            << "Starting loop number " << iLoop;

  nevent_ = 0;

  theAlignmentAlgo->startNewLoop();

  for (std::vector<AlignmentMonitorBase*>::const_iterator monitor = theMonitors.begin();  monitor != theMonitors.end();  ++monitor) {
     (*monitor)->startingNewLoop();
  }

  edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::startingNewLoop" 
                            << "Now physically apply alignments to  geometry...";


  // Propagate changes to reconstruction geometry (from initialisation or iteration)
  GeometryAligner aligner;
  if ( doTracker_ ) {
    std::auto_ptr<Alignments> alignments(theAlignableTracker->alignments());
    std::auto_ptr<AlignmentErrors> alignmentErrors(theAlignableTracker->alignmentErrors());
    aligner.applyAlignments<TrackerGeometry>( &(*theTracker),&(*alignments),&(*alignmentErrors), AlignTransform() ); // don't apply global a second time!
    std::auto_ptr<AlignmentSurfaceDeformations> aliDeforms(theAlignableTracker->surfaceDeformations());
    aligner.attachSurfaceDeformations<TrackerGeometry>(&(*theTracker), &(*aliDeforms));

  }
  if ( doMuon_ ) {
    std::auto_ptr<Alignments>      dtAlignments(       theAlignableMuon->dtAlignments());
    std::auto_ptr<AlignmentErrors> dtAlignmentErrors(  theAlignableMuon->dtAlignmentErrors());
    std::auto_ptr<Alignments>      cscAlignments(      theAlignableMuon->cscAlignments());
    std::auto_ptr<AlignmentErrors> cscAlignmentErrors( theAlignableMuon->cscAlignmentErrors());

    aligner.applyAlignments<DTGeometry>( &(*theMuonDT), &(*dtAlignments), &(*dtAlignmentErrors), AlignTransform() ); // don't apply global a second time!
    aligner.applyAlignments<CSCGeometry>( &(*theMuonCSC), &(*cscAlignments), &(*cscAlignmentErrors), AlignTransform() ); // nope!
  }
}
void AlignmentProducer::writeDB ( AlignmentSurfaceDeformations alignmentSurfaceDeformations,
const std::string &  surfaceDeformationRcd,
cond::Time_t  time 
) const [private]

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

Definition at line 890 of file AlignmentProducer.cc.

References Exception, edm::Service< T >::isAvailable(), saveDeformationsToDB_, and cond::rpcobgas::time.

{
  // Call service
  edm::Service<cond::service::PoolDBOutputService> poolDb;
  if (!poolDb.isAvailable()) { // Die if not available
    delete alignmentSurfaceDeformations; // promised to take over ownership...
    throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
  }
  
  if (saveDeformationsToDB_) {
    edm::LogInfo("Alignment") << "Writing AlignmentSurfaceDeformations to "
                              << surfaceDeformationRcd  << ".";
    poolDb->writeOne<AlignmentSurfaceDeformations>(alignmentSurfaceDeformations, time,
                                                   surfaceDeformationRcd);
  } else { // poolDb->writeOne(..) takes over 'surfaceDeformation' ownership,...
    delete alignmentSurfaceDeformations; // ...otherwise we have to delete, as promised!
  }
}
void AlignmentProducer::writeDB ( Alignments alignments,
const std::string &  alignRcd,
AlignmentErrors alignmentErrors,
const std::string &  errRcd,
const AlignTransform globalCoordinates,
cond::Time_t  time 
) 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 836 of file AlignmentProducer.cc.

References Exception, edm::Service< T >::isAvailable(), GeometryAligner::removeGlobalTransform(), saveApeToDB_, saveToDB_, cond::rpcobgas::time, and AlignTransform::transform().

Referenced by writeForRunRange().

{
  Alignments * tempAlignments = alignments;
  AlignmentErrors * tempAlignmentErrors = alignmentErrors;

  // Call service
  edm::Service<cond::service::PoolDBOutputService> poolDb;
  if (!poolDb.isAvailable()) { // Die if not available
    delete tempAlignments;      // promised to take over ownership...
    delete tempAlignmentErrors; // dito
    throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
  }

  if (globalCoordinates  // happens only if (applyDbAlignment_ == true)
      && globalCoordinates->transform() != AlignTransform::Transform::Identity) {

    tempAlignments = new Alignments();            // temporary storage for
    tempAlignmentErrors = new AlignmentErrors();  // final alignments and errors

    GeometryAligner aligner;
    aligner.removeGlobalTransform(alignments, alignmentErrors,
                                  *globalCoordinates,
                                  tempAlignments, tempAlignmentErrors);
    
    delete alignments;       // have to delete original alignments
    delete alignmentErrors;  // same thing for the errors

    edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::writeDB"
                              << "globalCoordinates removed from alignments (" << alignRcd
                              << ") and errors (" << alignRcd << ").";
  }
  
  if (saveToDB_) {
    edm::LogInfo("Alignment") << "Writing Alignments to " << alignRcd << ".";
    poolDb->writeOne<Alignments>(tempAlignments, time, alignRcd);
  } else { // poolDb->writeOne(..) takes over 'alignments' ownership,...
    delete tempAlignments; // ...otherwise we have to delete, as promised!
  }

  if (saveApeToDB_) {
    edm::LogInfo("Alignment") << "Writing AlignmentErrors to " << errRcd << ".";
    poolDb->writeOne<AlignmentErrors>(tempAlignmentErrors, time, errRcd);
  } else { // poolDb->writeOne(..) takes over 'alignmentErrors' ownership,...
    delete tempAlignmentErrors; // ...otherwise we have to delete, as promised!
  }
}
void AlignmentProducer::writeForRunRange ( cond::Time_t  time) [private]

Definition at line 791 of file AlignmentProducer.cc.

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

Referenced by endOfJob().

{
  if ( doTracker_ ) { // first tracker
    const AlignTransform *trackerGlobal = 0; // will be 'removed' from constants 
    if (globalPositions_) { // i.e. applied before in applyDB
      trackerGlobal = &align::DetectorGlobalPosition(*globalPositions_,
                                                     DetId(DetId::Tracker));
    }
        
    Alignments *alignments = theAlignableTracker->alignments();
    AlignmentErrors *alignmentErrors = theAlignableTracker->alignmentErrors();
    this->writeDB(alignments, "TrackerAlignmentRcd",
                  alignmentErrors, "TrackerAlignmentErrorRcd", trackerGlobal,
                  time);        
  }
      
  if ( doMuon_ ) { // now muon
    const AlignTransform *muonGlobal = 0; // will be 'removed' from constants 
    if (globalPositions_) { // i.e. applied before in applyDB
      muonGlobal = &align::DetectorGlobalPosition(*globalPositions_,
                                                  DetId(DetId::Muon));
    }
    // Get alignments+errors, first DT - ownership taken over by writeDB(..), so no delete
    Alignments      *alignments       = theAlignableMuon->dtAlignments();
    AlignmentErrors *alignmentErrors  = theAlignableMuon->dtAlignmentErrors();
    this->writeDB(alignments, "DTAlignmentRcd",
                  alignmentErrors, "DTAlignmentErrorRcd", muonGlobal,
                  time);
    
    // Get alignments+errors, now CSC - ownership taken over by writeDB(..), so no delete
    alignments       = theAlignableMuon->cscAlignments();
    alignmentErrors  = theAlignableMuon->cscAlignmentErrors();
    this->writeDB(alignments, "CSCAlignmentRcd",
                  alignmentErrors, "CSCAlignmentErrorRcd", muonGlobal,
                  time);
  }
      
  // Save surface deformations to database
  if (saveDeformationsToDB_ && doTracker_) {
    AlignmentSurfaceDeformations *alignmentSurfaceDeformations = theAlignableTracker->surfaceDeformations();
    this->writeDB(alignmentSurfaceDeformations, "TrackerSurfaceDeformationRcd", time);
  }
}

Member Data Documentation

Definition at line 180 of file AlignmentProducer.h.

Referenced by beginOfJob().

Definition at line 188 of file AlignmentProducer.h.

Referenced by duringLoop().

Definition at line 180 of file AlignmentProducer.h.

Referenced by applyDB().

Definition at line 190 of file AlignmentProducer.h.

Referenced by duringLoop().

Definition at line 181 of file AlignmentProducer.h.

Referenced by beginOfJob().

const bool AlignmentProducer::doMuon_ [private]
const bool AlignmentProducer::doTracker_ [private]

GlobalPositions that might be read from DB, NULL otherwise.

Definition at line 169 of file AlignmentProducer.h.

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

Definition at line 171 of file AlignmentProducer.h.

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

const bool AlignmentProducer::saveApeToDB_ [private]

Definition at line 182 of file AlignmentProducer.h.

Referenced by endOfJob(), and writeDB().

Definition at line 182 of file AlignmentProducer.h.

Referenced by endOfJob(), writeDB(), and writeForRunRange().

const bool AlignmentProducer::saveToDB_ [private]

Definition at line 182 of file AlignmentProducer.h.

Referenced by endOfJob(), and writeDB().

Definition at line 178 of file AlignmentProducer.h.

Referenced by beginOfJob().

const double AlignmentProducer::stRandomRotation_ [private]

Definition at line 179 of file AlignmentProducer.h.

Referenced by beginOfJob().

const double AlignmentProducer::stRandomShift_ [private]

Definition at line 179 of file AlignmentProducer.h.

Referenced by beginOfJob().

Definition at line 161 of file AlignmentProducer.h.

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

Definition at line 159 of file AlignmentProducer.h.

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

const unsigned int AlignmentProducer::theMaxLoops [private]

Definition at line 176 of file AlignmentProducer.h.

Referenced by endOfLoop().

boost::shared_ptr<CSCGeometry> AlignmentProducer::theMuonCSC [private]

Definition at line 167 of file AlignmentProducer.h.

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

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

Definition at line 166 of file AlignmentProducer.h.

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

Definition at line 172 of file AlignmentProducer.h.

Referenced by beginOfJob(), and endOfJob().

Definition at line 155 of file AlignmentProducer.h.

Referenced by addSurveyInfo_(), and readInSurveyRcds().

unsigned int AlignmentProducer::theSurveyIndex [private]

Definition at line 153 of file AlignmentProducer.h.

Referenced by addSurveyInfo_(), and readInSurveyRcds().

Definition at line 154 of file AlignmentProducer.h.

Referenced by addSurveyInfo_(), and readInSurveyRcds().

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

Definition at line 165 of file AlignmentProducer.h.

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

Definition at line 187 of file AlignmentProducer.h.

Referenced by duringLoop().

Definition at line 189 of file AlignmentProducer.h.

Referenced by endRun().

const bool AlignmentProducer::useExtras_ [private]

Definition at line 183 of file AlignmentProducer.h.

Referenced by beginOfJob().

const bool AlignmentProducer::useSurvey_ [private]

Definition at line 184 of file AlignmentProducer.h.

Referenced by readInSurveyRcds().

Definition at line 199 of file AlignmentProducer.h.

Definition at line 198 of file AlignmentProducer.h.

Definition at line 197 of file AlignmentProducer.h.

Definition at line 196 of file AlignmentProducer.h.

Definition at line 195 of file AlignmentProducer.h.

Referenced by readInSurveyRcds().

Definition at line 194 of file AlignmentProducer.h.

Referenced by readInSurveyRcds().