Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix systematic misalignment tool #12313

Merged
merged 3 commits into from
Nov 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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<TrackerTopology> tTopoHandle;
setup.get<TrackerTopologyRcd>().get(tTopoHandle);
const TrackerTopology* const tTopo = tTopoHandle.product();

edm::ESHandle<GeometricDet> geom;
setup.get<IdealGeometryRecord>().get(geom);
setup.get<IdealGeometryRecord>().get(geom);
edm::ESHandle<PTrackerParameters> ptp;
setup.get<PTrackerParametersRcd>().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> alignments;
edm::ESHandle<AlignmentErrorsExtended> alignmentErrors;

setup.get<TrackerAlignmentRcd>().get(alignments);
setup.get<TrackerAlignmentErrorExtendedRcd>().get(alignmentErrors);

//apply the latest alignments
GeometryAligner aligner;
aligner.applyAlignments<TrackerGeometry>( &(*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<cond::service::PoolDBOutputService> 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<Alignments>(&(*myAlignments), poolDbService->beginOfTime(), theAlignRecordName);
poolDbService->writeOne<AlignmentErrorsExtended>(&(*myAlignmentErrorsExtended), poolDbService->beginOfTime(), theErrorRecordName);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hroskes what is the reason to remove the possibility to write the APEs? I think it might still be useful even if it's not directly used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't really see the use case. All it did was take the APEs from the GT (or input sqlite file if you want) and copy them to the output sqlite file. What would it even mean to "misalign" the APEs?

If you think it would be useful I can add it back.

I'd like to extend this soon by adding misalignment for surface deformations, but I want to understand them better first.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use case is exactly this: take the APEs from the GT (or input sqlite file if you want) and copy them to the output sqlite file. Indeed it doesn't make sense to misalign the APE, but creating an APE payload that matches the misalignment you create makes a lot of sense to me. This functionality is not available but costs little effort to implement.


void TrackerSystematicMisalignments::applySystematicMisalignment(Alignable* ali)
{

const align::Alignables& comp = ali->components();
unsigned int nComp = comp.size();
//move then do for lower level object
Expand All @@ -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;
Expand All @@ -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));
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions Alignment/TrackerAlignment/test/testProduceAllMisalignments.sh
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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 )