CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
SiStripBadStripFromASCIIFile Class Reference
Inheritance diagram for SiStripBadStripFromASCIIFile:
ConditionDBWriter< SiStripBadStrip > edm::one::EDAnalyzer< edm::one::WatchRuns, edm::one::WatchLuminosityBlocks, edm::one::SharedResources > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 SiStripBadStripFromASCIIFile (const edm::ParameterSet &iConfig)
 
 ~SiStripBadStripFromASCIIFile () override=default
 
- Public Member Functions inherited from ConditionDBWriter< SiStripBadStrip >
 ConditionDBWriter (const edm::ParameterSet &iConfig)
 
 ~ConditionDBWriter () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::WatchRuns, edm::one::WatchLuminosityBlocks, edm::one::SharedResources >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const noexcept
 
bool wantsStreamRuns () const noexcept
 
 ~EDAnalyzerBase () 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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &)
 
- Static Public Member Functions inherited from ConditionDBWriter< SiStripBadStrip >
static void fillPSetDescription (edm::ParameterSetDescription &desc)
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

std::unique_ptr< SiStripBadStripgetNewObject () override
 

Private Attributes

const edm::FileInPath fp_
 
const bool isFlagAvailable_
 
const bool printdebug_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 23 of file SiStripBadStripFromASCIIFile.cc.

Constructor & Destructor Documentation

◆ SiStripBadStripFromASCIIFile()

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

Definition at line 37 of file SiStripBadStripFromASCIIFile.cc.

39  printdebug_(iConfig.getParameter<bool>("printDebug")),
40  isFlagAvailable_(iConfig.getParameter<bool>("isFlagAvailable")),
41  fp_(iConfig.getParameter<edm::FileInPath>("file")) {}
T getParameter(std::string const &) const
Definition: ParameterSet.h:307

◆ ~SiStripBadStripFromASCIIFile()

SiStripBadStripFromASCIIFile::~SiStripBadStripFromASCIIFile ( )
overridedefault

Member Function Documentation

◆ fillDescriptions()

void SiStripBadStripFromASCIIFile::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 43 of file SiStripBadStripFromASCIIFile.cc.

References edm::ConfigurationDescriptions::addWithDefaultLabel(), submitPVResolutionJobs::desc, and ConditionDBWriter< T >::fillPSetDescription().

43  {
45  ConditionDBWriter::fillPSetDescription(desc); // inherited from mother class
46  desc.setComment("Conditions Builder for SiStripBadStrip Objects from input ASCII file");
47  desc.add<edm::FileInPath>("file", edm::FileInPath("CondTools/SiStrip/data/DefectsFromConstructionDB.dat"));
48  desc.add<bool>("printDebug", false)->setComment("prints debug level messages");
49  desc.add<bool>("isFlagAvailable", true)->setComment("is the flag available in the input file");
50  descriptions.addWithDefaultLabel(desc);
51 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
static void fillPSetDescription(edm::ParameterSetDescription &desc)

◆ getNewObject()

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

Implements ConditionDBWriter< SiStripBadStrip >.

Definition at line 53 of file SiStripBadStripFromASCIIFile.cc.

References submitPVResolutionJobs::count, TauDecayModes::dec, writedatasetfile::firstrun, RemoveAddSevLevel::flag, fp_, edm::FileInPath::fullPath(), timingPdfMaker::infile, isFlagAvailable_, printdebug_, and FastTimerService_cff::range.

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

Member Data Documentation

◆ fp_

const edm::FileInPath SiStripBadStripFromASCIIFile::fp_
private

Definition at line 33 of file SiStripBadStripFromASCIIFile.cc.

Referenced by getNewObject().

◆ isFlagAvailable_

const bool SiStripBadStripFromASCIIFile::isFlagAvailable_
private

Definition at line 32 of file SiStripBadStripFromASCIIFile.cc.

Referenced by getNewObject().

◆ printdebug_

const bool SiStripBadStripFromASCIIFile::printdebug_
private

Definition at line 31 of file SiStripBadStripFromASCIIFile.cc.

Referenced by getNewObject().