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
 
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)
 
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 ESProduct , Transition Tr = Transition::Event>
auto esConsumes (eventsetup::EventSetupRecordKey const &, 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 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 ( )
inlineoverride

Definition at line 19 of file SiStripBadStripFromASCIIFile.h.

References getNewObject().

19 {};

Member Function Documentation

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

Implements ConditionDBWriter< SiStripBadStrip >.

Definition at line 41 of file SiStripBadStripFromASCIIFile.cc.

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

Referenced by ~SiStripBadStripFromASCIIFile().

41  {
42 
43  auto SiStripBadStrip_ = std::make_unique<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
std::string fullPath() const
Definition: FileInPath.cc:197

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.