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"))
30 else throw cms::Exception(
"BadConfig") <<
"mode must be one of \"phiy\", \"phipos\", \"phiz\", \"radius\"" << std::endl;
32 std::vector<edm::ParameterSet>
fitters = iConfig.
getParameter<std::vector<edm::ParameterSet> >(
"fitters");
33 for (std::vector<edm::ParameterSet>::const_iterator fitter = fitters.begin(); fitter != fitters.end(); ++fitter) {
38 (*residualsConstraint)->configure(
this);
39 m_quickChamberLookup[std::pair<CSCDetId,CSCDetId>((*residualsConstraint)->id_i(), (*residualsConstraint)->id_j())] = *residualsConstraint;
66 m_slope = tFileService->
make<TH1F>(
"slope",
"", 100, -0.5, 0.5);
83 m_drdz = tFileService->
make<TH1F>(
"drdz",
"", 100, -0.5, 0.5);
85 m_occupancy = tFileService->
make<TH2F>(
"occupancy",
"", 36, 1, 37, 20, 1, 21);
86 for (
int i = 1;
i <= 36;
i++) {
87 std::stringstream pairname;
89 if (i+1 == 37) pairname << 1;
90 else pairname << (i+1);
91 m_occupancy->GetXaxis()->SetBinLabel(i, pairname.str().c_str());
102 m_occupancy->GetYaxis()->SetBinLabel(9,
"ME-1/1b");
103 m_occupancy->GetYaxis()->SetBinLabel(10,
"ME-1/1a");
104 m_occupancy->GetYaxis()->SetBinLabel(11,
"ME+1/1a");
105 m_occupancy->GetYaxis()->SetBinLabel(12,
"ME+1/1b");
111 m_occupancy->GetYaxis()->SetBinLabel(12,
"ME+1/1");
113 m_occupancy->GetYaxis()->SetBinLabel(13,
"ME+1/2");
114 m_occupancy->GetYaxis()->SetBinLabel(14,
"ME+1/3");
115 m_occupancy->GetYaxis()->SetBinLabel(15,
"ME+2/1");
116 m_occupancy->GetYaxis()->SetBinLabel(16,
"ME+2/2");
117 m_occupancy->GetYaxis()->SetBinLabel(17,
"ME+3/1");
118 m_occupancy->GetYaxis()->SetBinLabel(18,
"ME+3/2");
119 m_occupancy->GetYaxis()->SetBinLabel(19,
"ME+4/1");
120 m_occupancy->GetYaxis()->SetBinLabel(20,
"ME+4/2");
122 m_XYpos_mep1 = tFileService->
make<TH2F>(
"XYpos_mep1",
"Positions: ME+1", 140, -700., 700., 140, -700., 700.);
123 m_XYpos_mep2 = tFileService->
make<TH2F>(
"XYpos_mep2",
"Positions: ME+2", 140, -700., 700., 140, -700., 700.);
124 m_XYpos_mep3 = tFileService->
make<TH2F>(
"XYpos_mep3",
"Positions: ME+3", 140, -700., 700., 140, -700., 700.);
125 m_XYpos_mep4 = tFileService->
make<TH2F>(
"XYpos_mep4",
"Positions: ME+4", 140, -700., 700., 140, -700., 700.);
126 m_XYpos_mem1 = tFileService->
make<TH2F>(
"XYpos_mem1",
"Positions: ME-1", 140, -700., 700., 140, -700., 700.);
127 m_XYpos_mem2 = tFileService->
make<TH2F>(
"XYpos_mem2",
"Positions: ME-2", 140, -700., 700., 140, -700., 700.);
128 m_XYpos_mem3 = tFileService->
make<TH2F>(
"XYpos_mem3",
"Positions: ME-3", 140, -700., 700., 140, -700., 700.);
129 m_XYpos_mem4 = tFileService->
make<TH2F>(
"XYpos_mem4",
"Positions: ME-4", 140, -700., 700., 140, -700., 700.);
193 for (std::vector<Alignable*>::const_iterator alignable =
m_alignables.begin(); alignable !=
m_alignables.end(); ++alignable) {
194 DetId id = (*alignable)->geomDetId();
196 throw cms::Exception(
"BadConfig") <<
"Only CSC chambers may be alignable" << std::endl;
199 std::vector<bool> selector = (*alignable)->alignmentParameters()->selector();
200 for (std::vector<bool>::const_iterator
i = selector.begin();
i != selector.end(); ++
i) {
201 if (!(*
i))
throw cms::Exception(
"BadConfig") <<
"All selector strings should be \"111111\"" << std::endl;
209 (*residualsConstraint)->setZplane(&*cscGeometry);
213 std::vector<std::ifstream*>
input;
215 input.push_back(
new std::ifstream(
fileName->c_str()));
222 for (std::vector<std::ifstream*>::const_iterator
file = input.begin();
file != input.end(); ++
file) {
247 for (ConstTrajTrackPairCollection::const_iterator trajtrack = trajtracks.begin(); trajtrack != trajtracks.end(); ++trajtrack) {
257 std::vector<TrajectoryMeasurement> measurements = traj->
measurements();
260 std::map<int,std::map<CSCDetId,bool> > stationsToChambers;
261 for (std::vector<TrajectoryMeasurement>::const_iterator measurement = measurements.begin(); measurement != measurements.end(); ++measurement) {
262 DetId id = measurement->recHit()->geographicalId();
269 if (stationsToChambers.find(station) == stationsToChambers.end()) stationsToChambers[station] = std::map<CSCDetId,bool>();
270 stationsToChambers[
station][chamberId] =
true;
273 GlobalPoint pos = measurement->recHit()->globalPosition();
286 std::map<CSCPairResidualsConstraint*,bool> residualsConstraints;
287 for (
std::map<
int,std::map<CSCDetId,bool> >::const_iterator iter = stationsToChambers.begin(); iter != stationsToChambers.end(); ++iter) {
288 for (std::map<CSCDetId,bool>::const_iterator one = iter->second.begin(); one != iter->second.end(); ++one) {
289 for (std::map<CSCDetId,bool>::const_iterator two = one; two != iter->second.end(); ++two) {
303 for (std::map<CSCPairResidualsConstraint*,bool>::const_iterator residualsConstraint = residualsConstraints.begin(); residualsConstraint != residualsConstraints.end(); ++residualsConstraint) {
304 residualsConstraint->first->addTrack(measurements, transientTrack,
m_trackTransformer);
315 (*residualsConstraint)->write(
output);
325 report <<
"cscReports = []" << std::endl << std::endl
326 <<
"class CSCChamberCorrection:" << std::endl
327 <<
" def __init__(self, name, detid, value):" << std::endl
328 <<
" self.name, self.detid, self.value = name, detid, value" << std::endl << std::endl
329 <<
"class CSCErrorMode:" << std::endl
330 <<
" def __init__(self, error):" << std::endl
331 <<
" self.error = error" << std::endl
332 <<
" self.terms = {}" << std::endl
333 <<
" self.detids = {}" << std::endl
334 <<
" def addTerm(self, name, detid, coefficient):" << std::endl
335 <<
" self.terms[name] = coefficient" << std::endl
336 <<
" self.detids[name] = detid" << std::endl << std::endl
337 <<
"class CSCConstraintResidual:" << std::endl
338 <<
" def __init__(self, i, j, before, uncert, residual, pull):" << std::endl
339 <<
" self.i, self.j, self.before, self.error, self.residual, self.pull = i, j, before, uncert, residual, pull" << std::endl << std::endl
340 <<
"class CSCFitterReport:" << std::endl
341 <<
" def __init__(self, name, oldchi2, newchi2):" << std::endl
342 <<
" self.name, self.oldchi2, self.newchi2 = name, oldchi2, newchi2" << std::endl
343 <<
" self.chamberCorrections = []" << std::endl
344 <<
" self.errorModes = []" << std::endl
345 <<
" self.constraintResiduals = []" << std::endl << std::endl
346 <<
" def addChamberCorrection(self, name, detid, value):" << std::endl
347 <<
" self.chamberCorrections.append(CSCChamberCorrection(name, detid, value))" << std::endl << std::endl
348 <<
" def addErrorMode(self, error):" << std::endl
349 <<
" self.errorModes.append(CSCErrorMode(error))" << std::endl << std::endl
350 <<
" def addErrorModeTerm(self, name, detid, coefficient):" << std::endl
351 <<
" self.errorModes[-1].addTerm(name, detid, coefficient)" << std::endl << std::endl
352 <<
" def addCSCConstraintResidual(self, i, j, before, uncert, residual, pull):" << std::endl
353 <<
" self.constraintResiduals.append(CSCConstraintResidual(i, j, before, uncert, residual, pull))" << std::endl << std::endl
354 <<
"import re" << std::endl
355 <<
"def nameToKey(name):" << std::endl
356 <<
" match = re.match(\"ME([\\+\\-])([1-4])/([1-4])/([0-9]{2})\", name)" << std::endl
357 <<
" if match is None: return None" << std::endl
358 <<
" endcap, station, ring, chamber = match.groups()" << std::endl
359 <<
" if endcap == \"+\": endcap = 1" << std::endl
360 <<
" else: endcap = 2" << std::endl
361 <<
" station = int(station)" << std::endl
362 <<
" ring = int(ring)" << std::endl
363 <<
" chamber = int(chamber)" << std::endl
364 <<
" return endcap, station, ring, chamber" << std::endl << std::endl;
367 for (std::vector<CSCChamberFitter>::const_iterator fitter =
m_fitters.begin(); fitter !=
m_fitters.end(); ++fitter) {
375 std::vector<CSCAlignmentCorrections*> corrections;
376 fitter->fit(corrections);
379 for (std::vector<CSCAlignmentCorrections*>::iterator correction = corrections.begin(); correction != corrections.end(); ++correction) {
383 if (writeReport) (*correction)->report(report);
TrackTransformer * m_trackTransformer
double p() const
momentum vector magnitude
T getParameter(std::string const &) const
std::vector< CSCChamberFitter > m_fitters
std::string m_writeTemporaryFile
CSCOverlapsAlignmentAlgorithm(const edm::ParameterSet &iConfig)
void initialize(const edm::EventSetup &iSetup, AlignableTracker *alignableTracker, AlignableMuon *alignableMuon, AlignableExtras *alignableExtras, AlignmentParameterStore *alignmentParameterStore)
Call at beginning of job (must be implemented in derived class)
std::string m_reportFileName
std::vector< std::string > m_readTemporaryFiles
Geom::Phi< T > phi() const
T * make(const Args &...args) const
make new ROOT object
std::string m_mode_string
AlignmentParameterStore * m_alignmentParameterStore
const Propagator * m_propagatorPointer
const ConstTrajTrackPairCollection & trajTrackPairs() const
define event information passed to algorithms
static std::string const input
TH1F * m_slopeResiduals_weighted
DataContainer const & measurements() const
void run(const edm::EventSetup &iSetup, const EventInfo &eventInfo)
Run the algorithm (must be implemented in derived class)
TProfile * m_fiducial_MEx2
TH1F * m_offsetResiduals_weighted
TH1F * m_offsetResiduals_normalized
~CSCOverlapsAlignmentAlgorithm()
std::vector< CSCPairResidualsConstraint * > m_residualsConstraints
TProfile * m_fiducial_MEx1
std::vector< Alignable * > m_alignables
virtual void terminate()
Called at end of job (must be implemented in derived class)
bool m_slopeFromTrackRefit
#define DEFINE_EDM_PLUGIN(factory, type, name)
AlignableNavigator * m_alignableNavigator
std::map< std::pair< CSCDetId, CSCDetId >, CSCPairResidualsConstraint * > m_quickChamberLookup
Constructor of the full muon geometry.
TProfile * m_fiducial_ME12
const align::Alignables & alignables(void) const
get all alignables
std::vector< ConstTrajTrackPair > ConstTrajTrackPairCollection
TProfile * m_fiducial_ME11
TH1F * m_slopeResiduals_normalized
std::string m_propagatorName