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>
23 
26 
28 
30 
34 
37 
38 namespace edmtest
39 {
41  {
42  public:
44  {
45  front = p.getUntrackedParameter<std::string>("outFilePrefix","Dump");
46  mDumpRequest = p.getUntrackedParameter <std::vector <std::string> > ("dump", std::vector<std::string>());
47  }
48 
49  explicit HcalDumpConditions(int i)
50  { }
51  ~ HcalDumpConditions() override { }
52  void analyze(const edm::Event& e, const edm::EventSetup& c) override;
53 
54  template<class S, class SRcd> void dumpIt(const std::vector<std::string>& mDumpRequest,
55  const edm::Event& e,
56  const edm::EventSetup& context,
57  const std::string name,
58  const HcalTopology * topo,
59  const std::string label="");
60  template<class S, class SRcd> void dumpIt(const std::vector<std::string>& mDumpRequest,
61  const edm::Event& e,
62  const edm::EventSetup& context,
63  const std::string name);
64  template<class S> void writeToFile(const S& myS, const edm::Event& e, const std::string name);
65 
66  private:
68  std::vector<std::string> mDumpRequest;
69  };
70 
71 
72  template<class S, class SRcd>
73  void HcalDumpConditions::dumpIt(const std::vector<std::string>& mDumpRequest,
74  const edm::Event& e,
75  const edm::EventSetup& context,
76  const std::string name,
77  const HcalTopology * topo,
78  const std::string label)
79  {
80  if (std::find (mDumpRequest.begin(), mDumpRequest.end(), name) != mDumpRequest.end())
81  {
83  if(!label.empty()) context.get<SRcd>().get(label, p);
84  else context.get<SRcd>().get(p);
85  S myobject(*p.product());
86  if( topo ) myobject.setTopo(topo);
87 
88  writeToFile(myobject, e, name);
89 
90  if ( context.get<SRcd>().validityInterval().first() == edm::IOVSyncValue::invalidIOVSyncValue() )
91  std::cout << "error: invalid IOV sync value !" << std::endl;
92  }
93  }
94 
95 
96  template<class S, class SRcd>
97  void HcalDumpConditions::dumpIt(const std::vector<std::string>& mDumpRequest,
98  const edm::Event& e,
99  const edm::EventSetup& context,
100  const std::string name)
101  {
102  if (std::find (mDumpRequest.begin(), mDumpRequest.end(), name) != mDumpRequest.end())
103  {
105  context.get<SRcd>().get(p);
106  S myobject(*p.product());
107 
108  writeToFile(myobject, e, name);
109 
110  if ( context.get<SRcd>().validityInterval().first() == edm::IOVSyncValue::invalidIOVSyncValue() )
111  std::cout << "error: invalid IOV sync value !" << std::endl;
112  }
113  }
114 
115  template<class S> void HcalDumpConditions::writeToFile(const S& myS, const edm::Event& e, const std::string name){
116  int myrun = e.id().run();
117  std::ostringstream file;
118  file << front << name.c_str() << "_Run" << myrun << ".txt";
119  std::ofstream outStream(file.str().c_str() );
120  std::cout << "HcalDumpConditions: ---- Dumping " << name << " ----" << std::endl;
121  HcalDbASCIIIO::dumpObject (outStream, myS );
122  }
123 
124  void
126  {
128  context.get<HcalRecNumberingRecord>().get( topology );
129  const HcalTopology* topo=&(*topology);
130 
131  using namespace edm::eventsetup;
132  std::cout <<"HcalDumpConditions::analyze-> I AM IN RUN NUMBER "<<e.id().run() <<std::endl;
133 
134  if (mDumpRequest.empty()) return;
135 
136  // dumpIt called for all possible ValueMaps. The function checks if the dump is actually requested.
137  dumpIt<HcalElectronicsMap, HcalElectronicsMapRcd> (mDumpRequest, e, context,"ElectronicsMap" );
138  dumpIt<HcalFrontEndMap, HcalFrontEndMapRcd> (mDumpRequest, e, context,"FrontEndMap" );
139  dumpIt<HcalQIEData, HcalQIEDataRcd> (mDumpRequest, e, context,"QIEData", topo);
140  dumpIt<HcalQIETypes, HcalQIETypesRcd> (mDumpRequest, e, context,"QIETypes", topo);
141  dumpIt<HcalPedestals, HcalPedestalsRcd> (mDumpRequest, e, context,"Pedestals", topo);
142  dumpIt<HcalPedestalWidths, HcalPedestalWidthsRcd> (mDumpRequest, e, context,"PedestalWidths", topo);
143  dumpIt<HcalPedestals, HcalPedestalsRcd> (mDumpRequest, e, context,"EffectivePedestals", topo, "effective");
144  dumpIt<HcalPedestalWidths, HcalPedestalWidthsRcd> (mDumpRequest, e, context,"EffectivePedestalWidths", topo, "effective");
145  dumpIt<HcalGains, HcalGainsRcd> (mDumpRequest, e, context,"Gains", topo);
146  dumpIt<HcalGainWidths, HcalGainWidthsRcd> (mDumpRequest, e, context,"GainWidths", topo);
147  dumpIt<HcalChannelQuality, HcalChannelQualityRcd> (mDumpRequest, e, context,"ChannelQuality", topo, "withTopo" );
148  dumpIt<HcalRespCorrs, HcalRespCorrsRcd> (mDumpRequest, e, context,"RespCorrs", topo);
149  dumpIt<HcalZSThresholds, HcalZSThresholdsRcd> (mDumpRequest, e, context,"ZSThresholds", topo);
150  dumpIt<HcalL1TriggerObjects, HcalL1TriggerObjectsRcd> (mDumpRequest, e, context,"L1TriggerObjects", topo);
151  dumpIt<HcalTimeCorrs, HcalTimeCorrsRcd> (mDumpRequest, e, context,"TimeCorrs", topo);
152  dumpIt<HcalLUTCorrs, HcalLUTCorrsRcd> (mDumpRequest, e, context,"LUTCorrs", topo);
153  dumpIt<HcalPFCorrs, HcalPFCorrsRcd> (mDumpRequest, e, context,"PFCorrs", topo);
154  dumpIt<HcalValidationCorrs, HcalValidationCorrsRcd> (mDumpRequest, e, context,"ValidationCorrs", topo);
155  dumpIt<HcalLutMetadata, HcalLutMetadataRcd> (mDumpRequest, e, context,"LutMetadata", topo);
156  dumpIt<HcalDcsValues, HcalDcsRcd> (mDumpRequest, e, context,"DcsValues" );
157  dumpIt<HcalDcsMap, HcalDcsMapRcd> (mDumpRequest, e, context,"DcsMap" );
158  dumpIt<HcalRecoParams, HcalRecoParamsRcd> (mDumpRequest, e, context,"RecoParams", topo);
159  dumpIt<HcalTimingParams, HcalTimingParamsRcd> (mDumpRequest, e, context,"TimingParams", topo);
160  dumpIt<HcalLongRecoParams, HcalLongRecoParamsRcd> (mDumpRequest, e, context,"LongRecoParams", topo);
161  dumpIt<HcalZDCLowGainFractions, HcalZDCLowGainFractionsRcd> (mDumpRequest, e, context,"ZDCLowGainFractions", topo);
162  dumpIt<HcalMCParams, HcalMCParamsRcd> (mDumpRequest, e, context,"MCParams", topo);
163  dumpIt<HcalFlagHFDigiTimeParams, HcalFlagHFDigiTimeParamsRcd>(mDumpRequest, e, context,"FlagHFDigiTimeParams", topo);
164  dumpIt<HcalSiPMParameters, HcalSiPMParametersRcd> (mDumpRequest, e, context,"SiPMParameters", topo);
165  dumpIt<HcalSiPMCharacteristics, HcalSiPMCharacteristicsRcd> (mDumpRequest, e, context,"SiPMCharacteristics" );
166  dumpIt<HcalTPChannelParameters, HcalTPChannelParametersRcd> (mDumpRequest, e, context,"TPChannelParameters", topo);
167  dumpIt<HcalTPParameters, HcalTPParametersRcd> (mDumpRequest, e, context,"TPParameters" );
168 
170  if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("CalibrationsSet")) != mDumpRequest.end()
171  || std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("CalibrationWidthsSet")) != mDumpRequest.end())
172  {
173  context.get<HcalDbRecord>().get( pSetup );
174  if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("CalibrationsSet")) != mDumpRequest.end()){
175  writeToFile(*pSetup->getHcalCalibrationsSet(),e,"CalibrationsSet");
176  }
177  if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("CalibrationWidthsSet")) != mDumpRequest.end()){
178  writeToFile(*pSetup->getHcalCalibrationWidthsSet(),e,"CalibrationWidthsSet");
179  }
180  }
181  }
183 }
RunNumber_t run() const
Definition: EventID.h:39
T getUntrackedParameter(std::string const &, T const &) const
CaloTopology const * topology(0)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void dumpIt(const std::vector< std::string > &mDumpRequest, const edm::Event &e, const edm::EventSetup &context, const std::string name, const HcalTopology *topo, const std::string label="")
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
HcalDumpConditions(edm::ParameterSet const &p)
std::vector< std::string > mDumpRequest
edm::EventID id() const
Definition: EventBase.h:60
bool dumpObject(std::ostream &fOutput, const HcalPedestals &fObject)
T get() const
Definition: EventSetup.h:62
void analyze(const edm::Event &e, const edm::EventSetup &c) override
T const * product() const
Definition: ESHandle.h:86
static const IOVSyncValue & invalidIOVSyncValue()
Definition: IOVSyncValue.cc:92
void writeToFile(const S &myS, const edm::Event &e, const std::string name)