#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 |
Definition at line 10 of file CaloMeanResponse.h.
CaloMeanResponse::CaloMeanResponse | ( | edm::ParameterSet const & | p | ) |
Definition at line 12 of file CaloMeanResponse.cc.
References edm::ParameterSet::getParameter(), readResponse(), scale, AlCaHLTBitMon_QueryRunRegistry::string, and useTable.
{ edm::ParameterSet m_p = p.getParameter<edm::ParameterSet>("CaloResponse"); edm::FileInPath fp = m_p.getParameter<edm::FileInPath>("ResponseFile"); std::string fName = fp.fullPath(); useTable = m_p.getParameter<bool>("UseResponseTable"); scale = m_p.getParameter<double>("ResponseScale"); edm::LogInfo("CaloSim") << "CaloMeanResponse initialized with scale " << scale << " and use Table " << useTable << " from file " << fName; readResponse (fName); }
CaloMeanResponse::~CaloMeanResponse | ( | ) | [virtual] |
Definition at line 26 of file CaloMeanResponse.cc.
{}
double CaloMeanResponse::getWeight | ( | int | genPID, |
double | genP | ||
) |
Definition at line 28 of file CaloMeanResponse.cc.
References newFWLiteAna::found, i, LogDebug, piLast, pionMomentum, pionTable, pionTypes, pLast, protonMomentum, protonTable, protonTypes, scale, useTable, and histoStyle::weight.
Referenced by CaloSD::getResponseWt().
{ double weight = 1; bool found=false; for (unsigned int i=0; i<pionTypes.size(); i++) { if (genPID == pionTypes[i]) { found = true; break; } } if (found) { weight = scale; if (useTable) { if (piLast >= 0) weight *= pionTable[piLast]; for (unsigned int i=0; i<pionTable.size(); i++) { if (genP < pionMomentum[i]) { if (i == 0) weight = scale*pionTable[i]; else weight = scale*((pionTable[i-1]*(pionMomentum[i]-genP)+ pionTable[i]*(genP-pionMomentum[i-1]))/ (pionMomentum[i]-pionMomentum[i-1])); break; } } } #ifdef DebugLog LogDebug("CaloSim") << "CaloMeanResponse::getWeight PID " << genPID << " uses pion list and gets weight " << weight << " for momentum " << genP/GeV << " GeV/c"; #endif } else { for (unsigned int i=0; i<protonTypes.size(); i++) { if (genPID == protonTypes[i]) { found = true; break; } } if (found) { weight = scale; if (useTable) { if (pLast >= 0) weight *= protonTable[pLast]; for (unsigned int i=0; i<protonTable.size(); i++) { if (genP < protonMomentum[i]) { if (i == 0) weight = scale*protonTable[i]; else weight = scale*((protonTable[i-1]*(protonMomentum[i]-genP)+ protonTable[i]*(genP-protonMomentum[i-1]))/ (protonMomentum[i]-protonMomentum[i-1])); break; } } } #ifdef DebugLog LogDebug("CaloSim") << "CaloMeanResponse::getWeight PID " << genPID << " uses proton list and gets weight " << weight << " for momentum " << genP/GeV << " GeV/c"; #endif } else { #ifdef DebugLog LogDebug("CaloSim") << "CaloMeanResponse::getWeight PID " << genPID << " is not in either lists and weight " << weight; #endif } } return weight; }
void CaloMeanResponse::readResponse | ( | std::string | fName | ) | [private] |
Definition at line 92 of file CaloMeanResponse.cc.
References i, recoMuon::in, EdgesToViz::infile, LogDebug, npart, evf::utils::pid, piLast, pionMomentum, pionTable, pionTypes, pLast, protonMomentum, protonTable, and protonTypes.
Referenced by CaloMeanResponse().
{ std::ifstream infile; infile.open(fName.c_str(), std::ios::in); if (infile) { int nene, npart, pid; double ene, responseData, responseMC, ratio; // First read the pion data infile >> nene >> npart; for (int i=0; i<npart; i++) { infile >> pid; pionTypes.push_back(pid); } for (int i=0; i<nene; i++) { infile >> ene >> responseData >> responseMC; if (responseMC > 0) ratio = responseData/responseMC; else ratio = 1; pionMomentum.push_back(ene*GeV); pionTable.push_back(ratio); } // Then read the proton data infile >> nene >> npart; for (int i=0; i<npart; i++) { infile >> pid; protonTypes.push_back(pid); } for (int i=0; i<nene; i++) { infile >> ene >> responseData >> responseMC; if (responseMC > 0) ratio = responseData/responseMC; else ratio = 1; protonMomentum.push_back(ene*GeV); protonTable.push_back(ratio); } infile.close(); } piLast = (int)(pionTable.size()) - 1; pLast = (int)(protonTable.size()) - 1; #ifdef DebugLog LogDebug("CaloSim") << "CaloMeanResponse::readResponse finds " << pionTypes.size() << " particles to use pion response" << " map with a table of " << pionTable.size() << " data points " << piLast; for (unsigned int i=0; i<pionTypes.size(); i++) LogDebug("CaloSim") << "Particle ID[" << i << "] = " << pionTypes[i]; for (unsigned int i=0; i<pionTable.size(); i++) LogDebug("CaloSim") << "Momentum[" << i << "] (" << pionMomentum[i]/GeV << " GeV/c) --> " << pionTable[i]; LogDebug("CaloSim") << "CaloMeanResponse::readResponse finds " << protonTypes.size() << " particles to use proton " << "response map with a table of " << protonTable.size() << " data points " << pLast; for (unsigned int i=0; i<protonTypes.size(); i++) LogDebug("CaloSim") << "Particle ID[" << i << "] = " << protonTypes[i]; for (unsigned int i=0; i<protonTable.size(); i++) LogDebug("CaloSim") << "Momentum[" << i << "] (" << protonMomentum[i]/GeV << " GeV/c) --> " << protonTable[i]; #endif }
int CaloMeanResponse::piLast [private] |
Definition at line 24 of file CaloMeanResponse.h.
Referenced by getWeight(), and readResponse().
std::vector<double> CaloMeanResponse::pionMomentum [private] |
Definition at line 26 of file CaloMeanResponse.h.
Referenced by getWeight(), and readResponse().
std::vector<double> CaloMeanResponse::pionTable [private] |
Definition at line 26 of file CaloMeanResponse.h.
Referenced by getWeight(), and readResponse().
std::vector<int> CaloMeanResponse::pionTypes [private] |
Definition at line 25 of file CaloMeanResponse.h.
Referenced by getWeight(), and readResponse().
int CaloMeanResponse::pLast [private] |
Definition at line 24 of file CaloMeanResponse.h.
Referenced by getWeight(), and readResponse().
std::vector<double> CaloMeanResponse::protonMomentum [private] |
Definition at line 27 of file CaloMeanResponse.h.
Referenced by getWeight(), and readResponse().
std::vector<double> CaloMeanResponse::protonTable [private] |
Definition at line 27 of file CaloMeanResponse.h.
Referenced by getWeight(), and readResponse().
std::vector<int> CaloMeanResponse::protonTypes [private] |
Definition at line 25 of file CaloMeanResponse.h.
Referenced by getWeight(), and readResponse().
double CaloMeanResponse::scale [private] |
Definition at line 23 of file CaloMeanResponse.h.
Referenced by CaloMeanResponse(), and getWeight().
bool CaloMeanResponse::useTable [private] |
Definition at line 22 of file CaloMeanResponse.h.
Referenced by CaloMeanResponse(), and getWeight().