CMS 3D CMS Logo

AlignPCLThresholdsReader.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <map>
10 
11 namespace edmtest {
13  public:
15  ~AlignPCLThresholdsReader() override;
16 
17  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
18 
19  private:
20  void analyze(const edm::Event& e, const edm::EventSetup& c) override;
21 
22  // ----------member data ---------------------------
24  const bool printdebug_;
26  };
27 
29  : thresholdToken_(esConsumes()),
30  printdebug_(p.getUntrackedParameter<bool>("printDebug", true)),
31  formatedOutput_(p.getUntrackedParameter<std::string>("outputFile", "")) {
32  edm::LogInfo("AlignPCLThresholdsReader") << "AlignPCLThresholdsReader" << std::endl;
33  }
34 
36  edm::LogInfo("AlignPCLThresholdsReader") << "~AlignPCLThresholdsReader " << std::endl;
37  }
38 
40  edm::LogInfo("AlignPCLThresholdsReader") << "### AlignPCLThresholdsReader::analyze ###" << std::endl;
41  edm::LogInfo("AlignPCLThresholdsReader") << " I AM IN RUN NUMBER " << e.id().run() << std::endl;
42  edm::LogInfo("AlignPCLThresholdsReader") << " ---EVENT NUMBER " << e.id().event() << std::endl;
43 
46 
48  //record not found
49  edm::LogInfo("AlignPCLThresholdsReader") << "Record \"AlignPCLThresholdsRcd"
50  << "\" does not exist " << std::endl;
51  }
52 
53  //this part gets the handle of the event source and the record (i.e. the Database)
55  edm::LogInfo("AlignPCLThresholdsReader") << "got eshandle" << std::endl;
56 
57  if (!thresholdHandle.isValid()) {
58  edm::LogError("AlignPCLThresholdsReader") << " Could not get Handle" << std::endl;
59  return;
60  }
61 
62  const AlignPCLThresholds* thresholds = thresholdHandle.product();
63  edm::LogInfo("AlignPCLThresholdsReader") << "got AlignPCLThresholds* " << std::endl;
64  edm::LogInfo("AlignPCLThresholdsReader") << "print pointer address : ";
65  edm::LogInfo("AlignPCLThresholdsReader") << thresholds << std::endl;
66 
67  edm::LogInfo("AlignPCLThresholdsReader") << "Size " << thresholds->size() << std::endl;
68  edm::LogInfo("AlignPCLThresholdsReader") << "Content of myThresholds " << std::endl;
69  // use built-in method in the CondFormat to print the content
70  if (printdebug_) {
71  thresholds->printAll();
72  }
73 
74  FILE* pFile = nullptr;
75  if (!formatedOutput_.empty())
76  pFile = fopen(formatedOutput_.c_str(), "w");
77  if (pFile) {
78  fprintf(pFile, "AlignPCLThresholds::printAll() \n");
79  fprintf(pFile,
80  " ======================================================================================================="
81  "============ \n");
82  fprintf(pFile, "N records cut: %i \n", thresholds->getNrecords());
83 
84  AlignPCLThresholds::threshold_map m_thresholds = thresholds->getThreshold_Map();
85 
86  for (auto it = m_thresholds.begin(); it != m_thresholds.end(); ++it) {
87  fprintf(pFile,
88  " ====================================================================================================="
89  "============== \n");
90  fprintf(pFile, "key : %s \n ", (it->first).c_str());
91  fprintf(pFile, "- Xcut : %8.3f um ", (it->second).getXcut());
92  fprintf(pFile, "| sigXcut : %8.3f ", (it->second).getSigXcut());
93  fprintf(pFile, "| maxMoveXcut : %8.3f um ", (it->second).getMaxMoveXcut());
94  fprintf(pFile, "| ErrorXcut : %8.3f um\n ", (it->second).getErrorXcut());
95 
96  fprintf(pFile, "- thetaXcut : %8.3f urad ", (it->second).getThetaXcut());
97  fprintf(pFile, "| sigThetaXcut : %8.3f ", (it->second).getSigThetaXcut());
98  fprintf(pFile, "| maxMoveThetaXcut : %8.3f urad ", (it->second).getMaxMoveThetaXcut());
99  fprintf(pFile, "| ErrorThetaXcut : %8.3f urad\n ", (it->second).getErrorThetaXcut());
100 
101  fprintf(pFile, "- Ycut : %8.3f um ", (it->second).getYcut());
102  fprintf(pFile, "| sigYcut : %8.3f ", (it->second).getSigXcut());
103  fprintf(pFile, "| maxMoveYcut : %8.3f um ", (it->second).getMaxMoveYcut());
104  fprintf(pFile, "| ErrorYcut : %8.3f um\n ", (it->second).getErrorYcut());
105 
106  fprintf(pFile, "- thetaYcut : %8.3f urad ", (it->second).getThetaYcut());
107  fprintf(pFile, "| sigThetaYcut : %8.3f ", (it->second).getSigThetaYcut());
108  fprintf(pFile, "| maxMoveThetaYcut : %8.3f urad ", (it->second).getMaxMoveThetaYcut());
109  fprintf(pFile, "| ErrorThetaYcut : %8.3f urad\n ", (it->second).getErrorThetaYcut());
110 
111  fprintf(pFile, "- Zcut : %8.3f um ", (it->second).getZcut());
112  fprintf(pFile, "| sigZcut : %8.3f ", (it->second).getSigZcut());
113  fprintf(pFile, "| maxMoveZcut : %8.3f um ", (it->second).getMaxMoveZcut());
114  fprintf(pFile, "| ErrorZcut : %8.3f um\n ", (it->second).getErrorZcut());
115 
116  fprintf(pFile, "- thetaZcut : %8.3f urad ", (it->second).getThetaZcut());
117  fprintf(pFile, "| sigThetaZcut : %8.3f ", (it->second).getSigThetaZcut());
118  fprintf(pFile, "| maxMoveThetaZcut : %8.3f urad ", (it->second).getMaxMoveThetaZcut());
119  fprintf(pFile, "| ErrorThetaZcut : %8.3f urad\n ", (it->second).getErrorThetaZcut());
120 
121  if ((it->second).hasExtraDOF()) {
122  for (unsigned int j = 0; j < (it->second).extraDOFSize(); j++) {
123  std::array<float, 4> extraDOFCuts = thresholds->getExtraDOFCutsForAlignable(it->first, j);
124  fprintf(pFile,
125  "Extra DOF: %i with label %s \n ",
126  j,
127  thresholds->getExtraDOFLabelForAlignable(it->first, j).c_str());
128  fprintf(pFile, "- cut : %8.3f ", extraDOFCuts.at(0));
129  fprintf(pFile, "| sigCut : %8.3f ", extraDOFCuts.at(1));
130  fprintf(pFile, "| maxMoveCut : %8.3f ", extraDOFCuts.at(2));
131  fprintf(pFile, "| maxErrorCut : %8.3f \n ", extraDOFCuts.at(3));
132  }
133  }
134  }
135  }
136  }
137 
140  desc.setComment("Reads payloads of type AlignPCLThresholds");
141  desc.addUntracked<bool>("printDebug", true);
142  desc.addUntracked<std::string>("outputFile", "");
143  descriptions.add("AlignPCLThresholdsReader", desc);
144  }
145 
147 } // namespace edmtest
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
edm::eventsetup::heterocontainer::HCTypeTag::findType
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
electrons_cff.bool
bool
Definition: electrons_cff.py:366
EDAnalyzer.h
particleFlowZeroSuppressionECAL_cff.thresholds
thresholds
Definition: particleFlowZeroSuppressionECAL_cff.py:31
edmtest
Definition: AlignPCLThresholdsReader.cc:11
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edmtest::AlignPCLThresholdsReader::thresholdToken_
const edm::ESGetToken< AlignPCLThresholds, AlignPCLThresholdsRcd > thresholdToken_
Definition: AlignPCLThresholdsReader.cc:23
AlignPCLThresholds
Definition: AlignPCLThresholds.h:11
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::one::EDAnalyzer
Definition: EDAnalyzer.h:30
edm::eventsetup::EventSetupRecordKey
Definition: EventSetupRecordKey.h:30
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
AlignPCLThresholdsRcd.h
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
edm::ESHandle
Definition: DTSurvey.h:22
edmtest::AlignPCLThresholdsReader::analyze
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Definition: AlignPCLThresholdsReader.cc:39
edm::eventsetup::EventSetupRecordKey::TypeTag
heterocontainer::HCTypeTag TypeTag
Definition: EventSetupRecordKey.h:32
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edmtest::AlignPCLThresholdsReader::~AlignPCLThresholdsReader
~AlignPCLThresholdsReader() override
Definition: AlignPCLThresholdsReader.cc:35
funct::true
true
Definition: Factorize.h:173
edm::ParameterSet
Definition: ParameterSet.h:47
AlignPCLThresholds.h
Event.h
edmtest::AlignPCLThresholdsReader
Definition: AlignPCLThresholdsReader.cc:12
edm::eventsetup::EventSetupRecordKey::type
const TypeTag & type() const
Definition: EventSetupRecordKey.h:40
edmtest::AlignPCLThresholdsReader::formatedOutput_
const std::string formatedOutput_
Definition: AlignPCLThresholdsReader.cc:25
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:155
edm::EventSetup
Definition: EventSetup.h:58
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
edmtest::AlignPCLThresholdsReader::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: AlignPCLThresholdsReader.cc:138
AlignPCLThresholds::threshold_map
std::map< std::string, AlignPCLThreshold > threshold_map
Definition: AlignPCLThresholds.h:13
edm::ESHandleBase::isValid
bool isValid() const
Definition: ESHandle.h:44
edm::ESGetToken< AlignPCLThresholds, AlignPCLThresholdsRcd >
edmtest::AlignPCLThresholdsReader::printdebug_
const bool printdebug_
Definition: AlignPCLThresholdsReader.cc:24
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
std
Definition: JetResolutionObject.h:76
EventSetup.h
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edmtest::AlignPCLThresholdsReader::AlignPCLThresholdsReader
AlignPCLThresholdsReader(edm::ParameterSet const &p)
Definition: AlignPCLThresholdsReader.cc:28
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::Event
Definition: Event.h:73
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37