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

270 {}

◆ endJob()

void RPCPhiEff::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 273 of file RPCPhiEff.cc.

273 {}

◆ fromCones()

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

Definition at line 209 of file RPCPhiEff.cc.

209 { return ""; }

◆ fromRaw()

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

Definition at line 212 of file RPCPhiEff.cc.

References gather_cfg::cout, iEvent, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, nano_mu_digi_cff::layer, m_rpcdigiToken, FastTimerService_cff::range, contentValuesCheck::ss, and relativeConstraints::station.

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