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::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 RPCPhiEff (const edm::ParameterSet &)
 
 ~RPCPhiEff () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () 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
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
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::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

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 55 of file RPCPhiEff.cc.

References m_outfileR.

56  : m_rpcbToken(consumes<std::vector<L1MuRegionalCand> >(ps.getParameter<edm::InputTag>("rpcb"))),
57  m_rpcfToken(consumes<std::vector<L1MuRegionalCand> >(ps.getParameter<edm::InputTag>("rpcf"))),
58  m_g4Token(consumes<edm::SimTrackContainer>(ps.getParameter<edm::InputTag>("g4"))),
59  m_rpcdigiToken(consumes<RPCDigiCollection>(ps.getParameter<edm::InputTag>("rpcdigi"))) {
60  //m_outfileC.open("phieffC.txt");
61  m_outfileR.open("muons.txt");
62 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< edm::SimTrackContainer > m_g4Token
Definition: RPCPhiEff.h:60
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< std::vector< L1MuRegionalCand > > m_rpcfToken
Definition: RPCPhiEff.h:59
edm::EDGetTokenT< RPCDigiCollection > m_rpcdigiToken
Definition: RPCPhiEff.h:61
edm::EDGetTokenT< std::vector< L1MuRegionalCand > > m_rpcbToken
Definition: RPCPhiEff.h:58
std::ofstream m_outfileR
Definition: RPCPhiEff.h:52

◆ ~RPCPhiEff()

RPCPhiEff::~RPCPhiEff ( )
override

Definition at line 64 of file RPCPhiEff.cc.

References m_outfileR.

64  {
65  //m_outfileC.close();
66  m_outfileR.close();
67 }
std::ofstream m_outfileR
Definition: RPCPhiEff.h:52

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 74 of file RPCPhiEff.cc.

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.

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

◆ beginJob()

void RPCPhiEff::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 272 of file RPCPhiEff.cc.

272 {}

◆ endJob()

void RPCPhiEff::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 275 of file RPCPhiEff.cc.

275 {}

◆ fromCones()

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

Definition at line 211 of file RPCPhiEff.cc.

211 { return ""; }

◆ fromRaw()

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

Definition at line 214 of file RPCPhiEff.cc.

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

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

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.