67 edm::LogError(
"MuonAlignment") <<
" Error!! At least one Muon subsystem (DT or CSC) must be monitorized!!" << std::endl;
68 edm::LogError(
"MuonAlignment") <<
" Please enable doDT or doCSC to True in your python cfg file!!!" << std::endl;
77 hLocalPositionDT=
dbe->
book2D(
"hLocalPositionDT",
"Local DT position (cm) absolute MEAN residuals;Sector;;cm", 14,1, 15,40,0,40);
78 hLocalAngleDT=
dbe->
book2D(
"hLocalAngleDT",
"Local DT angle (rad) absolute MEAN residuals;Sector;;rad", 14,1, 15,40,0,40);
95 hLocalPositionCSC=
dbe->
book2D(
"hLocalPositionCSC",
"Local CSC position (cm) absolute MEAN residuals;Sector;;cm",36,1,37,40,0,40);
96 hLocalAngleCSC=
dbe->
book2D(
"hLocalAngleCSC",
"Local CSC angle (rad) absolute MEAN residuals;Sector;;rad", 36,1,37,40,0,40);
117 double rangeX=0,rangeY=0;
118 std::string nameOfHistoLocalX,nameOfHistoLocalY,nameOfHistoLocalPhi,nameOfHistoLocalTheta;
142 for(
int wheel=-2;wheel<3;wheel++){
144 for (
int sector=1;sector<15;sector++){
146 if(!((sector==13 || sector ==14) &&
station!=4)){
148 std::stringstream Wheel; Wheel<<wheel;
149 std::stringstream Station; Station<<
station;
150 std::stringstream Sector; Sector<<sector;
152 nameOfHistoLocalX=
"ResidualLocalX_W"+Wheel.str()+
"MB"+Station.str()+
"S"+Sector.str();
153 nameOfHistoLocalPhi=
"ResidualLocalPhi_W"+Wheel.str()+
"MB"+Station.str()+
"S"+Sector.str();
154 nameOfHistoLocalTheta=
"ResidualLocalTheta_W"+Wheel.str()+
"MB"+Station.str()+
"S"+Sector.str();
155 nameOfHistoLocalY=
"ResidualLocalY_W"+Wheel.str()+
"MB"+Station.str()+
"S"+Sector.str();
158 "/DT/Wheel"+Wheel.str()+
159 "/Station"+Station.str()+
160 "/Sector"+Sector.str());
183 for(
int chamber=1;chamber<37;chamber++){
188 std::stringstream Station; Station<<
station;
189 std::stringstream Chamber; Chamber<<chamber;
191 nameOfHistoLocalX=
"ResidualLocalX_ME"+Station.str()+
"R"+Ring.str()+
"C"+Chamber.str();
192 nameOfHistoLocalPhi=
"ResidualLocalPhi_ME"+Station.str()+
"R"+Ring.str()+
"C"+Chamber.str();
193 nameOfHistoLocalTheta=
"ResidualLocalTheta_ME"+Station.str()+
"R"+Ring.str()+
"C"+Chamber.str();
194 nameOfHistoLocalY=
"ResidualLocalY_ME"+Station.str()+
"R"+Ring.str()+
"C"+Chamber.str();
197 "/CSC/Station"+Station.str()+
199 "/Chamber"+Chamber.str());
263 reco::TrackCollection::const_iterator
muon;
264 for (muon = muons->begin(); muon != muons->end(); ++
muon){
289 if ( (outerPerpSA-innerPerpSA) > 0 ) {
293 thePropagator = thePropagatorAlo.
product();
300 thePropagator = thePropagatorOpp.
product();
305 RecHitVector my4DTrack = this->
doMatching(*muon, all4DSegmentsDT, all4DSegmentsCSC, &indexCollectionDT, &indexCollectionCSC, theTrackingGeometry);
320 for(RecHitVector::iterator rechit = my4DTrack.begin(); rechit != my4DTrack.end(); ++rechit) {
322 const GeomDet* geomDet = theTrackingGeometry->idToDet((*rechit)->geographicalId());
327 if(pDest != 0 || cDest != 0) {
335 const long rawId= (*rechit)->geographicalId().rawId();
340 int wheel=0,
station=0,sector=0;
342 bool goAhead = (det==1 &&
doDT) || (det==2 &&
doCSC);
344 double residualLocalX=0,residualLocalPhi=0,residualLocalY=0,residualLocalTheta=0;
348 if(det == 1 &&
doDT) {
350 wheel=myChamber.
wheel();
352 sector=myChamber.
sector();
354 residualLocalX = (*rechit)->localPosition().x() -destiny.
localPosition().
x();
357 residualLocalPhi = atan2(((
RecSegment *)(*rechit))->localDirection().
z(),
361 residualLocalY = (*rechit)->localPosition().y() - destiny.
localPosition().
y();
364 residualLocalTheta = atan2(((
RecSegment *)(*rechit))->localDirection().
z(),
370 else if (det==2 &&
doCSC){
372 endcap= myChamber.
endcap();
378 residualLocalX = (*rechit)->localPosition().x() -destiny.
localPosition().
x();
380 residualLocalY = (*rechit)->localPosition().y() - destiny.
localPosition().
y();
382 residualLocalPhi = atan2(((
RecSegment *)(*rechit))->localDirection().
y(),
385 residualLocalTheta = atan2(((
RecSegment *)(*rechit))->localDirection().
y(),
390 residualLocalX=0,residualLocalPhi=0,residualLocalY=0,residualLocalTheta=0;
396 std::string nameOfHistoLocalX;
400 std::stringstream Wheel; Wheel<<wheel;
401 std::stringstream Station; Station<<
station;
402 std::stringstream Sector; Sector<<sector;
404 nameOfHistoLocalX=
"ResidualLocalX_W"+Wheel.str()+
"MB"+Station.str()+
"S"+Sector.str();
407 else if(det==2 &&
doCSC){
409 std::stringstream Station; Station<<
station;
410 std::stringstream Chamber; Chamber<<chamber;
412 nameOfHistoLocalX=
"ResidualLocalX_ME"+Station.str()+
"R"+Ring.str()+
"C"+Chamber.str();
426 residualLocalPhi += 3.1416;
427 residualLocalTheta +=3.1416;
436 else if(det==2) {
unitsLocalY.at(position)->Fill(residualLocalY);
442 if (countPoints==1) countTracks++;
450 edm::LogError(
"MuonAlignment") <<
" Error!! Exception in propagator catched" << std::endl;
475 std::vector<int> positionDT;
476 std::vector<int> positionCSC;
480 for(
unsigned int counter = 0; counter != staTrack.
recHitsSize()-1; counter++) {
492 int NumberOfDTSegment = 0;
494 for(segmentDT = all4DSegmentsDT->begin(); segmentDT != all4DSegmentsDT->end(); ++segmentDT) {
497 bool isNewChamber =
true;
500 for(std::vector<int>::iterator positionIt = positionDT.begin(); positionIt != positionDT.end(); positionIt++) {
503 if(NumberOfDTSegment == *positionIt) isNewChamber =
false;
507 for(std::vector<std::vector<int> >::iterator collect = indexCollectionDT->begin(); collect != indexCollectionDT->end(); ++collect) {
510 for(std::vector<int>::iterator positionIt = (*collect).begin(); positionIt != (*collect).end(); positionIt++) {
513 if(NumberOfDTSegment == *positionIt) isNewChamber =
false;
520 DTChamberId myChamber((*segmentDT).geographicalId().rawId());
522 if(myLayer.wheel() == myChamber.wheel() && myLayer.station() == myChamber.station() && myLayer.sector() == myChamber.sector()) {
525 positionDT.push_back(NumberOfDTSegment);
537 int NumberOfCSCSegment = 0;
539 for(segmentCSC = all4DSegmentsCSC->begin(); segmentCSC != all4DSegmentsCSC->end(); segmentCSC++) {
542 bool isNewChamber =
true;
545 for(std::vector<int>::iterator positionIt = positionCSC.begin(); positionIt != positionCSC.end(); positionIt++) {
548 if(NumberOfCSCSegment == *positionIt) isNewChamber =
false;
551 for(std::vector<std::vector<int> >::iterator collect = indexCollectionCSC->begin(); collect != indexCollectionCSC->end(); ++collect) {
554 for(std::vector<int>::iterator positionIt = (*collect).begin(); positionIt != (*collect).end(); positionIt++) {
557 if(NumberOfCSCSegment == *positionIt) isNewChamber =
false;
563 CSCDetId myChamber((*segmentCSC).geographicalId().rawId());
565 if(myLayer.chamberId() == myChamber.chamberId()) {
567 positionCSC.push_back(NumberOfCSCSegment);
571 NumberOfCSCSegment++;
576 indexCollectionDT->push_back(positionDT);
577 indexCollectionCSC->push_back(positionCSC);
581 std::reverse(my4DTrack.begin(),my4DTrack.end());
599 edm::LogInfo(
"MuonAlignment") <<
"Number of Hits considered for residuals: " <<
numberOfHits << std::endl << std::endl;
628 if (nameHistoLocalX.Contains(
"MB") )
632 sscanf(nameHistoLocalX,
"ResidualLocalX_W%dMB%1dS%d",&wheel,&station,§or);
634 Int_t nstation=station - 1;
635 Int_t nwheel=wheel+2;
640 Int_t ybin=1+nwheel*8+nstation*2;
642 snprintf(binLabel,
sizeof(binLabel),
"MB%d/%d_X",wheel, station );
651 if (nameHistoLocalX.Contains(
"ME"))
655 sscanf(nameHistoLocalX,
"ResidualLocalX_ME%dR%1dC%d",&station,&ring,&chamber);
660 Int_t ybin=
abs(station)*2+
ring;
662 if (station>0) ybin=ybin+10;
663 else ybin = 11 -ybin;
666 snprintf(binLabel,
sizeof(binLabel),
"ME%d/%d_X", station,ring );
675 if (nameHistoLocalTheta.Contains(
"MB"))
680 sscanf(nameHistoLocalTheta,
"ResidualLocalTheta_W%dMB%1dS%d",&wheel,&station,§or);
683 Int_t nstation=station - 1;
684 Int_t nwheel=wheel+2;
689 Int_t ybin=2+nwheel*8+nstation*2;
691 snprintf(binLabel,
sizeof(binLabel),
"MB%d/%d_#theta",wheel,station );
701 if (nameHistoLocalPhi.Contains(
"MB"))
706 sscanf(nameHistoLocalPhi,
"ResidualLocalPhi_W%dMB%1dS%d",&wheel,&station,§or);
708 Int_t nstation=station - 1;
709 Int_t nwheel=wheel+2;
714 Int_t ybin=1+nwheel*8+nstation*2;
716 snprintf(binLabel,
sizeof(binLabel),
"MB%d/%d_#phi", wheel,station );
725 if (nameHistoLocalPhi.Contains(
"ME"))
730 sscanf(nameHistoLocalPhi,
"ResidualLocalPhi_ME%dR%1dC%d",&station,&ring,&chamber);
735 Int_t ybin=
abs(station)*2+
ring;
737 if (station>0) ybin=ybin+10;
738 else ybin = 11 -ybin;
741 snprintf(binLabel,
sizeof(binLabel),
"ME%d/%d_#phi", station,ring );
750 if (nameHistoLocalTheta.Contains(
"ME"))
755 sscanf(nameHistoLocalTheta,
"ResidualLocalTheta_ME%dR%1dC%d",&station,&ring,&chamber);
760 Int_t ybin=
abs(station)*2+
ring;
762 if (station>0) ybin=ybin+10;
763 else ybin = 11 -ybin;
766 snprintf(binLabel,
sizeof(binLabel),
"ME%d/%d_#theta", station,ring );
776 if (nameHistoLocalY.Contains(
"MB"))
781 sscanf(nameHistoLocalY,
"ResidualLocalY_W%dMB%1dS%d",&wheel,&station,§or);
784 Int_t nstation=station - 1;
785 Int_t nwheel=wheel+2;
790 Int_t ybin=2+nwheel*8+nstation*2;
792 snprintf(binLabel,
sizeof(binLabel),
"MB%d/%d_Y", wheel,station );
802 if (nameHistoLocalY.Contains(
"ME"))
807 sscanf(nameHistoLocalY,
"ResidualLocalY_ME%dR%1dC%d",&station,&ring,&chamber);
812 Int_t ybin=
abs(station)*2+
ring;
814 if (station>0) ybin=ybin+10;
815 else ybin = 11 -ybin;
818 snprintf(binLabel,
sizeof(binLabel),
"ME%d/%d_Y", station,ring );
830 if(outputMEsInRootFile){
MonitorElement * hLocalPhiRmsDT
std::vector< MonitorElement * > unitsLocalX
MonitorElement * hLocalPositionRmsDT
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
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
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
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
std::string trackRefitterType
MonitorElement * hLocalPhiMeanDT
virtual SubDetector subDetector() const =0
Which subdetector.
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.
void beginJob()
Inizialize parameters for histo binning.
std::vector< TrackingRecHit * > RecHitVector
MuonAlignment(const edm::EventSetup &iSetup)
TrajectoryStateOnSurface innermostMeasurementState() const
MonitorElement * hLocalAngleRmsCSC
uint32_t rawId() const
get the raw id
C::const_iterator const_iterator
constant access iterator type
edm::ParameterSet parameters
MonitorElement * hLocalAngleRmsDT
edm::InputTag theMuonCollectionLabel
FreeTrajectoryState * freeState(bool withErrors=true) const
double resLocalXRangeStation2
MonitorElement * hLocalAngleDT
MonitorElement * hLocalThetaRmsDT
std::vector< MonitorElement * > unitsLocalTheta
MonitorElement * hLocalYRmsDT
MonitorElement * hLocalThetaRmsCSC
std::string getName(Reflex::Type &cc)
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) ...
edm::InputTag theRecHits4DTagDT
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
std::vector< MonitorElement * > unitsLocalPhi
virtual TrajectoryStateOnSurface propagate(const FreeTrajectoryState &, const Surface &) const
std::vector< std::vector< int > > intDVector
std::vector< MonitorElement * > unitsLocalY
edm::InputTag theRecHits4DTagCSC
MonitorElement * hLocalPhiMeanCSC
T const * product() const
MonitorElement * hLocalAngleCSC
double resLocalYRangeStation3
MonitorElement * hLocalXRmsDT
unsigned int min1DTrackRecHitSize
void endJob(void)
Save the histos.
double resLocalYRangeStation4
const BoundPlane & surface() const
The nominal surface of the GeomDet.
MonitorElement * hLocalPositionRmsCSC
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.
T const * get() const
Returns C++ pointer to the item.
int wheel() const
Return the wheel number.
std::stringstream topFolder
MonitorElement * hLocalThetaMeanDT
MonitorElement * hLocalPositionDT
void setCurrentFolder(const std::string &fullpath)
double resLocalXRangeStation4
double resLocalXRangeStation3