CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
SiStripGainFromAsciiFile Class Reference

#include <SiStripGainFromAsciiFile.h>

Inheritance diagram for SiStripGainFromAsciiFile:
ConditionDBWriter< SiStripApvGain > edm::EDAnalyzer edm::EDConsumerBase

Classes

struct  FibersGain
 

Public Member Functions

 SiStripGainFromAsciiFile (const edm::ParameterSet &)
 
 ~SiStripGainFromAsciiFile ()
 
- Public Member Functions inherited from ConditionDBWriter< SiStripApvGain >
 ConditionDBWriter (const edm::ParameterSet &iConfig)
 
virtual ~ConditionDBWriter ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

SiStripApvGaingetNewObject ()
 

Private Attributes

std::string Asciifilename_
 
edm::FileInPath fp_
 
__gnu_cxx::hash_map< unsigned
int, FibersGain
GainsMap
 
float referenceValue_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from ConditionDBWriter< SiStripApvGain >
void setDoStore (const bool doStore)
 When set to false the payload will not be written to the db. More...
 
void storeOnDbNow ()
 
cond::Time_t timeOfLastIOV ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 12 of file SiStripGainFromAsciiFile.h.

Constructor & Destructor Documentation

SiStripGainFromAsciiFile::SiStripGainFromAsciiFile ( const edm::ParameterSet iConfig)
explicit

Definition at line 15 of file SiStripGainFromAsciiFile.cc.

References Asciifilename_, fp_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), referenceValue_, and AlCaHLTBitMon_QueryRunRegistry::string.

16 
17 
18  Asciifilename_=iConfig.getParameter<std::string>("InputFileName");
19  referenceValue_ = iConfig.getParameter<double>("referenceValue");
20  fp_ = iConfig.getUntrackedParameter<edm::FileInPath>("file",edm::FileInPath("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat"));
21 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
SiStripGainFromAsciiFile::~SiStripGainFromAsciiFile ( )

Definition at line 24 of file SiStripGainFromAsciiFile.cc.

24  {
25  edm::LogInfo("SiStripGainFromAsciiFile::~SiStripGainFromAsciiFile");
26 }

Member Function Documentation

SiStripApvGain * SiStripGainFromAsciiFile::getNewObject ( )
privatevirtual

Implements ConditionDBWriter< SiStripApvGain >.

Definition at line 28 of file SiStripGainFromAsciiFile.cc.

References Asciifilename_, DetId::det(), cond::rpcobgas::detid, SiStripGainFromAsciiFile::FibersGain::fiber, fp_, edm::FileInPath::fullPath(), GainsMap, SiStripGainFromAsciiFile::FibersGain::hard_reset(), EdgesToViz::infile, getGTfromDQMFile::obj, SiStripApvGain::put(), matplotRender::reader, referenceValue_, and DetId::Tracker.

28  {
29 
31 
32  uint32_t detid;
33  FibersGain FG;
34 
35  std::stringstream ss;
36  ss.str("");
37  ss << "[SiStripGainFromAsciiFile::getNewObject]\n Reading Ascii File\n";
38  std::ifstream infile;
39  infile.open (Asciifilename_.c_str());
40  if (infile.is_open()){
41  while (infile.good()){
42  infile >> detid >> FG.fiber[0] >> FG.fiber[1] >> FG.fiber[2];
43  ss << detid << " " << FG.fiber[0] << " " << FG.fiber[1] << " " << FG.fiber[2] << std::endl;
44  GainsMap.insert(std::pair<unsigned int,FibersGain>(detid,FG));
45  }
46  infile.close();
47  edm::LogInfo("SiStripGainFromAsciiFile") << ss.str();
48  } else {
49  edm::LogError("SiStripGainFromAsciiFile")<< " [SiStripGainFromAsciiFile::getNewObject] Error opening file " << Asciifilename_ << std::endl;
50  assert(0);
51  }
52 
53 
54 
56 
57  const std::vector<uint32_t> DetIds = reader.getAllDetIds();
58 
59  ss.str("");
60  ss << "[SiStripGainFromAsciiFile::getNewObject]\n Filling SiStripApvGain object";
61  short nApvPair;
62  for(std::vector<uint32_t>::const_iterator it=DetIds.begin(); it!=DetIds.end(); it++){
63 
64  if (DetId(*it).det()!=DetId::Tracker)
65  continue;
66 
67  nApvPair=reader.getNumberOfApvsAndStripLength(*it).first/2;
68 
69  ss << "Looking at detid " << *it << " nApvPairs " << nApvPair << std::endl;
70 
71  __gnu_cxx::hash_map< unsigned int,FibersGain>::const_iterator iter=GainsMap.find(*it);
72 
73  if (iter!=GainsMap.end()){
74  FG = iter->second;
75  ss << " " << FG.fiber[0] << " " << FG.fiber[1] << " " << FG.fiber[2] << std::endl;
76  }
77  else {
78  ss << "Hard reset for detid " << *it << std::endl;
79  FG.hard_reset(referenceValue_);
80  }
81 
82  std::vector<float> DetGainsVector;
83 
84  if (nApvPair==2){
85  DetGainsVector.push_back(FG.fiber[0]/referenceValue_);
86  DetGainsVector.push_back(FG.fiber[0]/referenceValue_);
87  DetGainsVector.push_back(FG.fiber[2]/referenceValue_);
88  DetGainsVector.push_back(FG.fiber[2]/referenceValue_);
89  } else if (nApvPair==3){
90  DetGainsVector.push_back(FG.fiber[0]/referenceValue_);
91  DetGainsVector.push_back(FG.fiber[0]/referenceValue_);
92  DetGainsVector.push_back(FG.fiber[1]/referenceValue_);
93  DetGainsVector.push_back(FG.fiber[1]/referenceValue_);
94  DetGainsVector.push_back(FG.fiber[2]/referenceValue_);
95  DetGainsVector.push_back(FG.fiber[2]/referenceValue_);
96  } else {
97  edm::LogError("SiStripGainFromAsciiFile") << " SiStripGainFromAsciiFile::getNewObject] ERROR for detid " << *it << " not expected number of APV pairs " << nApvPair <<std::endl;
98  }
99 
100  SiStripApvGain::Range range(DetGainsVector.begin(),DetGainsVector.end());
101  if ( ! obj->put(*it,range) ){
102  edm::LogError("SiStripGainFromAsciiFile")<<" [SiStripGainFromAsciiFile::getNewObject] detid already exists"<<std::endl;
103  ss <<" [SiStripGainFromAsciiFile::getNewObject] detid already exists"<<std::endl;
104  }
105  }
106  edm::LogInfo("SiStripGainFromAsciiFile") << ss.str();
107 
108  return obj;
109 }
__gnu_cxx::hash_map< unsigned int, FibersGain > GainsMap
bool put(const uint32_t &detID, Range input)
std::pair< ContainerIterator, ContainerIterator > Range
Definition: DetId.h:18
list infile
Definition: EdgesToViz.py:90
std::string fullPath() const
Definition: FileInPath.cc:171
Detector det() const
get the detector field from this detid
Definition: DetId.h:35

Member Data Documentation

std::string SiStripGainFromAsciiFile::Asciifilename_
private

Definition at line 33 of file SiStripGainFromAsciiFile.h.

Referenced by getNewObject(), and SiStripGainFromAsciiFile().

edm::FileInPath SiStripGainFromAsciiFile::fp_
private

Definition at line 35 of file SiStripGainFromAsciiFile.h.

Referenced by getNewObject(), and SiStripGainFromAsciiFile().

__gnu_cxx::hash_map< unsigned int,FibersGain> SiStripGainFromAsciiFile::GainsMap
private

Definition at line 37 of file SiStripGainFromAsciiFile.h.

Referenced by getNewObject().

float SiStripGainFromAsciiFile::referenceValue_
private

Definition at line 34 of file SiStripGainFromAsciiFile.h.

Referenced by getNewObject(), and SiStripGainFromAsciiFile().