Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /** \file RecoAnalyzerTC.cc
0002  *  function to get some information about the TrackCandidates
0003  *
0004  *  $Date: 2007/05/14 07:39:33 $
0005  *  $Revision: 1.3 $
0006  *  \author Maarten Thomas
0007  */
0008 
0009 #include "Alignment/LaserAlignment/test/RecoAnalyzer.h"
0010 #include "FWCore/Framework/interface/Event.h" 
0011 #include "FWCore/Framework/interface/ESHandle.h" 
0012 #include "FWCore/Framework/interface/EventSetup.h" 
0013 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" 
0014 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" 
0015 #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h" 
0016 #include "DataFormats/GeometryVector/interface/GlobalPoint.h" 
0017 #include "DataFormats/DetId/interface/DetId.h" 
0018 #include "DataFormats/TrackCandidate/interface/TrackCandidateCollection.h" 
0019 #include "DataFormats/TrackCandidate/interface/TrackCandidate.h" 
0020 #include "DataFormats/TrackReco/interface/Track.h" 
0021 #include "DataFormats/TrackReco/interface/TrackFwd.h" 
0022 
0023 void RecoAnalyzer::trackerTC(edm::Event const& theEvent, edm::EventSetup const& theSetup)
0024 {
0025   // label of the source
0026   std::string src = "ckfTrackCandidates";
0027   std::string srcTracks = "ctfWithMaterialTracks";
0028   
0029   // access the tracker
0030   edm::ESHandle<TrackerGeometry> theTrackerGeometry;
0031   theSetup.get<TrackerDigiGeometryRecord>().get(theTrackerGeometry);
0032   const TrackerGeometry& theTracker(*theTrackerGeometry);
0033 
0034   // get the TrackCandidate Collection
0035   edm::Handle<TrackCandidateCollection> theTCCollection;
0036   theEvent.getByLabel(src, theTCCollection );
0037   // get the Track Collection
0038   edm::Handle<reco::TrackCollection> theTrackCollection;
0039   theEvent.getByLabel(srcTracks, theTrackCollection);
0040   
0041   int numberOfTC = 0;
0042 
0043   for (TrackCandidateCollection::const_iterator i=theTCCollection->begin(); i!=theTCCollection->end();i++)
0044   {
0045     const TrackCandidate * theTC = &(*i);
0046     const TrackCandidate::range& recHitVec=theTC->recHits();
0047 
0048     std::cout << " ******* hits of TrackCandidate " << numberOfTC << " *******" << std::endl;
0049       // loop over the RecHits
0050     for (edm::OwnVector<TrackingRecHit>::const_iterator j=recHitVec.first; j!=recHitVec.second; j++)
0051     {    
0052       if ( (*j).isValid() )
0053       {
0054         GlobalPoint HitPosition = theTracker.idToDet((*j).geographicalId())->surface().toGlobal((*j).localPosition());
0055 
0056         std::cout << " HitPosition (x, y, z, R, phi) = " << HitPosition.x() << " " << HitPosition.y() << " " << HitPosition.z() << " " 
0057           << HitPosition.perp() << " " << HitPosition.phi() << std::endl;
0058       }
0059     }
0060     numberOfTC++;
0061   }
0062 
0063   int nTracks = 0;
0064   std::cout << " Number of Tracks in this event: " << theTrackCollection->size() << std::endl;
0065   for(auto const& track : *theTrackCollection)
0066   {
0067     nTracks++;
0068     std::cout << " Hits in Track " << nTracks << ": " << std::endl;
0069     for(auto const& hit : track->recHits())
0070     {
0071         if ( hit->isValid() )
0072         {
0073           GlobalPoint HitPosition = theTracker.idToDet(hit->geographicalId())->surface().toGlobal(hit->localPosition());
0074 
0075           std::cout << "   HitPosition in Track (x, y, z, R, phi) = " << HitPosition.x() << " " << HitPosition.y() << " " << HitPosition.z() << " " 
0076             << HitPosition.perp() << " " << HitPosition.phi() << std::endl;
0077         }
0078     }
0079   }
0080 
0081 }