CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

Public Member Functions

 RPCPhiEff (const edm::ParameterSet &)
 
 ~RPCPhiEff ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void beginJob (const edm::EventSetup &)
 
virtual void endJob ()
 
std::string fromCones (const edm::Event &iEvent)
 
std::string fromRaw (const edm::Event &iEvent)
 

Private Attributes

RPCConst m_const
 
edm::InputTag m_g4
 
std::ofstream m_outfileC
 
std::ofstream m_outfileR
 
edm::InputTag m_rpcb
 
edm::InputTag m_rpcdigi
 
edm::InputTag m_rpcf
 
RPCConst rpcconst
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- 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::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

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

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

Definition at line 39 of file RPCPhiEff.h.

Constructor & Destructor Documentation

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

Definition at line 65 of file RPCPhiEff.cc.

References m_outfileR.

65  :
66  m_rpcb( ps.getParameter< edm::InputTag >("rpcb") ),
67  m_rpcf( ps.getParameter< edm::InputTag >("rpcf") ),
68  m_g4( ps.getParameter< edm::InputTag >("g4") ),
69  m_rpcdigi( ps.getParameter< edm::InputTag >("rpcdigi") )
70 {
71 
72 
73  //m_outfileC.open("phieffC.txt");
74  m_outfileR.open("muons.txt");
75 
76 }
T getParameter(std::string const &) const
edm::InputTag m_rpcf
Definition: RPCPhiEff.h:60
edm::InputTag m_rpcdigi
Definition: RPCPhiEff.h:62
edm::InputTag m_rpcb
Definition: RPCPhiEff.h:59
edm::InputTag m_g4
Definition: RPCPhiEff.h:61
std::ofstream m_outfileR
Definition: RPCPhiEff.h:52
RPCPhiEff::~RPCPhiEff ( )

Definition at line 79 of file RPCPhiEff.cc.

References m_outfileR.

80 {
81 
82  //m_outfileC.close();
83  m_outfileR.close();
84 
85 }
std::ofstream m_outfileR
Definition: RPCPhiEff.h:52

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 94 of file RPCPhiEff.cc.

References abs, reco::deltaR(), edm::EventID::event(), edm::Event::getByLabel(), edm::EventBase::id(), m_const, m_g4, m_outfileR, m_rpcb, m_rpcf, pi, and RPCConst::towerNumFromEta().

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

Definition at line 381 of file RPCPhiEff.cc.

382 {
383 }
void RPCPhiEff::endJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 386 of file RPCPhiEff.cc.

387 {
388 }
std::string RPCPhiEff::fromCones ( const edm::Event iEvent)
private

Definition at line 252 of file RPCPhiEff.cc.

252  {
253 
254  return "";
255 }
std::string RPCPhiEff::fromRaw ( const edm::Event iEvent)
private

Definition at line 305 of file RPCPhiEff.cc.

References gather_cfg::cout, edm::Event::getByLabel(), m_rpcdigi, and relativeConstraints::station.

305  {
306 
307  std::stringstream ss;
308 
309  // Digi data.
311  iEvent.getByLabel(m_rpcdigi,rpcDigis);
312 
313  std::set<int> hwPlanes;
314 
316  for (detUnitIt=rpcDigis->begin();
317  detUnitIt!=rpcDigis->end();
318  ++detUnitIt)
319  {
320 
321  const RPCDigiCollection::Range& range = (*detUnitIt).second;
322  bool hasBX0 = false;
323  for (RPCDigiCollection::const_iterator digiIt = range.first;
324  digiIt!=range.second;
325  ++digiIt)
326  {
327  if (digiIt->bx() == 0) {
328  hasBX0 = true;
329  break;
330  }
331  }
332 
333  if (!hasBX0) continue;
334 
335  const RPCDetId& id = (*detUnitIt).first;
336  int station = id.station();
337  int layer = id.layer();
338  //int region = id.region();
339 
340  if (station == 3)
341  hwPlanes.insert(5);
342 
343  else if (station == 4)
344  hwPlanes.insert(6);
345 
346  else if (station == 1 && layer == 1)
347  hwPlanes.insert(1);
348 
349  else if (station == 1 && layer == 2)
350  hwPlanes.insert(2);
351 
352  else if (station == 2 && layer == 1)
353  hwPlanes.insert(3);
354 
355  else if (station == 2 && layer == 2)
356  hwPlanes.insert(4);
357 
358  else
359  std::cout << "??????????????" << std::endl;
360 
361  }
362 
363 
364  for (std::set<int>::iterator it= hwPlanes.begin();
365  it!= hwPlanes.end();
366  ++it)
367  {
368  ss << " " << *it;
369  }
370 
371 
372 
373 
374  return ss.str();
375 
376 
377 
378 }
edm::InputTag m_rpcdigi
Definition: RPCPhiEff.h:62
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
std::vector< DigiType >::const_iterator const_iterator
tuple cout
Definition: gather_cfg.py:121
std::pair< const_iterator, const_iterator > Range

Member Data Documentation

RPCConst RPCPhiEff::m_const
private

Definition at line 64 of file RPCPhiEff.h.

Referenced by analyze().

edm::InputTag RPCPhiEff::m_g4
private

Definition at line 61 of file RPCPhiEff.h.

Referenced by analyze().

std::ofstream RPCPhiEff::m_outfileC
private

Definition at line 51 of file RPCPhiEff.h.

std::ofstream RPCPhiEff::m_outfileR
private

Definition at line 52 of file RPCPhiEff.h.

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

edm::InputTag RPCPhiEff::m_rpcb
private

Definition at line 59 of file RPCPhiEff.h.

Referenced by analyze().

edm::InputTag RPCPhiEff::m_rpcdigi
private

Definition at line 62 of file RPCPhiEff.h.

Referenced by fromRaw().

edm::InputTag RPCPhiEff::m_rpcf
private

Definition at line 60 of file RPCPhiEff.h.

Referenced by analyze().

RPCConst RPCPhiEff::rpcconst
private

Definition at line 57 of file RPCPhiEff.h.