#include <Alignment/CommonAlignmentProducer/plugins/AlignmentProducer.h>
Public Types | |
typedef std::vector< Alignable * > | Alignables |
typedef std::pair< const Trajectory *, const reco::Track * > | ConstTrajTrackPair |
typedef std::vector < ConstTrajTrackPair > | ConstTrajTrackPairCollection |
Public Member Functions | |
AlignmentProducer (const edm::ParameterSet &iConfig) | |
Constructor. | |
virtual void | beginOfJob (const edm::EventSetup &) |
Called at beginning of job. | |
virtual Status | duringLoop (const edm::Event &, const edm::EventSetup &) |
Called at each event. | |
virtual void | endOfJob () |
Called at end of job. | |
virtual Status | endOfLoop (const edm::EventSetup &, unsigned int iLoop) |
Called at end of loop. | |
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. | |
void | createGeometries_ (const edm::EventSetup &) |
Create tracker and muon geometries. | |
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. | |
Private Attributes | |
bool | applyDbAlignment_ |
bool | doMisalignmentScenario_ |
bool | doMuon_ |
bool | doTracker_ |
int | nevent_ |
bool | saveToDB_ |
int | stNFixAlignables_ |
double | stRandomRotation_ |
double | stRandomShift_ |
AlignableMuon * | theAlignableMuon |
AlignableTracker * | theAlignableTracker |
AlignmentAlgorithmBase * | theAlignmentAlgo |
AlignmentParameterStore * | theAlignmentParameterStore |
unsigned int | theMaxLoops |
std::vector < AlignmentMonitorBase * > | theMonitors |
boost::shared_ptr< CSCGeometry > | theMuonCSC |
boost::shared_ptr< DTGeometry > | theMuonDT |
edm::ParameterSet | theParameterSet |
const SurveyErrors * | theSurveyErrors |
unsigned int | theSurveyIndex |
const Alignments * | theSurveyValues |
boost::shared_ptr < TrackerGeometry > | theTracker |
bool | useSurvey_ |
Definition at line 37 of file AlignmentProducer.h.
typedef std::vector<Alignable*> AlignmentProducer::Alignables |
Definition at line 41 of file AlignmentProducer.h.
typedef std::pair<const Trajectory*, const reco::Track*> AlignmentProducer::ConstTrajTrackPair |
Definition at line 42 of file AlignmentProducer.h.
typedef std::vector<ConstTrajTrackPair> AlignmentProducer::ConstTrajTrackPairCollection |
Definition at line 43 of file AlignmentProducer.h.
AlignmentProducer::AlignmentProducer | ( | const edm::ParameterSet & | iConfig | ) |
Constructor.
Definition at line 66 of file AlignmentProducer.cc.
References doMuon_, doTracker_, Exception, DBSPlugin::get(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), produceCSC(), produceDT(), produceTracker(), edm::ESProducer::setWhatProduced(), theAlignmentAlgo, and theMonitors.
00066 : 00067 theAlignmentAlgo(0), theAlignmentParameterStore(0), 00068 theAlignableTracker(0), theAlignableMuon(0), 00069 nevent_(0), theParameterSet(iConfig), 00070 theMaxLoops( iConfig.getUntrackedParameter<unsigned int>("maxLoops",0) ), 00071 stNFixAlignables_(iConfig.getParameter<int>("nFixAlignables") ), 00072 stRandomShift_(iConfig.getParameter<double>("randomShift")), 00073 stRandomRotation_(iConfig.getParameter<double>("randomRotation")), 00074 applyDbAlignment_( iConfig.getUntrackedParameter<bool>("applyDbAlignment",false) ), 00075 doMisalignmentScenario_(iConfig.getParameter<bool>("doMisalignmentScenario")), 00076 saveToDB_(iConfig.getParameter<bool>("saveToDB")), 00077 doTracker_( iConfig.getUntrackedParameter<bool>("doTracker") ), 00078 doMuon_( iConfig.getUntrackedParameter<bool>("doMuon") ), 00079 useSurvey_( iConfig.getParameter<bool>("useSurvey") ) 00080 { 00081 00082 edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::AlignmentProducer"; 00083 00084 // Tell the framework what data is being produced 00085 if (doTracker_) { 00086 setWhatProduced(this, &AlignmentProducer::produceTracker); 00087 } 00088 if (doMuon_) { 00089 setWhatProduced(this, &AlignmentProducer::produceDT); 00090 setWhatProduced(this, &AlignmentProducer::produceCSC); 00091 } 00092 00093 // Create the alignment algorithm 00094 edm::ParameterSet algoConfig = iConfig.getParameter<edm::ParameterSet>( "algoConfig" ); 00095 std::string algoName = algoConfig.getParameter<std::string>("algoName"); 00096 theAlignmentAlgo = AlignmentAlgorithmPluginFactory::get( )->create( algoName, algoConfig ); 00097 00098 // Check if found 00099 if ( !theAlignmentAlgo ) 00100 throw cms::Exception("BadConfig") << "Couldn't find algorithm called " << algoName; 00101 00102 edm::ParameterSet monitorConfig = iConfig.getParameter<edm::ParameterSet>( "monitorConfig" ); 00103 std::vector<std::string> monitors = monitorConfig.getUntrackedParameter<std::vector<std::string> >( "monitors" ); 00104 00105 for (std::vector<std::string>::const_iterator miter = monitors.begin(); miter != monitors.end(); ++miter) { 00106 AlignmentMonitorBase* newMonitor = AlignmentMonitorPluginFactory::get()->create(*miter, monitorConfig.getUntrackedParameter<edm::ParameterSet>(*miter)); 00107 00108 if (!newMonitor) throw cms::Exception("BadConfig") << "Couldn't find monitor named " << *miter; 00109 00110 theMonitors.push_back(newMonitor); 00111 } 00112 00113 }
AlignmentProducer::~AlignmentProducer | ( | ) |
Destructor.
Definition at line 118 of file AlignmentProducer.cc.
References theAlignableMuon, theAlignableTracker, and theAlignmentParameterStore.
00119 { 00120 00121 delete theAlignmentParameterStore; 00122 delete theAlignableTracker; 00123 delete theAlignableMuon; 00124 00125 }
Add survey info to an alignable.
Definition at line 574 of file AlignmentProducer.cc.
References Alignable::alignableObjectId(), Alignable::components(), error, Exception, i, Alignable::id(), AlignableSurface::length(), Alignments::m_align, SurveyErrors::m_surveyErrors, SurveyError::matrix(), SurveyError::rawId(), rot, AlignableSurface::setLength(), Alignable::setSurvey(), AlignableSurface::setWidth(), SurveyError::structureType(), Alignable::surface(), theSurveyErrors, theSurveyIndex, theSurveyValues, and AlignableSurface::width().
Referenced by beginOfJob().
00575 { 00576 const std::vector<Alignable*>& comp = ali->components(); 00577 00578 unsigned int nComp = comp.size(); 00579 00580 for (unsigned int i = 0; i < nComp; ++i) addSurveyInfo_(comp[i]); 00581 00582 const SurveyError& error = theSurveyErrors->m_surveyErrors[theSurveyIndex]; 00583 00584 if ( ali->id() != error.rawId() || 00585 ali->alignableObjectId() != error.structureType() ) 00586 { 00587 throw cms::Exception("DatabaseError") 00588 << "Error reading survey info from DB. Mismatched id!"; 00589 } 00590 00591 const CLHEP::Hep3Vector& pos = theSurveyValues->m_align[theSurveyIndex].translation(); 00592 const CLHEP::HepRotation& rot = theSurveyValues->m_align[theSurveyIndex].rotation(); 00593 00594 AlignableSurface surf( align::PositionType( pos.x(), pos.y(), pos.z() ), 00595 align::RotationType( rot.xx(), rot.xy(), rot.xz(), 00596 rot.yx(), rot.yy(), rot.yz(), 00597 rot.zx(), rot.zy(), rot.zz() ) ); 00598 00599 surf.setWidth( ali->surface().width() ); 00600 surf.setLength( ali->surface().length() ); 00601 00602 ali->setSurvey( new SurveyDet( surf, error.matrix() ) ); 00603 00604 ++theSurveyIndex; 00605 }
void AlignmentProducer::beginOfJob | ( | const edm::EventSetup & | iSetup | ) | [virtual] |
Called at beginning of job.
Reimplemented from edm::EDLooper.
Definition at line 158 of file AlignmentProducer.cc.
References addSurveyInfo_(), align::AlignableMuon, AlignmentParameterStore_cfi::AlignmentParameterStore, GeometryAligner::applyAlignments(), applyDbAlignment_, TrackerScenarioBuilder::applyScenario(), MuonScenarioBuilder::applyScenario(), createGeometries_(), AlignableMuon::CSCEndcaps(), align::DetectorGlobalPosition(), doMisalignmentScenario_, doMuon_, doTracker_, AlignableMuon::DTBarrel(), edm::EventSetup::get(), edm::ParameterSet::getParameter(), AlignmentAlgorithmBase::initialize(), iter, DetId::Muon, nevent_, simpleMisalignment_(), stNFixAlignables_, stRandomRotation_, stRandomShift_, theAlignableMuon, theAlignableTracker, theAlignmentAlgo, theAlignmentParameterStore, theMonitors, theMuonCSC, theMuonDT, theParameterSet, theSurveyErrors, theSurveyIndex, theSurveyValues, theTracker, DetId::Tracker, and useSurvey_.
00159 { 00160 edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::beginOfJob"; 00161 00162 nevent_ = 0; 00163 GeometryAligner aligner; 00164 00165 // Create the geometries from the ideal geometries (first time only) 00166 this->createGeometries_( iSetup ); 00167 00168 // Retrieve and apply alignments, if requested (requires DB setup) 00169 if ( applyDbAlignment_ ) { 00170 // iSetup.get<TrackerDigiGeometryRecord>().getRecord<GlobalPositionRcd>().get(globalPositionRcd_); 00171 edm::ESHandle<Alignments> globalPositionRcd; 00172 iSetup.get<GlobalPositionRcd>().get(globalPositionRcd); 00173 if ( doTracker_ ) { 00174 edm::ESHandle<Alignments> alignments; 00175 iSetup.get<TrackerAlignmentRcd>().get( alignments ); 00176 edm::ESHandle<AlignmentErrors> alignmentErrors; 00177 iSetup.get<TrackerAlignmentErrorRcd>().get( alignmentErrors ); 00178 aligner.applyAlignments<TrackerGeometry>( &(*theTracker), &(*alignments), &(*alignmentErrors), 00179 align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Tracker)) ); 00180 } 00181 if ( doMuon_ ) { 00182 edm::ESHandle<Alignments> dtAlignments; 00183 iSetup.get<DTAlignmentRcd>().get( dtAlignments ); 00184 edm::ESHandle<AlignmentErrors> dtAlignmentErrors; 00185 iSetup.get<DTAlignmentErrorRcd>().get( dtAlignmentErrors ); 00186 aligner.applyAlignments<DTGeometry>( &(*theMuonDT), &(*dtAlignments), &(*dtAlignmentErrors), 00187 align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Muon)) ); 00188 00189 edm::ESHandle<Alignments> cscAlignments; 00190 iSetup.get<CSCAlignmentRcd>().get( cscAlignments ); 00191 edm::ESHandle<AlignmentErrors> cscAlignmentErrors; 00192 iSetup.get<CSCAlignmentErrorRcd>().get( cscAlignmentErrors ); 00193 aligner.applyAlignments<CSCGeometry>( &(*theMuonCSC), &(*cscAlignments), &(*cscAlignmentErrors), 00194 align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Muon)) ); 00195 } 00196 } 00197 00198 // Create alignable tracker and muon 00199 if (doTracker_) 00200 { 00201 theAlignableTracker = new AlignableTracker( &(*theTracker) ); 00202 00203 if (useSurvey_) 00204 { 00205 edm::ESHandle<Alignments> surveys; 00206 edm::ESHandle<SurveyErrors> surveyErrors; 00207 00208 iSetup.get<TrackerSurveyRcd>().get(surveys); 00209 iSetup.get<TrackerSurveyErrorRcd>().get(surveyErrors); 00210 00211 theSurveyIndex = 0; 00212 theSurveyValues = &*surveys; 00213 theSurveyErrors = &*surveyErrors; 00214 addSurveyInfo_(theAlignableTracker); 00215 } 00216 } 00217 00218 if (doMuon_) 00219 { 00220 theAlignableMuon = new AlignableMuon( &(*theMuonDT), &(*theMuonCSC) ); 00221 00222 if (useSurvey_) 00223 { 00224 edm::ESHandle<Alignments> dtSurveys; 00225 edm::ESHandle<SurveyErrors> dtSurveyErrors; 00226 edm::ESHandle<Alignments> cscSurveys; 00227 edm::ESHandle<SurveyErrors> cscSurveyErrors; 00228 00229 iSetup.get<DTSurveyRcd>().get(dtSurveys); 00230 iSetup.get<DTSurveyErrorRcd>().get(dtSurveyErrors); 00231 iSetup.get<CSCSurveyRcd>().get(cscSurveys); 00232 iSetup.get<CSCSurveyErrorRcd>().get(cscSurveyErrors); 00233 00234 theSurveyIndex = 0; 00235 theSurveyValues = &*dtSurveys; 00236 theSurveyErrors = &*dtSurveyErrors; 00237 std::vector<Alignable*> barrels = theAlignableMuon->DTBarrel(); 00238 for (std::vector<Alignable*>::const_iterator iter = barrels.begin(); iter != barrels.end(); ++iter) { 00239 addSurveyInfo_(*iter); 00240 } 00241 00242 theSurveyIndex = 0; 00243 theSurveyValues = &*cscSurveys; 00244 theSurveyErrors = &*cscSurveyErrors; 00245 std::vector<Alignable*> endcaps = theAlignableMuon->CSCEndcaps(); 00246 for (std::vector<Alignable*>::const_iterator iter = endcaps.begin(); iter != endcaps.end(); ++iter) { 00247 addSurveyInfo_(*iter); 00248 } 00249 } 00250 } 00251 00252 // Create alignment parameter builder 00253 edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::beginOfJob" 00254 << "Creating AlignmentParameterBuilder"; 00255 edm::ParameterSet aliParamBuildCfg = 00256 theParameterSet.getParameter<edm::ParameterSet>("ParameterBuilder"); 00257 AlignmentParameterBuilder alignmentParameterBuilder(theAlignableTracker, 00258 theAlignableMuon, 00259 aliParamBuildCfg ); 00260 // Fix alignables if requested 00261 if (stNFixAlignables_>0) alignmentParameterBuilder.fixAlignables(stNFixAlignables_); 00262 00263 // Get list of alignables 00264 Alignables theAlignables = alignmentParameterBuilder.alignables(); 00265 edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::beginOfJob" 00266 << "got " << theAlignables.size() << " alignables"; 00267 00268 // Create AlignmentParameterStore 00269 edm::ParameterSet aliParamStoreCfg = 00270 theParameterSet.getParameter<edm::ParameterSet>("ParameterStore"); 00271 theAlignmentParameterStore = new AlignmentParameterStore(theAlignables, aliParamStoreCfg); 00272 edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::beginOfJob" 00273 << "AlignmentParameterStore created!"; 00274 00275 // Apply misalignment scenario to alignable tracker and muon if requested 00276 // WARNING: this assumes scenarioConfig can be passed to both muon and tracker 00277 if (doMisalignmentScenario_ && (doTracker_ || doMuon_)) { 00278 edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::beginOfJob" 00279 << "Applying misalignment scenario to " 00280 << (doTracker_ ? "tracker" : "") 00281 << (doMuon_ ? (doTracker_ ? " and muon" : "muon") : "."); 00282 edm::ParameterSet scenarioConfig 00283 = theParameterSet.getParameter<edm::ParameterSet>( "MisalignmentScenario" ); 00284 if (doTracker_) { 00285 TrackerScenarioBuilder scenarioBuilder( theAlignableTracker ); 00286 scenarioBuilder.applyScenario( scenarioConfig ); 00287 } 00288 if (doMuon_) { 00289 MuonScenarioBuilder muonScenarioBuilder( theAlignableMuon ); 00290 muonScenarioBuilder.applyScenario( scenarioConfig ); 00291 } 00292 } else { 00293 edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::beginOfJob" 00294 << "NOT applying misalignment scenario!"; 00295 } 00296 00297 // Apply simple misalignment 00298 const std::string sParSel(theParameterSet.getParameter<std::string>("parameterSelectorSimple")); 00299 this->simpleMisalignment_(theAlignables, sParSel, stRandomShift_, stRandomRotation_, true); 00300 00301 // Initialize alignment algorithm 00302 theAlignmentAlgo->initialize( iSetup, theAlignableTracker, 00303 theAlignableMuon, theAlignmentParameterStore ); 00304 00305 for (std::vector<AlignmentMonitorBase*>::const_iterator monitor = theMonitors.begin(); monitor != theMonitors.end(); ++monitor) { 00306 (*monitor)->beginOfJob(theAlignableTracker, theAlignableMuon, theAlignmentParameterStore); 00307 } 00308 }
void AlignmentProducer::createGeometries_ | ( | const edm::EventSetup & | iSetup | ) | [private] |
Create tracker and muon geometries.
Definition at line 551 of file AlignmentProducer.cc.
References DTGeometryBuilderFromDDD::build(), CSCGeometryBuilderFromDDD::build(), TrackerGeomBuilderFromGeometricDet::build(), doMuon_, doTracker_, edm::EventSetup::get(), theMuonCSC, theMuonDT, and theTracker.
Referenced by beginOfJob().
00552 { 00553 edm::ESHandle<DDCompactView> cpv; 00554 iSetup.get<IdealGeometryRecord>().get( cpv ); 00555 00556 if (doTracker_) { 00557 edm::ESHandle<GeometricDet> geometricDet; 00558 iSetup.get<IdealGeometryRecord>().get( geometricDet ); 00559 TrackerGeomBuilderFromGeometricDet trackerBuilder; 00560 theTracker = boost::shared_ptr<TrackerGeometry>( trackerBuilder.build(&(*geometricDet)) ); 00561 } 00562 00563 if (doMuon_) { 00564 edm::ESHandle<MuonDDDConstants> mdc; 00565 iSetup.get<MuonNumberingRecord>().get(mdc); 00566 DTGeometryBuilderFromDDD DTGeometryBuilder; 00567 CSCGeometryBuilderFromDDD CSCGeometryBuilder; 00568 theMuonDT = boost::shared_ptr<DTGeometry>(DTGeometryBuilder.build(&(*cpv), *mdc)); 00569 theMuonCSC = boost::shared_ptr<CSCGeometry>( new CSCGeometry ); 00570 CSCGeometryBuilder.build( theMuonCSC, &(*cpv), *mdc ); 00571 } 00572 }
edm::EDLooper::Status AlignmentProducer::duringLoop | ( | const edm::Event & | event, | |
const edm::EventSetup & | setup | |||
) | [virtual] |
Called at each event.
Implements edm::EDLooper.
Definition at line 442 of file AlignmentProducer.cc.
References edm::Event::getByLabel(), edm::ParameterSet::getParameter(), i, edm::EDLooper::kContinue, nevent_, AlignmentAlgorithmBase::run(), theAlignmentAlgo, theMonitors, and theParameterSet.
00444 { 00445 nevent_++; 00446 00447 // Printout event number 00448 for ( int i=10; i<10000000; i*=10 ) 00449 if ( nevent_<10*i && (nevent_%i)==0 ) 00450 edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::duringLoop" 00451 << "Events processed: " << nevent_; 00452 00453 // Retrieve trajectories and tracks from the event 00454 // -> merely skip if collection is empty 00455 edm::InputTag tjTag = theParameterSet.getParameter<edm::InputTag>("tjTkAssociationMapTag"); 00456 edm::Handle<TrajTrackAssociationCollection> m_TrajTracksMap; 00457 if ( event.getByLabel( tjTag, m_TrajTracksMap ) ) { 00458 00459 // Form pairs of trajectories and tracks 00460 ConstTrajTrackPairCollection trajTracks; 00461 for ( TrajTrackAssociationCollection::const_iterator iPair = m_TrajTracksMap->begin(); 00462 iPair != m_TrajTracksMap->end(); iPair++ ) 00463 trajTracks.push_back( ConstTrajTrackPair( &(*(*iPair).key), &(*(*iPair).val) ) ); 00464 00465 // Run the alignment algorithm 00466 theAlignmentAlgo->run( setup, trajTracks ); 00467 00468 for (std::vector<AlignmentMonitorBase*>::const_iterator monitor = theMonitors.begin(); monitor != theMonitors.end(); ++monitor) { 00469 (*monitor)->duringLoop(setup, trajTracks); 00470 } 00471 } else { 00472 edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::duringLoop" 00473 << "No track collection found: skipping event"; 00474 } 00475 00476 00477 return kContinue; 00478 }
void AlignmentProducer::endOfJob | ( | ) | [virtual] |
Called at end of job.
Reimplemented from edm::EDLooper.
Definition at line 312 of file AlignmentProducer.cc.
References AlignableTracker::alignmentErrors(), AlignableTracker::alignments(), AlignableMuon::cscAlignmentErrors(), AlignableMuon::cscAlignments(), doMuon_, doTracker_, AlignableMuon::dtAlignmentErrors(), AlignableMuon::dtAlignments(), edm::Service< T >::isAvailable(), saveToDB_, theAlignableMuon, theAlignableTracker, and theMonitors.
00313 { 00314 edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::endOfJob"; 00315 00316 for (std::vector<AlignmentMonitorBase*>::const_iterator monitor = theMonitors.begin(); monitor != theMonitors.end(); ++monitor) { 00317 (*monitor)->endOfJob(); 00318 } 00319 00320 // Save alignments to database 00321 if (saveToDB_) { 00322 edm::LogInfo("Alignment") << "Writing Alignments to DB..."; 00323 // Call service 00324 edm::Service<cond::service::PoolDBOutputService> poolDbService; 00325 if( !poolDbService.isAvailable() ) // Die if not available 00326 throw cms::Exception("NotAvailable") << "PoolDBOutputService not available"; 00327 00328 if ( doTracker_ ) { 00329 // Get alignments+errors 00330 Alignments* alignments = theAlignableTracker->alignments(); 00331 AlignmentErrors* alignmentErrors = theAlignableTracker->alignmentErrors(); 00332 00333 // FIXME: remove the global coordinate transformation from these alignments! 00334 // GeometryAligner aligner; 00335 // Alignments localAlignments = aligner.removeGlobalTransform(alignments, 00336 // align::DetectorGlobalPosition(*globalPositionRcd_, DetId(DetId::Tracker))); 00337 // and put &localAlignments into the database 00338 // (the removal code should be in GeometryAligner so that a 00339 // developer can see that the inverse is properly calculated in 00340 // the same file that it is added) 00341 00342 // Store 00343 const std::string alignRecordName("TrackerAlignmentRcd"); 00344 const std::string errorRecordName("TrackerAlignmentErrorRcd"); 00345 00346 poolDbService->writeOne<Alignments>(alignments, poolDbService->beginOfTime(), 00347 alignRecordName); 00348 poolDbService->writeOne<AlignmentErrors>(alignmentErrors, poolDbService->beginOfTime(), 00349 errorRecordName); 00350 } 00351 00352 if ( doMuon_ ) { 00353 // Get alignments+errors 00354 Alignments* dtAlignments = theAlignableMuon->dtAlignments(); 00355 AlignmentErrors* dtAlignmentErrors = theAlignableMuon->dtAlignmentErrors(); 00356 Alignments* cscAlignments = theAlignableMuon->cscAlignments(); 00357 AlignmentErrors* cscAlignmentErrors = theAlignableMuon->cscAlignmentErrors(); 00358 00359 // FIXME: remove the global coordinate transformation from these alignments! 00360 // GeometryAligner aligner; 00361 // Alignments localDTAlignments = aligner.removeGlobalTransform(alignments, align::DetectorGlobalPosition(*globalPositionRcd_, DetId(DetId::Muon))); 00362 // Alignments localCSCAlignments = aligner.removeGlobalTransform(alignments, align::DetectorGlobalPosition(*globalPositionRcd_, DetId(DetId::Muon))); 00363 // and put &localDTAlignments, &localCSCAlignments into the database 00364 00365 const std::string dtAlignRecordName("DTAlignmentRcd"); 00366 const std::string dtErrorRecordName("DTAlignmentErrorRcd"); 00367 const std::string cscAlignRecordName("CSCAlignmentRcd"); 00368 const std::string cscErrorRecordName("CSCAlignmentErrorRcd"); 00369 00370 poolDbService->writeOne<Alignments>(dtAlignments, poolDbService->beginOfTime(), 00371 dtAlignRecordName); 00372 poolDbService->writeOne<AlignmentErrors>(dtAlignmentErrors, poolDbService->beginOfTime(), 00373 dtErrorRecordName); 00374 00375 poolDbService->writeOne<Alignments>(cscAlignments, poolDbService->beginOfTime(), 00376 cscAlignRecordName); 00377 poolDbService->writeOne<AlignmentErrors>(cscAlignmentErrors, poolDbService->beginOfTime(), 00378 cscErrorRecordName); 00379 } 00380 } 00381 }
edm::EDLooper::Status AlignmentProducer::endOfLoop | ( | const edm::EventSetup & | iSetup, | |
unsigned int | iLoop | |||
) | [virtual] |
Called at end of loop.
Implements edm::EDLooper.
Definition at line 422 of file AlignmentProducer.cc.
References edm::EDLooper::kContinue, edm::EDLooper::kStop, AlignmentAlgorithmBase::terminate(), theAlignmentAlgo, theMaxLoops, and theMonitors.
00423 { 00424 edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::endOfLoop" 00425 << "Ending loop " << iLoop; 00426 00427 edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::endOfLoop" 00428 << "Terminating algorithm."; 00429 theAlignmentAlgo->terminate(); 00430 00431 for (std::vector<AlignmentMonitorBase*>::const_iterator monitor = theMonitors.begin(); monitor != theMonitors.end(); ++monitor) { 00432 (*monitor)->endOfLoop(iSetup); 00433 } 00434 00435 if ( iLoop == theMaxLoops-1 || iLoop >= theMaxLoops ) return kStop; 00436 else return kContinue; 00437 }
boost::shared_ptr< CSCGeometry > AlignmentProducer::produceCSC | ( | const MuonGeometryRecord & | iRecord | ) | [virtual] |
Produce the muon CSC geometry.
Definition at line 149 of file AlignmentProducer.cc.
References theMuonCSC.
Referenced by AlignmentProducer().
00150 { 00151 edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::produceCSC"; 00152 return theMuonCSC; 00153 }
boost::shared_ptr< DTGeometry > AlignmentProducer::produceDT | ( | const MuonGeometryRecord & | iRecord | ) | [virtual] |
Produce the muon DT geometry.
Definition at line 140 of file AlignmentProducer.cc.
References theMuonDT.
Referenced by AlignmentProducer().
00141 { 00142 edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::produceDT"; 00143 return theMuonDT; 00144 }
boost::shared_ptr< TrackerGeometry > AlignmentProducer::produceTracker | ( | const TrackerDigiGeometryRecord & | iRecord | ) | [virtual] |
Produce the tracker geometry.
Definition at line 131 of file AlignmentProducer.cc.
References theTracker.
Referenced by AlignmentProducer().
00132 { 00133 edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::produceTracker"; 00134 return theTracker; 00135 }
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 482 of file AlignmentProducer.cc.
References funct::abs(), Alignable::alignmentParameters(), AlignmentParameterSelector::convertParamSel(), RigidBodyAlignmentParameters::dalpha, RigidBodyAlignmentParameters::dbeta, RigidBodyAlignmentParameters::dgamma, RigidBodyAlignmentParameters::dx, RigidBodyAlignmentParameters::dy, RigidBodyAlignmentParameters::dz, Exception, it, Alignable::move(), RigidBodyAlignmentParameters::N_PARAM, output(), r, random, Alignable::rotateInGlobalFrame(), Alignable::rotateInLocalFrame(), s1, s2, AlignmentParameters::selector(), Alignable::surface(), AlignableSurface::toGlobal(), and align::toMatrix().
Referenced by beginOfJob().
00484 { 00485 00486 std::ostringstream output; // collecting output 00487 00488 if (shift > 0. || rot > 0.) { 00489 output << "Adding random flat shift of max size " << shift 00490 << " and adding random flat rotation of max size " << rot <<" to "; 00491 00492 std::vector<bool> commSel(0); 00493 if (selection != "-1") { 00494 AlignmentParameterSelector aSelector(0,0); // no alignable needed here... 00495 const std::vector<char> cSel(aSelector.convertParamSel(selection)); 00496 if (cSel.size() < RigidBodyAlignmentParameters::N_PARAM) { 00497 throw cms::Exception("BadConfig") 00498 << "[AlignmentProducer::simpleMisalignment_]\n" 00499 << "Expect selection string '" << selection << "' to be at least of length " 00500 << RigidBodyAlignmentParameters::N_PARAM << " or to be '-1'.\n" 00501 << "(Most probably you have to adjust the parameter 'parameterSelectorSimple'.)"; 00502 } 00503 for (std::vector<char>::const_iterator cIter = cSel.begin(); cIter != cSel.end(); ++cIter) { 00504 commSel.push_back(*cIter == '0' ? false : true); 00505 } 00506 output << "parameters defined by (" << selection 00507 << "), representing (x,y,z,alpha,beta,gamma),"; 00508 } else { 00509 output << "the active parameters of each alignable,"; 00510 } 00511 output << " in " << (local ? "local" : "global") << " frame."; 00512 00513 for (std::vector<Alignable*>::const_iterator it = alivec.begin(); it != alivec.end(); ++it) { 00514 Alignable* ali=(*it); 00515 std::vector<bool> mysel(commSel.empty() ? ali->alignmentParameters()->selector() : commSel); 00516 00517 if (std::abs(shift)>0.00001) { 00518 double s0 = 0., s1 = 0., s2 = 0.; 00519 if (mysel[RigidBodyAlignmentParameters::dx]) s0 = shift * double(random()%1000-500)/500.; 00520 if (mysel[RigidBodyAlignmentParameters::dy]) s1 = shift * double(random()%1000-500)/500.; 00521 if (mysel[RigidBodyAlignmentParameters::dz]) s2 = shift * double(random()%1000-500)/500.; 00522 00523 if (local) ali->move( ali->surface().toGlobal(align::LocalVector(s0,s1,s2)) ); 00524 else ali->move( align::GlobalVector(s0,s1,s2) ); 00525 00526 //AlignmentPositionError ape(dx,dy,dz); 00527 //ali->addAlignmentPositionError(ape); 00528 } 00529 00530 if (std::abs(rot)>0.00001) { 00531 align::EulerAngles r(3); 00532 if (mysel[RigidBodyAlignmentParameters::dalpha]) r(1)=rot*double(random()%1000-500)/500.; 00533 if (mysel[RigidBodyAlignmentParameters::dbeta]) r(2)=rot*double(random()%1000-500)/500.; 00534 if (mysel[RigidBodyAlignmentParameters::dgamma]) r(3)=rot*double(random()%1000-500)/500.; 00535 00536 const align::RotationType mrot = align::toMatrix(r); 00537 if (local) ali->rotateInLocalFrame(mrot); 00538 else ali->rotateInGlobalFrame(mrot); 00539 00540 //ali->addAlignmentPositionErrorFromRotation(mrot); 00541 } 00542 } // end loop on alignables 00543 } else { 00544 output << "No simple misalignment added!"; 00545 } 00546 edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::simpleMisalignment_" << output.str(); 00547 }
Called at beginning of loop.
Implements edm::EDLooper.
Definition at line 385 of file AlignmentProducer.cc.
References AlignableTracker::alignmentErrors(), AlignableTracker::alignments(), GeometryAligner::applyAlignments(), AlignableMuon::cscAlignmentErrors(), AlignableMuon::cscAlignments(), doMuon_, doTracker_, AlignableMuon::dtAlignmentErrors(), AlignableMuon::dtAlignments(), AlignmentAlgorithmBase::startNewLoop(), theAlignableMuon, theAlignableTracker, theAlignmentAlgo, and theMonitors.
00386 { 00387 edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::startingNewLoop" 00388 << "Starting loop number " << iLoop; 00389 00390 theAlignmentAlgo->startNewLoop(); 00391 00392 for (std::vector<AlignmentMonitorBase*>::const_iterator monitor = theMonitors.begin(); monitor != theMonitors.end(); ++monitor) { 00393 (*monitor)->startingNewLoop(); 00394 } 00395 00396 edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::startingNewLoop" 00397 << "Now physically apply alignments to geometry..."; 00398 00399 00400 // Propagate changes to reconstruction geometry (from initialisation or iteration) 00401 GeometryAligner aligner; 00402 if ( doTracker_ ) { 00403 std::auto_ptr<Alignments> alignments(theAlignableTracker->alignments()); 00404 std::auto_ptr<AlignmentErrors> alignmentErrors(theAlignableTracker->alignmentErrors()); 00405 aligner.applyAlignments<TrackerGeometry>( &(*theTracker),&(*alignments),&(*alignmentErrors), AlignTransform() ); // don't apply global a second time! 00406 } 00407 if ( doMuon_ ) { 00408 std::auto_ptr<Alignments> dtAlignments( theAlignableMuon->dtAlignments()); 00409 std::auto_ptr<AlignmentErrors> dtAlignmentErrors( theAlignableMuon->dtAlignmentErrors()); 00410 std::auto_ptr<Alignments> cscAlignments( theAlignableMuon->cscAlignments()); 00411 std::auto_ptr<AlignmentErrors> cscAlignmentErrors( theAlignableMuon->cscAlignmentErrors()); 00412 00413 aligner.applyAlignments<DTGeometry>( &(*theMuonDT), &(*dtAlignments), &(*dtAlignmentErrors), AlignTransform() ); // don't apply global a second time! 00414 aligner.applyAlignments<CSCGeometry>( &(*theMuonCSC), &(*cscAlignments), &(*cscAlignmentErrors), AlignTransform() ); // nope! 00415 } 00416 }
bool AlignmentProducer::applyDbAlignment_ [private] |
bool AlignmentProducer::doMuon_ [private] |
Definition at line 117 of file AlignmentProducer.h.
Referenced by AlignmentProducer(), beginOfJob(), createGeometries_(), endOfJob(), and startingNewLoop().
bool AlignmentProducer::doTracker_ [private] |
Definition at line 117 of file AlignmentProducer.h.
Referenced by AlignmentProducer(), beginOfJob(), createGeometries_(), endOfJob(), and startingNewLoop().
int AlignmentProducer::nevent_ [private] |
bool AlignmentProducer::saveToDB_ [private] |
int AlignmentProducer::stNFixAlignables_ [private] |
double AlignmentProducer::stRandomRotation_ [private] |
double AlignmentProducer::stRandomShift_ [private] |
AlignableMuon* AlignmentProducer::theAlignableMuon [private] |
Definition at line 100 of file AlignmentProducer.h.
Referenced by beginOfJob(), endOfJob(), startingNewLoop(), and ~AlignmentProducer().
Definition at line 99 of file AlignmentProducer.h.
Referenced by beginOfJob(), endOfJob(), startingNewLoop(), and ~AlignmentProducer().
Definition at line 95 of file AlignmentProducer.h.
Referenced by AlignmentProducer(), beginOfJob(), duringLoop(), endOfLoop(), and startingNewLoop().
Definition at line 97 of file AlignmentProducer.h.
Referenced by beginOfJob(), and ~AlignmentProducer().
unsigned int AlignmentProducer::theMaxLoops [private] |
std::vector<AlignmentMonitorBase*> AlignmentProducer::theMonitors [private] |
Definition at line 96 of file AlignmentProducer.h.
Referenced by AlignmentProducer(), beginOfJob(), duringLoop(), endOfJob(), endOfLoop(), and startingNewLoop().
boost::shared_ptr<CSCGeometry> AlignmentProducer::theMuonCSC [private] |
Definition at line 104 of file AlignmentProducer.h.
Referenced by beginOfJob(), createGeometries_(), and produceCSC().
boost::shared_ptr<DTGeometry> AlignmentProducer::theMuonDT [private] |
Definition at line 103 of file AlignmentProducer.h.
Referenced by beginOfJob(), createGeometries_(), and produceDT().
const SurveyErrors* AlignmentProducer::theSurveyErrors [private] |
Definition at line 93 of file AlignmentProducer.h.
Referenced by addSurveyInfo_(), and beginOfJob().
unsigned int AlignmentProducer::theSurveyIndex [private] |
Definition at line 91 of file AlignmentProducer.h.
Referenced by addSurveyInfo_(), and beginOfJob().
const Alignments* AlignmentProducer::theSurveyValues [private] |
Definition at line 92 of file AlignmentProducer.h.
Referenced by addSurveyInfo_(), and beginOfJob().
boost::shared_ptr<TrackerGeometry> AlignmentProducer::theTracker [private] |
Definition at line 102 of file AlignmentProducer.h.
Referenced by beginOfJob(), createGeometries_(), and produceTracker().
bool AlignmentProducer::useSurvey_ [private] |