test
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 Member Functions | Private Attributes
SiStripBadStripFromASCIIFile Class Reference

#include <SiStripBadStripFromASCIIFile.h>

Inheritance diagram for SiStripBadStripFromASCIIFile:
ConditionDBWriter< SiStripBadStrip > edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 SiStripBadStripFromASCIIFile (const edm::ParameterSet &iConfig)
 
 ~SiStripBadStripFromASCIIFile ()
 
- Public Member Functions inherited from ConditionDBWriter< SiStripBadStrip >
 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
std::vector< ConsumesInfoconsumesInfo () const
 
 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
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual SiStripBadStripgetNewObject ()
 

Private Attributes

edm::FileInPath fp_
 
bool printdebug_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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< SiStripBadStrip >
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 13 of file SiStripBadStripFromASCIIFile.h.

Constructor & Destructor Documentation

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

Definition at line 33 of file SiStripBadStripFromASCIIFile.cc.

References fp_, and edm::ParameterSet::getUntrackedParameter().

33  :
35  printdebug_(iConfig.getUntrackedParameter<bool>("printDebug",false))
36 {
37  fp_ = iConfig.getUntrackedParameter<edm::FileInPath>("file",edm::FileInPath("CalibTracker/SiStripQuality/data/DefectsFromConstructionDB.dat"));
38  }
T getUntrackedParameter(std::string const &, T const &) const
SiStripBadStripFromASCIIFile::~SiStripBadStripFromASCIIFile ( )
inline

Definition at line 19 of file SiStripBadStripFromASCIIFile.h.

19 {};

Member Function Documentation

SiStripBadStrip * SiStripBadStripFromASCIIFile::getNewObject ( )
privatevirtual

Implements ConditionDBWriter< SiStripBadStrip >.

Definition at line 41 of file SiStripBadStripFromASCIIFile.cc.

References KineDebug3::count(), gather_cfg::cout, TauDecayModes::dec, SiStripBadStrip::encode(), fp_, edm::FileInPath::fullPath(), timingPdfMaker::infile, and SiStripBadStrip::put().

41  {
42 
43  SiStripBadStrip* SiStripBadStrip_ = new SiStripBadStrip();
44 
45  // open file and fill DB
46  ifstream infile((fp_.fullPath()).c_str());
47  if(!infile){std::cout << "Problem while trying to open File: " << (fp_.fullPath()).c_str() << std::endl;}
48 
49 
50  //variables needed for reading file and filling of SiStripBadStripObject
51  uint32_t detid;
52  short flag;
53  short channel;
54 
55  bool firstrun=true;
56  short tempchannel=0;
57  int count =0;
58  std::vector<unsigned int> theSiStripVector;
59  short tempflag=0;
60  uint32_t tempdetid=0;
61 
62 
63  while(!infile.eof()){
64 
65  // get data from file:
66  //infile >> detid >> channel >> flag;
67 
68  //if no flag is available, use the following:
69  infile >> detid >> channel;
70  flag = 1;
71 
72  unsigned int theBadStripRange=0;
73 
74  // first loop ?
75  if(firstrun) {
76  tempdetid=detid;
77  tempchannel=channel;
78  tempflag=flag;
79  count =0;
80  firstrun=false;
81  }
82 
83 
84  if(detid==tempdetid){
85  if (channel!=tempchannel+count || flag != tempflag){
86  // 1.badstrip, nconsectrips, flag
87  theBadStripRange = SiStripBadStrip_->encode(tempchannel-1, count, tempflag); // In the quality object, strips are counted from 0 to 767!!! Therefore "tempchannel-1"!
88  // In the input txt-file, they have to be from 1 to 768 instead!!!
89  edm::LogInfo("SiStripBadStripFromASCIIFile")<< "detid " << tempdetid << " \t"
90  << " firstBadStrip " << tempchannel << "\t "
91  << " NconsecutiveBadStrips " << count << "\t "
92  <<"flag " << tempflag << "\t"
93  << " packed integer " << std::hex << theBadStripRange << std::dec
94  << std::endl;
95 
96  theSiStripVector.push_back(theBadStripRange);
97 
98  if (infile.eof()){ // Don't forget to save the last strip before eof!!!
99  SiStripBadStrip::Range range(theSiStripVector.begin(),theSiStripVector.end());
100  if ( ! SiStripBadStrip_->put(tempdetid,range) )
101  edm::LogError("SiStripBadStripFromASCIIFile")<<"[SiStripBadStripFromASCIIFile::GetNewObject] detid already exists"<<std::endl;
102  theSiStripVector.clear();
103  }
104 
105  count=1;
106  tempchannel=channel;
107  tempflag=flag;
108 
109  }else{count++;}
110  }
111 
112  if(detid!=tempdetid){
113  // 1.badstrip, nconsectrips, flag
114  theBadStripRange = SiStripBadStrip_->encode(tempchannel-1, count, tempflag); // In the quality object, strips are counted from 0 to 767!!! Therefore "tempchannel-1"!
115  // In the input txt-file, they have to be from 1 to 768 instead!!!
116  edm::LogInfo("SiStripBadStripFromASCIIFile")<< "detid " << tempdetid << " \t"
117  << " firstBadStrip " << tempchannel << "\t "
118  << " NconsecutiveBadStrips " << count << "\t "
119  <<"flag " << tempflag << "\t"
120  << " packed integer " << std::hex << theBadStripRange << std::dec
121  << std::endl;
122 
123  theSiStripVector.push_back(theBadStripRange);
124 
125  // populate db object
126  SiStripBadStrip::Range range(theSiStripVector.begin(),theSiStripVector.end());
127  if ( ! SiStripBadStrip_->put(tempdetid,range) )
128  edm::LogError("SiStripBadStripFromASCIIFile")<<"[SiStripBadStripFromASCIIFile::GetNewObject] detid already exists"<<std::endl;
129  theSiStripVector.clear();
130 
131  count=1;
132  tempdetid=detid;
133  tempchannel=channel;
134  tempflag=flag;
135  }
136  }
137 
138  return SiStripBadStrip_;
139 }
std::pair< ContainerIterator, ContainerIterator > Range
tuple cout
Definition: gather_cfg.py:145
std::string fullPath() const
Definition: FileInPath.cc:184
bool put(const uint32_t &detID, const InputVector &vect)
unsigned int encode(const unsigned short &first, const unsigned short &NconsecutiveBadStrips, const unsigned short &flag=0)

Member Data Documentation

edm::FileInPath SiStripBadStripFromASCIIFile::fp_
private

Definition at line 25 of file SiStripBadStripFromASCIIFile.h.

Referenced by getNewObject(), and SiStripBadStripFromASCIIFile().

bool SiStripBadStripFromASCIIFile::printdebug_
private

Definition at line 26 of file SiStripBadStripFromASCIIFile.h.