diff --git a/Alignment/TrackerAlignment/plugins/TrackerSystematicMisalignments.cc b/Alignment/TrackerAlignment/plugins/TrackerSystematicMisalignments.cc index 388dbe9be921a..fe8340157fb15 100644 --- a/Alignment/TrackerAlignment/plugins/TrackerSystematicMisalignments.cc +++ b/Alignment/TrackerAlignment/plugins/TrackerSystematicMisalignments.cc @@ -40,7 +40,7 @@ TrackerSystematicMisalignments::TrackerSystematicMisalignments(const edm::Parame { // use existing geometry m_fromDBGeom = cfg.getUntrackedParameter< bool > ("fromDBGeom"); - + // constants m_radialEpsilon = cfg.getUntrackedParameter< double > ("radialEpsilon"); m_telescopeEpsilon = cfg.getUntrackedParameter< double > ("telescopeEpsilon"); @@ -54,34 +54,34 @@ TrackerSystematicMisalignments::TrackerSystematicMisalignments(const edm::Parame m_ellipticalDelta = cfg.getUntrackedParameter< double > ("ellipticalDelta"); m_skewDelta = cfg.getUntrackedParameter< double > ("skewDelta"); - m_sagittaDelta = cfg.getUntrackedParameter< double > ("sagittaDelta"); - + m_sagittaDelta = cfg.getUntrackedParameter< double > ("sagittaDelta"); + if (m_radialEpsilon > -990.0){ - edm::LogWarning("MisalignedTracker") << "Applying radial ..."; + edm::LogWarning("MisalignedTracker") << "Applying radial ..."; } if (m_telescopeEpsilon > -990.0){ - edm::LogWarning("MisalignedTracker") << "Applying telescope ..."; + edm::LogWarning("MisalignedTracker") << "Applying telescope ..."; } if (m_layerRotEpsilon > -990.0){ - edm::LogWarning("MisalignedTracker") << "Applying layer rotation ..."; + edm::LogWarning("MisalignedTracker") << "Applying layer rotation ..."; } if (m_bowingEpsilon > -990.0){ - edm::LogWarning("MisalignedTracker") << "Applying bowing ..."; + edm::LogWarning("MisalignedTracker") << "Applying bowing ..."; } if (m_zExpEpsilon > -990.0){ - edm::LogWarning("MisalignedTracker") << "Applying z-expansion ..."; + edm::LogWarning("MisalignedTracker") << "Applying z-expansion ..."; } if (m_twistEpsilon > -990.0){ - edm::LogWarning("MisalignedTracker") << "Applying twist ..."; + edm::LogWarning("MisalignedTracker") << "Applying twist ..."; } if (m_ellipticalEpsilon > -990.0){ - edm::LogWarning("MisalignedTracker") << "Applying elliptical ..."; + edm::LogWarning("MisalignedTracker") << "Applying elliptical ..."; } if (m_skewEpsilon > -990.0){ - edm::LogWarning("MisalignedTracker") << "Applying skew ..."; + edm::LogWarning("MisalignedTracker") << "Applying skew ..."; } if (m_sagittaEpsilon > -990.0){ - edm::LogWarning("MisalignedTracker") << "Applying sagitta ..."; + edm::LogWarning("MisalignedTracker") << "Applying sagitta ..."; } // get flag for suppression of blind movements @@ -90,7 +90,7 @@ TrackerSystematicMisalignments::TrackerSystematicMisalignments(const edm::Parame { edm::LogWarning("MisalignedTracker") << "Blind movements suppressed (TIB/TOB in z, TID/TEC in r)"; } - + // compatibility with old (weird) z convention oldMinusZconvention = cfg.getUntrackedParameter< bool > ("oldMinusZconvention"); if (oldMinusZconvention) @@ -106,62 +106,62 @@ TrackerSystematicMisalignments::TrackerSystematicMisalignments(const edm::Parame void TrackerSystematicMisalignments::beginJob() { - + } void TrackerSystematicMisalignments::analyze(const edm::Event& event, const edm::EventSetup& setup){ - + //Retrieve tracker topology from geometry edm::ESHandle tTopoHandle; setup.get().get(tTopoHandle); const TrackerTopology* const tTopo = tTopoHandle.product(); - + edm::ESHandle geom; - setup.get().get(geom); + setup.get().get(geom); edm::ESHandle ptp; setup.get().get( ptp ); TrackerGeometry* tracker = TrackerGeomBuilderFromGeometricDet().build(&*geom, *ptp ); - + //take geometry from DB or randomly generate geometry if (m_fromDBGeom){ //build the tracker edm::ESHandle alignments; edm::ESHandle alignmentErrors; - + setup.get().get(alignments); setup.get().get(alignmentErrors); - + //apply the latest alignments GeometryAligner aligner; aligner.applyAlignments( &(*tracker), &(*alignments), &(*alignmentErrors), AlignTransform() ); - + } - + theAlignableTracker = new AlignableTracker(&(*tracker), tTopo); - + applySystematicMisalignment( &(*theAlignableTracker) ); - + // -------------- writing out to alignment record -------------- Alignments* myAlignments = theAlignableTracker->alignments() ; AlignmentErrorsExtended* myAlignmentErrorsExtended = theAlignableTracker->alignmentErrors() ; - + // Store alignment[Error]s to DB edm::Service poolDbService; std::string theAlignRecordName = "TrackerAlignmentRcd"; std::string theErrorRecordName = "TrackerAlignmentErrorExtendedRcd"; - + // Call service if( !poolDbService.isAvailable() ) // Die if not available throw cms::Exception("NotAvailable") << "PoolDBOutputService not available"; - + poolDbService->writeOne(&(*myAlignments), poolDbService->beginOfTime(), theAlignRecordName); poolDbService->writeOne(&(*myAlignmentErrorsExtended), poolDbService->beginOfTime(), theErrorRecordName); } void TrackerSystematicMisalignments::applySystematicMisalignment(Alignable* ali) { - + const align::Alignables& comp = ali->components(); unsigned int nComp = comp.size(); //move then do for lower level object @@ -180,32 +180,32 @@ void TrackerSystematicMisalignments::applySystematicMisalignment(Alignable* ali) switch(subdetid) { // TIB/TON blind to z - case SiStripDetId::TIB: - case SiStripDetId::TOB: - blindToZ = true; + case SiStripDetId::TIB: + case SiStripDetId::TOB: + blindToZ = true; break; // TID/TEC blind to R - case SiStripDetId::TID: - case SiStripDetId::TEC: - blindToR = true; + case SiStripDetId::TID: + case SiStripDetId::TEC: + blindToR = true; break; - default: + default: break; } } - const int level = ali->alignableObjectId(); - if ((level == 1)||(level == 2)){ + const int level = ali->alignableObjectId(); + if ((level == 1)||(level == 2)){ const align::PositionType gP = ali->globalPosition(); const align::GlobalVector gVec = findSystematicMis( gP, blindToZ, blindToR); ali->move( gVec ); } -} +} align::GlobalVector TrackerSystematicMisalignments::findSystematicMis( const align::PositionType& globalPos, const bool blindToZ, const bool blindToR ){ //align::GlobalVector TrackerSystematicMisalignments::findSystematicMis( align::PositionType globalPos ){ // calculates shift for the current alignable - // all corrections are calculated w.r.t. the original geometry + // all corrections are calculated w.r.t. the original geometry double deltaX = 0.0; double deltaY = 0.0; double deltaZ = 0.0; @@ -223,7 +223,7 @@ align::GlobalVector TrackerSystematicMisalignments::findSystematicMis( const ali deltaZ += m_telescopeEpsilon*oldR; } if (m_layerRotEpsilon > -990.0){ - // The following number was chosen such that the Layer Rotation systematic + // The following number was chosen such that the Layer Rotation systematic // misalignment would not cause an overall rotation of the tracker. const double Roffset = 57.0; const double xP = oldR*cos(oldPhi+m_layerRotEpsilon*(oldR-Roffset)); @@ -261,7 +261,7 @@ align::GlobalVector TrackerSystematicMisalignments::findSystematicMis( const ali // Compatibility with old version <= 1.5 if (oldMinusZconvention) deltaZ = -deltaZ; - + align::GlobalVector gV( deltaX, deltaY, deltaZ ); return gV; } diff --git a/Alignment/TrackerAlignment/python/TrackerSystematicMisalignments_cfi.py b/Alignment/TrackerAlignment/python/TrackerSystematicMisalignments_cfi.py index bf68434a142d3..8d92d203c8301 100644 --- a/Alignment/TrackerAlignment/python/TrackerSystematicMisalignments_cfi.py +++ b/Alignment/TrackerAlignment/python/TrackerSystematicMisalignments_cfi.py @@ -6,12 +6,12 @@ #epsilons radialEpsilon = cms.untracked.double(-999.0), # default 5e-4 ~ 600 um telescopeEpsilon = cms.untracked.double(-999.0), # default 5e-4 ~ 600 um - layerRotEpsilon = cms.untracked.double(-999.0), # 9.43e-6 mm^-1 - bowingEpsilon = cms.untracked.double(-999.0), #6.77e-9 mm^-2 + layerRotEpsilon = cms.untracked.double(-999.0), # 9.43e-6 cm^-1 + bowingEpsilon = cms.untracked.double(-999.0), #6.77e-9 cm^-2 zExpEpsilon = cms.untracked.double(-999.0), # 2.02e-4 - twistEpsilon = cms.untracked.double(-999.0),# 2.04e-6 mm^-1 + twistEpsilon = cms.untracked.double(-999.0),# 2.04e-6 cm^-1 ellipticalEpsilon = cms.untracked.double(-999.0), # 5e-4 - skewEpsilon = cms.untracked.double(-999.0), # 5.5e-2 mm + skewEpsilon = cms.untracked.double(-999.0), # 5.5e-2 cm sagittaEpsilon = cms.untracked.double(-999.0), #5.0e-4 #misalignment phases diff --git a/Alignment/TrackerAlignment/test/testProduceAllMisalignments.sh b/Alignment/TrackerAlignment/test/testProduceAllMisalignments.sh new file mode 100755 index 0000000000000..8973800935f2b --- /dev/null +++ b/Alignment/TrackerAlignment/test/testProduceAllMisalignments.sh @@ -0,0 +1,18 @@ +#! /bin/bash + +#to use: +#set the input geometry and IOV in testProduceSystematicMisalignment_cfg.py +#set the output file name to outputfile.db or folder/outputfile.db +# (outputfile.db is replaced by (misalignment name).db) + +#set the magnitude for each one in the comment after the -999 +#set the phases for the phi dependent misalignments + +#then cmsenv and run this +#don't bother submitting to a queue, the whole thing takes less than 2 minutes + +for a in $(grep Epsilon testProduceSystematicMisalignment_cfg.py | grep 999 | sed "s/Epsilon.*//"); do + sed -r -e "s/(${a}Epsilon.*)-999. *#/\1/" -e "s|outputfile.db|${a}.db|" testProduceSystematicMisalignment_cfg.py > ${a}_cfg.py + cmsRun ${a}_cfg.py + rm ${a}_cfg.py +done diff --git a/Alignment/TrackerAlignment/test/testProduceSystematicMisalignment_cfg.py b/Alignment/TrackerAlignment/test/testProduceSystematicMisalignment_cfg.py index 4ac45dc6d6af3..77994c833371e 100644 --- a/Alignment/TrackerAlignment/test/testProduceSystematicMisalignment_cfg.py +++ b/Alignment/TrackerAlignment/test/testProduceSystematicMisalignment_cfg.py @@ -1,75 +1,101 @@ -import FWCore.ParameterSet.Config as cms +#================================= +#inputs +globaltag = '74X_dataRun2_Prompt_v4' #APEs are copied from this GT (and IdealGeometry and TrackerTopology are used) +inputsqlitefile = None #if None, uses the GT alignment +alignmenttag = 'Alignments' #tag name for TrackerAlignmentRcd in the input file, also used for the output file +runnumberalignmentIOV = 1 #any run number in the iov that you want to start from -process = cms.Process("TEST") -process.load("FWCore.MessageService.MessageLogger_cfi") +outputfilename = 'outputfile.db' + + +#misalignment amplitudes, -999 means no misalignment +#the commented numbers are the default magnitudes, which produce a maximum movement of around 600 microns +#see Alignment/TrackerAlignment/plugins/TrackerSystematicMisalignments.cc for definitions +#see also https://twiki.cern.ch/twiki/bin/viewauth/CMS/SystematicMisalignmentsofTracker +radialEpsilon = -999. # 5e-4 +telescopeEpsilon = -999. # 5e-4 +layerRotEpsilon = -999. # 9.43e-6 #cm^-1 +bowingEpsilon = -999. # 6.77e-9 #cm^-2 +zExpEpsilon = -999. # 2.02e-4 +twistEpsilon = -999. # 2.04e-6 #cm^-1 +ellipticalEpsilon = -999. # 5e-4 +skewEpsilon = -999. # 5.5e-2 #cm +sagittaEpsilon = -999. # 5.0e-4 + +#phases for phi dependent misalignments +ellipticalDelta = 0. +skewDelta = 0. +sagittaDelta = 0. +#================================= -process.load("Geometry.CMSCommonData.cmsIdealGeometryXML_cfi") -process.load("Geometry.TrackerNumberingBuilder.trackerNumberingGeometry_cfi") -#process.load("CondCore.DBCommon.CondDBSetup_cfi") -from CondCore.DBCommon.CondDBSetup_cfi import * -process.source = cms.Source("EmptySource") +import FWCore.ParameterSet.Config as cms + +process = cms.Process("TrackerSystematicMisalignments") +process.load("FWCore.MessageService.MessageLogger_cfi") + +process.load("Configuration.Geometry.GeometryRecoDB_cff") + +process.load("CondCore.DBCommon.CondDBSetup_cfi") +process.source = cms.Source("EmptySource", + firstRun=cms.untracked.uint32(runnumberalignmentIOV), +) process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(1) + input = cms.untracked.int32(1) ) # initial geom # configure the database file - use survey one for default -from CondCore.DBCommon.CondDBSetup_cfi import * -process.trackerGeom = cms.ESSource("PoolDBESSource", - CondDBSetup, - timetype = cms.string('runnumber'), - toGet = cms.VPSet( - cms.PSet( - record = cms.string('TrackerAlignmentRcd'), - tag = cms.string('Alignments') - ), - cms.PSet( - record = cms.string('TrackerAlignmentErrorExtendedRcd'), - tag = cms.string('AlignmentErrorsExtended') - )), - connect = cms.string('sqlite_file:inputdbfile.db') -) - - +process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff") +process.GlobalTag.globaltag=globaltag +if inputsqlitefile is not None: + process.GlobalTag.toGet = cms.VPSet( + cms.PSet( + record = cms.string('TrackerAlignmentRcd'), + tag = cms.string(alignmenttag), + connect = cms.untracked.string('sqlite_file:'+inputsqlitefile), + ), + ) + + # input process.load("Alignment.TrackerAlignment.TrackerSystematicMisalignments_cfi") process.TrackerSystematicMisalignments.fromDBGeom = True #uncomment one or more of these to apply the misalignment(s) -#process.TrackerSystematicMisalignments.radialEpsilon = 5.00e-4 # default 5e-4 ~ 600 um -#process.TrackerSystematicMisalignments.telescopeEpsilon = 5.00e-4 # default 5e-4 ~ 600 um -#process.TrackerSystematicMisalignments.layerRotEpsilon = 9.43e-6 # 9.43e-6 -#process.TrackerSystematicMisalignments.bowingEpsilon = 6.77e-9 # 6.77e-9 -#process.TrackerSystematicMisalignments.zExpEpsilon = 2.02e-4 # 2.02e-4 -#process.TrackerSystematicMisalignments.twistEpsilon = 2.04e-6 # 2.04e-6 -#process.TrackerSystematicMisalignments.ellipticalEpsilon = 5.00e-4 # 5e-4 -#process.TrackerSystematicMisalignments.skewEpsilon = 5.5e-2 # 5.5e-2 -#process.TrackerSystematicMisalignments.sagittaEpsilon = 5.00e-4 # 5.0e-4 +process.TrackerSystematicMisalignments.radialEpsilon = radialEpsilon +process.TrackerSystematicMisalignments.telescopeEpsilon = telescopeEpsilon +process.TrackerSystematicMisalignments.layerRotEpsilon = layerRotEpsilon +process.TrackerSystematicMisalignments.bowingEpsilon = bowingEpsilon +process.TrackerSystematicMisalignments.zExpEpsilon = zExpEpsilon +process.TrackerSystematicMisalignments.twistEpsilon = twistEpsilon +process.TrackerSystematicMisalignments.ellipticalEpsilon = ellipticalEpsilon +process.TrackerSystematicMisalignments.skewEpsilon = skewEpsilon +process.TrackerSystematicMisalignments.sagittaEpsilon = sagittaEpsilon #misalignment phases -process.TrackerSystematicMisalignments.ellipticalDelta = 0 -process.TrackerSystematicMisalignments.skewDelta = 0 -process.TrackerSystematicMisalignments.sagittaDelta = 0 - +process.TrackerSystematicMisalignments.ellipticalDelta = ellipticalDelta +process.TrackerSystematicMisalignments.skewDelta = skewDelta +process.TrackerSystematicMisalignments.sagittaDelta = sagittaDelta + # output process.PoolDBOutputService = cms.Service("PoolDBOutputService", - CondDBSetup, - toPut = cms.VPSet(cms.PSet( - record = cms.string('TrackerAlignmentRcd'), - tag = cms.string('Alignments') - ), - cms.PSet( - record = cms.string('TrackerAlignmentErrorExtendedRcd'), - tag = cms.string('AlignmentErrorsExtended') - )), - connect = cms.string('sqlite_file:outputdbfile.db') + process.CondDBSetup, + toPut = cms.VPSet( + cms.PSet( + record = cms.string('TrackerAlignmentRcd'), + tag = cms.string(alignmenttag), + ), + cms.PSet( + record = cms.string('TrackerAlignmentErrorExtendedRcd'), + tag = cms.string('AlignmentErrorsExtended'), + ), + ), + connect = cms.string('sqlite_file:'+outputfilename), ) process.p = cms.Path( process.TrackerSystematicMisalignments ) - -