13 LogTrace(
metname) <<
"[MuonAlignment] Constructor called!" << std::endl;
61 edm::LogError(
"MuonAlignment") <<
" Error!! At least one Muon subsystem " 62 "(DT or CSC) must be monitorized!!" 64 edm::LogError(
"MuonAlignment") <<
" Please enable doDT or doCSC to True in your python cfg file!!!" << std::endl;
74 "hLocalPositionDT",
"Local DT position (cm) absolute MEAN residuals;Sector;;cm", 14, 1, 15, 40, 0, 40);
76 "hLocalAngleDT",
"Local DT angle (rad) absolute MEAN residuals;Sector;;rad", 14, 1, 15, 40, 0, 40);
78 dbe->
book2D(
"hLocalPositionRmsDT",
"Local DT position (cm) RMS residuals;Sector;;cm", 14, 1, 15, 40, 0, 40);
80 dbe->
book2D(
"hLocalAngleRmsDT",
"Local DT angle (rad) RMS residuals;Sector;;rad", 14, 1, 15, 40, 0, 40);
83 "Distribution of absolute MEAN Local X (cm) residuals " 84 "for DT;<X> (cm);number of chambers",
89 "Distribution of RMS Local X (cm) residuals " 90 "for DT;X RMS (cm);number of chambers",
95 "Distribution of absolute MEAN Local Y (cm) residuals " 96 "for DT;<Y> (cm);number of chambers",
101 "Distribution of RMS Local Y (cm) residuals " 102 "for DT;Y RMS (cm);number of chambers",
108 "Distribution of MEAN #phi (rad) residuals " 109 "for DT;<#phi>(rad);number of chambers",
114 "Distribution of RMS #phi (rad) residuals " 115 "for DT;#phi RMS (rad);number of chambers",
120 "Distribution of MEAN #theta (rad) residuals for " 121 "DT;<#theta>(rad);number of chambers",
126 "Distribution of RMS #theta (rad) residuals for " 127 "DT;#theta RMS (rad);number of chambers",
136 "hLocalPositionCSC",
"Local CSC position (cm) absolute MEAN residuals;Sector;;cm", 36, 1, 37, 40, 0, 40);
138 "hLocalAngleCSC",
"Local CSC angle (rad) absolute MEAN residuals;Sector;;rad", 36, 1, 37, 40, 0, 40);
140 dbe->
book2D(
"hLocalPositionRmsCSC",
"Local CSC position (cm) RMS residuals;Sector;;cm", 36, 1, 37, 40, 0, 40);
142 dbe->
book2D(
"hLocalAngleRmsCSC",
"Local CSC angle (rad) RMS residuals;Sector;;rad", 36, 1, 37, 40, 0, 40);
145 "Distribution of absolute MEAN Local X (cm) residuals " 146 "for CSC;<X> (cm);number of chambers",
151 "Distribution of RMS Local X (cm) residuals " 152 "for CSC;X RMS (cm);number of chambers",
157 "Distribution of absolute MEAN Local Y (cm) residuals " 158 "for CSC;<Y> (cm);number of chambers",
163 "Distribution of RMS Local Y (cm) residuals " 164 "for CSC;Y RMS (cm);number of chambers",
170 "Distribution of absolute MEAN #phi (rad) residuals for " 171 "CSC;<#phi>(rad);number of chambers",
176 "Distribution of RMS #phi (rad) residuals " 177 "for CSC;#phi RMS (rad);number of chambers",
182 "Distribution of absolute MEAN #theta (rad) residuals " 183 "for CSC;<#theta>(rad);number of chambers",
188 "Distribution of RMS #theta (rad) residuals for " 189 "CSC;#theta RMS (rad);number of chambers",
201 double rangeX = 0, rangeY = 0;
202 std::string nameOfHistoLocalX, nameOfHistoLocalY, nameOfHistoLocalPhi, nameOfHistoLocalTheta;
229 for (
int sector = 1; sector < 15; sector++) {
230 if (!((sector == 13 || sector == 14) &&
station != 4)) {
231 std::stringstream Wheel;
233 std::stringstream Station;
235 std::stringstream Sector;
238 nameOfHistoLocalX =
"ResidualLocalX_W" + Wheel.str() +
"MB" + Station.str() +
"S" + Sector.str();
239 nameOfHistoLocalPhi =
"ResidualLocalPhi_W" + Wheel.str() +
"MB" + Station.str() +
"S" + Sector.str();
240 nameOfHistoLocalTheta =
"ResidualLocalTheta_W" + Wheel.str() +
"MB" + Station.str() +
"S" + Sector.str();
241 nameOfHistoLocalY =
"ResidualLocalY_W" + Wheel.str() +
"MB" + Station.str() +
"S" + Sector.str();
244 "/Sector" + Sector.str());
270 std::stringstream Ring;
272 std::stringstream Station;
274 std::stringstream Chamber;
277 nameOfHistoLocalX =
"ResidualLocalX_ME" + Station.str() +
"R" + Ring.str() +
"C" + Chamber.str();
278 nameOfHistoLocalPhi =
"ResidualLocalPhi_ME" + Station.str() +
"R" + Ring.str() +
"C" + Chamber.str();
279 nameOfHistoLocalTheta =
"ResidualLocalTheta_ME" + Station.str() +
"R" + Ring.str() +
"C" + Chamber.str();
280 nameOfHistoLocalY =
"ResidualLocalY_ME" + Station.str() +
"R" + Ring.str() +
"C" + Chamber.str();
283 "/Chamber" + Chamber.str());
347 reco::TrackCollection::const_iterator
muon;
348 for (muon = muons->begin(); muon != muons->end(); ++
muon) {
373 if ((outerPerpSA - innerPerpSA) > 0) {
376 thePropagator = thePropagatorAlo.
product();
383 thePropagator = thePropagatorOpp.
product();
388 *muon, all4DSegmentsDT, all4DSegmentsCSC, &indexCollectionDT, &indexCollectionCSC, theTrackingGeometry);
400 for (RecHitVector::iterator rechit = my4DTrack.begin(); rechit != my4DTrack.end(); ++rechit) {
401 const GeomDet *geomDet = theTrackingGeometry->
idToDet((*rechit)->geographicalId());
406 if (pDest !=
nullptr || cDest !=
nullptr) {
415 const long rawId = (*rechit)->geographicalId().rawId();
422 bool goAhead = (det == 1 &&
doDT) || (det == 2 &&
doCSC);
424 double residualLocalX = 0, residualLocalPhi = 0, residualLocalY = 0, residualLocalTheta = 0;
428 if (det == 1 &&
doDT) {
430 wheel = myChamber.
wheel();
432 sector = myChamber.
sector();
434 residualLocalX = (*rechit)->localPosition().x() - destiny.
localPosition().
x();
436 residualLocalPhi = atan2(((
RecSegment *)(*rechit))->localDirection().
z(),
440 residualLocalY = (*rechit)->localPosition().y() - destiny.
localPosition().
y();
442 residualLocalTheta = atan2(((
RecSegment *)(*rechit))->localDirection().
z(),
447 }
else if (det == 2 &&
doCSC) {
449 endcap = myChamber.
endcap();
456 residualLocalX = (*rechit)->localPosition().x() - destiny.
localPosition().
x();
458 residualLocalY = (*rechit)->localPosition().y() - destiny.
localPosition().
y();
460 residualLocalPhi = atan2(((
RecSegment *)(*rechit))->localDirection().
y(),
464 residualLocalTheta = atan2(((
RecSegment *)(*rechit))->localDirection().
y(),
469 residualLocalX = 0, residualLocalPhi = 0, residualLocalY = 0, residualLocalTheta = 0;
476 if (det == 1 &&
doDT) {
477 std::stringstream Wheel;
479 std::stringstream Station;
481 std::stringstream Sector;
484 nameOfHistoLocalX =
"ResidualLocalX_W" + Wheel.str() +
"MB" + Station.str() +
"S" + Sector.str();
486 }
else if (det == 2 &&
doCSC) {
487 std::stringstream Ring;
489 std::stringstream Station;
491 std::stringstream Chamber;
494 nameOfHistoLocalX =
"ResidualLocalX_ME" + Station.str() +
"R" + Ring.str() +
"C" + Chamber.str();
507 residualLocalPhi += 3.1416;
508 residualLocalTheta += 3.1416;
514 if (det == 1 &&
station != 4) {
527 if (countPoints == 1)
536 edm::LogError(
"MuonAlignment") <<
" Error!! Exception in propagator catched" << std::endl;
567 std::vector<int> positionDT;
568 std::vector<int> positionCSC;
582 int NumberOfDTSegment = 0;
584 for (segmentDT = all4DSegmentsDT->begin(); segmentDT != all4DSegmentsDT->end(); ++segmentDT) {
586 bool isNewChamber =
true;
590 for (std::vector<int>::iterator positionIt = positionDT.begin(); positionIt != positionDT.end(); positionIt++) {
592 if (NumberOfDTSegment == *positionIt)
593 isNewChamber =
false;
597 for (std::vector<std::vector<int>>::iterator collect = indexCollectionDT->begin();
598 collect != indexCollectionDT->end();
601 for (std::vector<int>::iterator positionIt = (*collect).begin(); positionIt != (*collect).end();
605 if (NumberOfDTSegment == *positionIt)
606 isNewChamber =
false;
612 DTChamberId myChamber((*segmentDT).geographicalId().rawId());
614 if (myLayer.wheel() == myChamber.wheel() && myLayer.station() == myChamber.station() &&
615 myLayer.sector() == myChamber.sector()) {
617 positionDT.push_back(NumberOfDTSegment);
628 int NumberOfCSCSegment = 0;
630 for (segmentCSC = all4DSegmentsCSC->begin(); segmentCSC != all4DSegmentsCSC->end(); segmentCSC++) {
632 bool isNewChamber =
true;
635 for (std::vector<int>::iterator positionIt = positionCSC.begin(); positionIt != positionCSC.end();
638 if (NumberOfCSCSegment == *positionIt)
639 isNewChamber =
false;
642 for (std::vector<std::vector<int>>::iterator collect = indexCollectionCSC->begin();
643 collect != indexCollectionCSC->end();
646 for (std::vector<int>::iterator positionIt = (*collect).begin(); positionIt != (*collect).end();
649 if (NumberOfCSCSegment == *positionIt)
650 isNewChamber =
false;
655 CSCDetId myChamber((*segmentCSC).geographicalId().rawId());
657 if (myLayer.chamberId() == myChamber.chamberId()) {
659 positionCSC.push_back(NumberOfCSCSegment);
663 NumberOfCSCSegment++;
668 indexCollectionDT->push_back(positionDT);
669 indexCollectionCSC->push_back(positionCSC);
679 bool outputMEsInRootFile =
parameters.getParameter<
bool>(
"OutputMEsInRootFile");
708 if (nameHistoLocalX.Contains(
"MB"))
712 sscanf(nameHistoLocalX,
"ResidualLocalX_W%dMB%1dS%d", &wheel, &station, §or);
714 Int_t nstation = station - 1;
715 Int_t nwheel = wheel + 2;
720 Int_t ybin = 1 + nwheel * 8 + nstation * 2;
722 snprintf(binLabel,
sizeof(binLabel),
"MB%d/%d_X", wheel, station);
731 if (nameHistoLocalX.Contains(
"ME"))
735 sscanf(nameHistoLocalX,
"ResidualLocalX_ME%dR%1dC%d", &station, &ring, &chamber);
740 Int_t ybin =
abs(station) * 2 +
ring;
741 if (
abs(station) == 1)
749 snprintf(binLabel,
sizeof(binLabel),
"ME%d/%d_X", station, ring);
758 if (nameHistoLocalTheta.Contains(
"MB"))
762 sscanf(nameHistoLocalTheta,
"ResidualLocalTheta_W%dMB%1dS%d", &wheel, &station, §or);
765 Int_t nstation = station - 1;
766 Int_t nwheel = wheel + 2;
771 Int_t ybin = 2 + nwheel * 8 + nstation * 2;
773 snprintf(binLabel,
sizeof(binLabel),
"MB%d/%d_#theta", wheel, station);
783 if (nameHistoLocalPhi.Contains(
"MB"))
787 sscanf(nameHistoLocalPhi,
"ResidualLocalPhi_W%dMB%1dS%d", &wheel, &station, §or);
789 Int_t nstation = station - 1;
790 Int_t nwheel = wheel + 2;
795 Int_t ybin = 1 + nwheel * 8 + nstation * 2;
797 snprintf(binLabel,
sizeof(binLabel),
"MB%d/%d_#phi", wheel, station);
806 if (nameHistoLocalPhi.Contains(
"ME"))
810 sscanf(nameHistoLocalPhi,
"ResidualLocalPhi_ME%dR%1dC%d", &station, &ring, &chamber);
815 Int_t ybin =
abs(station) * 2 +
ring;
816 if (
abs(station) == 1)
824 snprintf(binLabel,
sizeof(binLabel),
"ME%d/%d_#phi", station, ring);
833 if (nameHistoLocalTheta.Contains(
"ME"))
837 sscanf(nameHistoLocalTheta,
"ResidualLocalTheta_ME%dR%1dC%d", &station, &ring, &chamber);
842 Int_t ybin =
abs(station) * 2 +
ring;
843 if (
abs(station) == 1)
851 snprintf(binLabel,
sizeof(binLabel),
"ME%d/%d_#theta", station, ring);
860 if (nameHistoLocalY.Contains(
"MB"))
864 sscanf(nameHistoLocalY,
"ResidualLocalY_W%dMB%1dS%d", &wheel, &station, §or);
867 Int_t nstation = station - 1;
868 Int_t nwheel = wheel + 2;
873 Int_t ybin = 2 + nwheel * 8 + nstation * 2;
875 snprintf(binLabel,
sizeof(binLabel),
"MB%d/%d_Y", wheel, station);
885 if (nameHistoLocalY.Contains(
"ME"))
889 sscanf(nameHistoLocalY,
"ResidualLocalY_ME%dR%1dC%d", &station, &ring, &chamber);
894 Int_t ybin =
abs(station) * 2 +
ring;
895 if (
abs(station) == 1)
903 snprintf(binLabel,
sizeof(binLabel),
"ME%d/%d_Y", station, ring);
915 if (outputMEsInRootFile) {
MonitorElement * hLocalPhiRmsDT
MonitorElement * book2D(char_string const &name, char_string const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
edm::EDGetTokenT< CSCSegmentCollection > theRecHits4DTagCSC
std::vector< MonitorElement * > unitsLocalX
edm::ErrorSummaryEntry Error
MonitorElement * hLocalPositionRmsDT
void analyze(const edm::Event &, const edm::EventSetup &) override
Get the analysis.
MonitorElement * hLocalThetaMeanCSC
MonitorElement * hLocalYMeanDT
void beginJob() override
Inizialize parameters for histo binning.
void setBinContent(int binx, double content)
set content of bin (1-D)
RecHitVector doMatching(const reco::Track &, edm::Handle< DTRecSegment4DCollection > &, edm::Handle< CSCSegmentCollection > &, intDVector *, intDVector *, edm::ESHandle< GlobalTrackingGeometry > &)
MonitorElement * hLocalPhiRmsCSC
double resLocalYRangeStation2
MonitorElement * hLocalYRmsCSC
MonitorElement * hLocalPositionCSC
double resLocalXRangeStation1
bool getByToken(EDGetToken token, Handle< PROD > &result) const
MonitorElement * hLocalXMeanDT
size_t recHitsSize() const
Get number of RecHits. (Warning, this includes invalid hits, which are not physical hits)...
LocalVector localDirection() const
LocalPoint localPosition() const
double resLocalYRangeStation1
std::string trackRefitterType
MonitorElement * hLocalPhiMeanDT
constexpr uint32_t rawId() const
get the raw id
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
GlobalPoint globalPosition() const
edm::EDGetTokenT< reco::TrackCollection > theMuonCollectionLabel
MonitorElement * book1D(char_string const &name, char_string const &title, int const nchX, double const lowX, double const highX)
Book 1D histogram.
const Plane & surface() const
The nominal surface of the GeomDet.
std::vector< TrackingRecHit * > RecHitVector
MuonAlignment(const edm::EventSetup &iSetup)
TrajectoryStateOnSurface innermostMeasurementState() const
void endJob(void) override
Save the histos.
MonitorElement * hLocalAngleRmsCSC
C::const_iterator const_iterator
constant access iterator type
MonitorElement * hLocalAngleRmsDT
double resLocalXRangeStation2
MonitorElement * get(std::string const &path) const
get ME from full pathname (e.g. "my/long/dir/my_histo")
FreeTrajectoryState const * freeState(bool withErrors=true) const
MonitorElement * hLocalAngleDT
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
MonitorElement * hLocalThetaRmsDT
Abs< T >::type abs(const T &t)
std::vector< MonitorElement * > unitsLocalTheta
MonitorElement * hLocalYRmsDT
MonitorElement * hLocalThetaRmsCSC
T const * get() const
Returns C++ pointer to the item.
TrajectoryStateOnSurface outermostMeasurementState() const
MonitorElement * hLocalXMeanCSC
MonitorElement * hLocalYMeanCSC
std::vector< MonitorElement * > unitsLocalPhi
std::vector< std::vector< int > > intDVector
TString getName(TString structure, int layer, TString geometry)
void setCurrentFolder(std::string const &fullpath)
std::vector< MonitorElement * > unitsLocalY
MonitorElement * hLocalPhiMeanCSC
edm::EDGetTokenT< DTRecSegment4DCollection > theRecHits4DTagDT
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
MonitorElement * hLocalAngleCSC
double resLocalYRangeStation3
void save(std::string const &filename, std::string const &path="", std::string const &pattern="", std::string const &rewrite="", uint32_t run=0, uint32_t lumi=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, std::string const &fileupdate="RECREATE")
MonitorElement * hLocalXRmsDT
unsigned int min1DTrackRecHitSize
double resLocalYRangeStation4
MonitorElement * hLocalPositionRmsCSC
static int position[264][3]
TrackingRecHitRef recHit(size_t i) const
Get i-th hit on the track.
const GeomDet * idToDet(DetId) const override
DetId geographicalId() const
MonitorElement * hLocalXRmsCSC
int station() const
Return the station number.
unsigned int min4DTrackSegmentSize
virtual SubDetector subDetector() const
Which subdetector.
int wheel() const
Return the wheel number.
std::stringstream topFolder
T const * product() const
MonitorElement * hLocalThetaMeanDT
MonitorElement * hLocalPositionDT
double resLocalXRangeStation4
double resLocalXRangeStation3