Skip to content

Commit

Permalink
Merge branch 'master' into from-CMSSW_13_1_0_pre2
Browse files Browse the repository at this point in the history
  • Loading branch information
AnnikaStein authored Apr 4, 2023
2 parents 07aac71 + a9d6650 commit 69c5fe7
Show file tree
Hide file tree
Showing 1,068 changed files with 208,927 additions and 31,382 deletions.
37 changes: 37 additions & 0 deletions Alignment/TrackerAlignment/interface/AlignableStackDet.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#ifndef Alignment_TrackerAlignment_AlignableStackDet_H
#define Alignment_TrackerAlignment_AlignableStackDet_H

/** \class AlignableStackDet
* An alignable for StackDets in the Phase-2 Outer Tracker detector,
* taking care of consistency with AlignableDet components.
*
* First implementation March 2022
* \author Marco Musich, U. Pisa / INFN
* $Date: 2022/03/15 13:36:00 $
* $Revision: 1.0 $
*/

#include "Alignment/CommonAlignment/interface/AlignableDet.h"
#include "Geometry/CommonDetUnit/interface/StackGeomDet.h"

class AlignTransformErrorExtended;
class Bounds;
class StripGeomDetType;

class AlignableStackDet : public AlignableDet {
public:
/// Constructor
AlignableStackDet(const StackGeomDet *geomDet);
/// reduntantly make destructor virtual
~AlignableStackDet() override = default;

/// first consistify with component detunits, then call method from AlignableDet
Alignments *alignments() const override;

private:
/// make alignments consistent with daughters
void consistifyAlignments();
const Plane theLowerDetSurface;
};

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,18 @@ class AlignableTrackerBuilder {
void buildStripDetectorAlignable(
const GeomDet*, int subdetId, Alignables& aliDets, Alignables& aliDetUnits, bool update = false);

void buildOuterTrackerDetectorAlignable(
const GeomDet*, int subdetId, Alignables& aliDets, Alignables& aliDetUnits, bool update = false);

/// Builds all composite Alignables for the tracker. The hierarchy and
/// numbers of components are determined in TrackerAlignmentLevelBuilder.
void buildAlignableComposites(bool update = false);
/// Builds the PixelDetector by hand.
void buildPixelDetector(AlignableTracker*);
/// Builds the StripDetector by hand.
void buildStripDetector(AlignableTracker*);
/// Builds the Phase-2 Outer Tracker Detector by hand.
void buildOuterTrackerDetector(AlignableTracker*);

//========================== PRIVATE DATA ===================================
//===========================================================================
Expand Down
54 changes: 54 additions & 0 deletions Alignment/TrackerAlignment/python/Scenarios_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -3090,6 +3090,60 @@ def TECRing7Shift(shift):
),
)

MisalignmentScenario10MuPhase2 = MisalignmentScenarioSettings.clone(
setError = cms.bool(False),
scale = cms.double(0.01), # shifts in 100um

P2PXBHalfBarrels = cms.PSet(
DetUnits = cms.PSet(
dYlocal = cms.double(0.1),
dXlocal = cms.double(0.1),
),
),

P2OTBHalfBarrels = cms.PSet(
DetUnits = cms.PSet(
dYlocal = cms.double(0.1),
dXlocal = cms.double(0.1),
),
),

P2PXECEndcaps = cms.PSet(
DetUnits = cms.PSet(
dYlocal = cms.double(0.1),
dXlocal = cms.double(0.1),
),
),

P2OTECEndcaps = cms.PSet(
DetUnits = cms.PSet(
dYlocal = cms.double(0.1),
dXlocal = cms.double(0.1),
),
),

)

MisalignmentScenario10MuPixelPhase2 = MisalignmentScenarioSettings.clone(
setError = cms.bool(False),
scale = cms.double(0.01), # shifts in 100um

P2PXBHalfBarrels = cms.PSet(
DetUnits = cms.PSet(
dYlocal = cms.double(0.1),
dXlocal = cms.double(0.1),
),
),

P2PXECEndcaps = cms.PSet(
DetUnits = cms.PSet(
dYlocal = cms.double(0.1),
dXlocal = cms.double(0.1),
),
),

)

MisalignmentScenario100Mu = MisalignmentScenarioSettings.clone(
setError = cms.bool(False),
scale = cms.double(0.01), # shifts in 100um
Expand Down
54 changes: 54 additions & 0 deletions Alignment/TrackerAlignment/src/AlignableStackDet.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* $Date: 2011/09/05 16:59:07 $
* $Revision: 1.9 $
*/

#include "Alignment/CommonAlignment/interface/AlignableSurface.h"
#include "Alignment/TrackerAlignment/interface/AlignableStackDet.h"
#include "CondFormats/Alignment/interface/AlignTransformErrorExtended.h"
#include "CondFormats/Alignment/interface/AlignmentErrorsExtended.h"
#include "DataFormats/GeometryCommonDetAlgo/interface/AlignmentPositionError.h"
#include "DataFormats/GeometryCommonDetAlgo/interface/GlobalError.h"
#include "DataFormats/GeometrySurface/interface/BoundPlane.h"
#include "DataFormats/GeometrySurface/interface/Bounds.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Utilities/interface/Exception.h"
#include "Geometry/CommonDetUnit/interface/StackGeomDet.h"
#include <cmath>

AlignableStackDet::AlignableStackDet(const StackGeomDet* stackedDet)
: AlignableDet(stackedDet, true), // true: adding DetUnits
theLowerDetSurface(stackedDet->lowerDet()->surface()) {
// check order lower/upper
const Alignables units(this->components());
if (units.size() != 2 || stackedDet->lowerDet()->geographicalId() != units[0]->geomDetId() ||
stackedDet->upperDet()->geographicalId() != units[1]->geomDetId()) {
throw cms::Exception("LogicError") << "[AlignableStackDet] "
<< "Either != 2 components or "
<< "upper/lower in wrong order for consistifyAlignments.";
}
}

//__________________________________________________________________________________________________
Alignments* AlignableStackDet::alignments() const {
const_cast<AlignableStackDet*>(this)->consistifyAlignments();
return this->AlignableDet::alignments();
}

//__________________________________________________________________________________________________
void AlignableStackDet::consistifyAlignments() {
// Now we have all to calculate new position and rotation via PlaneBuilderForGluedDet.
const PositionType oldPos(theSurface.position()); // From old surface for keeping...
const RotationType oldRot(theSurface.rotation()); // ...track of changes.

// The plane is *not* built in the middle, but on the Lower surface
// see usage in Geometry/TrackerGeometryBuilder/src/TrackerGeomBuilderFromGeometricDet.cc
theSurface = AlignableSurface(theLowerDetSurface);

// But do not forget to keep track of movements/rotations:
const GlobalVector movement(theSurface.position().basicVector() - oldPos.basicVector());
// Seems to be correct down to delta angles 4.*1e-8:
const RotationType rotation(oldRot.multiplyInverse(theSurface.rotation()));
this->addDisplacement(movement);
this->addRotation(rotation);
}
88 changes: 85 additions & 3 deletions Alignment/TrackerAlignment/src/AlignableTrackerBuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
// geometry
#include "Geometry/CommonDetUnit/interface/GeomDet.h"
#include "Geometry/CommonDetUnit/interface/GluedGeomDet.h"
#include "Geometry/CommonTopologies/interface/StackGeomDet.h"

// alignment
#include "Alignment/CommonAlignment/interface/AlignableObjectId.h"
#include "Alignment/CommonAlignment/interface/AlignableDetUnit.h"
#include "Alignment/CommonAlignment/interface/AlignableCompositeBuilder.h"
#include "Alignment/TrackerAlignment/interface/AlignableSiStripDet.h"
#include "Alignment/TrackerAlignment/interface/AlignableStackDet.h"
#include "Alignment/TrackerAlignment/interface/TrackerAlignableIndexer.h"

#include "DataFormats/SiStripDetId/interface/SiStripDetId.h"
Expand Down Expand Up @@ -63,8 +65,15 @@ void AlignableTrackerBuilder ::buildAlignables(AlignableTracker* trackerAlignabl

// create pixel-detector
buildPixelDetector(trackerAlignables);
// create strip-detector
buildStripDetector(trackerAlignables);

// for the Outer Tracker, decide which geometry we are addressing
if (alignableObjectId_.geometry() < AlignableObjectId::Geometry::PhaseII) {
// create strip-detector
buildStripDetector(trackerAlignables);
} else {
// create Phase2 Outer Tracker-detector
buildOuterTrackerDetector(trackerAlignables);
}

// tracker itself is of course also an Alignable
alignableMap_->get("Tracker").push_back(trackerAlignables);
Expand Down Expand Up @@ -123,7 +132,12 @@ void AlignableTrackerBuilder ::convertGeomDetsToAlignables(const TrackingGeometr
subdetId == SiStripDetId::TEC) {
// for strip we create also <TIB/TID/TOB/TEC>ModuleUnit list
// for 1D components of 2D layers
buildStripDetectorAlignable(geomDet, subdetId, alignables, aliUnits, update);

if (alignableObjectId_.geometry() < AlignableObjectId::Geometry::PhaseII) {
buildStripDetectorAlignable(geomDet, subdetId, alignables, aliUnits, update);
} else {
buildOuterTrackerDetectorAlignable(geomDet, subdetId, alignables, aliUnits, update);
}

} else {
throw cms::Exception("LogicError") << "[AlignableTrackerBuilder] GeomDet of unknown subdetector";
Expand Down Expand Up @@ -236,6 +250,52 @@ void AlignableTrackerBuilder ::buildStripDetectorAlignable(
// AlignableSiStripDet -> AlignableDet, see above
}

//_____________________________________________________________________________
void AlignableTrackerBuilder ::buildOuterTrackerDetectorAlignable(
const GeomDet* geomDet, int subdetId, Alignables& aliDets, Alignables& aliDetUnits, bool update) {
// hopefully all the geomdets are composite (either PS or SS modules in Ph-2 Outer Tracker)
if (!geomDet->components().empty()) {
// 2D-module, convert it to StackGeomDet
const StackGeomDet* stackGeomDet = dynamic_cast<const StackGeomDet*>(geomDet);
if (!stackGeomDet) {
throw cms::Exception("LogicError") << "[AlignableTrackerBuilder] dynamic_cast<const StackGeomDet*> "
<< "failed.";
}

// components (AlignableDetUnits) constructed within
if (update) {
auto ali = std::find_if(aliDets.cbegin(), aliDets.cend(), [&stackGeomDet](const auto& i) {
return i->id() == stackGeomDet->geographicalId().rawId();
});
if (ali != aliDets.end()) {
auto aliStackDet = dynamic_cast<AlignableStackDet*>(*ali);
if (aliStackDet) {
aliStackDet->update(geomDet);
} else {
throw cms::Exception("LogicError") << "[AlignableTrackerBuilder::buildOuterTrackerDetectorAlignable] "
<< "cast to 'AlignableStackDet*' failed while it should not\n";
}
} else {
throw cms::Exception("GeometryMismatch")
<< "[AlignableTrackerBuilder::buildStripDetectorAlignable] "
<< "GeomDet with DetId " << stackGeomDet->geographicalId().rawId() << " not found in current geometry.\n";
}
} else {
aliDets.push_back(new AlignableStackDet(stackGeomDet));
}
const auto& addAliDetUnits = aliDets.back()->components();
const auto& nAddedUnits = addAliDetUnits.size();

if (!update) {
// reserve space for the additional units:
aliDetUnits.reserve(aliDetUnits.size() + nAddedUnits - 1);
aliDetUnits.insert(aliDetUnits.end(), addAliDetUnits.begin(), addAliDetUnits.end());
}
numDetUnits += nAddedUnits;
} // no else: stacked components of AlignableDet constructed within
// AlignableStackDet -> AlignableDet, see above
}

//_____________________________________________________________________________
void AlignableTrackerBuilder ::buildAlignableComposites(bool update) {
unsigned int numCompositeAlignables = 0;
Expand Down Expand Up @@ -316,3 +376,25 @@ void AlignableTrackerBuilder ::buildStripDetector(AlignableTracker* trackerAlign
<< " of " << tibName << ", " << tidName << ", " << tobName << " and "
<< tecName;
}

//_____________________________________________________________________________
void AlignableTrackerBuilder ::buildOuterTrackerDetector(AlignableTracker* trackerAlignables) {
const std::string& tidName = alignableObjectId_.idToString(align::TIDEndcap);
const std::string& tobName = alignableObjectId_.idToString(align::TOBBarrel);
const std::string& stripName = alignableObjectId_.idToString(align::Strip);

auto& tidAlignables = alignableMap_->find(tidName);
auto& tobAlignables = alignableMap_->find(tobName);
auto& stripAlignables = alignableMap_->get(stripName);

stripAlignables.push_back(new AlignableComposite(tobAlignables[0]->id(), align::Strip, align::RotationType()));
stripAlignables[0]->addComponent(tobAlignables[0]);
stripAlignables[0]->addComponent(tidAlignables[0]);
stripAlignables[0]->addComponent(tidAlignables[1]);

trackerAlignables->addComponent(stripAlignables[0]);

edm::LogInfo("AlignableBuildProcess") << "@SUB=AlignableTrackerBuilder::buildStripDetector"
<< "Built " << stripName << "-detector Alignable, consisting of Alignables"
<< " of " << tidName << " and " << tobName;
}
1 change: 1 addition & 0 deletions Alignment/TrackerAlignment/test/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@

<test name="test_PixelBaryCentreTool" command="pixelPositions.sh"/>
<test name="test_ProduceSystematicMisalignment" command="testProduceAllMisalignments.sh"/>
<test name="test_CreateRandomMisalignment" command="testCreateRandomMisalignment.sh"/>
Loading

0 comments on commit 69c5fe7

Please sign in to comment.