5 m_minHitsPerChamber(iConfig.getParameter<
int>(
"minHitsPerChamber")),
6 m_maxdrdz(iConfig.getParameter<double>(
"maxdrdz")),
7 m_fiducial(iConfig.getParameter<
bool>(
"fiducial")),
8 m_useHitWeights(iConfig.getParameter<
bool>(
"useHitWeights")),
9 m_slopeFromTrackRefit(iConfig.getParameter<
bool>(
"slopeFromTrackRefit")),
10 m_minStationsInTrackRefits(iConfig.getParameter<
int>(
"minStationsInTrackRefits")),
11 m_truncateSlopeResid(iConfig.getParameter<double>(
"truncateSlopeResid")),
12 m_truncateOffsetResid(iConfig.getParameter<double>(
"truncateOffsetResid")),
13 m_combineME11(iConfig.getParameter<
bool>(
"combineME11")),
14 m_useTrackWeights(iConfig.getParameter<
bool>(
"useTrackWeights")),
15 m_errorFromRMS(iConfig.getParameter<
bool>(
"errorFromRMS")),
16 m_minTracksPerOverlap(iConfig.getParameter<
int>(
"minTracksPerOverlap")),
17 m_makeHistograms(iConfig.getParameter<
bool>(
"makeHistograms")),
18 m_mode_string(iConfig.getParameter<
std::
string>(
"mode")),
19 m_reportFileName(iConfig.getParameter<
std::
string>(
"reportFileName")),
20 m_minP(iConfig.getParameter<double>(
"minP")),
21 m_maxRedChi2(iConfig.getParameter<double>(
"maxRedChi2")),
22 m_writeTemporaryFile(iConfig.getParameter<
std::
string>(
"writeTemporaryFile")),
23 m_readTemporaryFiles(iConfig.getParameter<
std::
vector<
std::
string> >(
"readTemporaryFiles")),
24 m_doAlignment(iConfig.getParameter<
bool>(
"doAlignment")) {
34 throw cms::Exception(
"BadConfig") <<
"mode must be one of \"phiy\", \"phipos\", \"phiz\", \"radius\"" << std::endl;
36 std::vector<edm::ParameterSet>
fitters = iConfig.
getParameter<std::vector<edm::ParameterSet> >(
"fitters");
37 for (std::vector<edm::ParameterSet>::const_iterator fitter =
fitters.begin(); fitter !=
fitters.end(); ++fitter) {
41 for (std::vector<CSCPairResidualsConstraint*>::const_iterator residualsConstraint =
m_residualsConstraints.begin();
43 ++residualsConstraint) {
44 (*residualsConstraint)->configure(
this);
45 m_quickChamberLookup[std::pair<CSCDetId, CSCDetId>((*residualsConstraint)->id_i(), (*residualsConstraint)->id_j())] =
73 m_slope = tFileService->
make<TH1F>(
"slope",
"", 100, -0.5, 0.5);
90 m_drdz = tFileService->
make<TH1F>(
"drdz",
"", 100, -0.5, 0.5);
92 m_occupancy = tFileService->
make<TH2F>(
"occupancy",
"", 36, 1, 37, 20, 1, 21);
93 for (
int i = 1;
i <= 36;
i++) {
94 std::stringstream pairname;
100 m_occupancy->GetXaxis()->SetBinLabel(
i, pairname.str().c_str());
111 m_occupancy->GetYaxis()->SetBinLabel(9,
"ME-1/1b");
112 m_occupancy->GetYaxis()->SetBinLabel(10,
"ME-1/1a");
113 m_occupancy->GetYaxis()->SetBinLabel(11,
"ME+1/1a");
114 m_occupancy->GetYaxis()->SetBinLabel(12,
"ME+1/1b");
119 m_occupancy->GetYaxis()->SetBinLabel(12,
"ME+1/1");
121 m_occupancy->GetYaxis()->SetBinLabel(13,
"ME+1/2");
122 m_occupancy->GetYaxis()->SetBinLabel(14,
"ME+1/3");
123 m_occupancy->GetYaxis()->SetBinLabel(15,
"ME+2/1");
124 m_occupancy->GetYaxis()->SetBinLabel(16,
"ME+2/2");
125 m_occupancy->GetYaxis()->SetBinLabel(17,
"ME+3/1");
126 m_occupancy->GetYaxis()->SetBinLabel(18,
"ME+3/2");
127 m_occupancy->GetYaxis()->SetBinLabel(19,
"ME+4/1");
128 m_occupancy->GetYaxis()->SetBinLabel(20,
"ME+4/2");
130 m_XYpos_mep1 = tFileService->
make<TH2F>(
"XYpos_mep1",
"Positions: ME+1", 140, -700., 700., 140, -700., 700.);
131 m_XYpos_mep2 = tFileService->
make<TH2F>(
"XYpos_mep2",
"Positions: ME+2", 140, -700., 700., 140, -700., 700.);
132 m_XYpos_mep3 = tFileService->
make<TH2F>(
"XYpos_mep3",
"Positions: ME+3", 140, -700., 700., 140, -700., 700.);
133 m_XYpos_mep4 = tFileService->
make<TH2F>(
"XYpos_mep4",
"Positions: ME+4", 140, -700., 700., 140, -700., 700.);
134 m_XYpos_mem1 = tFileService->
make<TH2F>(
"XYpos_mem1",
"Positions: ME-1", 140, -700., 700., 140, -700., 700.);
135 m_XYpos_mem2 = tFileService->
make<TH2F>(
"XYpos_mem2",
"Positions: ME-2", 140, -700., 700., 140, -700., 700.);
136 m_XYpos_mem3 = tFileService->
make<TH2F>(
"XYpos_mem3",
"Positions: ME-3", 140, -700., 700., 140, -700., 700.);
137 m_XYpos_mem4 = tFileService->
make<TH2F>(
"XYpos_mem4",
"Positions: ME-4", 140, -700., 700., 140, -700., 700.);
201 if (alignableTracker ==
nullptr)
207 DetId id = alignable->geomDetId();
209 throw cms::Exception(
"BadConfig") <<
"Only CSC chambers may be alignable" << std::endl;
212 std::vector<bool> selector = alignable->alignmentParameters()->selector();
213 for (std::vector<bool>::const_iterator
i = selector.begin();
i != selector.end(); ++
i) {
215 throw cms::Exception(
"BadConfig") <<
"All selector strings should be \"111111\"" << std::endl;
222 for (std::vector<CSCPairResidualsConstraint*>::const_iterator residualsConstraint =
m_residualsConstraints.begin();
224 ++residualsConstraint) {
225 (*residualsConstraint)->setZplane(&*cscGeometry);
229 std::vector<std::ifstream*>
input;
236 for (std::vector<CSCPairResidualsConstraint*>::const_iterator residualsConstraint =
m_residualsConstraints.begin();
238 ++residualsConstraint) {
255 for (std::vector<CSCPairResidualsConstraint*>::const_iterator residualsConstraint =
258 ++residualsConstraint) {
271 for (ConstTrajTrackPairCollection::const_iterator trajtrack = trajtracks.begin(); trajtrack != trajtracks.end();
282 std::vector<TrajectoryMeasurement> measurements = traj->
measurements();
285 std::map<int, std::map<CSCDetId, bool> > stationsToChambers;
286 for (std::vector<TrajectoryMeasurement>::const_iterator measurement = measurements.begin();
287 measurement != measurements.end();
289 DetId id = measurement->recHit()->geographicalId();
297 if (stationsToChambers.find(
station) == stationsToChambers.end())
298 stationsToChambers[
station] = std::map<CSCDetId, bool>();
299 stationsToChambers[
station][chamberId] =
true;
339 std::map<CSCPairResidualsConstraint*, bool> residualsConstraints;
340 for (
std::map<
int, std::map<CSCDetId, bool> >::const_iterator iter = stationsToChambers.begin();
341 iter != stationsToChambers.end();
343 for (std::map<CSCDetId, bool>::const_iterator
one = iter->second.begin();
one != iter->second.end(); ++
one) {
344 for (std::map<CSCDetId, bool>::const_iterator
two =
one;
two != iter->second.end(); ++
two) {
350 residualsConstraints[quick->second] =
true;
354 residualsConstraints[quick->second] =
true;
360 for (std::map<CSCPairResidualsConstraint*, bool>::const_iterator residualsConstraint =
361 residualsConstraints.begin();
362 residualsConstraint != residualsConstraints.end();
363 ++residualsConstraint) {
364 residualsConstraint->first->addTrack(measurements, transientTrack,
m_trackTransformer);
374 for (std::vector<CSCPairResidualsConstraint*>::const_iterator residualsConstraint =
m_residualsConstraints.begin();
376 ++residualsConstraint) {
377 (*residualsConstraint)->write(
output);
387 report <<
"cscReports = []" << std::endl
389 <<
"class CSCChamberCorrection:" << std::endl
390 <<
" def __init__(self, name, detid, value):" << std::endl
391 <<
" self.name, self.detid, self.value = name, detid, value" << std::endl
393 <<
"class CSCErrorMode:" << std::endl
394 <<
" def __init__(self, error):" << std::endl
395 <<
" self.error = error" << std::endl
396 <<
" self.terms = {}" << std::endl
397 <<
" self.detids = {}" << std::endl
398 <<
" def addTerm(self, name, detid, coefficient):" << std::endl
399 <<
" self.terms[name] = coefficient" << std::endl
400 <<
" self.detids[name] = detid" << std::endl
402 <<
"class CSCConstraintResidual:" << std::endl
403 <<
" def __init__(self, i, j, before, uncert, residual, pull):" << std::endl
404 <<
" self.i, self.j, self.before, self.error, self.residual, self.pull = i, j, before, uncert, "
408 <<
"class CSCFitterReport:" << std::endl
409 <<
" def __init__(self, name, oldchi2, newchi2):" << std::endl
410 <<
" self.name, self.oldchi2, self.newchi2 = name, oldchi2, newchi2" << std::endl
411 <<
" self.chamberCorrections = []" << std::endl
412 <<
" self.errorModes = []" << std::endl
413 <<
" self.constraintResiduals = []" << std::endl
415 <<
" def addChamberCorrection(self, name, detid, value):" << std::endl
416 <<
" self.chamberCorrections.append(CSCChamberCorrection(name, detid, value))" << std::endl
418 <<
" def addErrorMode(self, error):" << std::endl
419 <<
" self.errorModes.append(CSCErrorMode(error))" << std::endl
421 <<
" def addErrorModeTerm(self, name, detid, coefficient):" << std::endl
422 <<
" self.errorModes[-1].addTerm(name, detid, coefficient)" << std::endl
424 <<
" def addCSCConstraintResidual(self, i, j, before, uncert, residual, pull):" << std::endl
425 <<
" self.constraintResiduals.append(CSCConstraintResidual(i, j, before, uncert, residual, pull))"
428 <<
"import re" << std::endl
429 <<
"def nameToKey(name):" << std::endl
430 <<
" match = re.match(\"ME([\\+\\-])([1-4])/([1-4])/([0-9]{2})\", name)" << std::endl
431 <<
" if match is None: return None" << std::endl
432 <<
" endcap, station, ring, chamber = match.groups()" << std::endl
433 <<
" if endcap == \"+\": endcap = 1" << std::endl
434 <<
" else: endcap = 2" << std::endl
435 <<
" station = int(station)" << std::endl
436 <<
" ring = int(ring)" << std::endl
437 <<
" chamber = int(chamber)" << std::endl
438 <<
" return endcap, station, ring, chamber" << std::endl
442 for (std::vector<CSCChamberFitter>::const_iterator fitter =
m_fitters.begin(); fitter !=
m_fitters.end();
448 std::vector<CSCAlignmentCorrections*> corrections;
449 fitter->fit(corrections);
452 for (std::vector<CSCAlignmentCorrections*>::iterator
correction = corrections.begin();
457 (*correction)->plot();
459 (*correction)->report(
report);