Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:56:27

0001 /** \file ReadLaserRecHitAlgorithm.cc
0002  *  Algorithm to read RecHits from the LaserBeams
0003  *
0004  *  $Date: 2007/12/04 23:51:47 $
0005  *  $Revision: 1.3 $
0006  *  \author Maarten Thomas
0007  */
0008 
0009 #include "Alignment/LaserAlignment/test/ReadLaserRecHitAlgorithm.h"
0010 #include "FWCore/Framework/interface/ESHandle.h" 
0011 #include "FWCore/Framework/interface/EventSetup.h" 
0012 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" 
0013 #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h" 
0014 #include "DataFormats/GeometrySurface/interface/LocalError.h" 
0015 #include "DataFormats/GeometryVector/interface/LocalPoint.h" 
0016 #include "DataFormats/GeometryVector/interface/GlobalPoint.h" 
0017 #include "DataFormats/GeometryCommonDetAlgo/interface/GlobalError.h" 
0018 #include "DataFormats/GeometryCommonDetAlgo/interface/ErrorFrameTransformer.h" 
0019 
0020 ReadLaserRecHitAlgorithm::ReadLaserRecHitAlgorithm(const edm::ParameterSet& conf) : conf_(conf) {}
0021 
0022 ReadLaserRecHitAlgorithm::~ReadLaserRecHitAlgorithm() {}
0023 
0024 
0025 void ReadLaserRecHitAlgorithm::run(const SiStripRecHit2DCollection* input, const edm::EventSetup& theSetup)
0026 {
0027   // access the Tracker
0028   edm::ESHandle<TrackerGeometry> theTrackerGeometry;
0029   theSetup.get<TrackerDigiGeometryRecord>().get(theTrackerGeometry);
0030   const TrackerGeometry& theTracker(*theTrackerGeometry);
0031 
0032   for ( SiStripRecHit2DCollection::const_iterator detunit_iterator = input->begin(), detunit_end = input->end(); 
0033             detunit_iterator != detunit_end; ++detunit_iterator) 
0034   {
0035     SiStripRecHit2DCollection::DetSet rechitRange = *detunit_iterator;
0036     unsigned int id = detunit_iterator->detId();
0037 
0038     const StripGeomDetUnit* const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.idToDet(DetId(id)));
0039 
0040     if(id!=999999999){ //if is valid detector
0041       SiStripRecHit2DCollection::DetSet::const_iterator rechitRangeIteratorBegin = rechitRange.begin();
0042       SiStripRecHit2DCollection::DetSet::const_iterator rechitRangeIteratorEnd   = rechitRange.end();
0043       SiStripRecHit2DCollection::DetSet::const_iterator iter=rechitRangeIteratorBegin;
0044       for(iter=rechitRangeIteratorBegin;iter!=rechitRangeIteratorEnd;++iter){//loop on the rechit
0045       SiStripRecHit2D const rechit=*iter;
0046       LocalPoint position=rechit.localPosition();
0047       LocalError error=rechit.localPositionError();
0048       GlobalPoint gPosition = theStripDet->surface().toGlobal(position);
0049 
0050       ErrorFrameTransformer theErrorTransformer;
0051       GlobalError gError = theErrorTransformer.transform(error, theStripDet->surface());
0052 
0053 
0054       //GeomDet& det=rechit->det();
0055       //DetId id=rechit.geographicalId();
0056 //        std::vector<const SiStripCluster*> clust=rechit.cluster();
0057       std::cout << "local position:\t" << position.x() << "\t" << position.y() << "\t" << position.z() << "\t\t"
0058             << "global position:\t" << gPosition.x() << "\t" << gPosition.y() << "\t" << gPosition.z() << std::endl;
0059       std::cout << "local error:\t" << error.xx() << "\t" << error.xy() << "\t" <<error.yy() << "\t\t" 
0060             << "global error:\t" << gError.cxx() << "\t" << gError.cyy() << "\t" << gError.czz() << std::endl;
0061       //      std::cout<<"det id: "<<id.rawid<<std::endl;
0062       }
0063     }
0064   }
0065 }
0066 
0067 
0068 void ReadLaserRecHitAlgorithm::run(const SiStripMatchedRecHit2DCollection* input, const edm::EventSetup& theSetup)
0069 {
0070     // loop over detunits
0071   for ( SiStripMatchedRecHit2DCollection::const_iterator detunit_iterator = input->begin(), detunit_end = input->end(); 
0072             detunit_iterator != detunit_end; ++detunit_iterator) 
0073   {
0074     SiStripMatchedRecHit2DCollection::DetSet rechitRange = *detunit_iterator;
0075     unsigned int id = detunit_iterator->detId();
0076     if(id!=999999999){ //if is valid detector
0077       SiStripMatchedRecHit2DCollection::DetSet::const_iterator rechitRangeIteratorBegin = rechitRange.begin();
0078       SiStripMatchedRecHit2DCollection::DetSet::const_iterator rechitRangeIteratorEnd   = rechitRange.end();
0079       SiStripMatchedRecHit2DCollection::DetSet::const_iterator iter=rechitRangeIteratorBegin;
0080       for(iter=rechitRangeIteratorBegin;iter!=rechitRangeIteratorEnd;++iter){//loop on the rechit
0081       SiStripMatchedRecHit2D const rechit=*iter;
0082       LocalPoint position=rechit.localPosition();
0083       LocalError error=rechit.localPositionError();
0084       //GeomDet& det=rechit->det();
0085       //DetId id=rechit.geographicalId();
0086       //      std::vector<const SiStripCluster*> clust=rechit.cluster();
0087       std::cout<<"local position: "<<position.x()<<" "<<position.y()<<" "<<position.z()<<" "<<std::endl;
0088       std::cout<<"local error: "<<error.xx()<<" "<<error.xy()<<" "<<error.yy()<<" "<<std::endl;
0089       //      std::cout<<"det id: "<<id.rawid<<std::endl;
0090       }
0091     }
0092   }
0093 }
0094 
0095 
0096 
0097 
0098