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_PFCuts = esConsumes<HcalPFCuts, HcalPFCutsRcd>();
58  tok_ChannelQuality = esConsumes<HcalChannelQuality, HcalChannelQualityRcd>();
59  tok_RespCorrs = esConsumes<HcalRespCorrs, HcalRespCorrsRcd>();
60  tok_ZSThresholds = esConsumes<HcalZSThresholds, HcalZSThresholdsRcd>();
61  tok_L1TriggerObjects = esConsumes<HcalL1TriggerObjects, HcalL1TriggerObjectsRcd>();
62  tok_TimeCorrs = esConsumes<HcalTimeCorrs, HcalTimeCorrsRcd>();
63  tok_LUTCorrs = esConsumes<HcalLUTCorrs, HcalLUTCorrsRcd>();
64  tok_PFCorrs = esConsumes<HcalPFCorrs, HcalPFCorrsRcd>();
65  tok_ValidationCorrs = esConsumes<HcalValidationCorrs, HcalValidationCorrsRcd>();
66  tok_LutMetadata = esConsumes<HcalLutMetadata, HcalLutMetadataRcd>();
67  tok_DcsValues = esConsumes<HcalDcsValues, HcalDcsRcd>();
68  tok_DcsMap = esConsumes<HcalDcsMap, HcalDcsMapRcd>();
69  tok_RecoParams = esConsumes<HcalRecoParams, HcalRecoParamsRcd>();
70  tok_TimingParams = esConsumes<HcalTimingParams, HcalTimingParamsRcd>();
71  tok_LongRecoParams = esConsumes<HcalLongRecoParams, HcalLongRecoParamsRcd>();
72  tok_ZDCLowGainFractions = esConsumes<HcalZDCLowGainFractions, HcalZDCLowGainFractionsRcd>();
73  tok_MCParams = esConsumes<HcalMCParams, HcalMCParamsRcd>();
74  tok_FlagHFDigiTimeParams = esConsumes<HcalFlagHFDigiTimeParams, HcalFlagHFDigiTimeParamsRcd>();
75  tok_SiPMParameters = esConsumes<HcalSiPMParameters, HcalSiPMParametersRcd>();
76  tok_SiPMCharacteristics = esConsumes<HcalSiPMCharacteristics, HcalSiPMCharacteristicsRcd>();
77  tok_TPChannelParameters = esConsumes<HcalTPChannelParameters, HcalTPChannelParametersRcd>();
78  tok_TPParameters = esConsumes<HcalTPParameters, HcalTPParametersRcd>();
79  }
80 
81  explicit HcalDumpConditions(int i) {}
82  ~HcalDumpConditions() override {}
83  void analyze(const edm::Event& e, const edm::EventSetup& c) override;
84 
85  template <class S, class SRcd>
86  void dumpIt(const std::vector<std::string>& mDumpRequest,
87  const edm::Event& e,
88  const edm::EventSetup& context,
89  const std::string name,
90  const edm::ESGetToken<S, SRcd> tok);
91  template <class S, class SRcd>
92  void dumpIt(const std::vector<std::string>& mDumpRequest,
93  const edm::Event& e,
94  const edm::EventSetup& context,
95  const std::string name,
96  const HcalTopology* topo,
97  const edm::ESGetToken<S, SRcd> tok);
98  template <class S>
99  void writeToFile(const S& myS, const edm::Event& e, const std::string name);
100 
101  private:
103  std::vector<std::string> mDumpRequest;
138  };
139 
140  template <class S, class SRcd>
141  void HcalDumpConditions::dumpIt(const std::vector<std::string>& mDumpRequest,
142  const edm::Event& e,
143  const edm::EventSetup& context,
144  const std::string name,
145  const edm::ESGetToken<S, SRcd> tok) {
146  if (std::find(mDumpRequest.begin(), mDumpRequest.end(), name) != mDumpRequest.end()) {
147  const S& myobject = context.getData(tok);
148 
149  writeToFile(myobject, e, name);
150 
151  if (context.get<SRcd>().validityInterval().first() == edm::IOVSyncValue::invalidIOVSyncValue())
152  std::cout << "error: invalid IOV sync value !" << std::endl;
153  }
154  }
155 
156  template <class S, class SRcd>
157  void HcalDumpConditions::dumpIt(const std::vector<std::string>& mDumpRequest,
158  const edm::Event& e,
159  const edm::EventSetup& context,
160  const std::string name,
161  const HcalTopology* topo,
162  const edm::ESGetToken<S, SRcd> tok) {
163  if (std::find(mDumpRequest.begin(), mDumpRequest.end(), name) != mDumpRequest.end()) {
164  S myobject = context.getData(tok);
165  if (topo)
166  myobject.setTopo(topo);
167 
168  writeToFile(myobject, e, name);
169 
170  if (context.get<SRcd>().validityInterval().first() == edm::IOVSyncValue::invalidIOVSyncValue())
171  std::cout << "error: invalid IOV sync value !" << std::endl;
172  }
173  }
174 
175  template <class S>
176  void HcalDumpConditions::writeToFile(const S& myS, const edm::Event& e, const std::string name) {
177  int myrun = e.id().run();
178  std::ostringstream file;
179  file << front << name.c_str() << "_Run" << myrun << ".txt";
180  std::ofstream outStream(file.str().c_str());
181  std::cout << "HcalDumpConditions: ---- Dumping " << name << " ----" << std::endl;
182  HcalDbASCIIIO::dumpObject(outStream, myS);
183  }
184 
186  const HcalTopology* topo = &context.getData(m_toktopo);
187 
188  using namespace edm::eventsetup;
189  std::cout << "HcalDumpConditions::analyze-> I AM IN RUN NUMBER " << e.id().run() << std::endl;
190 
191  if (mDumpRequest.empty())
192  return;
193 
194  // dumpIt called for all possible ValueMaps. The function checks if the dump is actually requested.
195 
196  dumpIt<HcalElectronicsMap, HcalElectronicsMapRcd>(mDumpRequest, e, context, "ElectronicsMap", tok_ElectronicsMap);
197  dumpIt<HcalFrontEndMap, HcalFrontEndMapRcd>(mDumpRequest, e, context, "FrontEndMap", tok_FrontEndMap);
198  dumpIt<HcalQIEData, HcalQIEDataRcd>(mDumpRequest, e, context, "QIEData", topo, tok_QIEData);
199  dumpIt<HcalQIETypes, HcalQIETypesRcd>(mDumpRequest, e, context, "QIETypes", topo, tok_QIETypes);
200  dumpIt<HcalPedestals, HcalPedestalsRcd>(mDumpRequest, e, context, "Pedestals", topo, tok_Pedestals);
201  dumpIt<HcalPedestalWidths, HcalPedestalWidthsRcd>(
202  mDumpRequest, e, context, "PedestalWidths", topo, tok_PedestalWidths);
203  dumpIt<HcalPedestals, HcalPedestalsRcd>(
204  mDumpRequest, e, context, "EffectivePedestals", topo, tok_Pedestals_effective);
205  dumpIt<HcalPedestalWidths, HcalPedestalWidthsRcd>(
206  mDumpRequest, e, context, "EffectivePedestalWidths", topo, tok_PedestalWidths_effective);
207  dumpIt<HcalGains, HcalGainsRcd>(mDumpRequest, e, context, "Gains", topo, tok_Gains);
208  dumpIt<HcalGainWidths, HcalGainWidthsRcd>(mDumpRequest, e, context, "GainWidths", topo, tok_GainWidths);
209  dumpIt<HcalPFCuts, HcalPFCutsRcd>(mDumpRequest, e, context, "PFCuts", topo, tok_PFCuts);
210  dumpIt<HcalChannelQuality, HcalChannelQualityRcd>(
211  mDumpRequest, e, context, "ChannelQuality", topo, tok_ChannelQuality);
212  dumpIt<HcalRespCorrs, HcalRespCorrsRcd>(mDumpRequest, e, context, "RespCorrs", topo, tok_RespCorrs);
213  dumpIt<HcalZSThresholds, HcalZSThresholdsRcd>(mDumpRequest, e, context, "ZSThresholds", topo, tok_ZSThresholds);
214  dumpIt<HcalL1TriggerObjects, HcalL1TriggerObjectsRcd>(
215  mDumpRequest, e, context, "L1TriggerObjects", topo, tok_L1TriggerObjects);
216  dumpIt<HcalTimeCorrs, HcalTimeCorrsRcd>(mDumpRequest, e, context, "TimeCorrs", topo, tok_TimeCorrs);
217  dumpIt<HcalLUTCorrs, HcalLUTCorrsRcd>(mDumpRequest, e, context, "LUTCorrs", topo, tok_LUTCorrs);
218  dumpIt<HcalPFCorrs, HcalPFCorrsRcd>(mDumpRequest, e, context, "PFCorrs", topo, tok_PFCorrs);
219  dumpIt<HcalValidationCorrs, HcalValidationCorrsRcd>(
220  mDumpRequest, e, context, "ValidationCorrs", topo, tok_ValidationCorrs);
221  dumpIt<HcalLutMetadata, HcalLutMetadataRcd>(mDumpRequest, e, context, "LutMetadata", topo, tok_LutMetadata);
222  dumpIt<HcalDcsValues, HcalDcsRcd>(mDumpRequest, e, context, "DcsValues", tok_DcsValues);
223  dumpIt<HcalDcsMap, HcalDcsMapRcd>(mDumpRequest, e, context, "DcsMap", tok_DcsMap);
224  dumpIt<HcalRecoParams, HcalRecoParamsRcd>(mDumpRequest, e, context, "RecoParams", topo, tok_RecoParams);
225  dumpIt<HcalTimingParams, HcalTimingParamsRcd>(mDumpRequest, e, context, "TimingParams", topo, tok_TimingParams);
226  dumpIt<HcalLongRecoParams, HcalLongRecoParamsRcd>(
227  mDumpRequest, e, context, "LongRecoParams", topo, tok_LongRecoParams);
228  dumpIt<HcalZDCLowGainFractions, HcalZDCLowGainFractionsRcd>(
229  mDumpRequest, e, context, "ZDCLowGainFractions", topo, tok_ZDCLowGainFractions);
230  dumpIt<HcalMCParams, HcalMCParamsRcd>(mDumpRequest, e, context, "MCParams", topo, tok_MCParams);
231  dumpIt<HcalFlagHFDigiTimeParams, HcalFlagHFDigiTimeParamsRcd>(
232  mDumpRequest, e, context, "FlagHFDigiTimeParams", topo, tok_FlagHFDigiTimeParams);
233  dumpIt<HcalSiPMParameters, HcalSiPMParametersRcd>(
234  mDumpRequest, e, context, "SiPMParameters", topo, tok_SiPMParameters);
235  dumpIt<HcalSiPMCharacteristics, HcalSiPMCharacteristicsRcd>(
236  mDumpRequest, e, context, "SiPMCharacteristics", tok_SiPMCharacteristics);
237  dumpIt<HcalTPChannelParameters, HcalTPChannelParametersRcd>(
238  mDumpRequest, e, context, "TPChannelParameters", topo, tok_TPChannelParameters);
239  dumpIt<HcalTPParameters, HcalTPParametersRcd>(mDumpRequest, e, context, "TPParameters", tok_TPParameters);
240  }
242 } // namespace edmtest
edm::ESGetToken< HcalChannelQuality, HcalChannelQualityRcd > tok_ChannelQuality
edm::ESGetToken< HcalPedestals, HcalPedestalsRcd > tok_Pedestals_effective
edm::ESGetToken< HcalDbService, HcalDbRecord > m_tokdb
edm::ESGetToken< HcalRespCorrs, HcalRespCorrsRcd > tok_RespCorrs
edm::ESGetToken< HcalQIETypes, HcalQIETypesRcd > tok_QIETypes
edm::ESGetToken< HcalPedestalWidths, HcalPedestalWidthsRcd > tok_PedestalWidths
edm::ESGetToken< HcalTimingParams, HcalTimingParamsRcd > tok_TimingParams
edm::ESGetToken< HcalZDCLowGainFractions, HcalZDCLowGainFractionsRcd > tok_ZDCLowGainFractions
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)
edm::ESGetToken< HcalFrontEndMap, HcalFrontEndMapRcd > tok_FrontEndMap
edm::ESGetToken< HcalQIEData, HcalQIEDataRcd > tok_QIEData
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
edm::ESGetToken< HcalPedestalWidths, HcalPedestalWidthsRcd > tok_PedestalWidths_effective
edm::ESGetToken< HcalZSThresholds, HcalZSThresholdsRcd > tok_ZSThresholds
edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > m_toktopo
edm::ESGetToken< HcalLUTCorrs, HcalLUTCorrsRcd > tok_LUTCorrs
edm::ESGetToken< HcalSiPMParameters, HcalSiPMParametersRcd > tok_SiPMParameters
edm::ESGetToken< HcalDcsValues, HcalDcsRcd > tok_DcsValues
edm::ESGetToken< HcalPedestals, HcalPedestalsRcd > tok_Pedestals
edm::ESGetToken< HcalPFCorrs, HcalPFCorrsRcd > tok_PFCorrs
edm::ESGetToken< HcalElectronicsMap, HcalElectronicsMapRcd > tok_ElectronicsMap
edm::ESGetToken< HcalSiPMCharacteristics, HcalSiPMCharacteristicsRcd > tok_SiPMCharacteristics
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
HcalDumpConditions(edm::ParameterSet const &p)
edm::ESGetToken< HcalLutMetadata, HcalLutMetadataRcd > tok_LutMetadata
edm::ESGetToken< HcalFlagHFDigiTimeParams, HcalFlagHFDigiTimeParamsRcd > tok_FlagHFDigiTimeParams
edm::ESGetToken< HcalDcsMap, HcalDcsMapRcd > tok_DcsMap
edm::ESGetToken< HcalTPChannelParameters, HcalTPChannelParametersRcd > tok_TPChannelParameters
edm::ESGetToken< HcalRecoParams, HcalRecoParamsRcd > tok_RecoParams
edm::ESGetToken< HcalGains, HcalGainsRcd > tok_Gains
std::vector< std::string > mDumpRequest
edm::ESGetToken< HcalGainWidths, HcalGainWidthsRcd > tok_GainWidths
edm::ESGetToken< HcalPFCuts, HcalPFCutsRcd > tok_PFCuts
bool dumpObject(std::ostream &fOutput, const HcalPedestals &fObject)
edm::ESGetToken< HcalValidationCorrs, HcalValidationCorrsRcd > tok_ValidationCorrs
edm::ESGetToken< HcalLongRecoParams, HcalLongRecoParamsRcd > tok_LongRecoParams
void analyze(const edm::Event &e, const edm::EventSetup &c) override
edm::ESGetToken< HcalMCParams, HcalMCParamsRcd > tok_MCParams
edm::ESGetToken< HcalL1TriggerObjects, HcalL1TriggerObjectsRcd > tok_L1TriggerObjects
edm::ESGetToken< HcalTPParameters, HcalTPParametersRcd > tok_TPParameters
edm::ESGetToken< HcalTimeCorrs, HcalTimeCorrsRcd > tok_TimeCorrs
static const IOVSyncValue & invalidIOVSyncValue()
Definition: IOVSyncValue.cc:78
void writeToFile(const S &myS, const edm::Event &e, const std::string name)