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 ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void beginJob ()
 
virtual void endJob ()
 
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 &)
 
- 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

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

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

Definition at line 40 of file RPCPhiEff.h.

Constructor & Destructor Documentation

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

Definition at line 57 of file RPCPhiEff.cc.

References m_outfileR.

57  :
58  m_rpcbToken( consumes<std::vector<L1MuRegionalCand> > (
59  ps.getParameter< edm::InputTag >("rpcb"))),
60  m_rpcfToken( consumes<std::vector<L1MuRegionalCand> > (
61  ps.getParameter< edm::InputTag >("rpcf"))),
62  m_g4Token( consumes<edm::SimTrackContainer>(
63  ps.getParameter< edm::InputTag >("g4"))),
64  m_rpcdigiToken( consumes<RPCDigiCollection> (
65  ps.getParameter< edm::InputTag >("rpcdigi")))
66 {
67 
68 
69  //m_outfileC.open("phieffC.txt");
70  m_outfileR.open("muons.txt");
71 
72 }
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::SimTrackContainer > m_g4Token
Definition: RPCPhiEff.h:62
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< std::vector< L1MuRegionalCand > > m_rpcfToken
Definition: RPCPhiEff.h:61
edm::EDGetTokenT< RPCDigiCollection > m_rpcdigiToken
Definition: RPCPhiEff.h:63
edm::EDGetTokenT< std::vector< L1MuRegionalCand > > m_rpcbToken
Definition: RPCPhiEff.h:60
std::ofstream m_outfileR
Definition: RPCPhiEff.h:53
RPCPhiEff::~RPCPhiEff ( )

Definition at line 75 of file RPCPhiEff.cc.

References m_outfileR.

76 {
77 
78  //m_outfileC.close();
79  m_outfileR.close();
80 
81 }
std::ofstream m_outfileR
Definition: RPCPhiEff.h:53

Member Function Documentation

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

Definition at line 90 of file RPCPhiEff.cc.

References funct::abs(), reco::deltaR(), edm::EventID::event(), edm::Event::getByToken(), edm::EventBase::id(), m_const, m_g4Token, m_outfileR, m_rpcbToken, m_rpcfToken, electrons_cff::matched, pi, tkConvValidator_cfi::simTracks, and RPCConst::towerNumFromEta().

92 {
93 
94 
97 
98  iEvent.getByToken(m_rpcbToken, rpcBarrel);
99  iEvent.getByToken(m_rpcfToken, rpcForward);
100 
101 
102  std::vector< edm::Handle<std::vector<L1MuRegionalCand> > > handleVec;
103  handleVec.push_back( rpcBarrel );
104  handleVec.push_back( rpcForward );
105 
106  // Fetch MCdata
108  iEvent.getByToken(m_g4Token, simTracks);
109 
110  float etaGen = 0, phiGen = 0, ptGen = 0;
111 
112  int noOfMuons = 0;
113  int noOfRecMuons = 0;
114  int noOfMatchedRecMuons = 0;
115 
116  bool firstRunForMuonMatchingCnt = true;
117 
118  // ask MC muons to be separated
119  double deltarMin = -1;
120  edm::SimTrackContainer::const_iterator simTrk = simTracks->begin();
121  for (; simTrk != simTracks->end(); ++simTrk) {
122 
123  if (simTrk->type() != -13 && simTrk->type()!=13) continue;
124 
125  edm::SimTrackContainer::const_iterator simTrk2 = simTrk;
126  ++simTrk2;
127  for (; simTrk2 != simTracks->end(); ++simTrk2) {
128  if (simTrk2->type() != -13 && simTrk2->type()!=13) continue;
129  double drCand = reco::deltaR(simTrk2->momentum(), simTrk->momentum());
130  if (drCand < deltarMin || deltarMin < 0) deltarMin = drCand;
131  }
132 
133 
134  }
135 
136  //std::cout << deltarMin << std::endl;
137  if (deltarMin < 0.7 && deltarMin > 0) return;
138 
139  simTrk = simTracks->begin();
140  for (; simTrk != simTracks->end(); simTrk++) {
141  int type = simTrk->type();
142  if (type == 13 || type == -13) {
143  // Get the data
144  const math::XYZTLorentzVectorD momentum = simTrk->momentum();
145  etaGen = momentum.eta();
146  ptGen = momentum.Pt();
147  phiGen = momentum.phi();
148  noOfMuons++;
149 
150  bool matched = false;
151  int ptCodeRec = 0;
152  int towerRec = 0;
153  int phiRec = 0;
154  //int muonsFound=0;
155  int qual = 0;
156  int ghost = 0; // number of ghost for montecarlo muon
157 
158  // Iter rpc muon cands, perform delta R matching
159  // todo perform matching also using eta...
160  for ( std::vector< edm::Handle<std::vector<L1MuRegionalCand> > >::iterator it = handleVec.begin();
161  it != handleVec.end();
162  ++it )
163  {
164  std::vector<L1MuRegionalCand>::const_iterator itRPC;
165  for (itRPC=(*it)->begin(); itRPC!=(*it)->end(); itRPC++){
166  int ptCode = itRPC->pt_packed();
167  if (ptCode != 0) {
168 
169  if (firstRunForMuonMatchingCnt) ++noOfRecMuons;
170  ptCodeRec=ptCode;
171  phiRec=itRPC->phi_packed();
172  qual = itRPC->quality();
173  towerRec = itRPC->eta_packed();
174  if (towerRec > 16) {
175  towerRec = - ( (~towerRec & 63) + 1);
176  }
177  // match
178  float pi = 3.14159265;
179  //float phiPhys = 2*pi*float(phiRec)/144-pi;
180  float phiScaled = phiGen;
181  if (phiScaled<0) phiScaled += 2*pi;
182  int phiHwGen = (phiScaled)/2/pi*144;
183 
184  //std::cout << "phi " << phiGen << " " << phiHwGen << " " << phiRec
185  // << " eta " << etaGen << " " << m_const.towerNumFromEta(etaGen) << " "<< towerRec << std::endl;
186  if ( ( std::abs(phiHwGen-phiRec) < 10) && (std::abs(m_const.towerNumFromEta(etaGen)-towerRec)<1) )
187  {
188  if (matched) { // we have matched m.c. earlier, this is ghost
189  ++ghost;
190  }
191  matched = true;
192  ++noOfMatchedRecMuons;
193  m_outfileR << etaGen << " " << phiGen << " " << ptGen
194  << " " << towerRec << " " << phiRec << " " << ptCodeRec << " " << qual
195  << " " << ghost
196  << std::endl;
197  }
198  } // (ptCode != 0)
199  } // muon cands iter ends
200  } // barrell/fwd iter ends
201  firstRunForMuonMatchingCnt=false;
202  if (!matched) {
203  m_outfileR << etaGen << " " << phiGen << " " << ptGen
204  << " " << 0 << " " << 0 << " " << 0 << " " << 0
205  << " " << 0
206  << std::endl;
207 
208  }
209 
210 
211  }
212  }
213 
214  edm::EventID id = iEvent.id();
215  edm::EventNumber_t evNum = id.event();
216  edm::RunNumber_t rnNum = id.run();
217 
218  if (noOfMatchedRecMuons!=noOfRecMuons) {
219  edm::LogInfo("RPCEffWarn") << " MuonCands " << noOfRecMuons
220  << " matched " << noOfMatchedRecMuons
221  << " in run " << rnNum
222  << " event " << evNum;
223  }
224 
225 
226 
227  /*
228  m_outfileC << etaGen << " " << phiGen << " " << ptGen << " "
229  << phiRec << " " << towerRec << " " << muonsFound << " "
230  << fromCones(iEvent) <<std::endl;*/
231  /*m_outfileR << etaGen << " " << phiGen << " " << ptGen << " "
232  << phiRec << " " << towerRec << " " << muonsFound << " "
233  << fromRaw(iEvent) <<std::endl;*/
234 
235 
236  /*
237  m_outfileR << etaGen << " " << phiGen << " " << ptGen << " "
238  << phiRec << " " << towerRec << " " << muonsFound << " "
239  << std::endl;
240 
241  */
242 
243 
244 }
type
Definition: HCALResponse.h:21
EventNumber_t event() const
Definition: EventID.h:41
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:14
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
unsigned long long EventNumber_t
edm::EDGetTokenT< edm::SimTrackContainer > m_g4Token
Definition: RPCPhiEff.h:62
const Double_t pi
edm::EDGetTokenT< std::vector< L1MuRegionalCand > > m_rpcfToken
Definition: RPCPhiEff.h:61
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:28
edm::EventID id() const
Definition: EventBase.h:60
edm::EDGetTokenT< std::vector< L1MuRegionalCand > > m_rpcbToken
Definition: RPCPhiEff.h:60
static int towerNumFromEta(const double eta)
Definition: RPCConst.cc:62
unsigned int RunNumber_t
std::ofstream m_outfileR
Definition: RPCPhiEff.h:53
RPCConst m_const
Definition: RPCPhiEff.h:65
void RPCPhiEff::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 328 of file RPCPhiEff.cc.

329 {
330 }
void RPCPhiEff::endJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 333 of file RPCPhiEff.cc.

334 {
335 }
std::string RPCPhiEff::fromCones ( const edm::Event iEvent)
private

Definition at line 246 of file RPCPhiEff.cc.

246  {
247 
248  return "";
249 }
std::string RPCPhiEff::fromRaw ( const edm::Event iEvent)
private

Definition at line 252 of file RPCPhiEff.cc.

References gather_cfg::cout, edm::Event::getByToken(), m_rpcdigiToken, and relativeConstraints::station.

252  {
253 
254  std::stringstream ss;
255 
256  // Digi data.
258  iEvent.getByToken(m_rpcdigiToken, rpcDigis);
259 
260  std::set<int> hwPlanes;
261 
263  for (detUnitIt=rpcDigis->begin();
264  detUnitIt!=rpcDigis->end();
265  ++detUnitIt)
266  {
267 
268  const RPCDigiCollection::Range& range = (*detUnitIt).second;
269  bool hasBX0 = false;
270  for (RPCDigiCollection::const_iterator digiIt = range.first;
271  digiIt!=range.second;
272  ++digiIt)
273  {
274  if (digiIt->bx() == 0) {
275  hasBX0 = true;
276  break;
277  }
278  }
279 
280  if (!hasBX0) continue;
281 
282  const RPCDetId& id = (*detUnitIt).first;
283  int station = id.station();
284  int layer = id.layer();
285  //int region = id.region();
286 
287  if (station == 3)
288  hwPlanes.insert(5);
289 
290  else if (station == 4)
291  hwPlanes.insert(6);
292 
293  else if (station == 1 && layer == 1)
294  hwPlanes.insert(1);
295 
296  else if (station == 1 && layer == 2)
297  hwPlanes.insert(2);
298 
299  else if (station == 2 && layer == 1)
300  hwPlanes.insert(3);
301 
302  else if (station == 2 && layer == 2)
303  hwPlanes.insert(4);
304 
305  else
306  std::cout << "??????????????" << std::endl;
307 
308  }
309 
310 
311  for (std::set<int>::iterator it= hwPlanes.begin();
312  it!= hwPlanes.end();
313  ++it)
314  {
315  ss << " " << *it;
316  }
317 
318 
319 
320 
321  return ss.str();
322 
323 
324 
325 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
edm::EDGetTokenT< RPCDigiCollection > m_rpcdigiToken
Definition: RPCPhiEff.h:63
std::vector< RPCDigi >::const_iterator const_iterator
std::pair< const_iterator, const_iterator > Range

Member Data Documentation

RPCConst RPCPhiEff::m_const
private

Definition at line 65 of file RPCPhiEff.h.

Referenced by analyze().

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

Definition at line 62 of file RPCPhiEff.h.

Referenced by analyze().

std::ofstream RPCPhiEff::m_outfileC
private

Definition at line 52 of file RPCPhiEff.h.

std::ofstream RPCPhiEff::m_outfileR
private

Definition at line 53 of file RPCPhiEff.h.

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

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

Definition at line 60 of file RPCPhiEff.h.

Referenced by analyze().

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

Definition at line 63 of file RPCPhiEff.h.

Referenced by fromRaw().

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

Definition at line 61 of file RPCPhiEff.h.

Referenced by analyze().

RPCConst RPCPhiEff::rpcconst
private

Definition at line 58 of file RPCPhiEff.h.