CMS 3D CMS Logo

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

#include <CaloMeanResponse.h>

Public Member Functions

 CaloMeanResponse (edm::ParameterSet const &p)
 
double getWeight (int genPID, double genP)
 
virtual ~CaloMeanResponse ()
 

Private Member Functions

void readResponse (std::string fName)
 

Private Attributes

int piLast
 
std::vector< double > pionMomentum
 
std::vector< double > pionTable
 
std::vector< int > pionTypes
 
int pLast
 
std::vector< double > protonMomentum
 
std::vector< double > protonTable
 
std::vector< int > protonTypes
 
double scale
 
bool useTable
 

Detailed Description

Definition at line 10 of file CaloMeanResponse.h.

Constructor & Destructor Documentation

◆ CaloMeanResponse()

CaloMeanResponse::CaloMeanResponse ( edm::ParameterSet const &  p)

Definition at line 12 of file CaloMeanResponse.cc.

12  {
13  edm::ParameterSet m_p = p.getParameter<edm::ParameterSet>("CaloResponse");
14  edm::FileInPath fp = m_p.getParameter<edm::FileInPath>("ResponseFile");
15  std::string fName = fp.fullPath();
16  useTable = m_p.getParameter<bool>("UseResponseTable");
17  scale = m_p.getParameter<double>("ResponseScale");
18  edm::LogVerbatim("CaloSim") << "CaloMeanResponse initialized with scale " << scale << " and use Table " << useTable
19  << " from file " << fName;
21 }

References MainPageGenerator::fName, personalPlayback::fp, edm::ParameterSet::getParameter(), AlCaHLTBitMon_ParallelJobs::p, readResponse(), scale, AlCaHLTBitMon_QueryRunRegistry::string, and useTable.

◆ ~CaloMeanResponse()

CaloMeanResponse::~CaloMeanResponse ( )
virtual

Definition at line 23 of file CaloMeanResponse.cc.

23 {}

Member Function Documentation

◆ getWeight()

double CaloMeanResponse::getWeight ( int  genPID,
double  genP 
)

Definition at line 25 of file CaloMeanResponse.cc.

25  {
26  double weight = 1;
27  bool found = false;
28  for (unsigned int i = 0; i < pionTypes.size(); i++) {
29  if (genPID == pionTypes[i]) {
30  found = true;
31  break;
32  }
33  }
34  if (found) {
35  weight = scale;
36  if (useTable) {
37  if (piLast >= 0)
39  for (unsigned int i = 0; i < pionTable.size(); i++) {
40  if (genP < pionMomentum[i]) {
41  if (i == 0)
42  weight = scale * pionTable[i];
43  else
44  weight =
45  scale * ((pionTable[i - 1] * (pionMomentum[i] - genP) + pionTable[i] * (genP - pionMomentum[i - 1])) /
46  (pionMomentum[i] - pionMomentum[i - 1]));
47  break;
48  }
49  }
50  }
51 #ifdef EDM_ML_DEBUG
52  edm::LogVerbatim("CaloSim") << "CaloMeanResponse::getWeight PID " << genPID << " uses pion list and gets weight "
53  << weight << " for momentum " << genP / GeV << " GeV/c";
54 #endif
55  } else {
56  for (unsigned int i = 0; i < protonTypes.size(); i++) {
57  if (genPID == protonTypes[i]) {
58  found = true;
59  break;
60  }
61  }
62  if (found) {
63  weight = scale;
64  if (useTable) {
65  if (pLast >= 0)
67  for (unsigned int i = 0; i < protonTable.size(); i++) {
68  if (genP < protonMomentum[i]) {
69  if (i == 0)
71  else
72  weight =
73  scale *
74  ((protonTable[i - 1] * (protonMomentum[i] - genP) + protonTable[i] * (genP - protonMomentum[i - 1])) /
75  (protonMomentum[i] - protonMomentum[i - 1]));
76  break;
77  }
78  }
79  }
80 #ifdef EDM_ML_DEBUG
81  edm::LogVerbatim("CaloSim") << "CaloMeanResponse::getWeight PID " << genPID << " uses proton list and gets "
82  << "weight " << weight << " for momentum " << genP / GeV << " GeV/c";
83 #endif
84  } else {
85 #ifdef EDM_ML_DEBUG
86  edm::LogVerbatim("CaloSim") << "CaloMeanResponse::getWeight PID " << genPID << " is not in either lists and "
87  << "weight " << weight;
88 #endif
89  }
90  }
91  return weight;
92 }

References newFWLiteAna::found, GeV, mps_fire::i, piLast, pionMomentum, pionTable, pionTypes, pLast, protonMomentum, protonTable, protonTypes, scale, useTable, and mps_merge::weight.

◆ readResponse()

void CaloMeanResponse::readResponse ( std::string  fName)
private

Definition at line 94 of file CaloMeanResponse.cc.

94  {
95  std::ifstream infile;
96  infile.open(fName.c_str(), std::ios::in);
97 
98  if (infile) {
99  int nene, npart, pid;
100  double ene, responseData, responseMC, ratio;
101 
102  // First read the pion data
103  infile >> nene >> npart;
104  for (int i = 0; i < npart; i++) {
105  infile >> pid;
106  pionTypes.push_back(pid);
107  }
108  for (int i = 0; i < nene; i++) {
109  infile >> ene >> responseData >> responseMC;
110  if (responseMC > 0)
111  ratio = responseData / responseMC;
112  else
113  ratio = 1;
114  pionMomentum.push_back(ene * GeV);
115  pionTable.push_back(ratio);
116  }
117 
118  // Then read the proton data
119  infile >> nene >> npart;
120  for (int i = 0; i < npart; i++) {
121  infile >> pid;
122  protonTypes.push_back(pid);
123  }
124  for (int i = 0; i < nene; i++) {
125  infile >> ene >> responseData >> responseMC;
126  if (responseMC > 0)
127  ratio = responseData / responseMC;
128  else
129  ratio = 1;
130  protonMomentum.push_back(ene * GeV);
131  protonTable.push_back(ratio);
132  }
133  infile.close();
134  }
135 
136  piLast = (int)(pionTable.size()) - 1;
137  pLast = (int)(protonTable.size()) - 1;
138 #ifdef EDM_ML_DEBUG
139  edm::LogVerbatim("CaloSim") << "CaloMeanResponse::readResponse finds " << pionTypes.size()
140  << " particles to use pion "
141  << "response map with a table of " << pionTable.size() << " data points " << piLast;
142  for (unsigned int i = 0; i < pionTypes.size(); i++)
143  edm::LogVerbatim("CaloSim") << "Particle ID[" << i << "] = " << pionTypes[i];
144  for (unsigned int i = 0; i < pionTable.size(); i++)
145  edm::LogVerbatim("CaloSim") << "Momentum[" << i << "] (" << pionMomentum[i] / GeV << " GeV/c) --> " << pionTable[i];
146  edm::LogVerbatim("CaloSim") << "CaloMeanResponse::readResponse finds " << protonTypes.size() << " particles to use "
147  << "proton response map with a table of " << protonTable.size() << " data points "
148  << pLast;
149  for (unsigned int i = 0; i < protonTypes.size(); i++)
150  edm::LogVerbatim("CaloSim") << "Particle ID[" << i << "] = " << protonTypes[i];
151  for (unsigned int i = 0; i < protonTable.size(); i++)
152  edm::LogVerbatim("CaloSim") << "Momentum[" << i << "] (" << protonMomentum[i] / GeV << " GeV/c) --> "
153  << protonTable[i];
154 #endif
155 }

References MainPageGenerator::fName, GeV, mps_fire::i, recoMuon::in, timingPdfMaker::infile, createfilelist::int, npart, piLast, pionMomentum, pionTable, pionTypes, pLast, protonMomentum, protonTable, protonTypes, and particleFlowDisplacedVertex_cfi::ratio.

Referenced by CaloMeanResponse().

Member Data Documentation

◆ piLast

int CaloMeanResponse::piLast
private

Definition at line 21 of file CaloMeanResponse.h.

Referenced by getWeight(), and readResponse().

◆ pionMomentum

std::vector<double> CaloMeanResponse::pionMomentum
private

Definition at line 23 of file CaloMeanResponse.h.

Referenced by getWeight(), and readResponse().

◆ pionTable

std::vector<double> CaloMeanResponse::pionTable
private

Definition at line 23 of file CaloMeanResponse.h.

Referenced by getWeight(), and readResponse().

◆ pionTypes

std::vector<int> CaloMeanResponse::pionTypes
private

Definition at line 22 of file CaloMeanResponse.h.

Referenced by getWeight(), and readResponse().

◆ pLast

int CaloMeanResponse::pLast
private

Definition at line 21 of file CaloMeanResponse.h.

Referenced by getWeight(), and readResponse().

◆ protonMomentum

std::vector<double> CaloMeanResponse::protonMomentum
private

Definition at line 24 of file CaloMeanResponse.h.

Referenced by getWeight(), and readResponse().

◆ protonTable

std::vector<double> CaloMeanResponse::protonTable
private

Definition at line 24 of file CaloMeanResponse.h.

Referenced by getWeight(), and readResponse().

◆ protonTypes

std::vector<int> CaloMeanResponse::protonTypes
private

Definition at line 22 of file CaloMeanResponse.h.

Referenced by getWeight(), and readResponse().

◆ scale

double CaloMeanResponse::scale
private

Definition at line 20 of file CaloMeanResponse.h.

Referenced by CaloMeanResponse(), and getWeight().

◆ useTable

bool CaloMeanResponse::useTable
private

Definition at line 19 of file CaloMeanResponse.h.

Referenced by CaloMeanResponse(), and getWeight().

mps_fire.i
i
Definition: mps_fire.py:428
CaloMeanResponse::pionTable
std::vector< double > pionTable
Definition: CaloMeanResponse.h:23
mps_merge.weight
weight
Definition: mps_merge.py:88
personalPlayback.fp
fp
Definition: personalPlayback.py:523
CaloMeanResponse::protonTable
std::vector< double > protonTable
Definition: CaloMeanResponse.h:24
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
CaloMeanResponse::pionTypes
std::vector< int > pionTypes
Definition: CaloMeanResponse.h:22
npart
double npart
Definition: HydjetWrapper.h:46
MainPageGenerator.fName
fName
Definition: MainPageGenerator.py:301
edm::FileInPath
Definition: FileInPath.h:61
CaloMeanResponse::pionMomentum
std::vector< double > pionMomentum
Definition: CaloMeanResponse.h:23
particleFlowDisplacedVertex_cfi.ratio
ratio
Definition: particleFlowDisplacedVertex_cfi.py:93
CaloMeanResponse::piLast
int piLast
Definition: CaloMeanResponse.h:21
CaloMeanResponse::useTable
bool useTable
Definition: CaloMeanResponse.h:19
edm::ParameterSet
Definition: ParameterSet.h:47
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
GeV
const double GeV
Definition: MathUtil.h:16
recoMuon::in
Definition: RecoMuonEnumerators.h:6
CaloMeanResponse::readResponse
void readResponse(std::string fName)
Definition: CaloMeanResponse.cc:94
createfilelist.int
int
Definition: createfilelist.py:10
CaloMeanResponse::pLast
int pLast
Definition: CaloMeanResponse.h:21
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
timingPdfMaker.infile
infile
Definition: timingPdfMaker.py:349
CaloMeanResponse::protonTypes
std::vector< int > protonTypes
Definition: CaloMeanResponse.h:22
edm::Log
Definition: MessageLogger.h:70
CaloMeanResponse::scale
double scale
Definition: CaloMeanResponse.h:20
weight
Definition: weight.py:1
CaloMeanResponse::protonMomentum
std::vector< double > protonMomentum
Definition: CaloMeanResponse.h:24