CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
RPCPhiEff Class Reference

#include <MyLib/RPCPhiEff/src/RPCPhiEff.cc>

Inheritance diagram for RPCPhiEff:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 RPCPhiEff (const edm::ParameterSet &)
 
 ~RPCPhiEff () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () 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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
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 analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginJob () override
 
void endJob () override
 
std::string fromCones (const edm::Event &iEvent)
 
std::string fromRaw (const edm::Event &iEvent)
 

Private Attributes

RPCConst m_const
 
edm::EDGetTokenT< edm::SimTrackContainerm_g4Token
 
std::ofstream m_outfileC
 
std::ofstream m_outfileR
 
edm::EDGetTokenT< std::vector< L1MuRegionalCand > > m_rpcbToken
 
edm::EDGetTokenT< RPCDigiCollectionm_rpcdigiToken
 
edm::EDGetTokenT< std::vector< L1MuRegionalCand > > m_rpcfToken
 
RPCConst rpcconst
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 40 of file RPCPhiEff.h.

Constructor & Destructor Documentation

◆ RPCPhiEff()

RPCPhiEff::RPCPhiEff ( const edm::ParameterSet ps)
explicit

Definition at line 56 of file RPCPhiEff.cc.

57  : m_rpcbToken(consumes<std::vector<L1MuRegionalCand> >(ps.getParameter<edm::InputTag>("rpcb"))),
58  m_rpcfToken(consumes<std::vector<L1MuRegionalCand> >(ps.getParameter<edm::InputTag>("rpcf"))),
59  m_g4Token(consumes<edm::SimTrackContainer>(ps.getParameter<edm::InputTag>("g4"))),
60  m_rpcdigiToken(consumes<RPCDigiCollection>(ps.getParameter<edm::InputTag>("rpcdigi"))) {
61  //m_outfileC.open("phieffC.txt");
62  m_outfileR.open("muons.txt");
63 }

References m_outfileR.

◆ ~RPCPhiEff()

RPCPhiEff::~RPCPhiEff ( )
override

Definition at line 65 of file RPCPhiEff.cc.

65  {
66  //m_outfileC.close();
67  m_outfileR.close();
68 }

References m_outfileR.

Member Function Documentation

◆ analyze()

void RPCPhiEff::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDAnalyzer.

Definition at line 75 of file RPCPhiEff.cc.

75  {
78 
79  iEvent.getByToken(m_rpcbToken, rpcBarrel);
80  iEvent.getByToken(m_rpcfToken, rpcForward);
81 
82  std::vector<edm::Handle<std::vector<L1MuRegionalCand> > > handleVec;
83  handleVec.push_back(rpcBarrel);
84  handleVec.push_back(rpcForward);
85 
86  // Fetch MCdata
88  iEvent.getByToken(m_g4Token, simTracks);
89 
90  float etaGen = 0, phiGen = 0, ptGen = 0;
91 
92  int noOfMuons = 0;
93  int noOfRecMuons = 0;
94  int noOfMatchedRecMuons = 0;
95 
96  bool firstRunForMuonMatchingCnt = true;
97 
98  // ask MC muons to be separated
99  double deltarMin = -1;
100  edm::SimTrackContainer::const_iterator simTrk = simTracks->begin();
101  for (; simTrk != simTracks->end(); ++simTrk) {
102  if (simTrk->type() != -13 && simTrk->type() != 13)
103  continue;
104 
105  edm::SimTrackContainer::const_iterator simTrk2 = simTrk;
106  ++simTrk2;
107  for (; simTrk2 != simTracks->end(); ++simTrk2) {
108  if (simTrk2->type() != -13 && simTrk2->type() != 13)
109  continue;
110  double drCand = reco::deltaR(simTrk2->momentum(), simTrk->momentum());
111  if (drCand < deltarMin || deltarMin < 0)
112  deltarMin = drCand;
113  }
114  }
115 
116  //std::cout << deltarMin << std::endl;
117  if (deltarMin < 0.7 && deltarMin > 0)
118  return;
119 
120  simTrk = simTracks->begin();
121  for (; simTrk != simTracks->end(); simTrk++) {
122  int type = simTrk->type();
123  if (type == 13 || type == -13) {
124  // Get the data
125  const math::XYZTLorentzVectorD momentum = simTrk->momentum();
126  etaGen = momentum.eta();
127  ptGen = momentum.Pt();
128  phiGen = momentum.phi();
129  noOfMuons++;
130 
131  bool matched = false;
132  int ptCodeRec = 0;
133  int towerRec = 0;
134  int phiRec = 0;
135  //int muonsFound=0;
136  int qual = 0;
137  int ghost = 0; // number of ghost for montecarlo muon
138 
139  // Iter rpc muon cands, perform delta R matching
140  // todo perform matching also using eta...
141  for (std::vector<edm::Handle<std::vector<L1MuRegionalCand> > >::iterator it = handleVec.begin();
142  it != handleVec.end();
143  ++it) {
144  std::vector<L1MuRegionalCand>::const_iterator itRPC;
145  for (itRPC = (*it)->begin(); itRPC != (*it)->end(); itRPC++) {
146  int ptCode = itRPC->pt_packed();
147  if (ptCode != 0) {
148  if (firstRunForMuonMatchingCnt)
149  ++noOfRecMuons;
150  ptCodeRec = ptCode;
151  phiRec = itRPC->phi_packed();
152  qual = itRPC->quality();
153  towerRec = itRPC->eta_packed();
154  if (towerRec > 16) {
155  towerRec = -((~towerRec & 63) + 1);
156  }
157  // match
158  float pi = 3.14159265;
159  //float phiPhys = 2*pi*float(phiRec)/144-pi;
160  float phiScaled = phiGen;
161  if (phiScaled < 0)
162  phiScaled += 2 * pi;
163  int phiHwGen = (phiScaled) / 2 / pi * 144;
164 
165  //std::cout << "phi " << phiGen << " " << phiHwGen << " " << phiRec
166  // << " eta " << etaGen << " " << m_const.towerNumFromEta(etaGen) << " "<< towerRec << std::endl;
167  if ((std::abs(phiHwGen - phiRec) < 10) && (std::abs(m_const.towerNumFromEta(etaGen) - towerRec) < 1)) {
168  if (matched) { // we have matched m.c. earlier, this is ghost
169  ++ghost;
170  }
171  matched = true;
172  ++noOfMatchedRecMuons;
173  m_outfileR << etaGen << " " << phiGen << " " << ptGen << " " << towerRec << " " << phiRec << " "
174  << ptCodeRec << " " << qual << " " << ghost << std::endl;
175  }
176  } // (ptCode != 0)
177  } // muon cands iter ends
178  } // barrell/fwd iter ends
179  firstRunForMuonMatchingCnt = false;
180  if (!matched) {
181  m_outfileR << etaGen << " " << phiGen << " " << ptGen << " " << 0 << " " << 0 << " " << 0 << " " << 0 << " "
182  << 0 << std::endl;
183  }
184  }
185  }
186 
187  edm::EventID id = iEvent.id();
188  edm::EventNumber_t evNum = id.event();
189  edm::RunNumber_t rnNum = id.run();
190 
191  if (noOfMatchedRecMuons != noOfRecMuons) {
192  edm::LogInfo("RPCEffWarn") << " MuonCands " << noOfRecMuons << " matched " << noOfMatchedRecMuons << " in run "
193  << rnNum << " event " << evNum;
194  }
195 
196  /*
197  m_outfileC << etaGen << " " << phiGen << " " << ptGen << " "
198  << phiRec << " " << towerRec << " " << muonsFound << " "
199  << fromCones(iEvent) <<std::endl;*/
200  /*m_outfileR << etaGen << " " << phiGen << " " << ptGen << " "
201  << phiRec << " " << towerRec << " " << muonsFound << " "
202  << fromRaw(iEvent) <<std::endl;*/
203 
204  /*
205  m_outfileR << etaGen << " " << phiGen << " " << ptGen << " "
206  << phiRec << " " << towerRec << " " << muonsFound << " "
207  << std::endl;
208 
209  */
210 }

References funct::abs(), reco::deltaR(), iEvent, m_const, m_g4Token, m_outfileR, m_rpcbToken, m_rpcfToken, muonTagProbeFilters_cff::matched, pi, TrackCandidateProducer_cfi::simTracks, RPCConst::towerNumFromEta(), and trackerHitRTTI::vector.

◆ beginJob()

void RPCPhiEff::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 273 of file RPCPhiEff.cc.

273 {}

◆ endJob()

void RPCPhiEff::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 276 of file RPCPhiEff.cc.

276 {}

◆ fromCones()

std::string RPCPhiEff::fromCones ( const edm::Event iEvent)
private

Definition at line 212 of file RPCPhiEff.cc.

212 { return ""; }

◆ fromRaw()

std::string RPCPhiEff::fromRaw ( const edm::Event iEvent)
private

Definition at line 215 of file RPCPhiEff.cc.

215  {
216  std::stringstream ss;
217 
218  // Digi data.
220  iEvent.getByToken(m_rpcdigiToken, rpcDigis);
221 
222  std::set<int> hwPlanes;
223 
225  for (detUnitIt = rpcDigis->begin(); detUnitIt != rpcDigis->end(); ++detUnitIt) {
226  const RPCDigiCollection::Range& range = (*detUnitIt).second;
227  bool hasBX0 = false;
228  for (RPCDigiCollection::const_iterator digiIt = range.first; digiIt != range.second; ++digiIt) {
229  if (digiIt->bx() == 0) {
230  hasBX0 = true;
231  break;
232  }
233  }
234 
235  if (!hasBX0)
236  continue;
237 
238  const RPCDetId& id = (*detUnitIt).first;
239  int station = id.station();
240  int layer = id.layer();
241  //int region = id.region();
242 
243  if (station == 3)
244  hwPlanes.insert(5);
245 
246  else if (station == 4)
247  hwPlanes.insert(6);
248 
249  else if (station == 1 && layer == 1)
250  hwPlanes.insert(1);
251 
252  else if (station == 1 && layer == 2)
253  hwPlanes.insert(2);
254 
255  else if (station == 2 && layer == 1)
256  hwPlanes.insert(3);
257 
258  else if (station == 2 && layer == 2)
259  hwPlanes.insert(4);
260 
261  else
262  std::cout << "??????????????" << std::endl;
263  }
264 
265  for (std::set<int>::iterator it = hwPlanes.begin(); it != hwPlanes.end(); ++it) {
266  ss << " " << *it;
267  }
268 
269  return ss.str();
270 }

References gather_cfg::cout, iEvent, phase1PixelTopology::layer, m_rpcdigiToken, FastTimerService_cff::range, contentValuesCheck::ss, and relativeConstraints::station.

Member Data Documentation

◆ m_const

RPCConst RPCPhiEff::m_const
private

Definition at line 63 of file RPCPhiEff.h.

Referenced by analyze().

◆ m_g4Token

edm::EDGetTokenT<edm::SimTrackContainer> RPCPhiEff::m_g4Token
private

Definition at line 60 of file RPCPhiEff.h.

Referenced by analyze().

◆ m_outfileC

std::ofstream RPCPhiEff::m_outfileC
private

Definition at line 51 of file RPCPhiEff.h.

◆ m_outfileR

std::ofstream RPCPhiEff::m_outfileR
private

Definition at line 52 of file RPCPhiEff.h.

Referenced by analyze(), RPCPhiEff(), and ~RPCPhiEff().

◆ m_rpcbToken

edm::EDGetTokenT<std::vector<L1MuRegionalCand> > RPCPhiEff::m_rpcbToken
private

Definition at line 58 of file RPCPhiEff.h.

Referenced by analyze().

◆ m_rpcdigiToken

edm::EDGetTokenT<RPCDigiCollection> RPCPhiEff::m_rpcdigiToken
private

Definition at line 61 of file RPCPhiEff.h.

Referenced by fromRaw().

◆ m_rpcfToken

edm::EDGetTokenT<std::vector<L1MuRegionalCand> > RPCPhiEff::m_rpcfToken
private

Definition at line 59 of file RPCPhiEff.h.

Referenced by analyze().

◆ rpcconst

RPCConst RPCPhiEff::rpcconst
private

Definition at line 56 of file RPCPhiEff.h.

muonTagProbeFilters_cff.matched
matched
Definition: muonTagProbeFilters_cff.py:62
edm::RunNumber_t
unsigned int RunNumber_t
Definition: RunLumiEventNumber.h:14
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
RPCPhiEff::m_const
RPCConst m_const
Definition: RPCPhiEff.h:63
relativeConstraints.station
station
Definition: relativeConstraints.py:67
math::XYZTLorentzVectorD
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:14
RPCPhiEff::m_g4Token
edm::EDGetTokenT< edm::SimTrackContainer > m_g4Token
Definition: RPCPhiEff.h:60
RPCDetId
Definition: RPCDetId.h:16
gather_cfg.cout
cout
Definition: gather_cfg.py:144
TrackCandidateProducer_cfi.simTracks
simTracks
Definition: TrackCandidateProducer_cfi.py:15
RPCPhiEff::m_outfileR
std::ofstream m_outfileR
Definition: RPCPhiEff.h:52
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::Handle
Definition: AssociativeIterator.h:50
MuonDigiCollection< RPCDetId, RPCDigi >::const_iterator
std::vector< RPCDigi >::const_iterator const_iterator
Definition: MuonDigiCollection.h:94
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
RPCPhiEff::m_rpcdigiToken
edm::EDGetTokenT< RPCDigiCollection > m_rpcdigiToken
Definition: RPCPhiEff.h:61
edm::EventNumber_t
unsigned long long EventNumber_t
Definition: RunLumiEventNumber.h:12
RPCPhiEff::m_rpcfToken
edm::EDGetTokenT< std::vector< L1MuRegionalCand > > m_rpcfToken
Definition: RPCPhiEff.h:59
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
type
type
Definition: SiPixelVCal_PayloadInspector.cc:39
iEvent
int iEvent
Definition: GenABIO.cc:224
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
MuonDigiCollection< RPCDetId, RPCDigi >::Range
std::pair< const_iterator, const_iterator > Range
Definition: MuonDigiCollection.h:95
reco::deltaR
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
pi
const Double_t pi
Definition: trackSplitPlot.h:36
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:159
edm::EventID
Definition: EventID.h:31
DigiContainerIterator
Definition: MuonDigiCollection.h:30
edm::InputTag
Definition: InputTag.h:15
RPCPhiEff::m_rpcbToken
edm::EDGetTokenT< std::vector< L1MuRegionalCand > > m_rpcbToken
Definition: RPCPhiEff.h:58
RPCConst::towerNumFromEta
static int towerNumFromEta(const double eta)
Definition: RPCConst.cc:60