74 theAlignmentAlgo(0), theAlignmentParameterStore(0),
75 theAlignableExtras(0), theAlignableTracker(0), theAlignableMuon(0),
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"))
97 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducer::AlignmentProducer";
110 std::string algoName = algoConfig.
getParameter<std::string>(
"algoName");
114 if ( !theAlignmentAlgo )
115 throw cms::Exception(
"BadConfig") <<
"Couldn't find algorithm called " << algoName;
118 std::vector<std::string> monitors = monitorConfig.
getUntrackedParameter<std::vector<std::string> >(
"monitors" );
120 for (std::vector<std::string>::const_iterator miter = monitors.begin(); miter != monitors.end(); ++miter) {
123 if (!newMonitor)
throw cms::Exception(
"BadConfig") <<
"Couldn't find monitor named " << *miter;
145 boost::shared_ptr<TrackerGeometry>
148 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducer::produceTracker";
154 boost::shared_ptr<DTGeometry>
157 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducer::produceDT";
163 boost::shared_ptr<CSCGeometry>
166 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducer::produceCSC";
175 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducer::beginOfJob";
189 this->applyDB<TrackerGeometry,TrackerAlignmentRcd,TrackerAlignmentErrorRcd>
190 (&(*theTracker), iSetup,
195 this->applyDB<DTGeometry,DTAlignmentRcd,DTAlignmentErrorRcd>
196 (&(*theMuonDT), iSetup,
198 this->applyDB<CSCGeometry,CSCAlignmentRcd,CSCAlignmentErrorRcd>
199 (&(*theMuonCSC), iSetup,
205 this->applyDB<TrackerGeometry,TrackerSurfaceDeformationRcd>(&(*theTracker), iSetup);
222 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducer::beginOfJob"
223 <<
"Creating AlignmentParameterBuilder";
234 Alignables theAlignables = alignmentParameterBuilder.alignables();
235 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducer::beginOfJob"
236 <<
"got " << theAlignables.size() <<
" alignables";
242 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducer::beginOfJob"
243 <<
"AlignmentParameterStore created!";
248 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducer::beginOfJob"
249 <<
"Applying misalignment scenario to "
263 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducer::beginOfJob"
264 <<
"NOT applying misalignment scenario!";
274 theAlignmentParameterStore );
276 for (std::vector<AlignmentMonitorBase*>::const_iterator monitor =
theMonitors.begin();
286 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducer::endOfJob";
288 for (std::vector<AlignmentMonitorBase*>::const_iterator monitor =
theMonitors.begin(); monitor !=
theMonitors.end(); ++monitor) {
289 (*monitor)->endOfJob();
293 edm::LogError(
"Alignment") <<
"@SUB=AlignmentProducer::endOfJob" <<
"Did not process any "
294 <<
"events in last loop, do not dare to store to DB.";
309 this->
writeDB(alignments,
"TrackerAlignmentRcd",
310 alignmentErrors,
"TrackerAlignmentErrorRcd", trackerGlobal);
322 this->
writeDB(alignments,
"DTAlignmentRcd",
323 alignmentErrors,
"DTAlignmentErrorRcd", muonGlobal);
328 this->
writeDB(alignments,
"CSCAlignmentRcd",
329 alignmentErrors,
"CSCAlignmentErrorRcd", muonGlobal);
335 this->
writeDB(alignmentSurfaceDeformations,
"TrackerSurfaceDeformationRcd");
348 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducer::startingNewLoop"
349 <<
"Starting loop number " << iLoop;
355 for (std::vector<AlignmentMonitorBase*>::const_iterator monitor =
theMonitors.begin(); monitor !=
theMonitors.end(); ++monitor) {
356 (*monitor)->startingNewLoop();
359 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducer::startingNewLoop"
360 <<
"Now physically apply alignments to geometry...";
397 edm::LogError(
"Alignment") <<
"@SUB=AlignmentProducer::endOfLoop"
398 <<
"Did not process any events in loop " << iLoop
399 <<
", stop processing without terminating algorithm.";
403 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducer::endOfLoop"
404 <<
"Ending loop " << iLoop <<
", terminating algorithm.";
408 for (std::vector<AlignmentMonitorBase*>::const_iterator monitor =
theMonitors.begin(); monitor !=
theMonitors.end(); ++monitor) {
409 (*monitor)->endOfLoop(iSetup);
428 for (
int i=10;
i<10000000;
i*=10 )
430 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducer::duringLoop"
431 <<
"Events processed: " <<
nevent_;
441 iPair != m_TrajTracksMap->end(); ++iPair) {
448 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducer::duringLoop"
449 <<
"initializing AlignableBeamSpot" << std::endl;
451 beamSpot->dxdz(), beamSpot->dydz());
459 clusterValueMapPtr = &(*clusterValueMap);
467 for (std::vector<AlignmentMonitorBase*>::const_iterator monitor =
theMonitors.begin();
469 (*monitor)->duringLoop(event, setup, trajTracks);
472 edm::LogError(
"Alignment") <<
"@SUB=AlignmentProducer::duringLoop"
473 <<
"No track collection found: skipping event";
499 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducer::endRun"
500 <<
"No Tk LAS beams to forward to algorithm.";
522 float shift,
float rot,
bool local)
525 std::ostringstream
output;
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 ";
531 std::vector<bool> commSel(0);
532 if (selection !=
"-1") {
537 <<
"[AlignmentProducer::simpleMisalignment_]\n"
538 <<
"Expect selection string '" << selection <<
"' to be at least of length "
540 <<
"(Most probably you have to adjust the parameter 'parameterSelectorSimple'.)";
542 for (std::vector<char>::const_iterator cIter = cSel.begin(); cIter != cSel.end(); ++cIter) {
543 commSel.push_back(*cIter ==
'0' ?
false :
true);
545 output <<
"parameters defined by (" << selection
546 <<
"), representing (x,y,z,alpha,beta,gamma),";
548 output <<
"the active parameters of each alignable,";
550 output <<
" in " << (local ?
"local" :
"global") <<
" frame.";
552 for (std::vector<Alignable*>::const_iterator it = alivec.begin(); it != alivec.end(); ++it) {
557 double s0 = 0., s1 = 0.,
s2 = 0.;
583 output <<
"No simple misalignment added!";
585 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducer::simpleMisalignment_" << output.str();
599 theTracker = boost::shared_ptr<TrackerGeometry>( trackerBuilder.
build(&(*geometricDet)) );
616 const std::vector<Alignable*>& comp = ali->
components();
618 unsigned int nComp = comp.size();
624 if ( ali->
id() != error.
rawId() ||
628 <<
"Error reading survey info from DB. Mismatched id!";
636 rot.yx(), rot.yy(), rot.yz(),
637 rot.zx(), rot.zy(), rot.zz() ) );
653 edm::LogInfo(
"Alignment") <<
"watcher tksurveyrcd: " << tkSurveyBool;
654 edm::LogInfo(
"Alignment") <<
"watcher tksurveyerrrcd: " << tkSurveyErrBool;
655 if ( tkSurveyBool || tkSurveyErrBool){
657 edm::LogInfo(
"Alignment") <<
"ADDING THE SURVEY INFORMATION";
677 if ( DTSurveyBool || DTSurveyErrBool || CSCSurveyBool || CSCSurveyErrBool ){
692 for (std::vector<Alignable*>::const_iterator iter = barrels.begin(); iter != barrels.end(); ++iter) {
700 for (std::vector<Alignable*>::const_iterator iter = endcaps.begin(); iter != endcaps.end(); ++iter) {
712 template<
class G,
class Rcd,
class ErrRcd>
721 iSetup.
get<Rcd>().
get(alignments);
724 iSetup.
get<ErrRcd>().
get(alignmentErrors);
735 template<
class G,
class DeformationRcd>
741 iSetup.
get<DeformationRcd>().
get(surfaceDeformations);
750 const std::string &alignRcd,
752 const std::string &errRcd,
761 delete tempAlignments;
762 delete tempAlignmentErrors;
763 throw cms::Exception(
"NotAvailable") <<
"PoolDBOutputService not available";
766 if (globalCoordinates
767 && globalCoordinates->
transform() != AlignTransform::Transform::Identity) {
775 tempAlignments, tempAlignmentErrors);
778 delete alignmentErrors;
780 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducer::writeDB"
781 <<
"globalCoordinates removed from alignments (" << alignRcd
782 <<
") and errors (" << alignRcd <<
").";
786 edm::LogInfo(
"Alignment") <<
"Writing Alignments to " << alignRcd <<
".";
789 delete tempAlignments;
793 edm::LogInfo(
"Alignment") <<
"Writing AlignmentErrors to " << errRcd <<
".";
796 delete tempAlignmentErrors;
803 const std::string &surfaceDeformationRcd)
const
808 delete alignmentSurfaceDeformations;
809 throw cms::Exception(
"NotAvailable") <<
"PoolDBOutputService not available";
813 edm::LogInfo(
"Alignment") <<
"Writing AlignmentSurfaceDeformations to "
814 << surfaceDeformationRcd <<
".";
816 surfaceDeformationRcd);
818 delete alignmentSurfaceDeformations;
std::vector< Alignable * > Alignables
align::Scalar width() const
AlignmentProducer(const edm::ParameterSet &iConfig)
Constructor.
virtual void beginLuminosityBlock(const edm::EventSetup &setup)
called at begin of luminosity block (no lumi block info passed yet)
virtual void beginRun(const edm::EventSetup &setup)
called at begin of run
T getParameter(std::string const &) const
align::ID id() const
Return the ID of Alignable, i.e. DetId of 'first' component GeomDet(Unit).
bool getByLabel(std::string const &label, Handle< PROD > &result) const
T getUntrackedParameter(std::string const &, T const &) const
virtual void terminate()=0
Call at end of job (must be implemented in derived class)
const bool applyDbDeformations_
AlignmentErrors * dtAlignmentErrors()
boost::shared_ptr< TrackerGeometry > theTracker
virtual void rotateInLocalFrame(const RotationType &rotation)
Rotation intepreted in the local reference frame.
const bool doMisalignmentScenario_
virtual void run(const edm::EventSetup &setup, const EventInfo &eventInfo)=0
Run the algorithm (must be implemented in derived class)
Builds a scenario from configuration and applies it to the alignable Muon.
AlignmentAlgorithmBase * theAlignmentAlgo
~AlignmentProducer()
Destructor.
virtual boost::shared_ptr< TrackerGeometry > produceTracker(const TrackerDigiGeometryRecord &iRecord)
Produce the tracker geometry.
Class to update a given geometry with a set of alignments.
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 readInSurveyRcds(const edm::EventSetup &)
read in survey records
ErrorMatrix matrix() const
virtual boost::shared_ptr< DTGeometry > produceDT(const MuonGeometryRecord &iRecord)
Produce the muon DT geometry.
virtual void endLuminosityBlock(const edm::EventSetup &setup)
called at end of luminosity block (no lumi block info passed yet)
virtual void beginRun(const edm::Run &run, const edm::EventSetup &setup)
Called at run start and calling algorithms beginRun.
#define DEFINE_FWK_LOOPER(type)
virtual Status endOfLoop(const edm::EventSetup &, unsigned int iLoop)
Called at end of loop.
edm::ParameterSet theParameterSet
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.
void setWidth(align::Scalar width)
const edm::InputTag tkLasBeamTag_
const Alignments * theSurveyValues
void addSurveyInfo_(Alignable *)
Add survey info to an alignable.
uint8_t structureType() const
void createGeometries_(const edm::EventSetup &)
Create tracker and muon geometries.
virtual Alignables components() const =0
Return vector of all direct components.
std::vector< AlignTransform > m_align
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
void removeGlobalTransform(const Alignments *alignments, const AlignmentErrors *alignmentErrors, const AlignTransform &globalCoordinates, Alignments *newAlignments, AlignmentErrors *newAlignmentErrors)
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
const bool applyDbAlignment_
virtual void endRun(const EndRunInfo &runInfo, const edm::EventSetup &setup)
called at end of run - order of arguments like in EDProducer etc.
void build(boost::shared_ptr< CSCGeometry > geom, const DDCompactView *fv, const MuonDDDConstants &muonConstants)
Build the geometry.
void setLength(align::Scalar length)
const unsigned int theMaxLoops
AlignableExtras * theAlignableExtras
Alignments * dtAlignments()
tuple AlignmentParameterStore
boost::shared_ptr< CSCGeometry > theMuonCSC
std::vector< Alignable * > CSCEndcaps()
const edm::InputTag clusterValueMapTag_
const int stNFixAlignables_
cond::Time_t beginOfTime() const
void attachSurfaceDeformations(C *geometry, const AlignmentSurfaceDeformations *surfaceDeformations)
unsigned int theSurveyIndex
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
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)
virtual void startingNewLoop(unsigned int iLoop)
Called at beginning of loop.
AlignmentParameterStore * theAlignmentParameterStore
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
AlignmentSurfaceDeformations * surfaceDeformations() const
Return surface deformations, sorted by DetId.
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)
void applyScenario(const edm::ParameterSet &scenario)
Apply misalignment scenario to the tracker.
boost::shared_ptr< DTGeometry > theMuonDT
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
const edm::InputTag beamSpotTag_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
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.
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
const SurveyErrors * theSurveyErrors
const edm::InputTag tjTkAssociationMapTag_
edm::ESWatcher< TrackerSurveyErrorRcd > watchTkSurveyErrRcd_
virtual Status duringLoop(const edm::Event &event, const edm::EventSetup &setup)
Called at each event.
std::vector< Alignable * > DTBarrel()
AlignableMuon * theAlignableMuon
const bool saveDeformationsToDB_
virtual void endOfJob()
Called at end of job.
AlgebraicVector EulerAngles
align::Scalar length() const
const double stRandomShift_
virtual void beginOfJob()
void build(boost::shared_ptr< DTGeometry > theGeometry, const DDCompactView *cview, const MuonDDDConstants &muonConstants)
virtual void rotateInGlobalFrame(const RotationType &rotation)=0
void setSurvey(const SurveyDet *)
Set survey info.
virtual void endLuminosityBlock(const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &setup)
Called at lumi block end, calling algorithm's endLuminosityBlock.
std::vector< ConstTrajTrackPair > ConstTrajTrackPairCollection
Alignments * cscAlignments()
TrackerGeometry * build(const GeometricDet *gd)
define run information passed to algorithms (in endRun)
bool check(const edm::EventSetup &iSetup)
void writeDB(Alignments *alignments, const std::string &alignRcd, AlignmentErrors *alignmentErrors, const std::string &errRcd, const AlignTransform *globalCoordinates) const
ESHandle< TrackerGeometry > geometry
virtual boost::shared_ptr< CSCGeometry > produceCSC(const MuonGeometryRecord &iRecord)
Produce the muon CSC geometry.
edm::ESWatcher< TrackerSurveyRcd > watchTkSurveyRcd_
align::GlobalPoints toGlobal(const align::LocalPoints &) const
Return in global coord given a set of local points.
AlignableTracker * theAlignableTracker
RotationType toMatrix(const EulerAngles &)
Convert rotation angles about x-, y-, z-axes to matrix.
virtual void beginLuminosityBlock(const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &setup)
Called at lumi block start, calling algorithm's beginLuminosityBlock.
std::vector< char > convertParamSel(const std::string &selString) const
Converting std::string into std::vector<char>
static unsigned int const shift
void applyDB(G *geometry, const edm::EventSetup &iSetup, const AlignTransform &globalPosition) const
const AlignTransform & DetectorGlobalPosition(const Alignments &allGlobals, const DetId &id)
virtual void startNewLoop()
Alignments * alignments() const
Return alignments, sorted by DetId.
std::vector< SurveyError > m_surveyErrors
std::pair< const Trajectory *, const reco::Track * > ConstTrajTrackPair
Builds a scenario from configuration and applies it to the alignable tracker.
const Alignments * globalPositions_
GlobalPositions that might be read from DB, NULL otherwise.
void applyScenario(const edm::ParameterSet &scenario)
Apply misalignment scenario to the Muon.
T get(const Candidate &c)
const double stRandomRotation_
define event information passed to algorithms