CMS 3D CMS Logo

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

#include <SiStripFedCablingManipulator.h>

Inheritance diagram for SiStripFedCablingManipulator:
edm::one::EDAnalyzer< edm::one::WatchRuns > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &es) override
 
void beginRun (const edm::Run &run, const edm::EventSetup &es) override
 
void endRun (const edm::Run &run, const edm::EventSetup &es) override
 
 SiStripFedCablingManipulator (const edm::ParameterSet &iConfig)
 
 ~SiStripFedCablingManipulator () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::WatchRuns >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const 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
 
bool wantsStreamRuns () const
 
 ~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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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
 
bool registeredToConsumeMany (TypeID const &, 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::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

std::unique_ptr
< SiStripFedCabling
manipulate (const SiStripFedCabling &)
 

Private Attributes

edm::ESGetToken
< SiStripFedCabling,
SiStripFedCablingRcd
fedCablingToken_
 
edm::ParameterSet iConfig_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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< B > consumes (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 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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
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 18 of file SiStripFedCablingManipulator.h.

Constructor & Destructor Documentation

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

Definition at line 6 of file SiStripFedCablingManipulator.cc.

7  : iConfig_(iConfig), fedCablingToken_(esConsumes<edm::Transition::EndRun>()) {
8  edm::LogInfo("SiStripFedCablingManipulator") << "SiStripFedCablingManipulator constructor " << std::endl;
9 }
edm::ESGetToken< SiStripFedCabling, SiStripFedCablingRcd > fedCablingToken_
Log< level::Info, false > LogInfo
SiStripFedCablingManipulator::~SiStripFedCablingManipulator ( )
override

Definition at line 11 of file SiStripFedCablingManipulator.cc.

11  {
12  edm::LogInfo("SiStripFedCablingManipulator")
13  << "SiStripFedCablingManipulator::~SiStripFedCablingManipulator()" << std::endl;
14 }
Log< level::Info, false > LogInfo

Member Function Documentation

void SiStripFedCablingManipulator::analyze ( const edm::Event e,
const edm::EventSetup es 
)
inlineoverridevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 22 of file SiStripFedCablingManipulator.h.

22 {};
void SiStripFedCablingManipulator::beginRun ( const edm::Run run,
const edm::EventSetup es 
)
inlineoverride

Definition at line 23 of file SiStripFedCablingManipulator.h.

23 {};
void SiStripFedCablingManipulator::endRun ( const edm::Run run,
const edm::EventSetup es 
)
override

Definition at line 16 of file SiStripFedCablingManipulator.cc.

References cond::service::PoolDBOutputService::appendOneIOV(), cond::service::PoolDBOutputService::beginOfTime(), cond::service::PoolDBOutputService::createOneIOV(), cond::service::PoolDBOutputService::currentTime(), fedCablingToken_, edm::EventSetup::getData(), edm::ParameterSet::getUntrackedParameter(), iConfig_, edm::Service< T >::isAvailable(), cond::service::PoolDBOutputService::isNewTagRequest(), manipulate(), getGTfromDQMFile::obj, and AlCaHLTBitMon_QueryRunRegistry::string.

16  {
17  const auto& esobj = es.getData(fedCablingToken_);
18 
19  auto obj = manipulate(esobj);
20 
21  cond::Time_t Time_ = 0;
22 
23  //And now write data in DB
25  if (dbservice.isAvailable()) {
26  if (!obj) {
27  edm::LogError("SiStripFedCablingManipulator") << "null pointer obj. nothing will be written " << std::endl;
28  return;
29  }
30 
31  std::string openIovAt = iConfig_.getUntrackedParameter<std::string>("OpenIovAt", "beginOfTime");
32  if (openIovAt == "beginOfTime")
33  Time_ = dbservice->beginOfTime();
34  else if (openIovAt == "currentTime")
35  dbservice->currentTime();
36  else
37  Time_ = iConfig_.getUntrackedParameter<uint32_t>("OpenIovAtTime", 1);
38 
39  //if first time tag is populated
40  if (dbservice->isNewTagRequest("SiStripFedCablingRcd")) {
41  edm::LogInfo("SiStripFedCablingManipulator") << "first request for storing objects with Record "
42  << "SiStripFedCablingRcd"
43  << " at time " << Time_ << std::endl;
44  dbservice->createOneIOV<SiStripFedCabling>(*obj, Time_, "SiStripFedCablingRcd");
45  } else {
46  edm::LogInfo("SiStripFedCablingManipulator") << "appending a new object to existing tag "
47  << "SiStripFedCablingRcd"
48  << " in since mode " << std::endl;
49  dbservice->appendOneIOV<SiStripFedCabling>(*obj, Time_, "SiStripFedCablingRcd");
50  }
51  } else {
52  edm::LogError("SiStripFedCablingManipulator") << "Service is unavailable" << std::endl;
53  }
54 }
T getUntrackedParameter(std::string const &, T const &) const
Log< level::Error, false > LogError
void createOneIOV(const T &payload, cond::Time_t firstSinceTime, const std::string &recordName)
bool getData(T &iHolder) const
Definition: EventSetup.h:128
void appendOneIOV(const T &payload, cond::Time_t sinceTime, const std::string &recordName)
unsigned long long Time_t
Definition: Time.h:14
bool isNewTagRequest(const std::string &recordName)
std::unique_ptr< SiStripFedCabling > manipulate(const SiStripFedCabling &)
bool isAvailable() const
Definition: Service.h:40
edm::ESGetToken< SiStripFedCabling, SiStripFedCablingRcd > fedCablingToken_
Log< level::Info, false > LogInfo
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
std::unique_ptr< SiStripFedCabling > SiStripFedCablingManipulator::manipulate ( const SiStripFedCabling iobj)
private

Definition at line 56 of file SiStripFedCablingManipulator.cc.

References Exception, SiStripFedCabling::fedConnections(), SiStripFedCabling::fedIds(), unpackBuffers-CaloStage1::feds, personalPlayback::fp, edm::ParameterSet::getParameter(), iConfig_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by endRun().

56  {
58  std::unique_ptr<SiStripFedCabling> oobj;
59 
60  std::ifstream inputFile_;
61  inputFile_.open(fp.c_str());
62 
63  std::map<uint32_t, std::pair<uint32_t, uint32_t> > dcuDetIdMap;
64  uint32_t dcuid, Olddetid, Newdetid;
65 
66  // if(fp.c_str()==""){
67  if (fp.empty()) {
68  edm::LogInfo("SiStripFedCablingManipulator")
69  << "::manipulate : since no file is specified, the copy of the input cabling will be applied" << std::endl;
70  oobj = std::make_unique<SiStripFedCabling>(iobj);
71  } else if (!inputFile_.is_open()) {
72  edm::LogError("SiStripFedCablingManipulator") << "::manipulate - ERROR in opening file " << fp << std::endl;
73  throw cms::Exception("CorruptedData") << "::manipulate - ERROR in opening file " << fp << std::endl;
74  } else {
75  for (;;) {
76  inputFile_ >> dcuid >> Olddetid >> Newdetid;
77 
78  if (!(inputFile_.eof() || inputFile_.fail())) {
79  if (dcuDetIdMap.find(dcuid) == dcuDetIdMap.end()) {
80  edm::LogInfo("SiStripFedCablingManipulator") << dcuid << " " << Olddetid << " " << Newdetid << std::endl;
81 
82  dcuDetIdMap[dcuid] = std::pair<uint32_t, uint32_t>(Olddetid, Newdetid);
83  } else {
84  edm::LogError("SiStripFedCablingManipulator")
85  << "::manipulate - ERROR duplicated dcuid " << dcuid << std::endl;
86  throw cms::Exception("CorruptedData")
87  << "SiStripFedCablingManipulator::manipulate - ERROR duplicated dcuid " << dcuid;
88  break;
89  }
90  } else if (inputFile_.eof()) {
91  edm::LogInfo("SiStripFedCablingManipulator") << "::manipulate - END of file reached" << std::endl;
92  break;
93  } else if (inputFile_.fail()) {
94  edm::LogError("SiStripFedCablingManipulator") << "::manipulate - ERROR while reading file" << std::endl;
95  break;
96  }
97  }
98  inputFile_.close();
99  std::map<uint32_t, std::pair<uint32_t, uint32_t> >::const_iterator it = dcuDetIdMap.begin();
100  for (; it != dcuDetIdMap.end(); ++it)
101  edm::LogInfo("SiStripFedCablingManipulator")
102  << "::manipulate - Map " << it->first << " " << it->second.first << " " << it->second.second;
103 
104  std::vector<FedChannelConnection> conns;
105 
106  auto feds = iobj.fedIds();
107  for (auto ifeds = feds.begin(); ifeds != feds.end(); ifeds++) {
108  auto conns_per_fed = iobj.fedConnections(*ifeds);
109  for (auto iconn = conns_per_fed.begin(); iconn != conns_per_fed.end(); ++iconn) {
110  std::map<uint32_t, std::pair<uint32_t, uint32_t> >::const_iterator it = dcuDetIdMap.find(iconn->dcuId());
111  if (it != dcuDetIdMap.end() && it->second.first == iconn->detId()) {
112  edm::LogInfo("SiStripFedCablingManipulator")
113  << "::manipulate - fedid " << *ifeds << " dcuid " << iconn->dcuId() << " oldDet " << iconn->detId()
114  << " newDetID " << it->second.second;
115  conns.push_back(FedChannelConnection(iconn->fecCrate(),
116  iconn->fecSlot(),
117  iconn->fecRing(),
118  iconn->ccuAddr(),
119  iconn->ccuChan(),
120  iconn->i2cAddr(0),
121  iconn->i2cAddr(1),
122  iconn->dcuId(),
123  it->second.second, //<------ New detid
124  iconn->nApvPairs(),
125  iconn->fedId(),
126  iconn->fedCh(),
127  iconn->fiberLength(),
128  iconn->dcu(),
129  iconn->pll(),
130  iconn->mux(),
131  iconn->lld()));
132  } else {
133  conns.push_back(FedChannelConnection(iconn->fecCrate(),
134  iconn->fecSlot(),
135  iconn->fecRing(),
136  iconn->ccuAddr(),
137  iconn->ccuChan(),
138  iconn->i2cAddr(0),
139  iconn->i2cAddr(1),
140  iconn->dcuId(),
141  iconn->detId(),
142  iconn->nApvPairs(),
143  iconn->fedId(),
144  iconn->fedCh(),
145  iconn->fiberLength(),
146  iconn->dcu(),
147  iconn->pll(),
148  iconn->mux(),
149  iconn->lld()));
150  }
151  }
152  }
153 
154  oobj = std::make_unique<SiStripFedCabling>(conns);
155  }
156  return oobj;
157 }
Log< level::Error, false > LogError
Class containning control, module, detector and connection information, at the level of a FED channel...
FedsConstIterRange fedIds() const
Log< level::Info, false > LogInfo
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
ConnsConstIterRange fedConnections(uint16_t fed_id) const

Member Data Documentation

edm::ESGetToken<SiStripFedCabling, SiStripFedCablingRcd> SiStripFedCablingManipulator::fedCablingToken_
private

Definition at line 30 of file SiStripFedCablingManipulator.h.

Referenced by endRun().

edm::ParameterSet SiStripFedCablingManipulator::iConfig_
private

Definition at line 29 of file SiStripFedCablingManipulator.h.

Referenced by endRun(), and manipulate().