CMS 3D CMS Logo

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

#include <HLTMCtruth.h>

Public Member Functions

void analyze (const edm::Handle< reco::CandidateView > &mctruth, const double &pthat, const double &weight, const edm::Handle< std::vector< SimTrack > > &simTracks, const edm::Handle< std::vector< SimVertex > > &simVertices, const edm::Handle< std::vector< PileupSummaryInfo > > &PupInfo, TTree *tree)
 
 HLTMCtruth ()
 
void setup (const edm::ParameterSet &pSet, TTree *tree)
 

Private Attributes

bool _Debug
 
bool _Gen
 
bool _Monte
 
float * mceta
 
float * mcphi
 
int * mcpid
 
float * mcpt
 
int * mcstatus
 
float * mcvx
 
float * mcvy
 
float * mcvz
 
int nab
 
int nbb
 
int nel3
 
int nmcpart
 
int nmu3
 
int npubx0
 
int npuvertbx0
 
int nwenu
 
int nwmunu
 
int nzee
 
int nzmumu
 
float ptEleMax
 
float pthatf
 
float ptMuMax
 
float weightf
 
float weightsignf
 

Detailed Description

$Date: November 2006 $Revision:

Author
P. Bargassa - Rice U.

Definition at line 30 of file HLTMCtruth.h.

Constructor & Destructor Documentation

HLTMCtruth::HLTMCtruth ( )

Definition at line 15 of file HLTMCtruth.cc.

References _Debug, _Gen, and _Monte.

15  {
16 
17  //set parameter defaults
18  _Monte=false;
19  _Gen=false;
20  _Debug=false;
21 }
bool _Gen
Definition: HLTMCtruth.h:55
bool _Debug
Definition: HLTMCtruth.h:55
bool _Monte
Definition: HLTMCtruth.h:55

Member Function Documentation

void HLTMCtruth::analyze ( const edm::Handle< reco::CandidateView > &  mctruth,
const double &  pthat,
const double &  weight,
const edm::Handle< std::vector< SimTrack > > &  simTracks,
const edm::Handle< std::vector< SimVertex > > &  simVertices,
const edm::Handle< std::vector< PileupSummaryInfo > > &  PupInfo,
TTree *  tree 
)

Analyze the Data

Definition at line 74 of file HLTMCtruth.cc.

References _Gen, _Monte, funct::abs(), rpcdqm::BX, edmIntegrityCheck::d, reco::Candidate::daughter(), PVValHelper::eta, reco::Candidate::eta(), mps_fire::i, edm::HandleBase::isValid(), mceta, mcphi, mcpid, mcpt, mcstatus, mcvx, mcvy, mcvz, nab, nbb, nel3, nmcpart, nmu3, npubx0, npuvertbx0, reco::Candidate::numberOfDaughters(), nwenu, nwmunu, nzee, nzmumu, AlCaHLTBitMon_ParallelJobs::p, BPhysicsValidation_cfi::pdgid, reco::Candidate::pdgId(), reco::Candidate::phi(), EnergyCorrector::pt, reco::Candidate::pt(), ptEleMax, pthatf, ptMuMax, alignCSCRings::r, tkConvValidator_cfi::simTracks, edm::View< T >::size(), mathSSE::sqrt(), reco::Candidate::status(), reco::Candidate::vx(), reco::Candidate::vy(), reco::Candidate::vz(), mps_merge::weight, weightf, weightsignf, x, y, and z.

Referenced by HLTBitAnalyzer::analyze().

80  {
81 
82  //std::cout << " Beginning HLTMCtruth " << std::endl;
83 
84  if (_Monte) {
85  int nmc = 0;
86  int mu3 = 0;
87  int el3 = 0;
88  int mab = 0;
89  int mbb = 0;
90  int wel = 0;
91  int wmu = 0;
92  int zee = 0;
93  int zmumu = 0;
94 
95  ptEleMax = -999.0;
96  ptMuMax = -999.0;
97  pthatf = pthat;
98  weightf = weight;
99  weightsignf = (weight > 0) ? 1. : -1.;
100  npubx0 = 0.0;
101  npuvertbx0 = 0;
102 
103  int npvtrue = 0;
104  int npuvert = 0;
105 
106  if(PupInfo.isValid()) {
107  std::vector<PileupSummaryInfo>::const_iterator PVI;
108  for(PVI = PupInfo->begin(); PVI != PupInfo->end(); ++PVI) {
109 
110  int BX = PVI->getBunchCrossing();
111  npvtrue = PVI->getTrueNumInteractions();
112  npuvert = PVI->getPU_NumInteractions();
113 
114  if(BX == 0)
115  {
116  npubx0+=npvtrue;
117  npuvertbx0+=npuvert;
118  }
119  }
120  }
121 
122  if((simTracks.isValid())&&(simVertices.isValid())){
123  for (auto const & j : *simTracks) {
124  int pdgid = j.type();
125  if (abs(pdgid)!=13) continue;
126  double pt = j.momentum().pt();
127  if (pt<5.0) continue;
128  double eta = j.momentum().eta();
129  if (abs(eta)>2.5) continue;
130  if (j.noVertex()) continue;
131  int vertIndex = j.vertIndex();
132  double x = simVertices->at(vertIndex).position().x();
133  double y = simVertices->at(vertIndex).position().y();
134  double r = sqrt(x*x+y*y);
135  if (r>200.) continue; // I think units are cm here
136  double z = simVertices->at(vertIndex).position().z();
137  if (abs(z)>400.) continue; // I think units are cm here
138  mu3 += 1;
139  break;
140  }
141 
142  }
143 
144  if (_Gen && mctruth.isValid()){
145 
146  for (size_t i = 0; i < mctruth->size(); ++ i) {
147  const reco::Candidate & p = (*mctruth)[i];
148 
149  mcpid[nmc] = p.pdgId();
150  mcstatus[nmc] = p.status();
151  mcpt[nmc] = p.pt();
152  mceta[nmc] = p.eta();
153  mcphi[nmc] = p.phi();
154  mcvx[nmc] = p.vx();
155  mcvy[nmc] = p.vy();
156  mcvz[nmc] = p.vz();
157 
158  if ((mcpid[nmc]==24)||(mcpid[nmc]==-24)) { // Checking W -> e/mu nu
159  size_t idg = p.numberOfDaughters();
160  for (size_t j=0; j != idg; ++j){
161  const reco::Candidate & d = *p.daughter(j);
162  if ((d.pdgId()==11)||(d.pdgId()==-11)){wel += 1;}
163  if ((d.pdgId()==13)||(d.pdgId()==-13)){wmu += 1;}
164 // if ( (abs(d.pdgId())!=24) && ((mcpid[nmc])*(d.pdgId())>0) )
165 // {std::cout << "Wrong sign between mother-W and daughter !" << std::endl;}
166  }
167  }
168  if (mcpid[nmc]==23) { // Checking Z -> 2 e/mu
169  size_t idg = p.numberOfDaughters();
170  for (size_t j=0; j != idg; ++j){
171  const reco::Candidate & d = *p.daughter(j);
172  if (d.pdgId()==11){zee += 1;}
173  if (d.pdgId()==-11){zee += 2;}
174  if (d.pdgId()==13){zmumu += 1;}
175  if (d.pdgId()==-13){zmumu += 2;}
176  }
177  }
178 
179  // Set-up flags, based on Pythia-generator information, for avoiding double-counting events when
180  // using both pp->{e,mu}X AND QCD samples
181 // if (((mcpid[nmc]==13)||(mcpid[nmc]==-13))&&(mcpt[nmc]>2.5)) {mu3 += 1;} // Flag for muons with pT > 2.5 GeV/c
182  if (((mcpid[nmc]==11)||(mcpid[nmc]==-11))&&(mcpt[nmc]>2.5)) {el3 += 1;} // Flag for electrons with pT > 2.5 GeV/c
183 
184  if (mcpid[nmc]==-5) {mab += 1;} // Flag for bbar
185  if (mcpid[nmc]==5) {mbb += 1;} // Flag for b
186 
187  if ((mcpid[nmc]==13)||(mcpid[nmc]==-13))
188  {if (p.pt()>ptMuMax) {ptMuMax=p.pt();} } // Save max pt of generated Muons
189  if ((mcpid[nmc]==11)||(mcpid[nmc]==-11))
190  {if (p.pt() > ptEleMax) ptEleMax=p.pt();} // Save max pt of generated Electrons
191 
192  nmc++;
193  }
194 
195  }
196  // else {std::cout << "%HLTMCtruth -- No MC truth information" << std::endl;}
197 
198  nmcpart = nmc;
199  nmu3 = mu3;
200  nel3 = el3;
201  nbb = mbb;
202  nab = mab;
203  nwenu = wel;
204  nwmunu = wmu;
205  if((zee%3)==0){nzee = zee/3;}
206 // else {std::cout << "Z does not decay in e+ e- !" << std::endl;}
207  if ((zmumu%3)==0){nzmumu = zmumu/3;}
208 // else {std::cout << "Z does not decay in mu+ mu- !" << std::endl;}
209 
210  }
211 
212 }
int * mcpid
Definition: HLTMCtruth.h:49
bool _Gen
Definition: HLTMCtruth.h:55
float * mcpt
Definition: HLTMCtruth.h:48
virtual double vx() const =0
x coordinate of vertex position
float pthatf
Definition: HLTMCtruth.h:52
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
size_type size() const
Definition: weight.py:1
float weightf
Definition: HLTMCtruth.h:52
virtual double vy() const =0
y coordinate of vertex position
float * mceta
Definition: HLTMCtruth.h:48
int nmcpart
Definition: HLTMCtruth.h:50
virtual int status() const =0
status word
int nzmumu
Definition: HLTMCtruth.h:50
float ptEleMax
Definition: HLTMCtruth.h:53
float ptMuMax
Definition: HLTMCtruth.h:53
virtual int pdgId() const =0
PDG identifier.
T sqrt(T t)
Definition: SSEVec.h:18
float * mcvy
Definition: HLTMCtruth.h:48
int npubx0
Definition: HLTMCtruth.h:51
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool _Monte
Definition: HLTMCtruth.h:55
float weightsignf
Definition: HLTMCtruth.h:52
bool isValid() const
Definition: HandleBase.h:74
virtual double eta() const =0
momentum pseudorapidity
virtual double pt() const =0
transverse momentum
float * mcvx
Definition: HLTMCtruth.h:48
float * mcphi
Definition: HLTMCtruth.h:48
float * mcvz
Definition: HLTMCtruth.h:48
int nwmunu
Definition: HLTMCtruth.h:50
virtual double vz() const =0
z coordinate of vertex position
virtual size_type numberOfDaughters() const =0
number of daughters
virtual double phi() const =0
momentum azimuthal angle
int npuvertbx0
Definition: HLTMCtruth.h:51
int * mcstatus
Definition: HLTMCtruth.h:49
void HLTMCtruth::setup ( const edm::ParameterSet pSet,
TTree *  tree 
)

Definition at line 24 of file HLTMCtruth.cc.

References _Debug, _Gen, _Monte, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNames(), mceta, mcphi, mcpid, mcpt, mcstatus, mcvx, mcvy, mcvz, nab, nbb, nel3, nmcpart, nmu3, npubx0, npuvertbx0, nwenu, nwmunu, nzee, nzmumu, ptEleMax, pthatf, ptMuMax, weightf, and weightsignf.

Referenced by HLTBitAnalyzer::HLTBitAnalyzer().

24  {
25 
26  edm::ParameterSet myMCParams = pSet.getParameter<edm::ParameterSet>("RunParameters") ;
27  std::vector<std::string> parameterNames = myMCParams.getParameterNames() ;
28 
29  for (auto & parameterName : parameterNames){
30  if ( parameterName == "Monte" ) _Monte = myMCParams.getParameter<bool>( parameterName );
31  else if ( parameterName == "GenTracks" ) _Gen = myMCParams.getParameter<bool>( parameterName );
32  else if ( parameterName == "Debug" ) _Debug = myMCParams.getParameter<bool>( parameterName );
33  }
34 
35  const int kMaxMcTruth = 10000;
36  mcpid = new int[kMaxMcTruth];
37  mcstatus = new int[kMaxMcTruth];
38  mcvx = new float[kMaxMcTruth];
39  mcvy = new float[kMaxMcTruth];
40  mcvz = new float[kMaxMcTruth];
41  mcpt = new float[kMaxMcTruth];
42  mceta = new float[kMaxMcTruth];
43  mcphi = new float[kMaxMcTruth];
44 
45  // MCtruth-specific branches of the tree
46  HltTree->Branch("NMCpart",&nmcpart,"NMCpart/I");
47  HltTree->Branch("MCpid",mcpid,"MCpid[NMCpart]/I");
48  HltTree->Branch("MCstatus",mcstatus,"MCstatus[NMCpart]/I");
49  HltTree->Branch("MCvtxX",mcvx,"MCvtxX[NMCpart]/F");
50  HltTree->Branch("MCvtxY",mcvy,"MCvtxY[NMCpart]/F");
51  HltTree->Branch("MCvtxZ",mcvz,"MCvtxZ[NMCpart]/F");
52  HltTree->Branch("MCpt",mcpt,"MCpt[NMCpart]/F");
53  HltTree->Branch("MCeta",mceta,"MCeta[NMCpart]/F");
54  HltTree->Branch("MCphi",mcphi,"MCphi[NMCpart]/F");
55  HltTree->Branch("MCPtHat",&pthatf,"MCPtHat/F");
56  HltTree->Branch("MCWeight",&weightf,"MCWeight/F");
57  HltTree->Branch("MCWeightSign",&weightsignf,"MCWeightSign/F");
58  HltTree->Branch("MCmu3",&nmu3,"MCmu3/I");
59  HltTree->Branch("MCel3",&nel3,"MCel3/I");
60  HltTree->Branch("MCbb",&nbb,"MCbb/I");
61  HltTree->Branch("MCab",&nab,"MCab/I");
62  HltTree->Branch("MCWenu",&nwenu,"MCWenu/I");
63  HltTree->Branch("MCWmunu",&nwmunu,"MCmunu/I");
64  HltTree->Branch("MCZee",&nzee,"MCZee/I");
65  HltTree->Branch("MCZmumu",&nzmumu,"MCZmumu/I");
66  HltTree->Branch("MCptEleMax",&ptEleMax,"MCptEleMax/F");
67  HltTree->Branch("MCptMuMax",&ptMuMax,"MCptMuMax/F");
68  HltTree->Branch("NPUTrueBX0",&npubx0, "NPUTrueBX0/I");
69  HltTree->Branch("NPUgenBX0",&npuvertbx0, "NPUgenBX0/I");
70 
71 }
T getParameter(std::string const &) const
int * mcpid
Definition: HLTMCtruth.h:49
bool _Gen
Definition: HLTMCtruth.h:55
float * mcpt
Definition: HLTMCtruth.h:48
float pthatf
Definition: HLTMCtruth.h:52
float weightf
Definition: HLTMCtruth.h:52
bool _Debug
Definition: HLTMCtruth.h:55
float * mceta
Definition: HLTMCtruth.h:48
int nmcpart
Definition: HLTMCtruth.h:50
int nzmumu
Definition: HLTMCtruth.h:50
float ptEleMax
Definition: HLTMCtruth.h:53
float ptMuMax
Definition: HLTMCtruth.h:53
float * mcvy
Definition: HLTMCtruth.h:48
int npubx0
Definition: HLTMCtruth.h:51
bool _Monte
Definition: HLTMCtruth.h:55
float weightsignf
Definition: HLTMCtruth.h:52
std::vector< std::string > getParameterNames() const
float * mcvx
Definition: HLTMCtruth.h:48
float * mcphi
Definition: HLTMCtruth.h:48
float * mcvz
Definition: HLTMCtruth.h:48
int nwmunu
Definition: HLTMCtruth.h:50
int npuvertbx0
Definition: HLTMCtruth.h:51
int * mcstatus
Definition: HLTMCtruth.h:49

Member Data Documentation

bool HLTMCtruth::_Debug
private

Definition at line 55 of file HLTMCtruth.h.

Referenced by HLTMCtruth(), and setup().

bool HLTMCtruth::_Gen
private

Definition at line 55 of file HLTMCtruth.h.

Referenced by analyze(), HLTMCtruth(), and setup().

bool HLTMCtruth::_Monte
private

Definition at line 55 of file HLTMCtruth.h.

Referenced by analyze(), HLTMCtruth(), and setup().

float * HLTMCtruth::mceta
private

Definition at line 48 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

float * HLTMCtruth::mcphi
private

Definition at line 48 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

int* HLTMCtruth::mcpid
private

Definition at line 49 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

float * HLTMCtruth::mcpt
private

Definition at line 48 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

int * HLTMCtruth::mcstatus
private

Definition at line 49 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

float* HLTMCtruth::mcvx
private

Definition at line 48 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

float * HLTMCtruth::mcvy
private

Definition at line 48 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

float * HLTMCtruth::mcvz
private

Definition at line 48 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

int HLTMCtruth::nab
private

Definition at line 50 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

int HLTMCtruth::nbb
private

Definition at line 50 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

int HLTMCtruth::nel3
private

Definition at line 50 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

int HLTMCtruth::nmcpart
private

Definition at line 50 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

int HLTMCtruth::nmu3
private

Definition at line 50 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

int HLTMCtruth::npubx0
private

Definition at line 51 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

int HLTMCtruth::npuvertbx0
private

Definition at line 51 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

int HLTMCtruth::nwenu
private

Definition at line 50 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

int HLTMCtruth::nwmunu
private

Definition at line 50 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

int HLTMCtruth::nzee
private

Definition at line 50 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

int HLTMCtruth::nzmumu
private

Definition at line 50 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

float HLTMCtruth::ptEleMax
private

Definition at line 53 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

float HLTMCtruth::pthatf
private

Definition at line 52 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

float HLTMCtruth::ptMuMax
private

Definition at line 53 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

float HLTMCtruth::weightf
private

Definition at line 52 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

float HLTMCtruth::weightsignf
private

Definition at line 52 of file HLTMCtruth.h.

Referenced by analyze(), and setup().