CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
FastTSGFromL2Muon Class Reference

#include <FastTSGFromL2Muon.h>

Inheritance diagram for FastTSGFromL2Muon:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual void beginRun (edm::Run const &run, edm::EventSetup const &es) override
 
 FastTSGFromL2Muon (const edm::ParameterSet &cfg)
 
virtual void produce (edm::Event &ev, const edm::EventSetup &es) override
 
virtual ~FastTSGFromL2Muon ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

bool clean (reco::TrackRef muRef, RectangularEtaPhiTrackingRegion *region, const BasicTrajectorySeed *aSeed, const SimTrack &theSimTrack)
 

Private Attributes

edm::ParameterSet theConfig
 
edm::InputTag theL2CollectionLabel
 
double thePtCut
 
MuonTrackingRegionBuildertheRegionBuilder
 
std::vector< edm::InputTagtheSeedCollectionLabels
 
MuonServiceProxytheService
 
edm::InputTag theSimTrackCollectionLabel
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 23 of file FastTSGFromL2Muon.h.

Constructor & Destructor Documentation

FastTSGFromL2Muon::FastTSGFromL2Muon ( const edm::ParameterSet cfg)

Definition at line 21 of file FastTSGFromL2Muon.cc.

References edm::ParameterSet::getParameter(), MuonServiceProxy_cff::MuonServiceProxy, theL2CollectionLabel, thePtCut, theSeedCollectionLabels, theService, and theSimTrackCollectionLabel.

21  : theConfig(cfg)
22 {
23  produces<L3MuonTrajectorySeedCollection>();
24 
25  edm::ParameterSet serviceParameters =
26  cfg.getParameter<edm::ParameterSet>("ServiceParameters");
27  theService = new MuonServiceProxy(serviceParameters);
28 
29  thePtCut = cfg.getParameter<double>("PtCut");
30 
31  theL2CollectionLabel = cfg.getParameter<edm::InputTag>("MuonCollectionLabel");
32  theSeedCollectionLabels = cfg.getParameter<std::vector<edm::InputTag> >("SeedCollectionLabels");
33  theSimTrackCollectionLabel = cfg.getParameter<edm::InputTag>("SimTrackCollectionLabel");
34  // useTFileService_ = cfg.getUntrackedParameter<bool>("UseTFileService",false);
35 
36 }
T getParameter(std::string const &) const
MuonServiceProxy * theService
std::vector< edm::InputTag > theSeedCollectionLabels
edm::InputTag theSimTrackCollectionLabel
edm::ParameterSet theConfig
edm::InputTag theL2CollectionLabel
FastTSGFromL2Muon::~FastTSGFromL2Muon ( )
virtual

Definition at line 38 of file FastTSGFromL2Muon.cc.

39 {
40 }

Member Function Documentation

void FastTSGFromL2Muon::beginRun ( edm::Run const &  run,
edm::EventSetup const &  es 
)
overridevirtual

Reimplemented from edm::EDProducer.

Definition at line 43 of file FastTSGFromL2Muon.cc.

References edm::ParameterSet::getParameter(), theConfig, theRegionBuilder, theService, and MuonServiceProxy::update().

44 {
45  //update muon proxy service
46  theService->update(es);
47 
48  //region builder
49  edm::ParameterSet regionBuilderPSet =
50  theConfig.getParameter<edm::ParameterSet>("MuonTrackingRegionBuilder");
51  theRegionBuilder = new MuonTrackingRegionBuilder(regionBuilderPSet,theService);
52 
53  /*
54  if(useTFileService_) {
55  edm::Service<TFileService> fs;
56  h_nSeedPerTrack = fs->make<TH1F>("nSeedPerTrack","nSeedPerTrack",76,-0.5,75.5);
57  h_nGoodSeedPerTrack = fs->make<TH1F>("nGoodSeedPerTrack","nGoodSeedPerTrack",75,-0.5,75.5);
58  h_nGoodSeedPerEvent = fs->make<TH1F>("nGoodSeedPerEvent","nGoodSeedPerEvent",75,-0.5,75.5);
59  } else {
60  h_nSeedPerTrack = 0;
61  h_nGoodSeedPerEvent = 0;
62  h_nGoodSeedPerTrack = 0;
63  }
64  */
65 
66 }
void update(const edm::EventSetup &setup)
update the services each event
T getParameter(std::string const &) const
MuonServiceProxy * theService
MuonTrackingRegionBuilder * theRegionBuilder
edm::ParameterSet theConfig
bool FastTSGFromL2Muon::clean ( reco::TrackRef  muRef,
RectangularEtaPhiTrackingRegion region,
const BasicTrajectorySeed aSeed,
const SimTrack theSimTrack 
)
private

Definition at line 180 of file FastTSGFromL2Muon.cc.

References SiPixelRawToDigiRegional_cfi::deltaPhi, MuonErrorMatrixValues_cff::etaRange, PixelRecoRange< T >::max(), PixelRecoRange< T >::mean(), CoreSimTrack::momentum(), PtMinSelector_cfg::ptMin, TkTrackingRegionsMargin< T >::right(), and mathSSE::sqrt().

Referenced by produce().

183  {
184 
185  // Eta cleaner
186  const PixelRecoRange<float>& etaRange = region->etaRange() ;
187  double etaSeed = theSimTrack.momentum().Eta();
188  double etaLimit = (fabs(fabs(etaRange.max())-fabs(etaRange.mean())) <0.05) ?
189  0.05 : fabs(fabs(etaRange.max()) - fabs(etaRange.mean())) ;
190  bool inEtaRange =
191  etaSeed >= (etaRange.mean() - etaLimit) &&
192  etaSeed <= (etaRange.mean() + etaLimit) ;
193  if ( !inEtaRange ) return false;
194 
195  // Phi cleaner
196  const TkTrackingRegionsMargin<float>& phiMargin = region->phiMargin();
197  double phiSeed = theSimTrack.momentum().Phi();
198  double phiLimit = (phiMargin.right() < 0.05 ) ? 0.05 : phiMargin.right();
199  bool inPhiRange =
200  (fabs(deltaPhi(phiSeed,double(region->direction().phi()))) < phiLimit );
201  if ( !inPhiRange ) return false;
202 
203  // pt cleaner
204  double ptSeed = std::sqrt(theSimTrack.momentum().Perp2());
205  double ptMin = (region->ptMin()>3.5) ? 3.5: region->ptMin();
206  bool inPtRange = ptSeed >= ptMin && ptSeed<= 2*(muRef->pt());
207  return inPtRange;
208 
209 }
T max() const
T sqrt(T t)
Definition: SSEVec.h:48
T mean() const
const math::XYZTLorentzVectorD & momentum() const
particle info...
Definition: CoreSimTrack.h:36
void FastTSGFromL2Muon::produce ( edm::Event ev,
const edm::EventSetup es 
)
overridevirtual

Implements edm::EDProducer.

Definition at line 70 of file FastTSGFromL2Muon.cc.

References clean(), edm::Event::getByLabel(), iseed, edm::Event::put(), TrajectorySeed::recHits(), MuonTrackingRegionBuilder::region(), query::result, MuonTrackingRegionBuilder::setEvent(), SiTrackerGSMatchedRecHit2D::simtrackId(), theL2CollectionLabel, thePtCut, theRegionBuilder, theSeedCollectionLabels, theService, theSimTrackCollectionLabel, and MuonServiceProxy::update().

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

71 {
72 
73  // Initialize the output product
74  std::auto_ptr<L3MuonTrajectorySeedCollection> result(new L3MuonTrajectorySeedCollection());
75 
76  //intialize service
77  theService->update(es);
78 
79  // Region builder
81 
82  // Retrieve the Monte Carlo truth (SimTracks)
84  ev.getByLabel(theSimTrackCollectionLabel,theSimTracks);
85 
86  // Retrieve L2 muon collection
88  ev.getByLabel(theL2CollectionLabel ,l2muonH);
89 
90  // Retrieve Seed collection
91  unsigned seedCollections = theSeedCollectionLabels.size();
92  std::vector<edm::Handle<edm::View<TrajectorySeed> > > theSeeds;
93  theSeeds.resize(seedCollections);
94  unsigned seed_size = 0;
95  for ( unsigned iseed=0; iseed<seedCollections; ++iseed ) {
96  ev.getByLabel(theSeedCollectionLabels[iseed], theSeeds[iseed]);
97  seed_size += theSeeds[iseed]->size();
98  }
99 
100  // Loop on L2 muons
101  unsigned int imu=0;
102  unsigned int imuMax=l2muonH->size();
103  // std::cout << "Found " << imuMax << " L2 muons" << std::endl;
104  for (;imu!=imuMax;++imu){
105 
106  // Make a ref to l2 muon
107  reco::TrackRef muRef(l2muonH, imu);
108 
109  // Cut on muons with low momenta
110  if ( muRef->pt() < thePtCut
111  || muRef->innerMomentum().Rho() < thePtCut
112  || muRef->innerMomentum().R() < 2.5 ) continue;
113 
114  // Define the region of interest
116 
117  // Copy the collection of seeds (ahem, this is time consuming!)
118  std::vector<TrajectorySeed> tkSeeds;
119  std::set<unsigned> tkIds;
120  tkSeeds.reserve(seed_size);
121  for ( unsigned iseed=0; iseed<seedCollections; ++iseed ) {
122  edm::Handle<edm::View<TrajectorySeed> > aSeedCollection = theSeeds[iseed];
123  unsigned nSeeds = aSeedCollection->size();
124  for (unsigned seednr = 0; seednr < nSeeds; ++seednr) {
125 
126  // The seed
127  const BasicTrajectorySeed* aSeed = &((*aSeedCollection)[seednr]);
128 
129  // Find the first hit of the Seed
130  TrajectorySeed::range theSeedingRecHitRange = aSeed->recHits();
131  const SiTrackerGSMatchedRecHit2D * theFirstSeedingRecHit =
132  (const SiTrackerGSMatchedRecHit2D*) (&(*(theSeedingRecHitRange.first)));
133 
134  // The SimTrack id associated to that recHit
135  int simTrackId = theFirstSeedingRecHit->simtrackId();
136 
137  // Track already associated to a seed
138  std::set<unsigned>::iterator tkId = tkIds.find(simTrackId);
139  if( tkId != tkIds.end() ) continue;
140 
141  const SimTrack& theSimTrack = (*theSimTracks)[simTrackId];
142 
143  if ( clean(muRef,region,aSeed,theSimTrack) ) tkSeeds.push_back(*aSeed);
144  tkIds.insert(simTrackId);
145 
146  } // End loop on seeds
147 
148  } // End loop on seed collections
149 
150  // Free memory
151  delete region;
152 
153  // A plot
154  // if(h_nSeedPerTrack) h_nSeedPerTrack->Fill(tkSeeds.size());
155 
156  // Another plot
157  // if(h_nGoodSeedPerTrack) h_nGoodSeedPerTrack->Fill(tkSeeds.size());
158 
159 
160  // Now create the Muon Trajectory Seed
161  unsigned int is=0;
162  unsigned int isMax=tkSeeds.size();
163  for (;is!=isMax;++is){
164  result->push_back( L3MuonTrajectorySeed(tkSeeds[is], muRef));
165  } // End of tk seed loop
166 
167  } // End of l2 muon loop
168 
169  // std::cout << "Found " << result->size() << " seeds for muons" << std::endl;
170 
171  // And yet another plot
172  // if(h_nGoodSeedPerEvent) h_nGoodSeedPerEvent->Fill(result->size());
173 
174  //put in the event
175  ev.put(result);
176 
177 }
void update(const edm::EventSetup &setup)
update the services each event
RectangularEtaPhiTrackingRegion * region(const reco::TrackRef &) const
define tracking region
MuonServiceProxy * theService
std::vector< edm::InputTag > theSeedCollectionLabels
virtual void setEvent(const edm::Event &)
pass the Event to the algo at each event
std::vector< L3MuonTrajectorySeed > L3MuonTrajectorySeedCollection
edm::InputTag theSimTrackCollectionLabel
MuonTrackingRegionBuilder * theRegionBuilder
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
tuple result
Definition: query.py:137
bool clean(reco::TrackRef muRef, RectangularEtaPhiTrackingRegion *region, const BasicTrajectorySeed *aSeed, const SimTrack &theSimTrack)
std::pair< const_iterator, const_iterator > range
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
int iseed
Definition: AMPTWrapper.h:124
range recHits() const
edm::InputTag theL2CollectionLabel

Member Data Documentation

edm::ParameterSet FastTSGFromL2Muon::theConfig
private

Definition at line 41 of file FastTSGFromL2Muon.h.

Referenced by beginRun().

edm::InputTag FastTSGFromL2Muon::theL2CollectionLabel
private

Definition at line 43 of file FastTSGFromL2Muon.h.

Referenced by FastTSGFromL2Muon(), and produce().

double FastTSGFromL2Muon::thePtCut
private

Definition at line 49 of file FastTSGFromL2Muon.h.

Referenced by FastTSGFromL2Muon(), and produce().

MuonTrackingRegionBuilder* FastTSGFromL2Muon::theRegionBuilder
private

Definition at line 50 of file FastTSGFromL2Muon.h.

Referenced by beginRun(), and produce().

std::vector<edm::InputTag> FastTSGFromL2Muon::theSeedCollectionLabels
private

Definition at line 44 of file FastTSGFromL2Muon.h.

Referenced by FastTSGFromL2Muon(), and produce().

MuonServiceProxy* FastTSGFromL2Muon::theService
private

Definition at line 48 of file FastTSGFromL2Muon.h.

Referenced by beginRun(), FastTSGFromL2Muon(), and produce().

edm::InputTag FastTSGFromL2Muon::theSimTrackCollectionLabel
private

Definition at line 42 of file FastTSGFromL2Muon.h.

Referenced by FastTSGFromL2Muon(), and produce().