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::HLTMCtruth ( )

Definition at line 15 of file HLTMCtruth.cc.

15  {
16  //set parameter defaults
17  _Monte = false;
18  _Gen = false;
19  _Debug = false;
20 }

References _Debug, _Gen, and _Monte.

Member Function Documentation

◆ analyze()

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.

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

References _Gen, _Monte, funct::abs(), L1TStage2uGTEmulatorClient_cff::BX, ztail::d, PVValHelper::eta, mps_fire::i, dqmiolumiharvest::j, mceta, mcphi, mcpid, mcpt, mcstatus, HLTBitAnalyser_cfi::mctruth, mcvx, mcvy, mcvz, nab, nbb, nel3, nmcpart, nmu3, npubx0, npuvertbx0, nwenu, nwmunu, nzee, nzmumu, AlCaHLTBitMon_ParallelJobs::p, EgammaValidation_cff::pdgid, DiDispStaMuonMonitor_cfi::pt, ptEleMax, pthatf, ptMuMax, alignCSCRings::r, TrackCandidateProducer_cfi::simTracks, HGCalValidator_cfi::simVertices, mathSSE::sqrt(), mps_merge::weight, weightf, weightsignf, x, y, and z.

Referenced by HLTBitAnalyzer::analyze().

◆ setup()

void HLTMCtruth::setup ( const edm::ParameterSet pSet,
TTree *  tree 
)

Definition at line 23 of file HLTMCtruth.cc.

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

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().

Member Data Documentation

◆ _Debug

bool HLTMCtruth::_Debug
private

Definition at line 54 of file HLTMCtruth.h.

Referenced by HLTMCtruth(), and setup().

◆ _Gen

bool HLTMCtruth::_Gen
private

Definition at line 54 of file HLTMCtruth.h.

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

◆ _Monte

bool HLTMCtruth::_Monte
private

Definition at line 54 of file HLTMCtruth.h.

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

◆ mceta

float * HLTMCtruth::mceta
private

Definition at line 47 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

◆ mcphi

float * HLTMCtruth::mcphi
private

Definition at line 47 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

◆ mcpid

int* HLTMCtruth::mcpid
private

Definition at line 48 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

◆ mcpt

float * HLTMCtruth::mcpt
private

Definition at line 47 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

◆ mcstatus

int * HLTMCtruth::mcstatus
private

Definition at line 48 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

◆ mcvx

float* HLTMCtruth::mcvx
private

Definition at line 47 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

◆ mcvy

float * HLTMCtruth::mcvy
private

Definition at line 47 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

◆ mcvz

float * HLTMCtruth::mcvz
private

Definition at line 47 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

◆ nab

int HLTMCtruth::nab
private

Definition at line 49 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

◆ nbb

int HLTMCtruth::nbb
private

Definition at line 49 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

◆ nel3

int HLTMCtruth::nel3
private

Definition at line 49 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

◆ nmcpart

int HLTMCtruth::nmcpart
private

Definition at line 49 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

◆ nmu3

int HLTMCtruth::nmu3
private

Definition at line 49 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

◆ npubx0

int HLTMCtruth::npubx0
private

Definition at line 50 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

◆ npuvertbx0

int HLTMCtruth::npuvertbx0
private

Definition at line 50 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

◆ nwenu

int HLTMCtruth::nwenu
private

Definition at line 49 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

◆ nwmunu

int HLTMCtruth::nwmunu
private

Definition at line 49 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

◆ nzee

int HLTMCtruth::nzee
private

Definition at line 49 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

◆ nzmumu

int HLTMCtruth::nzmumu
private

Definition at line 49 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

◆ ptEleMax

float HLTMCtruth::ptEleMax
private

Definition at line 52 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

◆ pthatf

float HLTMCtruth::pthatf
private

Definition at line 51 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

◆ ptMuMax

float HLTMCtruth::ptMuMax
private

Definition at line 52 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

◆ weightf

float HLTMCtruth::weightf
private

Definition at line 51 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

◆ weightsignf

float HLTMCtruth::weightsignf
private

Definition at line 51 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

HLTMCtruth::mcstatus
int * mcstatus
Definition: HLTMCtruth.h:48
DDAxes::y
mps_fire.i
i
Definition: mps_fire.py:428
HLTMCtruth::weightf
float weightf
Definition: HLTMCtruth.h:51
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
HLTMCtruth::_Debug
bool _Debug
Definition: HLTMCtruth.h:54
mps_merge.weight
weight
Definition: mps_merge.py:88
HLTBitAnalyser_cfi.mctruth
mctruth
GEN objects.
Definition: HLTBitAnalyser_cfi.py:17
HLTMCtruth::_Gen
bool _Gen
Definition: HLTMCtruth.h:54
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
TrackCandidateProducer_cfi.simTracks
simTracks
Definition: TrackCandidateProducer_cfi.py:15
HLTMCtruth::mcpid
int * mcpid
Definition: HLTMCtruth.h:48
HLTMCtruth::nzmumu
int nzmumu
Definition: HLTMCtruth.h:49
DDAxes::x
HLTMCtruth::mcpt
float * mcpt
Definition: HLTMCtruth.h:47
HLTMCtruth::ptMuMax
float ptMuMax
Definition: HLTMCtruth.h:52
HLTMCtruth::nbb
int nbb
Definition: HLTMCtruth.h:49
HLTMCtruth::ptEleMax
float ptEleMax
Definition: HLTMCtruth.h:52
HLTMCtruth::nzee
int nzee
Definition: HLTMCtruth.h:49
PVValHelper::eta
Definition: PVValidationHelpers.h:70
HLTMCtruth::mceta
float * mceta
Definition: HLTMCtruth.h:47
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
HLTMCtruth::nel3
int nel3
Definition: HLTMCtruth.h:49
DDAxes::z
HLTMCtruth::_Monte
bool _Monte
Definition: HLTMCtruth.h:54
HLTMCtruth::nmcpart
int nmcpart
Definition: HLTMCtruth.h:49
edm::ParameterSet
Definition: ParameterSet.h:47
HLTMCtruth::npubx0
int npubx0
Definition: HLTMCtruth.h:50
HLTMCtruth::mcvx
float * mcvx
Definition: HLTMCtruth.h:47
edm::ParameterSet::getParameterNames
std::vector< std::string > getParameterNames() const
Definition: ParameterSet.cc:663
HLTMCtruth::mcvy
float * mcvy
Definition: HLTMCtruth.h:47
HLTMCtruth::nwenu
int nwenu
Definition: HLTMCtruth.h:49
HLTMCtruth::weightsignf
float weightsignf
Definition: HLTMCtruth.h:51
HLTMCtruth::nmu3
int nmu3
Definition: HLTMCtruth.h:49
reco::Candidate
Definition: Candidate.h:27
alignCSCRings.r
r
Definition: alignCSCRings.py:93
HLTMCtruth::npuvertbx0
int npuvertbx0
Definition: HLTMCtruth.h:50
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
L1TStage2uGTEmulatorClient_cff.BX
BX
Definition: L1TStage2uGTEmulatorClient_cff.py:9
ztail.d
d
Definition: ztail.py:151
HLTMCtruth::mcvz
float * mcvz
Definition: HLTMCtruth.h:47
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
HGCalValidator_cfi.simVertices
simVertices
Definition: HGCalValidator_cfi.py:57
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
HLTMCtruth::nwmunu
int nwmunu
Definition: HLTMCtruth.h:49
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
EgammaValidation_cff.pdgid
pdgid
Definition: EgammaValidation_cff.py:30
HLTMCtruth::mcphi
float * mcphi
Definition: HLTMCtruth.h:47
weight
Definition: weight.py:1
HLTMCtruth::nab
int nab
Definition: HLTMCtruth.h:49
HLTMCtruth::pthatf
float pthatf
Definition: HLTMCtruth.h:51