CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
MuScleFitFilter Class Reference
Inheritance diagram for MuScleFitFilter:
edm::EDFilter edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 MuScleFitFilter (const edm::ParameterSet &)
 
 ~MuScleFitFilter () override
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDFilter () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void endJob () override
 
bool filter (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

bool debug
 
int eventsRead
 
int eventsWritten
 
int maxWrite
 
unsigned int minimumMuonsNumber
 
std::vector< double > Mmax
 
std::vector< double > Mmin
 
edm::EDGetTokenT< reco::MuonCollectiontheGlbMuonsToken
 
edm::InputTag theMuonLabel
 
int theMuonType
 
edm::EDGetTokenT< reco::TrackCollectiontheSaMuonsToken
 
edm::EDGetTokenT< reco::TrackCollectiontheTracksToken
 

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDFilter
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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 36 of file MuScleFitFilter.cc.

Constructor & Destructor Documentation

MuScleFitFilter::MuScleFitFilter ( const edm::ParameterSet iConfig)
explicit

Definition at line 71 of file MuScleFitFilter.cc.

References gather_cfg::cout, debug, eventsRead, eventsWritten, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), maxWrite, minimumMuonsNumber, Mmax, Mmin, theGlbMuonsToken, theMuonLabel, theMuonType, theSaMuonsToken, and theTracksToken.

72 {
73  debug = iConfig.getUntrackedParameter<bool>("debug",false);
74 
75  if (debug)
76  std::cout << "Constructor" << std::endl;
77 
78  // Parameters
79  // ----------
80  //ParameterSet serviceParameters = iConfig.getParameter<ParameterSet>("ServiceParameters");
81  //theService = new MuonServiceProxy(serviceParameters);
82  theMuonLabel = iConfig.getParameter<edm::InputTag>("MuonLabel");
83  theGlbMuonsToken = mayConsume<reco::MuonCollection>(theMuonLabel);
84  theSaMuonsToken = mayConsume<reco::TrackCollection>(theMuonLabel);
85  theTracksToken = mayConsume<reco::TrackCollection>(theMuonLabel);
86  theMuonType = iConfig.getParameter<int>("muonType");
87 
88  Mmin = iConfig.getUntrackedParameter<std::vector<double> >("Mmin");
89  Mmax = iConfig.getUntrackedParameter<std::vector<double> >("Mmax");
90  maxWrite = iConfig.getUntrackedParameter<int>("maxWrite",100000);
91 
92  minimumMuonsNumber = iConfig.getUntrackedParameter<unsigned int>("minimumMuonsNumber", 2);
93 
94  // The must have the same size and they must not be empty, otherwise abort.
95  if ( !(Mmin.size() == Mmax.size() && !Mmin.empty()) ) abort();
96 
97  // Count the total number of analyzed and written events
98  // -----------------------------------------------------
99  eventsRead = 0;
100  eventsWritten = 0;
101 
102 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< reco::TrackCollection > theTracksToken
edm::EDGetTokenT< reco::MuonCollection > theGlbMuonsToken
edm::EDGetTokenT< reco::TrackCollection > theSaMuonsToken
edm::InputTag theMuonLabel
unsigned int minimumMuonsNumber
std::vector< double > Mmax
std::vector< double > Mmin
MuScleFitFilter::~MuScleFitFilter ( )
override

Definition at line 107 of file MuScleFitFilter.cc.

References gather_cfg::cout, eventsRead, and eventsWritten.

107  {
108  std::cout << "Total number of events read = " << eventsRead << std::endl;
109  std::cout << "Total number of events written = " << eventsWritten << std::endl;
110 }

Member Function Documentation

void MuScleFitFilter::endJob ( void  )
inlineoverrideprivatevirtual

Reimplemented from edm::EDFilter.

Definition at line 43 of file MuScleFitFilter.cc.

43 {};
bool MuScleFitFilter::filter ( edm::Event event,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 117 of file MuScleFitFilter.cc.

References gather_cfg::cout, debug, DEFINE_FWK_MODULE, eventsRead, eventsWritten, maxWrite, minimumMuonsNumber, Mmax, Mmin, Mmu2, metsig::muon, extraflags_cff::muons, p4, reco::LeafCandidate::setCharge(), reco::LeafCandidate::setP4(), mathSSE::sqrt(), theGlbMuonsToken, theMuonType, theSaMuonsToken, theTracksToken, HiIsolationCommonParameters_cff::track, l1t::tracks, TriggerAnalyzer::write(), and DOFs::Z.

117  {
118 
119  // Cut the crap if we have stored enough stuff
120  // -------------------------------------------
121  if ( maxWrite != -1 && eventsWritten>=maxWrite ) return false;
122 
123  // Get the RecTrack and the RecMuon collection from the event
124  // ----------------------------------------------------------
125  std::unique_ptr<reco::MuonCollection> muons(new reco::MuonCollection());
126 
127  if (debug) std::cout << "Looking for muons of the right kind" << std::endl;
128 
129  if (theMuonType==1) { // GlobalMuons
130 
131  // Global muons:
132  // -------------
134  if (debug) std::cout << "Handle defined" << std::endl;
135  event.getByToken(theGlbMuonsToken, glbMuons);
136  if (debug)
137  std::cout << "Global muons: " << glbMuons->size() << std::endl;
138 
139  // Store the muon
140  // --------------
141  reco::MuonCollection::const_iterator glbMuon;
142  for (glbMuon=glbMuons->begin(); glbMuon!=glbMuons->end(); ++glbMuon) {
143  muons->push_back(*glbMuon);
144  if (debug) {
145  std::cout << " Reconstructed muon: pT = " << glbMuon->p4().Pt()
146  << " Eta = " << glbMuon->p4().Eta() << std::endl;
147  }
148  }
149  } else if (theMuonType==2) { // StandaloneMuons
150 
151  // Standalone muons:
152  // -----------------
154  event.getByToken(theSaMuonsToken, saMuons);
155  if (debug)
156  std::cout << "Standalone muons: " << saMuons->size() << std::endl;
157 
158  // Store the muon
159  // --------------
160  reco::TrackCollection::const_iterator saMuon;
161  for (saMuon=saMuons->begin(); saMuon!=saMuons->end(); ++saMuon) {
163  double energy = sqrt(saMuon->p()*saMuon->p()+Mmu2);
164  math::XYZTLorentzVector p4(saMuon->px(), saMuon->py(), saMuon->pz(), energy);
165  muon.setP4(p4);
166  muon.setCharge(saMuon->charge());
167  muons->push_back(muon);
168  }
169  } else if (theMuonType==3) { // Tracker tracks
170 
171  // Tracks:
172  // -------
174  event.getByToken(theTracksToken, tracks);
175  if (debug)
176  std::cout << "Tracker tracks: " << tracks->size() << std::endl;
177 
178  // Store the muon
179  // -------------
180  reco::TrackCollection::const_iterator track;
181  for (track=tracks->begin(); track!=tracks->end(); ++track) {
183  double energy = sqrt(track->p()*track->p()+Mmu2);
184  math::XYZTLorentzVector p4(track->px(), track->py(), track->pz(), energy);
185  muon.setP4(p4);
186  muon.setCharge(track->charge());
187  muons->push_back(muon);
188  }
189  } else {
190  std::cout << "Wrong muon type! Aborting." << std::endl;
191  abort();
192  }
193 
194  // Loop on RecMuon and reconstruct the resonance
195  // ---------------------------------------------
196  reco::MuonCollection::const_iterator muon1;
197  reco::MuonCollection::const_iterator muon2;
198 
199  bool resfound = false;
200 
201  // Require at least N muons of the selected type.
202  if( muons->size() >= minimumMuonsNumber ) {
203 
204  for (muon1=muons->begin(); muon1!=muons->end(); ++muon1) {
205 
206  if (debug) {
207  std::cout << " Reconstructed muon: pT = " << muon1->p4().Pt()
208  << " Eta = " << muon1->p4().Eta() << std::endl;
209  }
210 
211  // Recombine all the possible Z from reconstructed muons
212  // -----------------------------------------------------
213  if (muons->size()>1) {
214  for (muon2 = muon1+1; muon2!=muons->end(); ++muon2) {
215  if ( ((*muon1).charge()*(*muon2).charge())<0 ) { // This also gets rid of muon1==muon2
216  // reco::Particle::LorentzVector Z (muonCorr1 + muonCorr2);
217  reco::Particle::LorentzVector Z (muon1->p4()+muon2->p4());
218  // Loop on all the cuts on invariant mass.
219  // If it passes at least one of the cuts, the event will be accepted.
220  // ------------------------------------------------------------------
221  std::vector<double>::const_iterator mMinCut = Mmin.begin();
222  std::vector<double>::const_iterator mMaxCut = Mmax.begin();
223  for( ; mMinCut != Mmin.end(); ++mMinCut, ++mMaxCut ) {
224  // When the two borders are -1 do not cut.
225  if( *mMinCut == *mMaxCut && *mMaxCut == -1) {
226  resfound = true;
227  if (debug) {
228  std::cout << "Acceptiong event because mMinCut = " << *mMinCut << " = mMaxCut = " << *mMaxCut << std::endl;
229  }
230  }
231  else if (Z.mass()>*mMinCut && Z.mass()<*mMaxCut) {
232  resfound = true;
233  if (debug) {
234  std::cout << "One particle found with mass = " << Z.mass() << std::endl;
235  }
236  }
237  }
238  }
239  }
240  } else if (debug) {
241  std::cout << "Not enough reconstructed muons to make a resonance" << std::endl;
242  }
243  }
244  }
245  else if (debug) {
246  std::cout << "Skipping event because muons = " << muons->size() << " < " << "minimumMuonsNumber("<<minimumMuonsNumber<<")" << std::endl;
247  }
248 
249  // Store the event if it has a dimuon pair with mass within defined boundaries
250  // ---------------------------------------------------------------------------
251  bool write = false;
252  eventsRead++;
253  if ( resfound ) {
254  write = true;
255  eventsWritten++;
256  }
257  return write;
258 
259 }
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
void setCharge(Charge q) final
set electric charge
Definition: LeafCandidate.h:93
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
const double Mmu2
T sqrt(T t)
Definition: SSEVec.h:18
double p4[4]
Definition: TauolaWrapper.h:92
edm::EDGetTokenT< reco::TrackCollection > theTracksToken
edm::EDGetTokenT< reco::MuonCollection > theGlbMuonsToken
edm::EDGetTokenT< reco::TrackCollection > theSaMuonsToken
unsigned int minimumMuonsNumber
std::vector< double > Mmax
std::vector< double > Mmin
def write(self, setup)
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21
void setP4(const LorentzVector &p4) final
set 4-momentum

Member Data Documentation

bool MuScleFitFilter::debug
private
int MuScleFitFilter::eventsRead
private

Definition at line 43 of file MuScleFitFilter.cc.

Referenced by filter(), MuScleFitFilter(), and ~MuScleFitFilter().

int MuScleFitFilter::eventsWritten
private

Definition at line 48 of file MuScleFitFilter.cc.

Referenced by filter(), MuScleFitFilter(), and ~MuScleFitFilter().

int MuScleFitFilter::maxWrite
private

Definition at line 53 of file MuScleFitFilter.cc.

Referenced by filter(), and MuScleFitFilter().

unsigned int MuScleFitFilter::minimumMuonsNumber
private

Definition at line 54 of file MuScleFitFilter.cc.

Referenced by filter(), and MuScleFitFilter().

std::vector<double> MuScleFitFilter::Mmax
private

Definition at line 52 of file MuScleFitFilter.cc.

Referenced by filter(), and MuScleFitFilter().

std::vector<double> MuScleFitFilter::Mmin
private

Definition at line 51 of file MuScleFitFilter.cc.

Referenced by filter(), and MuScleFitFilter().

edm::EDGetTokenT<reco::MuonCollection> MuScleFitFilter::theGlbMuonsToken
private

Definition at line 59 of file MuScleFitFilter.cc.

Referenced by filter(), and MuScleFitFilter().

edm::InputTag MuScleFitFilter::theMuonLabel
private

Definition at line 58 of file MuScleFitFilter.cc.

Referenced by MuScleFitFilter().

int MuScleFitFilter::theMuonType
private

Definition at line 50 of file MuScleFitFilter.cc.

Referenced by filter(), and MuScleFitFilter().

edm::EDGetTokenT<reco::TrackCollection> MuScleFitFilter::theSaMuonsToken
private

Definition at line 60 of file MuScleFitFilter.cc.

Referenced by filter(), and MuScleFitFilter().

edm::EDGetTokenT<reco::TrackCollection> MuScleFitFilter::theTracksToken
private

Definition at line 61 of file MuScleFitFilter.cc.

Referenced by filter(), and MuScleFitFilter().