CMS 3D CMS Logo

HcalDumpConditions.cc
Go to the documentation of this file.
1 
2 /*----------------------------------------------------------------------
3 
4 R.Ofierzynski - 2.Oct. 2007
5  modified to dump all pedestals on screen, see
6  testHcalDBFake.cfg
7  testHcalDBFrontier.cfg
8 
9 July 29, 2009 Added HcalValidationCorrs - Gena Kukartsev
10 September 21, 2009 Added HcalLutMetadata - Gena Kukartsev
11 
12 ----------------------------------------------------------------------*/
13 
14 #include <stdexcept>
15 #include <string>
16 #include <iostream>
17 #include <fstream>
18 #include <sstream>
22 
25 
27 
29 
33 
36 
37 namespace edmtest {
39  public:
41  front = p.getUntrackedParameter<std::string>("outFilePrefix", "Dump");
42  mDumpRequest = p.getUntrackedParameter<std::vector<std::string> >("dump", std::vector<std::string>());
43  m_toktopo = esConsumes<HcalTopology, HcalRecNumberingRecord>();
44  m_tokdb = esConsumes<HcalDbService, HcalDbRecord>();
45 
46  tok_ElectronicsMap = esConsumes<HcalElectronicsMap, HcalElectronicsMapRcd>();
47  tok_FrontEndMap = esConsumes<HcalFrontEndMap, HcalFrontEndMapRcd>();
48  tok_QIEData = esConsumes<HcalQIEData, HcalQIEDataRcd>();
49  tok_QIETypes = esConsumes<HcalQIETypes, HcalQIETypesRcd>();
50  tok_Pedestals = esConsumes<HcalPedestals, HcalPedestalsRcd>();
51  tok_PedestalWidths = esConsumes<HcalPedestalWidths, HcalPedestalWidthsRcd>();
52  tok_Pedestals_effective = esConsumes<HcalPedestals, HcalPedestalsRcd>(edm::ESInputTag("", "effective"));
54  esConsumes<HcalPedestalWidths, HcalPedestalWidthsRcd>(edm::ESInputTag("", "effective"));
55  tok_Gains = esConsumes<HcalGains, HcalGainsRcd>();
56  tok_GainWidths = esConsumes<HcalGainWidths, HcalGainWidthsRcd>();
57  tok_ChannelQuality = esConsumes<HcalChannelQuality, HcalChannelQualityRcd>();
58  tok_RespCorrs = esConsumes<HcalRespCorrs, HcalRespCorrsRcd>();
59  tok_ZSThresholds = esConsumes<HcalZSThresholds, HcalZSThresholdsRcd>();
60  tok_L1TriggerObjects = esConsumes<HcalL1TriggerObjects, HcalL1TriggerObjectsRcd>();
61  tok_TimeCorrs = esConsumes<HcalTimeCorrs, HcalTimeCorrsRcd>();
62  tok_LUTCorrs = esConsumes<HcalLUTCorrs, HcalLUTCorrsRcd>();
63  tok_PFCorrs = esConsumes<HcalPFCorrs, HcalPFCorrsRcd>();
64  tok_ValidationCorrs = esConsumes<HcalValidationCorrs, HcalValidationCorrsRcd>();
65  tok_LutMetadata = esConsumes<HcalLutMetadata, HcalLutMetadataRcd>();
66  tok_DcsValues = esConsumes<HcalDcsValues, HcalDcsRcd>();
67  tok_DcsMap = esConsumes<HcalDcsMap, HcalDcsMapRcd>();
68  tok_RecoParams = esConsumes<HcalRecoParams, HcalRecoParamsRcd>();
69  tok_TimingParams = esConsumes<HcalTimingParams, HcalTimingParamsRcd>();
70  tok_LongRecoParams = esConsumes<HcalLongRecoParams, HcalLongRecoParamsRcd>();
71  tok_ZDCLowGainFractions = esConsumes<HcalZDCLowGainFractions, HcalZDCLowGainFractionsRcd>();
72  tok_MCParams = esConsumes<HcalMCParams, HcalMCParamsRcd>();
73  tok_FlagHFDigiTimeParams = esConsumes<HcalFlagHFDigiTimeParams, HcalFlagHFDigiTimeParamsRcd>();
74  tok_SiPMParameters = esConsumes<HcalSiPMParameters, HcalSiPMParametersRcd>();
75  tok_SiPMCharacteristics = esConsumes<HcalSiPMCharacteristics, HcalSiPMCharacteristicsRcd>();
76  tok_TPChannelParameters = esConsumes<HcalTPChannelParameters, HcalTPChannelParametersRcd>();
77  tok_TPParameters = esConsumes<HcalTPParameters, HcalTPParametersRcd>();
78  }
79 
80  explicit HcalDumpConditions(int i) {}
81  ~HcalDumpConditions() override {}
82  void analyze(const edm::Event& e, const edm::EventSetup& c) override;
83 
84  template <class S, class SRcd>
85  void dumpIt(const std::vector<std::string>& mDumpRequest,
86  const edm::Event& e,
87  const edm::EventSetup& context,
88  const std::string name,
89  const edm::ESGetToken<S, SRcd> tok);
90  template <class S, class SRcd>
91  void dumpIt(const std::vector<std::string>& mDumpRequest,
92  const edm::Event& e,
93  const edm::EventSetup& context,
94  const std::string name,
95  const HcalTopology* topo,
96  const edm::ESGetToken<S, SRcd> tok);
97  template <class S>
98  void writeToFile(const S& myS, const edm::Event& e, const std::string name);
99 
100  private:
102  std::vector<std::string> mDumpRequest;
136  };
137 
138  template <class S, class SRcd>
139  void HcalDumpConditions::dumpIt(const std::vector<std::string>& mDumpRequest,
140  const edm::Event& e,
141  const edm::EventSetup& context,
142  const std::string name,
143  const edm::ESGetToken<S, SRcd> tok) {
144  if (std::find(mDumpRequest.begin(), mDumpRequest.end(), name) != mDumpRequest.end()) {
145  const S& myobject = context.getData(tok);
146 
147  writeToFile(myobject, e, name);
148 
149  if (context.get<SRcd>().validityInterval().first() == edm::IOVSyncValue::invalidIOVSyncValue())
150  std::cout << "error: invalid IOV sync value !" << std::endl;
151  }
152  }
153 
154  template <class S, class SRcd>
155  void HcalDumpConditions::dumpIt(const std::vector<std::string>& mDumpRequest,
156  const edm::Event& e,
157  const edm::EventSetup& context,
158  const std::string name,
159  const HcalTopology* topo,
160  const edm::ESGetToken<S, SRcd> tok) {
161  if (std::find(mDumpRequest.begin(), mDumpRequest.end(), name) != mDumpRequest.end()) {
162  S myobject = context.getData(tok);
163  if (topo)
164  myobject.setTopo(topo);
165 
166  writeToFile(myobject, e, name);
167 
168  if (context.get<SRcd>().validityInterval().first() == edm::IOVSyncValue::invalidIOVSyncValue())
169  std::cout << "error: invalid IOV sync value !" << std::endl;
170  }
171  }
172 
173  template <class S>
174  void HcalDumpConditions::writeToFile(const S& myS, const edm::Event& e, const std::string name) {
175  int myrun = e.id().run();
176  std::ostringstream file;
177  file << front << name.c_str() << "_Run" << myrun << ".txt";
178  std::ofstream outStream(file.str().c_str());
179  std::cout << "HcalDumpConditions: ---- Dumping " << name << " ----" << std::endl;
180  HcalDbASCIIIO::dumpObject(outStream, myS);
181  }
182 
184  const HcalTopology* topo = &context.getData(m_toktopo);
185 
186  using namespace edm::eventsetup;
187  std::cout << "HcalDumpConditions::analyze-> I AM IN RUN NUMBER " << e.id().run() << std::endl;
188 
189  if (mDumpRequest.empty())
190  return;
191 
192  // dumpIt called for all possible ValueMaps. The function checks if the dump is actually requested.
193 
194  dumpIt<HcalElectronicsMap, HcalElectronicsMapRcd>(mDumpRequest, e, context, "ElectronicsMap", tok_ElectronicsMap);
195  dumpIt<HcalFrontEndMap, HcalFrontEndMapRcd>(mDumpRequest, e, context, "FrontEndMap", tok_FrontEndMap);
196  dumpIt<HcalQIEData, HcalQIEDataRcd>(mDumpRequest, e, context, "QIEData", topo, tok_QIEData);
197  dumpIt<HcalQIETypes, HcalQIETypesRcd>(mDumpRequest, e, context, "QIETypes", topo, tok_QIETypes);
198  dumpIt<HcalPedestals, HcalPedestalsRcd>(mDumpRequest, e, context, "Pedestals", topo, tok_Pedestals);
199  dumpIt<HcalPedestalWidths, HcalPedestalWidthsRcd>(
200  mDumpRequest, e, context, "PedestalWidths", topo, tok_PedestalWidths);
201  dumpIt<HcalPedestals, HcalPedestalsRcd>(
202  mDumpRequest, e, context, "EffectivePedestals", topo, tok_Pedestals_effective);
203  dumpIt<HcalPedestalWidths, HcalPedestalWidthsRcd>(
204  mDumpRequest, e, context, "EffectivePedestalWidths", topo, tok_PedestalWidths_effective);
205  dumpIt<HcalGains, HcalGainsRcd>(mDumpRequest, e, context, "Gains", topo, tok_Gains);
206  dumpIt<HcalGainWidths, HcalGainWidthsRcd>(mDumpRequest, e, context, "GainWidths", topo, tok_GainWidths);
207  dumpIt<HcalChannelQuality, HcalChannelQualityRcd>(
208  mDumpRequest, e, context, "ChannelQuality", topo, tok_ChannelQuality);
209  dumpIt<HcalRespCorrs, HcalRespCorrsRcd>(mDumpRequest, e, context, "RespCorrs", topo, tok_RespCorrs);
210  dumpIt<HcalZSThresholds, HcalZSThresholdsRcd>(mDumpRequest, e, context, "ZSThresholds", topo, tok_ZSThresholds);
211  dumpIt<HcalL1TriggerObjects, HcalL1TriggerObjectsRcd>(
212  mDumpRequest, e, context, "L1TriggerObjects", topo, tok_L1TriggerObjects);
213  dumpIt<HcalTimeCorrs, HcalTimeCorrsRcd>(mDumpRequest, e, context, "TimeCorrs", topo, tok_TimeCorrs);
214  dumpIt<HcalLUTCorrs, HcalLUTCorrsRcd>(mDumpRequest, e, context, "LUTCorrs", topo, tok_LUTCorrs);
215  dumpIt<HcalPFCorrs, HcalPFCorrsRcd>(mDumpRequest, e, context, "PFCorrs", topo, tok_PFCorrs);
216  dumpIt<HcalValidationCorrs, HcalValidationCorrsRcd>(
217  mDumpRequest, e, context, "ValidationCorrs", topo, tok_ValidationCorrs);
218  dumpIt<HcalLutMetadata, HcalLutMetadataRcd>(mDumpRequest, e, context, "LutMetadata", topo, tok_LutMetadata);
219  dumpIt<HcalDcsValues, HcalDcsRcd>(mDumpRequest, e, context, "DcsValues", tok_DcsValues);
220  dumpIt<HcalDcsMap, HcalDcsMapRcd>(mDumpRequest, e, context, "DcsMap", tok_DcsMap);
221  dumpIt<HcalRecoParams, HcalRecoParamsRcd>(mDumpRequest, e, context, "RecoParams", topo, tok_RecoParams);
222  dumpIt<HcalTimingParams, HcalTimingParamsRcd>(mDumpRequest, e, context, "TimingParams", topo, tok_TimingParams);
223  dumpIt<HcalLongRecoParams, HcalLongRecoParamsRcd>(
224  mDumpRequest, e, context, "LongRecoParams", topo, tok_LongRecoParams);
225  dumpIt<HcalZDCLowGainFractions, HcalZDCLowGainFractionsRcd>(
226  mDumpRequest, e, context, "ZDCLowGainFractions", topo, tok_ZDCLowGainFractions);
227  dumpIt<HcalMCParams, HcalMCParamsRcd>(mDumpRequest, e, context, "MCParams", topo, tok_MCParams);
228  dumpIt<HcalFlagHFDigiTimeParams, HcalFlagHFDigiTimeParamsRcd>(
229  mDumpRequest, e, context, "FlagHFDigiTimeParams", topo, tok_FlagHFDigiTimeParams);
230  dumpIt<HcalSiPMParameters, HcalSiPMParametersRcd>(
231  mDumpRequest, e, context, "SiPMParameters", topo, tok_SiPMParameters);
232  dumpIt<HcalSiPMCharacteristics, HcalSiPMCharacteristicsRcd>(
233  mDumpRequest, e, context, "SiPMCharacteristics", tok_SiPMCharacteristics);
234  dumpIt<HcalTPChannelParameters, HcalTPChannelParametersRcd>(
235  mDumpRequest, e, context, "TPChannelParameters", topo, tok_TPChannelParameters);
236  dumpIt<HcalTPParameters, HcalTPParametersRcd>(mDumpRequest, e, context, "TPParameters", tok_TPParameters);
237  }
239 } // namespace edmtest
edmtest::HcalDumpConditions::writeToFile
void writeToFile(const S &myS, const edm::Event &e, const std::string name)
Definition: HcalDumpConditions.cc:174
edmtest::HcalDumpConditions::tok_Pedestals_effective
edm::ESGetToken< HcalPedestals, HcalPedestalsRcd > tok_Pedestals_effective
Definition: HcalDumpConditions.cc:111
edmtest::HcalDumpConditions::tok_L1TriggerObjects
edm::ESGetToken< HcalL1TriggerObjects, HcalL1TriggerObjectsRcd > tok_L1TriggerObjects
Definition: HcalDumpConditions.cc:118
edmtest::HcalDumpConditions::tok_TimingParams
edm::ESGetToken< HcalTimingParams, HcalTimingParamsRcd > tok_TimingParams
Definition: HcalDumpConditions.cc:127
mps_fire.i
i
Definition: mps_fire.py:428
edm::ESInputTag
Definition: ESInputTag.h:87
edmtest::HcalDumpConditions::tok_QIEData
edm::ESGetToken< HcalQIEData, HcalQIEDataRcd > tok_QIEData
Definition: HcalDumpConditions.cc:107
edm::IOVSyncValue::invalidIOVSyncValue
static const IOVSyncValue & invalidIOVSyncValue()
Definition: IOVSyncValue.cc:78
edmtest
Definition: AlignPCLThresholdsReader.cc:11
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
edmtest::HcalDumpConditions
Definition: HcalDumpConditions.cc:38
AllObjects.h
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HcalTopology
Definition: HcalTopology.h:26
edmtest::HcalDumpConditions::m_tokdb
edm::ESGetToken< HcalDbService, HcalDbRecord > m_tokdb
Definition: HcalDumpConditions.cc:104
edmtest::HcalDumpConditions::tok_RespCorrs
edm::ESGetToken< HcalRespCorrs, HcalRespCorrsRcd > tok_RespCorrs
Definition: HcalDumpConditions.cc:116
edmtest::HcalDumpConditions::tok_QIETypes
edm::ESGetToken< HcalQIETypes, HcalQIETypesRcd > tok_QIETypes
Definition: HcalDumpConditions.cc:108
edmtest::HcalDumpConditions::dumpIt
void dumpIt(const std::vector< std::string > &mDumpRequest, const edm::Event &e, const edm::EventSetup &context, const std::string name, const edm::ESGetToken< S, SRcd > tok)
Definition: HcalDumpConditions.cc:139
HcalRecNumberingRecord.h
edmtest::HcalDumpConditions::tok_SiPMParameters
edm::ESGetToken< HcalSiPMParameters, HcalSiPMParametersRcd > tok_SiPMParameters
Definition: HcalDumpConditions.cc:132
EDAnalyzer.h
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
edmtest::HcalDumpConditions::tok_ElectronicsMap
edm::ESGetToken< HcalElectronicsMap, HcalElectronicsMapRcd > tok_ElectronicsMap
Definition: HcalDumpConditions.cc:105
edm::EDAnalyzer
Definition: EDAnalyzer.h:28
edmtest::HcalDumpConditions::tok_SiPMCharacteristics
edm::ESGetToken< HcalSiPMCharacteristics, HcalSiPMCharacteristicsRcd > tok_SiPMCharacteristics
Definition: HcalDumpConditions.cc:133
MakerMacros.h
edmtest::HcalDumpConditions::tok_PedestalWidths
edm::ESGetToken< HcalPedestalWidths, HcalPedestalWidthsRcd > tok_PedestalWidths
Definition: HcalDumpConditions.cc:110
edmtest::HcalDumpConditions::tok_PedestalWidths_effective
edm::ESGetToken< HcalPedestalWidths, HcalPedestalWidthsRcd > tok_PedestalWidths_effective
Definition: HcalDumpConditions.cc:112
edmtest::HcalDumpConditions::tok_ZDCLowGainFractions
edm::ESGetToken< HcalZDCLowGainFractions, HcalZDCLowGainFractionsRcd > tok_ZDCLowGainFractions
Definition: HcalDumpConditions.cc:129
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edmtest::HcalDumpConditions::tok_ZSThresholds
edm::ESGetToken< HcalZSThresholds, HcalZSThresholdsRcd > tok_ZSThresholds
Definition: HcalDumpConditions.cc:117
edmtest::HcalDumpConditions::tok_LUTCorrs
edm::ESGetToken< HcalLUTCorrs, HcalLUTCorrsRcd > tok_LUTCorrs
Definition: HcalDumpConditions.cc:120
edmtest::HcalDumpConditions::tok_FrontEndMap
edm::ESGetToken< HcalFrontEndMap, HcalFrontEndMapRcd > tok_FrontEndMap
Definition: HcalDumpConditions.cc:106
edmtest::HcalDumpConditions::tok_Pedestals
edm::ESGetToken< HcalPedestals, HcalPedestalsRcd > tok_Pedestals
Definition: HcalDumpConditions.cc:109
edmtest::HcalDumpConditions::tok_PFCorrs
edm::ESGetToken< HcalPFCorrs, HcalPFCorrsRcd > tok_PFCorrs
Definition: HcalDumpConditions.cc:121
HcalDbRecord.h
edmtest::HcalDumpConditions::tok_FlagHFDigiTimeParams
edm::ESGetToken< HcalFlagHFDigiTimeParams, HcalFlagHFDigiTimeParamsRcd > tok_FlagHFDigiTimeParams
Definition: HcalDumpConditions.cc:131
edmtest::HcalDumpConditions::m_toktopo
edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > m_toktopo
Definition: HcalDumpConditions.cc:103
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edmtest::HcalDumpConditions::tok_RecoParams
edm::ESGetToken< HcalRecoParams, HcalRecoParamsRcd > tok_RecoParams
Definition: HcalDumpConditions.cc:126
edmtest::HcalDumpConditions::tok_TPChannelParameters
edm::ESGetToken< HcalTPChannelParameters, HcalTPChannelParametersRcd > tok_TPChannelParameters
Definition: HcalDumpConditions.cc:134
edmtest::HcalDumpConditions::tok_Gains
edm::ESGetToken< HcalGains, HcalGainsRcd > tok_Gains
Definition: HcalDumpConditions.cc:113
edmtest::HcalDumpConditions::tok_LutMetadata
edm::ESGetToken< HcalLutMetadata, HcalLutMetadataRcd > tok_LutMetadata
Definition: HcalDumpConditions.cc:123
edmtest::HcalDumpConditions::mDumpRequest
std::vector< std::string > mDumpRequest
Definition: HcalDumpConditions.cc:102
edmtest::HcalDumpConditions::tok_GainWidths
edm::ESGetToken< HcalGainWidths, HcalGainWidthsRcd > tok_GainWidths
Definition: HcalDumpConditions.cc:114
edmtest::HcalDumpConditions::tok_DcsValues
edm::ESGetToken< HcalDcsValues, HcalDcsRcd > tok_DcsValues
Definition: HcalDumpConditions.cc:124
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
edmtest::HcalDumpConditions::HcalDumpConditions
HcalDumpConditions(edm::ParameterSet const &p)
Definition: HcalDumpConditions.cc:40
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
HcalAllRcds.h
edm::EventSetup
Definition: EventSetup.h:58
edm::ESGetToken
Definition: EventSetup.h:48
edmtest::HcalDumpConditions::front
std::string front
Definition: HcalDumpConditions.cc:101
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
edmtest::HcalDumpConditions::HcalDumpConditions
HcalDumpConditions(int i)
Definition: HcalDumpConditions.cc:80
HcalDbASCIIIO::dumpObject
bool dumpObject(std::ostream &fOutput, const HcalPedestals &fObject)
edmtest::HcalDumpConditions::tok_TPParameters
edm::ESGetToken< HcalTPParameters, HcalTPParametersRcd > tok_TPParameters
Definition: HcalDumpConditions.cc:135
HcalDbASCIIIO.h
edmtest::HcalDumpConditions::tok_DcsMap
edm::ESGetToken< HcalDcsMap, HcalDcsMapRcd > tok_DcsMap
Definition: HcalDumpConditions.cc:125
edmtest::HcalDumpConditions::analyze
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Definition: HcalDumpConditions.cc:183
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
EventSetup.h
S
Definition: CSCDBL1TPParametersExtended.h:16
HcalDbService.h
ParameterSet.h
edmtest::HcalDumpConditions::tok_LongRecoParams
edm::ESGetToken< HcalLongRecoParams, HcalLongRecoParamsRcd > tok_LongRecoParams
Definition: HcalDumpConditions.cc:128
edmtest::HcalDumpConditions::~HcalDumpConditions
~HcalDumpConditions() override
Definition: HcalDumpConditions.cc:81
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
edmtest::HcalDumpConditions::tok_TimeCorrs
edm::ESGetToken< HcalTimeCorrs, HcalTimeCorrsRcd > tok_TimeCorrs
Definition: HcalDumpConditions.cc:119
edm::Event
Definition: Event.h:73
edm::eventsetup
Definition: ES_DDDetector.cc:16
edmtest::HcalDumpConditions::tok_MCParams
edm::ESGetToken< HcalMCParams, HcalMCParamsRcd > tok_MCParams
Definition: HcalDumpConditions.cc:130
IOVSyncValue.h
edmtest::HcalDumpConditions::tok_ValidationCorrs
edm::ESGetToken< HcalValidationCorrs, HcalValidationCorrsRcd > tok_ValidationCorrs
Definition: HcalDumpConditions.cc:122
edmtest::HcalDumpConditions::tok_ChannelQuality
edm::ESGetToken< HcalChannelQuality, HcalChannelQualityRcd > tok_ChannelQuality
Definition: HcalDumpConditions.cc:115
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37