TransientTrackingRecHIts Usage

Complete: 5

Goal of the page

This page is intended to provide an example of how to build and use TransientTrackingRecHits.

What is a TransientTrackingRecHit

TransientTrackingRecHits are a transient, non-persistent version of TrackingRecHits. TrackingRecHits contain information which are not dependent on detector conditions: the global position, for example, depends on detector alignment, thus it is not a fixed value and is not saved on disk. TransientTrackingRecHits are created at runtime by the TransientTrackingRecHitBuilder and allow the access to information that may change during runs (e.g. geometry, magnetic field).

Instructions

Tip, idea The following example makes use of the TrackRefitter. If you are not familiar with it, please have a look at this twiki.

Set your runtime environment (shown for release %WBRELEASENEW%):
cd CMSSW_%WBRELEASENEW%/src
cmsenv

Create the development area for the analyzer:

mkdir Test
cd Test
mkedanlzr -track TTRHDemo
cd TTRHDemo

In this directory edit the BuildFile as follows:

<use name=FWCore/Framework>
<use name=FWCore/PluginManager>
<use name=FWCore/ParameterSet>
<use name=DataFormats/TrackReco>
<use name=TrackingTools/Records>
<use name=RecoTracker/TransientTrackingRecHit>
<flags EDM_PLUGIN=1>
<export>
   <lib name=TestTTRHDemoTTRHDemo>
   <use name=FWCore/Framework>
   <use name=FWCore/PluginManager>
   <use name=FWCore/ParameterSet>
   <use name=DataFormats/TrackReco>
   <use name=TrackingTools/Records>
   <use name=RecoTracker/TransientTrackingRecHit>
</export>

In the src directory edit TTRHDemo.cc:

#include <memory>
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/TrackReco/interface/TrackFwd.h"
#include "TrackingTools/Records/interface/TransientRecHitRecord.h"
#include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHitBuilder.h"
class TTRHDemo : public edm::EDAnalyzer {
public:
  explicit TTRHDemo(const edm::ParameterSet&);
  ~TTRHDemo();
private:
  virtual void beginJob(const edm::EventSetup&) ;
  virtual void analyze(const edm::Event&, const edm::EventSetup&);
  virtual void endJob() ;
  std::string theTrackerRecHitBuilderName;
};
TTRHDemo::TTRHDemo(const edm::ParameterSet& iConfig):
  theTrackerRecHitBuilderName(iConfig.getParameter<std::string>("TrackerRecHitBuilder")) { }
TTRHDemo::~TTRHDemo() { }
void TTRHDemo::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
  using namespace edm;
  using namespace reco;
  using namespace std;
  Handle<TrackCollection> tracks;
  iEvent.getByLabel("TrackRefitter", tracks);
  ESHandle<TransientTrackingRecHitBuilder> theTrackerRecHitBuilder;
  iSetup.get<TransientRecHitRecord>().get(theTrackerRecHitBuilderName,theTrackerRecHitBuilder);
  for(TrackCollection::const_iterator itTrack = tracks->begin(); itTrack != tracks->end(); ++itTrack) {
    const reco::HitPattern& p = itTrack->hitPattern();
    for (int i=0; i<p.numberOfHits(); i++) {
      TrackingRecHitRef rhit = itTrack->recHit(i);
      if (rhit->isValid()) {
   TransientTrackingRecHit::RecHitPointer tthit = theTrackerRecHitBuilder->build(&*rhit);
   GlobalPoint gPosition =  tthit->globalPosition();
   cout << "valid hit found with global position = "<< gPosition << endl;
      }
    }
  }
}
void TTRHDemo::beginJob(const edm::EventSetup&) { }     
void TTRHDemo::endJob() { }
DEFINE_FWK_MODULE(TTRHDemo);

Then, create a python configuration file, called ttrhdemo_cfg.py. Please take the correct Global Tag from SWGuideFrontierConditions and choose an input file from DBS Data Discovery page:

import FWCore.ParameterSet.Config as cms
process = cms.Process("Demo")
process.load("FWCore.MessageLogger.MessageLogger_cfi")
process.load("Configuration.StandardSequences.MagneticField_cff")
process.load("Configuration.StandardSequences.Services_cff")
process.load("Configuration.StandardSequences.Geometry_cff")
process.load("TrackingTools.TransientTrack.TransientTrackBuilder_cfi")
process.load("RecoTracker.TrackProducer.TrackRefitters_cff") 
process.load("Configuration.StandardSequences.FrontierConditions_CMS.GlobalTag_cff")
process.GlobalTag.globaltag = "myGlobalTag::All"
process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(10) )
process.source = cms.Source("PoolSource",fileNames = cms.untracked.vstring(
        'myInputFile.root')
)
process.demo = cms.EDAnalyzer("TTRHDemo",TrackerRecHitBuilder = cms.string('WithAngleAndTemplate'))
process.p = cms.Path(process.TrackRefitter*process.demo) 

Now, compile and run the analyzer:

scramv1 b
cmsRun ttrhdemo_cfg.py
The global position of the hits will be printed on the screen.

-- GiuseppeCerati - 10-Nov-2009

Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r4 - 2010-02-04 - GiuseppeCerati
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    CMSPublic All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback