CMS 3D CMS Logo

SiPixelFEDChannelContainerTestReader.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <map>
15 
17 public:
20 
21  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
22 
23 private:
24  void analyze(const edm::Event& e, const edm::EventSetup& c) override;
25 
26  // ----------member data ---------------------------
28  const bool printdebug_;
30 };
31 
33  : siPixelBadFEDChToken_(esConsumes()),
34  printdebug_(p.getUntrackedParameter<bool>("printDebug", true)),
35  formatedOutput_(p.getUntrackedParameter<std::string>("outputFile", "")) {
36  edm::LogInfo("SiPixelFEDChannelContainerTestReader") << "SiPixelFEDChannelContainerTestReader" << std::endl;
37 }
38 
40  edm::LogInfo("SiPixelFEDChannelContainerTestReader") << "~SiPixelFEDChannelContainerTestReader " << std::endl;
41 }
42 
44  edm::LogInfo("SiPixelFEDChannelContainerTestReader")
45  << "### SiPixelFEDChannelContainerTestReader::analyze ###" << std::endl;
46  edm::LogInfo("SiPixelFEDChannelContainerTestReader") << " I AM IN RUN NUMBER " << e.id().run() << std::endl;
47  edm::LogInfo("SiPixelFEDChannelContainerTestReader") << " ---EVENT NUMBER " << e.id().event() << std::endl;
48 
50  edm::eventsetup::EventSetupRecordKey::TypeTag::findType("SiPixelStatusScenariosRcd"));
51 
53  //record not found
54  edm::LogInfo("SiPixelFEDChannelContainerTestReader") << "Record \"SiPixelStatusScenariosRcd"
55  << "\" does not exist " << std::endl;
56  }
57 
58  //this part gets the handle of the event source and the record (i.e. the Database)
59  edm::ESHandle<SiPixelFEDChannelContainer> qualityCollectionHandle = context.getHandle(siPixelBadFEDChToken_);
60  edm::LogInfo("SiPixelFEDChannelContainerTestReader") << "got eshandle from context" << std::endl;
61 
62  const SiPixelFEDChannelContainer* quality_map = qualityCollectionHandle.product();
63  edm::LogInfo("SiPixelFEDChannelContainerTestReader") << "got SiPixelFEDChannelContainer* " << std::endl;
64  edm::LogInfo("SiPixelFEDChannelContainerTestReader") << "print pointer address : " << quality_map << std::endl;
65  edm::LogInfo("SiPixelFEDChannelContainerTestReader") << "Size " << quality_map->size() << std::endl;
66  edm::LogInfo("SiPixelFEDChannelContainerTestReader") << "Content of myQuality_Map " << std::endl;
67  // use built-in method in the CondFormat to print the content
68  if (printdebug_) {
69  quality_map->printAll();
70  }
71 
72  FILE* pFile = nullptr;
73  if (!formatedOutput_.empty())
74  pFile = fopen(formatedOutput_.c_str(), "w");
75  if (pFile) {
76  fprintf(pFile, "SiPixelFEDChannelContainer::printAll() \n");
77  fprintf(pFile,
78  " ========================================================================================================="
79  "========== \n");
80 
82 
83  for (auto it = m_qualities.begin(); it != m_qualities.end(); ++it) {
84  fprintf(pFile,
85  " ======================================================================================================="
86  "============ \n");
87  fprintf(pFile, "run : %s \n ", (it->first).c_str());
88  for (const auto& thePixelFEDChannel : it->second) {
89  DetId detId = thePixelFEDChannel.first;
90  fprintf(pFile, "DetId : %i \n", detId.rawId());
91  for (const auto& entry : thePixelFEDChannel.second) {
92  //unsigned int fed, link, roc_first, roc_last;
93  fprintf(pFile,
94  "fed : %i | link : %2i | roc_first : %2i | roc_last: %2i \n",
95  entry.fed,
96  entry.link,
97  entry.roc_first,
98  entry.roc_last);
99  }
100  }
101  }
102  }
103 }
104 
107  desc.setComment("Reads payloads of type SiPixelFEDChannelContainer");
108  desc.addUntracked<bool>("printDebug", true);
109  desc.addUntracked<std::string>("outputFile", "");
110  descriptions.add("SiPixelFEDChannelContainerTestReader", desc);
111 }
112 
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
const SiPixelBadFEDChannelsScenarioMap & getScenarioMap() const
T const * product() const
Definition: ESHandle.h:86
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Log< level::Info, false > LogInfo
Definition: DetId.h:17
void analyze(const edm::Event &e, const edm::EventSetup &c) override
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
void add(std::string const &label, ParameterSetDescription const &psetDescription)
heterocontainer::HCTypeTag TypeTag
std::unordered_map< std::string, SiPixelFEDChannelCollection > SiPixelBadFEDChannelsScenarioMap
const edm::ESGetToken< SiPixelFEDChannelContainer, SiPixelStatusScenariosRcd > siPixelBadFEDChToken_
static HCTypeTag findType(char const *iTypeName)
find a type based on the types name, if not found will return default HCTypeTag
Definition: HCTypeTag.cc:121