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::stream::EDProducer<> edm::stream::EDProducerBase 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::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- 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
std::vector< ConsumesInfoconsumesInfo () const
 
 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
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) 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::stream::EDProducer<>
typedef CacheContexts< T...> CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T...> HasAbility
 
typedef
CacheTypes::LuminosityBlockCache 
LuminosityBlockCache
 
typedef
LuminosityBlockContextT
< LuminosityBlockCache,
RunCache, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
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::stream::EDProducerBase.

Definition at line 43 of file FastTSGFromL2Muon.cc.

References edm::EDConsumerBase::consumesCollector(), edm::ParameterSet::getParameter(), HLT_25ns14e33_v1_cff::MuonTrackingRegionBuilder, 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");
52  theRegionBuilder = new MuonTrackingRegionBuilder(regionBuilderPSet,theService,iC);
53 
54  /*
55  if(useTFileService_) {
56  edm::Service<TFileService> fs;
57  h_nSeedPerTrack = fs->make<TH1F>("nSeedPerTrack","nSeedPerTrack",76,-0.5,75.5);
58  h_nGoodSeedPerTrack = fs->make<TH1F>("nGoodSeedPerTrack","nGoodSeedPerTrack",75,-0.5,75.5);
59  h_nGoodSeedPerEvent = fs->make<TH1F>("nGoodSeedPerEvent","nGoodSeedPerEvent",75,-0.5,75.5);
60  } else {
61  h_nSeedPerTrack = 0;
62  h_nGoodSeedPerEvent = 0;
63  h_nGoodSeedPerTrack = 0;
64  }
65  */
66 
67 }
void update(const edm::EventSetup &setup)
update the services each event
T getParameter(std::string const &) const
MuonServiceProxy * theService
MuonTrackingRegionBuilder * theRegionBuilder
edm::ParameterSet theConfig
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
bool FastTSGFromL2Muon::clean ( reco::TrackRef  muRef,
RectangularEtaPhiTrackingRegion region,
const BasicTrajectorySeed aSeed,
const SimTrack theSimTrack 
)
private

Definition at line 181 of file FastTSGFromL2Muon.cc.

References SiPixelRawToDigiRegional_cfi::deltaPhi, TrackingRegion::direction(), MuonErrorMatrixValues_cff::etaRange, RectangularEtaPhiTrackingRegion::etaRange(), PixelRecoRange< T >::max(), PixelRecoRange< T >::mean(), CoreSimTrack::momentum(), PV3DBase< T, PVType, FrameType >::phi(), RectangularEtaPhiTrackingRegion::phiMargin(), PtMinSelector_cfg::ptMin, TrackingRegion::ptMin(), TkTrackingRegionsMargin< T >::right(), and mathSSE::sqrt().

Referenced by produce().

184  {
185 
186  // Eta cleaner
187  const PixelRecoRange<float>& etaRange = region->etaRange() ;
188  double etaSeed = theSimTrack.momentum().Eta();
189  double etaLimit = (fabs(fabs(etaRange.max())-fabs(etaRange.mean())) <0.05) ?
190  0.05 : fabs(fabs(etaRange.max()) - fabs(etaRange.mean())) ;
191  bool inEtaRange =
192  etaSeed >= (etaRange.mean() - etaLimit) &&
193  etaSeed <= (etaRange.mean() + etaLimit) ;
194  if ( !inEtaRange ) return false;
195 
196  // Phi cleaner
197  const TkTrackingRegionsMargin<float>& phiMargin = region->phiMargin();
198  double phiSeed = theSimTrack.momentum().Phi();
199  double phiLimit = (phiMargin.right() < 0.05 ) ? 0.05 : phiMargin.right();
200  bool inPhiRange =
201  (fabs(deltaPhi(phiSeed,double(region->direction().phi()))) < phiLimit );
202  if ( !inPhiRange ) return false;
203 
204  // pt cleaner
205  double ptSeed = std::sqrt(theSimTrack.momentum().Perp2());
206  double ptMin = (region->ptMin()>3.5) ? 3.5: region->ptMin();
207  bool inPtRange = ptSeed >= ptMin && ptSeed<= 2*(muRef->pt());
208  return inPtRange;
209 
210 }
T max() const
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
GlobalVector const & direction() const
the direction around which region is constructed
T sqrt(T t)
Definition: SSEVec.h:48
T mean() const
float ptMin() const
minimal pt of interest
const math::XYZTLorentzVectorD & momentum() const
Definition: CoreSimTrack.h:22
const Range & etaRange() const
allowed eta range [eta_min, eta_max] interval
void FastTSGFromL2Muon::produce ( edm::Event ev,
const edm::EventSetup es 
)
overridevirtual

Implements edm::stream::EDProducerBase.

Definition at line 71 of file FastTSGFromL2Muon.cc.

References clean(), edm::Event::getByLabel(), iseed, edm::Event::put(), TrajectorySeed::recHits(), MuonTrackingRegionBuilder::region(), HLT_50ns_5e33_v3_cff::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().

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