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 Attributes
HLTMCtruth Class Reference

#include <HLTMCtruth.h>

Public Member Functions

void analyze (const edm::Handle< reco::CandidateView > &mctruth, const double &pthat, 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 _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 nwenu
 
int nwmunu
 
int nzee
 
int nzmumu
 
float ptEleMax
 
float pthatf
 
float ptMuMax
 

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, and _Monte.

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

Member Function Documentation

void HLTMCtruth::analyze ( const edm::Handle< reco::CandidateView > &  mctruth,
const double &  pthat,
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 69 of file HLTMCtruth.cc.

References _Monte, abs, reco::Candidate::daughter(), reco::Candidate::eta(), eta(), i, edm::HandleBase::isValid(), j, mceta, mcphi, mcpid, mcpt, mcstatus, mcvx, mcvy, mcvz, nab, nbb, nel3, nmcpart, nmu3, npubx0, reco::Candidate::numberOfDaughters(), nwenu, nwmunu, nzee, nzmumu, AlCaHLTBitMon_ParallelJobs::p, reco::Candidate::pdgId(), reco::Candidate::phi(), reco::Candidate::pt(), ptEleMax, pthatf, ptMuMax, alignCSCRings::r, mathSSE::sqrt(), reco::Candidate::status(), reco::Candidate::vx(), reco::Candidate::vy(), reco::Candidate::vz(), x, detailsBasic3DVector::y, and detailsBasic3DVector::z.

Referenced by HLTBitAnalyzer::analyze(), and HLTAnalyzer::analyze().

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

Definition at line 23 of file HLTMCtruth.cc.

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

Referenced by HLTAnalyzer::HLTAnalyzer(), and HLTBitAnalyzer::HLTBitAnalyzer().

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

Member Data Documentation

bool HLTMCtruth::_Debug
private

Definition at line 54 of file HLTMCtruth.h.

Referenced by HLTMCtruth(), and setup().

bool HLTMCtruth::_Monte
private

Definition at line 54 of file HLTMCtruth.h.

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

float * HLTMCtruth::mceta
private

Definition at line 47 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

float * HLTMCtruth::mcphi
private

Definition at line 47 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

int* HLTMCtruth::mcpid
private

Definition at line 48 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

float * HLTMCtruth::mcpt
private

Definition at line 47 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

int * HLTMCtruth::mcstatus
private

Definition at line 48 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

float* HLTMCtruth::mcvx
private

Definition at line 47 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

float * HLTMCtruth::mcvy
private

Definition at line 47 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

float * HLTMCtruth::mcvz
private

Definition at line 47 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

int HLTMCtruth::nab
private

Definition at line 49 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

int HLTMCtruth::nbb
private

Definition at line 49 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

int HLTMCtruth::nel3
private

Definition at line 49 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

int HLTMCtruth::nmcpart
private

Definition at line 49 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

int HLTMCtruth::nmu3
private

Definition at line 49 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

int HLTMCtruth::npubx0
private

Definition at line 50 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

int HLTMCtruth::nwenu
private

Definition at line 49 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

int HLTMCtruth::nwmunu
private

Definition at line 49 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

int HLTMCtruth::nzee
private

Definition at line 49 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

int HLTMCtruth::nzmumu
private

Definition at line 49 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

float HLTMCtruth::ptEleMax
private

Definition at line 52 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

float HLTMCtruth::pthatf
private

Definition at line 51 of file HLTMCtruth.h.

Referenced by analyze(), and setup().

float HLTMCtruth::ptMuMax
private

Definition at line 52 of file HLTMCtruth.h.

Referenced by analyze(), and setup().