8#include "CLHEP/Random/RandFlat.h"
9#include "CLHEP/Random/RandGaussZiggurat.h"
20 const IInterface* p ) :
23 declareInterface<INSWCalibSmearingTool>(
this);
32 ATH_MSG_ERROR(
"MM or STGC not part of initialized detector layout");
33 return StatusCode::FAILURE;
41 return StatusCode::SUCCESS;
57 return StatusCode::SUCCESS;
61 float efficiencyCut = 0.0;
70 return StatusCode::FAILURE;
74 std::map<Identifier,float>::const_iterator it =
m_hvMap.find(pcb_id);
76 double hv = it->second;
82 return StatusCode::SUCCESS;
87 if ( CLHEP::RandFlat::shoot(rndmEngine, 0. , 1.) > efficiencyCut ) {
91 return StatusCode::SUCCESS;
110 return StatusCode::SUCCESS;
115 float efficiencyCut = 0.0;
124 return StatusCode::FAILURE;
127 std::map<Identifier,float>::const_iterator it =
m_hvMap.find(pcb_id);
129 double hv = it->second;
135 return StatusCode::SUCCESS;
142 charge =
charge + CLHEP::RandGaussZiggurat::shoot(rndmEngine,0.0, chargeSmear);
146 if ( CLHEP::RandFlat::shoot(rndmEngine, 0. , 1.) > efficiencyCut ) {
151 return StatusCode::SUCCESS;
162 return StatusCode::FAILURE;
171 return StatusCode::SUCCESS;
180 time = time + CLHEP::RandGaussZiggurat::shoot(rndmEngine,0.0, timeSmear);
181 charge =
charge + CLHEP::RandGaussZiggurat::shoot(rndmEngine,0.0, chargeSmear);
185 if ( CLHEP::RandFlat::shoot(rndmEngine, 0. , 1.) >
m_channelEfficiency.value()[gasGap-1] ) {
190 return StatusCode::SUCCESS;
204 return StatusCode::SUCCESS;
217 return StatusCode::FAILURE;
219 else if(hv == -1.0) {
227 return StatusCode::SUCCESS;
238 gasGap = (multilayer-1)*4+
m_idHelperSvc->mmIdHelper().gasGap(
id);
242 etaSector < 0 ? etaSector = etaSector + 3 : etaSector = etaSector + 2;
245 int multilayer =
m_idHelperSvc->stgcIdHelper().multilayer(
id);
246 gasGap = (multilayer-1)*4+
m_idHelperSvc->stgcIdHelper().gasGap(
id);
250 etaSector < 0 ? etaSector = etaSector + 4 : etaSector = etaSector + 3;
258 if ( phiSector < 1 || phiSector> (
int)
m_phiSectors.value().size()
261 ATH_MSG_WARNING(
"Wrong phi, eta sector, or gasGap number: " << phiSector <<
" "
262 << etaSector <<
" " << gasGap <<
"Size of m_chargeSmear " <<
m_chargeSmear.value().size() <<
" size of m_etaSectors "<<
m_etaSectors.value().size());
281 std::map<Identifier,float>::const_iterator it =
m_hvMap.find(pcbId);
298 double eff = 1.0/(1+exp(-0.0551*(hv-510.54)));
309 return std::exp(-8.87971 + 0.0224561 * hv) / std::exp(-8.87971 + 0.0224561 * 570);
324 int pcb_strip = channel/1024;
325 pcb_strip = pcb_strip * 1024 + 512;
327 int stationName =
m_idHelperSvc->mmIdHelper().stationName(
id);
350 std::string fileNamesA[16] = {
"A01.txt",
"A02.txt",
"A03.txt",
"A04.txt",
351 "A05.txt",
"A06.txt",
"A07.txt",
"A08.txt",
352 "A09.txt",
"A10.txt",
"A11.txt",
"A12.txt",
353 "A13.txt",
"A14.txt",
"A15.txt",
"A16.txt" };
355 for (
int ifile = 0 ; ifile<16 ; ++ifile) {
359 std::ifstream
file(fileName,std::ios::in);
360 if ( !
file.is_open() ) {
361 ATH_MSG_DEBUG(
"HV File " << fileNamesA[ifile] <<
" not available " );
364 ATH_MSG_INFO(
"Reading HV from configuration file: " << fileName);
371 bool isLM,isSM,isIP,isHO;
374 std::string layerId[4] = {
"L1",
"L2",
"L3",
"L4"};
383 while ( getline(
file,line) ) {
389 std::string secName = fileNamesA[ifile].substr(0,2);
391 if ( secName.substr(0,1)==
"A" ) side = +1;
392 else if ( secName.substr(0,1)==
"C" ) side = -1;
395 return StatusCode::FAILURE;
397 int phiSec = std::stoi(fileNamesA[ifile].substr(1,2));
400 size_t fLM = line.find(
"LM");
401 size_t fSM = line.find(
"SM");
402 isLM = (fLM!=std::string::npos);
403 isSM = (fSM!=std::string::npos);
406 if ( isLM || isSM ) {
409 stationEta = side*std::stoi(line.substr(fSM+2,1));
412 stationEta = side*std::stoi(line.substr(fLM+2,1));
422 isSM ? stationName=55 : stationName=56;
425 std::size_t fIP = line.find(
"IP");
426 isIP = (fIP!=std::string::npos);
427 std::size_t fHO = line.find(
"HO");
428 isHO = (fHO!=std::string::npos);
429 if ( !isIP && !isHO ) {
431 return StatusCode::FAILURE;
433 else if ( isIP && isHO ) {
434 ATH_MSG_ERROR(
"ERROR multilayer id duplicated (IP and HO) ");
435 return StatusCode::FAILURE;
447 for (
int ilayer = 1; ilayer <= 4; ilayer++) {
448 for (
int ipcb = 1; ipcb <= endPCB; ipcb++) {
452 std::istringstream elem(line);
453 std::vector<std::string> elements;
456 std::string subs_elem;
458 if (!subs_elem.empty()) elements.push_back(subs_elem);
461 gasGap = std::stoi(elements[0]);
462 int readed_pcb = std::stoi(elements[1]);
463 if (gasGap != ilayer || readed_pcb != ipcb) {
465 return StatusCode::FAILURE;
468 HVval=std::stoi(elements[4]);
470 ATH_MSG_DEBUG(
"PCB done, stationName, stationEta, stationPhi, ml, layer, pcb, hv: "
472 << ilayer <<
" " << ipcb <<
" " << HVval );
474 int chanNum = (ipcb-1)*1024+512;
477 multilayer,ilayer,chanNum);
478 float hv = (float)HVval;
479 m_hvMap.insert(std::pair<Identifier,float>(pcbId,hv));
490 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
double charge(const T &p)
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.