6 m_minHitsPerChamber(iConfig.getParameter<
int>(
"minHitsPerChamber")),
7 m_maxdrdz(iConfig.getParameter<double>(
"maxdrdz")),
8 m_fiducial(iConfig.getParameter<
bool>(
"fiducial")),
9 m_useHitWeights(iConfig.getParameter<
bool>(
"useHitWeights")),
10 m_slopeFromTrackRefit(iConfig.getParameter<
bool>(
"slopeFromTrackRefit")),
11 m_minStationsInTrackRefits(iConfig.getParameter<
int>(
"minStationsInTrackRefits")),
12 m_truncateSlopeResid(iConfig.getParameter<double>(
"truncateSlopeResid")),
13 m_truncateOffsetResid(iConfig.getParameter<double>(
"truncateOffsetResid")),
14 m_combineME11(iConfig.getParameter<
bool>(
"combineME11")),
15 m_useTrackWeights(iConfig.getParameter<
bool>(
"useTrackWeights")),
16 m_errorFromRMS(iConfig.getParameter<
bool>(
"errorFromRMS")),
17 m_minTracksPerOverlap(iConfig.getParameter<
int>(
"minTracksPerOverlap")),
18 m_makeHistograms(iConfig.getParameter<
bool>(
"makeHistograms")),
26 m_mode_string(iConfig.getParameter<
std::
string>(
"mode")),
27 m_reportFileName(iConfig.getParameter<
std::
string>(
"reportFileName")),
28 m_minP(iConfig.getParameter<double>(
"minP")),
29 m_maxRedChi2(iConfig.getParameter<double>(
"maxRedChi2")),
30 m_writeTemporaryFile(iConfig.getParameter<
std::
string>(
"writeTemporaryFile")),
31 m_readTemporaryFiles(iConfig.getParameter<
std::
vector<
std::
string> >(
"readTemporaryFiles")),
32 m_doAlignment(iConfig.getParameter<
bool>(
"doAlignment")) {
42 throw cms::Exception(
"BadConfig") <<
"mode must be one of \"phiy\", \"phipos\", \"phiz\", \"radius\"" << std::endl;
44 std::vector<edm::ParameterSet>
fitters = iConfig.
getParameter<std::vector<edm::ParameterSet> >(
"fitters");
45 for (std::vector<edm::ParameterSet>::const_iterator fitter =
fitters.begin(); fitter !=
fitters.end(); ++fitter) {
49 for (std::vector<CSCPairResidualsConstraint*>::const_iterator residualsConstraint =
m_residualsConstraints.begin();
51 ++residualsConstraint) {
52 (*residualsConstraint)->configure(
this);
53 m_quickChamberLookup[std::pair<CSCDetId, CSCDetId>((*residualsConstraint)->id_i(), (*residualsConstraint)->id_j())] =
78 m_slope = tFileService->
make<TH1F>(
"slope",
"", 100, -0.5, 0.5);
95 m_drdz = tFileService->
make<TH1F>(
"drdz",
"", 100, -0.5, 0.5);
97 m_occupancy = tFileService->
make<TH2F>(
"occupancy",
"", 36, 1, 37, 20, 1, 21);
98 for (
int i = 1;
i <= 36;
i++) {
99 std::stringstream pairname;
100 pairname <<
i <<
"-";
105 m_occupancy->GetXaxis()->SetBinLabel(
i, pairname.str().c_str());
116 m_occupancy->GetYaxis()->SetBinLabel(9,
"ME-1/1b");
117 m_occupancy->GetYaxis()->SetBinLabel(10,
"ME-1/1a");
118 m_occupancy->GetYaxis()->SetBinLabel(11,
"ME+1/1a");
119 m_occupancy->GetYaxis()->SetBinLabel(12,
"ME+1/1b");
124 m_occupancy->GetYaxis()->SetBinLabel(12,
"ME+1/1");
126 m_occupancy->GetYaxis()->SetBinLabel(13,
"ME+1/2");
127 m_occupancy->GetYaxis()->SetBinLabel(14,
"ME+1/3");
128 m_occupancy->GetYaxis()->SetBinLabel(15,
"ME+2/1");
129 m_occupancy->GetYaxis()->SetBinLabel(16,
"ME+2/2");
130 m_occupancy->GetYaxis()->SetBinLabel(17,
"ME+3/1");
131 m_occupancy->GetYaxis()->SetBinLabel(18,
"ME+3/2");
132 m_occupancy->GetYaxis()->SetBinLabel(19,
"ME+4/1");
133 m_occupancy->GetYaxis()->SetBinLabel(20,
"ME+4/2");
135 m_XYpos_mep1 = tFileService->
make<TH2F>(
"XYpos_mep1",
"Positions: ME+1", 140, -700., 700., 140, -700., 700.);
136 m_XYpos_mep2 = tFileService->
make<TH2F>(
"XYpos_mep2",
"Positions: ME+2", 140, -700., 700., 140, -700., 700.);
137 m_XYpos_mep3 = tFileService->
make<TH2F>(
"XYpos_mep3",
"Positions: ME+3", 140, -700., 700., 140, -700., 700.);
138 m_XYpos_mep4 = tFileService->
make<TH2F>(
"XYpos_mep4",
"Positions: ME+4", 140, -700., 700., 140, -700., 700.);
139 m_XYpos_mem1 = tFileService->
make<TH2F>(
"XYpos_mem1",
"Positions: ME-1", 140, -700., 700., 140, -700., 700.);
140 m_XYpos_mem2 = tFileService->
make<TH2F>(
"XYpos_mem2",
"Positions: ME-2", 140, -700., 700., 140, -700., 700.);
141 m_XYpos_mem3 = tFileService->
make<TH2F>(
"XYpos_mem3",
"Positions: ME-3", 140, -700., 700., 140, -700., 700.);
142 m_XYpos_mem4 = tFileService->
make<TH2F>(
"XYpos_mem4",
"Positions: ME-4", 140, -700., 700., 140, -700., 700.);
206 if (alignableTracker ==
nullptr)
212 DetId id = alignable->geomDetId();
214 throw cms::Exception(
"BadConfig") <<
"Only CSC chambers may be alignable" << std::endl;
217 std::vector<bool>
selector = alignable->alignmentParameters()->selector();
220 throw cms::Exception(
"BadConfig") <<
"All selector strings should be \"111111\"" << std::endl;
226 for (std::vector<CSCPairResidualsConstraint*>::const_iterator residualsConstraint =
m_residualsConstraints.begin();
228 ++residualsConstraint) {
229 (*residualsConstraint)->setZplane(cscGeometry);
233 std::vector<std::ifstream*>
input;
240 for (std::vector<CSCPairResidualsConstraint*>::const_iterator residualsConstraint =
m_residualsConstraints.begin();
242 ++residualsConstraint) {
259 for (std::vector<CSCPairResidualsConstraint*>::const_iterator residualsConstraint =
262 ++residualsConstraint) {
274 for (ConstTrajTrackPairCollection::const_iterator trajtrack = trajtracks.begin(); trajtrack != trajtracks.end();
285 std::vector<TrajectoryMeasurement> measurements = traj->
measurements();
288 std::map<int, std::map<CSCDetId, bool> > stationsToChambers;
289 for (std::vector<TrajectoryMeasurement>::const_iterator measurement = measurements.begin();
290 measurement != measurements.end();
292 DetId id = measurement->recHit()->geographicalId();
300 if (stationsToChambers.find(
station) == stationsToChambers.end())
301 stationsToChambers[
station] = std::map<CSCDetId, bool>();
302 stationsToChambers[
station][chamberId] =
true;
342 std::map<CSCPairResidualsConstraint*, bool> residualsConstraints;
343 for (
std::map<
int, std::map<CSCDetId, bool> >::const_iterator iter = stationsToChambers.begin();
344 iter != stationsToChambers.end();
346 for (std::map<CSCDetId, bool>::const_iterator
one = iter->second.begin();
one != iter->second.end(); ++
one) {
347 for (std::map<CSCDetId, bool>::const_iterator
two =
one;
two != iter->second.end(); ++
two) {
353 residualsConstraints[quick->second] =
true;
357 residualsConstraints[quick->second] =
true;
363 for (std::map<CSCPairResidualsConstraint*, bool>::const_iterator residualsConstraint =
364 residualsConstraints.begin();
365 residualsConstraint != residualsConstraints.end();
366 ++residualsConstraint) {
367 residualsConstraint->first->addTrack(measurements, transientTrack,
m_trackTransformer);
377 for (std::vector<CSCPairResidualsConstraint*>::const_iterator residualsConstraint =
m_residualsConstraints.begin();
379 ++residualsConstraint) {
380 (*residualsConstraint)->write(
output);
390 report <<
"cscReports = []" << std::endl
392 <<
"class CSCChamberCorrection:" << std::endl
393 <<
" def __init__(self, name, detid, value):" << std::endl
394 <<
" self.name, self.detid, self.value = name, detid, value" << std::endl
396 <<
"class CSCErrorMode:" << std::endl
397 <<
" def __init__(self, error):" << std::endl
398 <<
" self.error = error" << std::endl
399 <<
" self.terms = {}" << std::endl
400 <<
" self.detids = {}" << std::endl
401 <<
" def addTerm(self, name, detid, coefficient):" << std::endl
402 <<
" self.terms[name] = coefficient" << std::endl
403 <<
" self.detids[name] = detid" << std::endl
405 <<
"class CSCConstraintResidual:" << std::endl
406 <<
" def __init__(self, i, j, before, uncert, residual, pull):" << std::endl
407 <<
" self.i, self.j, self.before, self.error, self.residual, self.pull = i, j, before, uncert, " 411 <<
"class CSCFitterReport:" << std::endl
412 <<
" def __init__(self, name, oldchi2, newchi2):" << std::endl
413 <<
" self.name, self.oldchi2, self.newchi2 = name, oldchi2, newchi2" << std::endl
414 <<
" self.chamberCorrections = []" << std::endl
415 <<
" self.errorModes = []" << std::endl
416 <<
" self.constraintResiduals = []" << std::endl
418 <<
" def addChamberCorrection(self, name, detid, value):" << std::endl
419 <<
" self.chamberCorrections.append(CSCChamberCorrection(name, detid, value))" << std::endl
421 <<
" def addErrorMode(self, error):" << std::endl
422 <<
" self.errorModes.append(CSCErrorMode(error))" << std::endl
424 <<
" def addErrorModeTerm(self, name, detid, coefficient):" << std::endl
425 <<
" self.errorModes[-1].addTerm(name, detid, coefficient)" << std::endl
427 <<
" def addCSCConstraintResidual(self, i, j, before, uncert, residual, pull):" << std::endl
428 <<
" self.constraintResiduals.append(CSCConstraintResidual(i, j, before, uncert, residual, pull))" 431 <<
"import re" << std::endl
432 <<
"def nameToKey(name):" << std::endl
433 <<
" match = re.match(\"ME([\\+\\-])([1-4])/([1-4])/([0-9]{2})\", name)" << std::endl
434 <<
" if match is None: return None" << std::endl
435 <<
" endcap, station, ring, chamber = match.groups()" << std::endl
436 <<
" if endcap == \"+\": endcap = 1" << std::endl
437 <<
" else: endcap = 2" << std::endl
438 <<
" station = int(station)" << std::endl
439 <<
" ring = int(ring)" << std::endl
440 <<
" chamber = int(chamber)" << std::endl
441 <<
" return endcap, station, ring, chamber" << std::endl
445 for (std::vector<CSCChamberFitter>::const_iterator fitter =
m_fitters.begin(); fitter !=
m_fitters.end();
451 std::vector<CSCAlignmentCorrections*> corrections;
452 fitter->fit(corrections);
455 for (std::vector<CSCAlignmentCorrections*>::iterator
correction = corrections.begin();
460 (*correction)->plot();
462 (*correction)->report(
report);
const edm::ESGetToken< Propagator, TrackingComponentsRecord > m_propToken
TrackTransformer * m_trackTransformer
T getParameter(std::string const &) const
std::vector< CSCChamberFitter > m_fitters
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
std::string m_writeTemporaryFile
std::string m_reportFileName
std::vector< std::string > m_readTemporaryFiles
CSCOverlapsAlignmentAlgorithm(const edm::ParameterSet &iConfig, edm::ConsumesCollector &)
~CSCOverlapsAlignmentAlgorithm() override
void run(const edm::EventSetup &iSetup, const EventInfo &eventInfo) override
Run the algorithm (must be implemented in derived class)
std::string m_mode_string
const align::Alignables & alignables(void) const
get all alignables
AlignmentParameterStore * m_alignmentParameterStore
const Propagator * m_propagatorPointer
std::map< std::pair< CSCDetId, CSCDetId >, CSCPairResidualsConstraint * > m_quickChamberLookup
define event information passed to algorithms
static std::string const input
TH1F * m_slopeResiduals_weighted
DataContainer const & measurements() const
reco::TransientTrack build(const reco::Track *p) const
void initialize(const edm::EventSetup &iSetup, AlignableTracker *alignableTracker, AlignableMuon *alignableMuon, AlignableExtras *alignableExtras, AlignmentParameterStore *alignmentParameterStore) override
Call at beginning of job (must be implemented in derived class)
TProfile * m_fiducial_MEx2
TH1F * m_offsetResiduals_weighted
const edm::ESGetToken< CSCGeometry, MuonGeometryRecord > m_cscGeometryToken
const edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > m_tthbToken
TH1F * m_offsetResiduals_normalized
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
TProfile * m_fiducial_MEx1
std::vector< CSCPairResidualsConstraint * > m_residualsConstraints
virtual void terminate()
Called at end of job (must be implemented in derived class)
bool m_slopeFromTrackRefit
T * make(const Args &...args) const
make new ROOT object
#define DEFINE_EDM_PLUGIN(factory, type, name)
align::Alignables m_alignables
eventInfo
add run, event number and lumi section
AlignableNavigator * m_alignableNavigator
Constructor of the full muon geometry.
TProfile * m_fiducial_ME12
TProfile * m_fiducial_ME11
TH1F * m_slopeResiduals_normalized
std::vector< ConstTrajTrackPair > ConstTrajTrackPairCollection