CMS 3D CMS Logo

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 () override
 
- Public Member Functions inherited from ConditionDBWriter< SiStripBadStrip >
 ConditionDBWriter (const edm::ParameterSet &iConfig)
 
 ~ConditionDBWriter () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

std::unique_ptr< SiStripBadStripgetNewObject () override
 

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 &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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 11 of file SiStripBadStripFromASCIIFile.h.

Constructor & Destructor Documentation

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

Definition at line 26 of file SiStripBadStripFromASCIIFile.cc.

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

28  printdebug_(iConfig.getUntrackedParameter<bool>("printDebug", false)) {
30  "file", edm::FileInPath("CalibTracker/SiStripQuality/data/DefectsFromConstructionDB.dat"));
31 }
T getUntrackedParameter(std::string const &, T const &) const
SiStripBadStripFromASCIIFile::~SiStripBadStripFromASCIIFile ( )
inlineoverride

Definition at line 15 of file SiStripBadStripFromASCIIFile.h.

References getNewObject().

15 {};

Member Function Documentation

std::unique_ptr< SiStripBadStrip > SiStripBadStripFromASCIIFile::getNewObject ( )
overrideprivatevirtual

Implements ConditionDBWriter< SiStripBadStrip >.

Definition at line 33 of file SiStripBadStripFromASCIIFile.cc.

References KineDebug3::count(), gather_cfg::cout, TauDecayModes::dec, writedatasetfile::firstrun, RemoveAddSevLevel::flag, fp_, and edm::FileInPath::fullPath().

Referenced by ~SiStripBadStripFromASCIIFile().

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

Member Data Documentation

edm::FileInPath SiStripBadStripFromASCIIFile::fp_
private

Definition at line 19 of file SiStripBadStripFromASCIIFile.h.

Referenced by getNewObject(), and SiStripBadStripFromASCIIFile().

bool SiStripBadStripFromASCIIFile::printdebug_
private

Definition at line 20 of file SiStripBadStripFromASCIIFile.h.