65 edm::LogError(
"MuonAlignment") <<
" Error!! At least one Muon subsystem (DT or CSC) must be monitorized!!" << std::endl;
66 edm::LogError(
"MuonAlignment") <<
" Please enable doDT or doCSC to True in your python cfg file!!!" << std::endl;
75 hLocalPositionDT=
dbe->
book2D(
"hLocalPositionDT",
"Local DT position (cm) absolute MEAN residuals;Sector;;cm", 14,1, 15,40,0,40);
76 hLocalAngleDT=
dbe->
book2D(
"hLocalAngleDT",
"Local DT angle (rad) absolute MEAN residuals;Sector;;rad", 14,1, 15,40,0,40);
93 hLocalPositionCSC=
dbe->
book2D(
"hLocalPositionCSC",
"Local CSC position (cm) absolute MEAN residuals;Sector;;cm",36,1,37,40,0,40);
94 hLocalAngleCSC=
dbe->
book2D(
"hLocalAngleCSC",
"Local CSC angle (rad) absolute MEAN residuals;Sector;;rad", 36,1,37,40,0,40);
115 double rangeX=0,rangeY=0;
116 std::string nameOfHistoLocalX,nameOfHistoLocalY,nameOfHistoLocalPhi,nameOfHistoLocalTheta;
140 for(
int wheel=-2;wheel<3;wheel++){
142 for (
int sector=1;sector<15;sector++){
144 if(!((sector==13 || sector ==14) &&
station!=4)){
146 std::stringstream Wheel; Wheel<<wheel;
147 std::stringstream Station; Station<<
station;
148 std::stringstream Sector; Sector<<sector;
150 nameOfHistoLocalX=
"ResidualLocalX_W"+Wheel.str()+
"MB"+Station.str()+
"S"+Sector.str();
151 nameOfHistoLocalPhi=
"ResidualLocalPhi_W"+Wheel.str()+
"MB"+Station.str()+
"S"+Sector.str();
152 nameOfHistoLocalTheta=
"ResidualLocalTheta_W"+Wheel.str()+
"MB"+Station.str()+
"S"+Sector.str();
153 nameOfHistoLocalY=
"ResidualLocalY_W"+Wheel.str()+
"MB"+Station.str()+
"S"+Sector.str();
156 "/DT/Wheel"+Wheel.str()+
157 "/Station"+Station.str()+
158 "/Sector"+Sector.str());
181 for(
int chamber=1;chamber<37;chamber++){
185 std::stringstream Ring; Ring<<
ring;
186 std::stringstream Station; Station<<
station;
187 std::stringstream Chamber; Chamber<<chamber;
189 nameOfHistoLocalX=
"ResidualLocalX_ME"+Station.str()+
"R"+Ring.str()+
"C"+Chamber.str();
190 nameOfHistoLocalPhi=
"ResidualLocalPhi_ME"+Station.str()+
"R"+Ring.str()+
"C"+Chamber.str();
191 nameOfHistoLocalTheta=
"ResidualLocalTheta_ME"+Station.str()+
"R"+Ring.str()+
"C"+Chamber.str();
192 nameOfHistoLocalY=
"ResidualLocalY_ME"+Station.str()+
"R"+Ring.str()+
"C"+Chamber.str();
195 "/CSC/Station"+Station.str()+
197 "/Chamber"+Chamber.str());
261 reco::TrackCollection::const_iterator
muon;
262 for (muon = muons->begin(); muon != muons->end(); ++
muon){
287 if ( (outerPerpSA-innerPerpSA) > 0 ) {
291 thePropagator = thePropagatorAlo.
product();
298 thePropagator = thePropagatorOpp.
product();
303 RecHitVector my4DTrack = this->
doMatching(*muon, all4DSegmentsDT, all4DSegmentsCSC, &indexCollectionDT, &indexCollectionCSC, theTrackingGeometry);
318 for(RecHitVector::iterator rechit = my4DTrack.begin(); rechit != my4DTrack.end(); ++rechit) {
320 const GeomDet* geomDet = theTrackingGeometry->idToDet((*rechit)->geographicalId());
325 if(pDest != 0 || cDest != 0) {
333 const long rawId= (*rechit)->geographicalId().rawId();
338 int wheel=0,
station=0,sector=0;
340 bool goAhead = (det==1 &&
doDT) || (det==2 &&
doCSC);
342 double residualLocalX=0,residualLocalPhi=0,residualLocalY=0,residualLocalTheta=0;
346 if(det == 1 &&
doDT) {
348 wheel=myChamber.
wheel();
350 sector=myChamber.
sector();
352 residualLocalX = (*rechit)->localPosition().x() -destiny.
localPosition().
x();
355 residualLocalPhi = atan2(((
RecSegment *)(*rechit))->localDirection().
z(),
359 residualLocalY = (*rechit)->localPosition().y() - destiny.
localPosition().
y();
362 residualLocalTheta = atan2(((
RecSegment *)(*rechit))->localDirection().
z(),
368 else if (det==2 &&
doCSC){
370 endcap= myChamber.
endcap();
376 residualLocalX = (*rechit)->localPosition().x() -destiny.
localPosition().
x();
378 residualLocalY = (*rechit)->localPosition().y() - destiny.
localPosition().
y();
380 residualLocalPhi = atan2(((
RecSegment *)(*rechit))->localDirection().
y(),
383 residualLocalTheta = atan2(((
RecSegment *)(*rechit))->localDirection().
y(),
388 residualLocalX=0,residualLocalPhi=0,residualLocalY=0,residualLocalTheta=0;
398 std::stringstream Wheel; Wheel<<wheel;
399 std::stringstream Station; Station<<
station;
400 std::stringstream Sector; Sector<<sector;
402 nameOfHistoLocalX=
"ResidualLocalX_W"+Wheel.str()+
"MB"+Station.str()+
"S"+Sector.str();
405 else if(det==2 &&
doCSC){
406 std::stringstream Ring; Ring<<
ring;
407 std::stringstream Station; Station<<
station;
408 std::stringstream Chamber; Chamber<<chamber;
410 nameOfHistoLocalX=
"ResidualLocalX_ME"+Station.str()+
"R"+Ring.str()+
"C"+Chamber.str();
424 residualLocalPhi += 3.1416;
425 residualLocalTheta +=3.1416;
434 else if(det==2) {
unitsLocalY.at(position)->Fill(residualLocalY);
440 if (countPoints==1) countTracks++;
448 edm::LogError(
"MuonAlignment") <<
" Error!! Exception in propagator catched" << std::endl;
473 std::vector<int> positionDT;
474 std::vector<int> positionCSC;
490 int NumberOfDTSegment = 0;
492 for(segmentDT = all4DSegmentsDT->begin(); segmentDT != all4DSegmentsDT->end(); ++segmentDT) {
495 bool isNewChamber =
true;
498 for(std::vector<int>::iterator positionIt = positionDT.begin(); positionIt != positionDT.end(); positionIt++) {
501 if(NumberOfDTSegment == *positionIt) isNewChamber =
false;
505 for(std::vector<std::vector<int> >::iterator collect = indexCollectionDT->begin(); collect != indexCollectionDT->end(); ++collect) {
508 for(std::vector<int>::iterator positionIt = (*collect).begin(); positionIt != (*collect).end(); positionIt++) {
511 if(NumberOfDTSegment == *positionIt) isNewChamber =
false;
518 DTChamberId myChamber((*segmentDT).geographicalId().rawId());
520 if(myLayer.wheel() == myChamber.wheel() && myLayer.station() == myChamber.station() && myLayer.sector() == myChamber.sector()) {
523 positionDT.push_back(NumberOfDTSegment);
535 int NumberOfCSCSegment = 0;
537 for(segmentCSC = all4DSegmentsCSC->begin(); segmentCSC != all4DSegmentsCSC->end(); segmentCSC++) {
540 bool isNewChamber =
true;
543 for(std::vector<int>::iterator positionIt = positionCSC.begin(); positionIt != positionCSC.end(); positionIt++) {
546 if(NumberOfCSCSegment == *positionIt) isNewChamber =
false;
549 for(std::vector<std::vector<int> >::iterator collect = indexCollectionCSC->begin(); collect != indexCollectionCSC->end(); ++collect) {
552 for(std::vector<int>::iterator positionIt = (*collect).begin(); positionIt != (*collect).end(); positionIt++) {
555 if(NumberOfCSCSegment == *positionIt) isNewChamber =
false;
561 CSCDetId myChamber((*segmentCSC).geographicalId().rawId());
563 if(myLayer.chamberId() == myChamber.chamberId()) {
565 positionCSC.push_back(NumberOfCSCSegment);
569 NumberOfCSCSegment++;
574 indexCollectionDT->push_back(positionDT);
575 indexCollectionCSC->push_back(positionCSC);
579 std::reverse(my4DTrack.begin(),my4DTrack.end());
597 edm::LogInfo(
"MuonAlignment") <<
"Number of Hits considered for residuals: " <<
numberOfHits << std::endl << std::endl;
626 if (nameHistoLocalX.Contains(
"MB") )
630 sscanf(nameHistoLocalX,
"ResidualLocalX_W%dMB%1dS%d",&wheel,&station,§or);
632 Int_t nstation=station - 1;
633 Int_t nwheel=wheel+2;
638 Int_t ybin=1+nwheel*8+nstation*2;
640 snprintf(binLabel,
sizeof(binLabel),
"MB%d/%d_X",wheel, station );
649 if (nameHistoLocalX.Contains(
"ME"))
653 sscanf(nameHistoLocalX,
"ResidualLocalX_ME%dR%1dC%d",&station,&ring,&chamber);
658 Int_t ybin=
abs(station)*2+
ring;
660 if (station>0) ybin=ybin+10;
661 else ybin = 11 -ybin;
664 snprintf(binLabel,
sizeof(binLabel),
"ME%d/%d_X", station,ring );
673 if (nameHistoLocalTheta.Contains(
"MB"))
678 sscanf(nameHistoLocalTheta,
"ResidualLocalTheta_W%dMB%1dS%d",&wheel,&station,§or);
681 Int_t nstation=station - 1;
682 Int_t nwheel=wheel+2;
687 Int_t ybin=2+nwheel*8+nstation*2;
689 snprintf(binLabel,
sizeof(binLabel),
"MB%d/%d_#theta",wheel,station );
699 if (nameHistoLocalPhi.Contains(
"MB"))
704 sscanf(nameHistoLocalPhi,
"ResidualLocalPhi_W%dMB%1dS%d",&wheel,&station,§or);
706 Int_t nstation=station - 1;
707 Int_t nwheel=wheel+2;
712 Int_t ybin=1+nwheel*8+nstation*2;
714 snprintf(binLabel,
sizeof(binLabel),
"MB%d/%d_#phi", wheel,station );
723 if (nameHistoLocalPhi.Contains(
"ME"))
728 sscanf(nameHistoLocalPhi,
"ResidualLocalPhi_ME%dR%1dC%d",&station,&ring,&chamber);
733 Int_t ybin=
abs(station)*2+
ring;
735 if (station>0) ybin=ybin+10;
736 else ybin = 11 -ybin;
739 snprintf(binLabel,
sizeof(binLabel),
"ME%d/%d_#phi", station,ring );
748 if (nameHistoLocalTheta.Contains(
"ME"))
753 sscanf(nameHistoLocalTheta,
"ResidualLocalTheta_ME%dR%1dC%d",&station,&ring,&chamber);
758 Int_t ybin=
abs(station)*2+
ring;
760 if (station>0) ybin=ybin+10;
761 else ybin = 11 -ybin;
764 snprintf(binLabel,
sizeof(binLabel),
"ME%d/%d_#theta", station,ring );
774 if (nameHistoLocalY.Contains(
"MB"))
779 sscanf(nameHistoLocalY,
"ResidualLocalY_W%dMB%1dS%d",&wheel,&station,§or);
782 Int_t nstation=station - 1;
783 Int_t nwheel=wheel+2;
788 Int_t ybin=2+nwheel*8+nstation*2;
790 snprintf(binLabel,
sizeof(binLabel),
"MB%d/%d_Y", wheel,station );
800 if (nameHistoLocalY.Contains(
"ME"))
805 sscanf(nameHistoLocalY,
"ResidualLocalY_ME%dR%1dC%d",&station,&ring,&chamber);
810 Int_t ybin=
abs(station)*2+
ring;
812 if (station>0) ybin=ybin+10;
813 else ybin = 11 -ybin;
816 snprintf(binLabel,
sizeof(binLabel),
"ME%d/%d_Y", station,ring );
828 if(outputMEsInRootFile){
MonitorElement * hLocalPhiRmsDT
edm::EDGetTokenT< CSCSegmentCollection > theRecHits4DTagCSC
std::vector< MonitorElement * > unitsLocalX
MonitorElement * hLocalPositionRmsDT
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
virtual FreeTrajectoryState propagate(const FreeTrajectoryState &ftsStart, const GlobalPoint &pDest) const final
MonitorElement * hLocalThetaMeanCSC
MonitorElement * hLocalYMeanDT
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 * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
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
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
void analyze(const edm::Event &, const edm::EventSetup &)
Get the analysis.
edm::EDGetTokenT< reco::TrackCollection > theMuonCollectionLabel
void beginJob()
Inizialize parameters for histo binning.
const Plane & surface() const
The nominal surface of the GeomDet.
std::vector< TrackingRecHit * > RecHitVector
MuonAlignment(const edm::EventSetup &iSetup)
TrajectoryStateOnSurface innermostMeasurementState() const
MonitorElement * hLocalAngleRmsCSC
uint32_t rawId() const
get the raw id
edm::ParameterSet parameters
MonitorElement * hLocalAngleRmsDT
double resLocalXRangeStation2
FreeTrajectoryState const * freeState(bool withErrors=true) const
MonitorElement * hLocalAngleDT
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 * get(const std::string &path) const
get ME from full pathname (e.g. "my/long/dir/my_histo")
MonitorElement * hLocalYMeanCSC
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
std::vector< MonitorElement * > unitsLocalPhi
std::vector< std::vector< int > > intDVector
std::vector< MonitorElement * > unitsLocalY
MonitorElement * hLocalPhiMeanCSC
edm::EDGetTokenT< DTRecSegment4DCollection > theRecHits4DTagDT
T const * product() const
MonitorElement * hLocalAngleCSC
double resLocalYRangeStation3
MonitorElement * hLocalXRmsDT
unsigned int min1DTrackRecHitSize
void endJob(void)
Save the histos.
double resLocalYRangeStation4
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, const uint32_t lumi=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE", const bool resetMEsAfterWriting=false)
MonitorElement * hLocalPositionRmsCSC
static std::atomic< unsigned int > counter
static int position[264][3]
TrackingRecHitRef recHit(size_t i) const
Get i-th hit on the track.
DetId geographicalId() const
MonitorElement * hLocalXRmsCSC
int station() const
Return the station number.
unsigned int min4DTrackSegmentSize
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
virtual SubDetector subDetector() const
Which subdetector.
int wheel() const
Return the wheel number.
std::stringstream topFolder
MonitorElement * hLocalThetaMeanDT
MonitorElement * hLocalPositionDT
void setCurrentFolder(const std::string &fullpath)
double resLocalXRangeStation4
double resLocalXRangeStation3