Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:25:13

0001 // File: ReadRecHitAlgorithm.cc
0002 // Description:  Analyzer that reads rechits
0003 // Author:  C. Genta
0004 // Creation Date:  OGU Aug. 1, 2005
0005 
0006 #include <vector>
0007 #include <algorithm>
0008 #include <iostream>
0009 
0010 #include "RecoLocalTracker/SiStripRecHitConverter/test/ReadRecHitAlgorithm.h"
0011 #include "DataFormats/Common/interface/OwnVector.h"
0012 #include "DataFormats/TrackerRecHit2D/interface/ProjectedSiStripRecHit2D.h"
0013 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
0014 
0015 #include "DataFormats/GeometrySurface/interface/LocalError.h"
0016 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
0017 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0018 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0019 using namespace std;
0020 
0021 ReadRecHitAlgorithm::ReadRecHitAlgorithm(const edm::ParameterSet& conf) : conf_(conf) {}
0022 
0023 ReadRecHitAlgorithm::~ReadRecHitAlgorithm() {}
0024 
0025 void ReadRecHitAlgorithm::run(const SiStripRecHit2DCollection* input) {
0026   for (SiStripRecHit2DCollection::const_iterator detunit_iterator = input->begin(); detunit_iterator != input->end();
0027        ++detunit_iterator) {
0028     for (SiStripRecHit2DCollection::DetSet::const_iterator iter = detunit_iterator->begin(),
0029                                                            end = detunit_iterator->end();
0030          iter != end;
0031          ++iter) {  //loop on the rechit
0032       SiStripRecHit2D const& rechit = *iter;
0033       LocalPoint position = rechit.localPosition();
0034       LocalError error = rechit.localPositionError();
0035       //GeomDet& det=rechit->det();
0036       //DetId id=rechit.geographicalId();
0037       SiStripRecHit2D::ClusterRef clust = rechit.cluster();
0038       edm::LogInfo("ReadRecHit") << "local position: " << position.x() << " " << position.y() << " " << position.z()
0039                                  << "\n"
0040                                  << "local error: " << error.xx() << " " << error.xy() << " " << error.yy();
0041       if (clust.isNonnull()) {
0042         edm::LogInfo("ReadRecHit") << "barycenter= " << clust->barycenter();
0043       } else {
0044         edm::LogError("ReadRecHit") << "The cluster is empty!";
0045       }
0046       //      std::cout<<"det id: "<<id.rawid<<std::endl;
0047     }
0048   }
0049 }
0050 
0051 void ReadRecHitAlgorithm::run(const SiStripMatchedRecHit2DCollection* input) {
0052   for (SiStripMatchedRecHit2DCollection::const_iterator detunit_iterator = input->begin();
0053        detunit_iterator != input->end();
0054        ++detunit_iterator) {
0055     for (SiStripMatchedRecHit2DCollection::DetSet::const_iterator iter = detunit_iterator->begin(),
0056                                                                   end = detunit_iterator->end();
0057          iter != end;
0058          ++iter) {  //loop on the rechit
0059       SiStripMatchedRecHit2D const& rechit = *iter;
0060       LocalPoint position = rechit.localPosition();
0061       LocalError error = rechit.localPositionError();
0062       auto det = rechit.det();
0063       //DetId id=rechit.geographicalId();
0064       //      std::vector<const SiStripCluster*> clust=rechit.cluster();
0065       edm::LogInfo("ReadRecHit") << "local position: " << position.x() << " " << position.y() << " " << position.z()
0066                                  << "\n"
0067                                  << "local error: " << error.xx() << " " << error.xy() << " " << error.yy();
0068 
0069       auto m = iter->monoHit();
0070       auto s = iter->stereoHit();
0071       ProjectedSiStripRecHit2D projrechit(m.localPosition(), m.localPositionError(), *det, m);
0072       ProjectedSiStripRecHit2D projsrechit(s.localPosition(), s.localPositionError(), *det, s);
0073 
0074       edm::LogVerbatim("ReadRecHit") << "Checking shareinput\nALL:";
0075 
0076       edm::LogVerbatim("ReadRecHit") << "Matched with its mono ---------->";
0077       if (iter->sharesInput(&m, TrackingRecHit::all))
0078         edm::LogVerbatim("ReadRecHit") << "FAILED!";
0079       else
0080         edm::LogVerbatim("ReadRecHit") << "PASSED!";
0081 
0082       edm::LogVerbatim("ReadRecHit") << "Matched with its stereo ---------->";
0083       if (iter->sharesInput(&s, TrackingRecHit::all))
0084         edm::LogVerbatim("ReadRecHit") << "FAILED!";
0085       else
0086         edm::LogVerbatim("ReadRecHit") << "PASSED!";
0087 
0088       edm::LogVerbatim("ReadRecHit") << "Mono with its matched ---------->";
0089       if (m.sharesInput(&rechit, TrackingRecHit::all))
0090         edm::LogVerbatim("ReadRecHit") << "FAILED!";
0091       else
0092         edm::LogVerbatim("ReadRecHit") << "PASSED!";
0093 
0094       edm::LogVerbatim("ReadRecHit") << "Stereo with its matched ---------->";
0095       if (s.sharesInput(&rechit, TrackingRecHit::all))
0096         edm::LogVerbatim("ReadRecHit") << "FAILED!";
0097       else
0098         edm::LogVerbatim("ReadRecHit") << "PASSED!";
0099 
0100       edm::LogVerbatim("ReadRecHit") << "Mono with itsself ---------->";
0101       if (m.sharesInput(&m, TrackingRecHit::all))
0102         edm::LogVerbatim("ReadRecHit") << "PASSED!";
0103       else
0104         edm::LogVerbatim("ReadRecHit") << "FAILED!";
0105 
0106       edm::LogVerbatim("ReadRecHit") << "Stereo with itsself ---------->";
0107       if (s.sharesInput(&s, TrackingRecHit::all))
0108         edm::LogVerbatim("ReadRecHit") << "PASSED!";
0109       else
0110         edm::LogVerbatim("ReadRecHit") << "FAILED!";
0111 
0112       edm::LogVerbatim("ReadRecHit") << "Mono with stereo ---------->";
0113       if (m.sharesInput(&s, TrackingRecHit::all))
0114         edm::LogVerbatim("ReadRecHit") << "FAILED!";
0115       else
0116         edm::LogVerbatim("ReadRecHit") << "PASSED!";
0117 
0118       edm::LogVerbatim("ReadRecHit") << "Stereo with mono ---------->";
0119       if (s.sharesInput(&m, TrackingRecHit::all))
0120         edm::LogVerbatim("ReadRecHit") << "FAILED!";
0121       else
0122         edm::LogVerbatim("ReadRecHit") << "PASSED!";
0123 
0124       edm::LogVerbatim("ReadRecHit") << "Mono with projected mono---------->";
0125       if (m.sharesInput(&projrechit, TrackingRecHit::all))
0126         edm::LogVerbatim("ReadRecHit") << "PASSED!";
0127       else
0128         edm::LogVerbatim("ReadRecHit") << "FAILED!";
0129 
0130       edm::LogVerbatim("ReadRecHit") << "Stereo with projected mono ---------->";
0131       if (s.sharesInput(&projrechit, TrackingRecHit::all))
0132         edm::LogVerbatim("ReadRecHit") << "FAILED!";
0133       else
0134         edm::LogVerbatim("ReadRecHit") << "PASSED!";
0135 
0136       edm::LogVerbatim("ReadRecHit") << "Matched with projected mono ---------->";
0137       if (iter->sharesInput(&projrechit, TrackingRecHit::all))
0138         edm::LogVerbatim("ReadRecHit") << "FAILED!";
0139       else
0140         edm::LogVerbatim("ReadRecHit") << "PASSED!";
0141 
0142       edm::LogVerbatim("ReadRecHit") << "Projected mono with mono---------->";
0143       if (projrechit.sharesInput(&m, TrackingRecHit::all))
0144         edm::LogVerbatim("ReadRecHit") << "PASSED!";
0145       else
0146         edm::LogVerbatim("ReadRecHit") << "FAILED!";
0147 
0148       edm::LogVerbatim("ReadRecHit") << "Projected mono with stereo ---------->";
0149       if (projrechit.sharesInput(&s, TrackingRecHit::all))
0150         edm::LogVerbatim("ReadRecHit") << "FAILED!";
0151       else
0152         edm::LogVerbatim("ReadRecHit") << "PASSED!";
0153 
0154       edm::LogVerbatim("ReadRecHit") << "Projected mono with matched ---------->";
0155       if (projrechit.sharesInput(&rechit, TrackingRecHit::all))
0156         edm::LogVerbatim("ReadRecHit") << "FAILED!";
0157       else
0158         edm::LogVerbatim("ReadRecHit") << "PASSED!";
0159 
0160       edm::LogVerbatim("ReadRecHit") << "Projected mono with projected stereo ---------->";
0161       if (projrechit.sharesInput(&projsrechit, TrackingRecHit::all))
0162         edm::LogVerbatim("ReadRecHit") << "FAILED!";
0163       else
0164         edm::LogVerbatim("ReadRecHit") << "PASSED!";
0165 
0166       edm::LogVerbatim("ReadRecHit") << "Projected mono with itsself ---------->";
0167       if (projrechit.sharesInput(&projrechit, TrackingRecHit::all))
0168         edm::LogVerbatim("ReadRecHit") << "PASSED!";
0169       else
0170         edm::LogVerbatim("ReadRecHit") << "FAILED!";
0171 
0172       edm::LogVerbatim("ReadRecHit") << "Matched with itsself ---------->";
0173       if (rechit.sharesInput(&rechit, TrackingRecHit::all))
0174         edm::LogVerbatim("ReadRecHit") << "PASSED!";
0175       else
0176         edm::LogVerbatim("ReadRecHit") << "FAILED!";
0177 
0178       edm::LogVerbatim("ReadRecHit") << "Checking shareinput\nSOME:";
0179 
0180       edm::LogVerbatim("ReadRecHit") << "Matched with its mono ---------->";
0181       if (iter->sharesInput(&m, TrackingRecHit::some))
0182         edm::LogVerbatim("ReadRecHit") << "PASSED!";
0183       else
0184         edm::LogVerbatim("ReadRecHit") << "FAILED!";
0185 
0186       edm::LogVerbatim("ReadRecHit") << "Matched with its stereo ---------->";
0187       if (iter->sharesInput(&s, TrackingRecHit::some))
0188         edm::LogVerbatim("ReadRecHit") << "PASSED!";
0189       else
0190         edm::LogVerbatim("ReadRecHit") << "FAILED!";
0191 
0192       edm::LogVerbatim("ReadRecHit") << "Mono with its matched ---------->";
0193       if (m.sharesInput(&rechit, TrackingRecHit::some))
0194         edm::LogVerbatim("ReadRecHit") << "PASSED!";
0195       else
0196         edm::LogVerbatim("ReadRecHit") << "FAILED!";
0197 
0198       edm::LogVerbatim("ReadRecHit") << "Stereo with its matched ---------->";
0199       if (s.sharesInput(&rechit, TrackingRecHit::some))
0200         edm::LogVerbatim("ReadRecHit") << "PASSED!";
0201       else
0202         edm::LogVerbatim("ReadRecHit") << "FAILED!";
0203 
0204       edm::LogVerbatim("ReadRecHit") << "Mono with itsself ---------->";
0205       if (m.sharesInput(&m, TrackingRecHit::some))
0206         edm::LogVerbatim("ReadRecHit") << "PASSED!";
0207       else
0208         edm::LogVerbatim("ReadRecHit") << "FAILED!";
0209 
0210       edm::LogVerbatim("ReadRecHit") << "Stereo with itsself ---------->";
0211       if (s.sharesInput(&s, TrackingRecHit::some))
0212         edm::LogVerbatim("ReadRecHit") << "PASSED!";
0213       else
0214         edm::LogVerbatim("ReadRecHit") << "FAILED!";
0215 
0216       edm::LogVerbatim("ReadRecHit") << "Mono with stereo ---------->";
0217       if (m.sharesInput(&s, TrackingRecHit::some))
0218         edm::LogVerbatim("ReadRecHit") << "FAILED!";
0219       else
0220         edm::LogVerbatim("ReadRecHit") << "PASSED!";
0221 
0222       edm::LogVerbatim("ReadRecHit") << "Stereo with mono ---------->";
0223       if (s.sharesInput(&m, TrackingRecHit::some))
0224         edm::LogVerbatim("ReadRecHit") << "FAILED!";
0225       else
0226         edm::LogVerbatim("ReadRecHit") << "PASSED!";
0227 
0228       edm::LogVerbatim("ReadRecHit") << "Mono with projected mono---------->";
0229       if (m.sharesInput(&projrechit, TrackingRecHit::some))
0230         edm::LogVerbatim("ReadRecHit") << "PASSED!";
0231       else
0232         edm::LogVerbatim("ReadRecHit") << "FAILED!";
0233 
0234       edm::LogVerbatim("ReadRecHit") << "Stereo with projected mono ---------->";
0235       if (s.sharesInput(&projrechit, TrackingRecHit::some))
0236         edm::LogVerbatim("ReadRecHit") << "FAILED!";
0237       else
0238         edm::LogVerbatim("ReadRecHit") << "PASSED!";
0239 
0240       edm::LogVerbatim("ReadRecHit") << "Matched with projected mono ---------->";
0241       if (iter->sharesInput(&projrechit, TrackingRecHit::some))
0242         edm::LogVerbatim("ReadRecHit") << "PASSED!";
0243       else
0244         edm::LogVerbatim("ReadRecHit") << "FAILED!";
0245 
0246       edm::LogVerbatim("ReadRecHit") << "Projected mono with mono---------->";
0247       if (projrechit.sharesInput(&m, TrackingRecHit::some))
0248         edm::LogVerbatim("ReadRecHit") << "PASSED!";
0249       else
0250         edm::LogVerbatim("ReadRecHit") << "FAILED!";
0251 
0252       edm::LogVerbatim("ReadRecHit") << "Projected mono with stereo ---------->";
0253       if (projrechit.sharesInput(&s, TrackingRecHit::some))
0254         edm::LogVerbatim("ReadRecHit") << "FAILED!";
0255       else
0256         edm::LogVerbatim("ReadRecHit") << "PASSED!";
0257 
0258       edm::LogVerbatim("ReadRecHit") << "Projected mono with matched ---------->";
0259       if (projrechit.sharesInput(&rechit, TrackingRecHit::some))
0260         edm::LogVerbatim("ReadRecHit") << "PASSED!";
0261       else
0262         edm::LogVerbatim("ReadRecHit") << "FAILED!";
0263 
0264       edm::LogVerbatim("ReadRecHit") << "Projected mono with projected stereo ---------->";
0265       if (projrechit.sharesInput(&projsrechit, TrackingRecHit::some))
0266         edm::LogVerbatim("ReadRecHit") << "FAILED!";
0267       else
0268         edm::LogVerbatim("ReadRecHit") << "PASSED!";
0269 
0270       edm::LogVerbatim("ReadRecHit") << "Projected mono with itsself ---------->";
0271       if (projrechit.sharesInput(&projrechit, TrackingRecHit::some))
0272         edm::LogVerbatim("ReadRecHit") << "PASSED!";
0273       else
0274         edm::LogVerbatim("ReadRecHit") << "FAILED!";
0275 
0276       edm::LogVerbatim("ReadRecHit") << "Matched with itsself ---------->";
0277       if (rechit.sharesInput(&rechit, TrackingRecHit::some))
0278         edm::LogVerbatim("ReadRecHit") << "PASSED!";
0279       else
0280         edm::LogVerbatim("ReadRecHit") << "FAILED!";
0281     }
0282   }
0283 }