CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CastorDumpConditions.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Castor
4 // Class: CastorDumpConditions
5 //
13 //
14 // Original Author: Luiz Mundim Filho
15 // Created: Thu Mar 12 14:45:44 CET 2009
16 // $Id: CastorDumpConditions.cc,v 1.1 2011/05/09 19:38:47 mundim Exp $
17 //
18 //
19 
20 // system include files
21 #include <memory>
22 #include <iostream>
23 #include <fstream>
24 #include <sstream>
25 #include <string>
26 
27 // user include files
30 
34 
37 
49 
51 //
52 // class decleration
53 //
54 
56 public:
57  explicit CastorDumpConditions(const edm::ParameterSet&);
58 
59  template <class S, class SRcd>
60  void dumpIt(const std::vector<std::string>& mDumpRequest,
61  const edm::Event& e,
62  const edm::EventSetup& context,
63  const std::string name);
64 
65 private:
67  std::vector<std::string> mDumpRequest;
68  void analyze(const edm::Event&, const edm::EventSetup&) override;
69 
70  // ----------member data ---------------------------
71 };
72 
73 //
74 // constants, enums and typedefs
75 //
76 
77 //
78 // static data member definitions
79 //
80 
81 //
82 // constructors and destructor
83 //
85 
86 {
87  file_prefix = iConfig.getUntrackedParameter<std::string>("outFilePrefix", "Dump");
88  mDumpRequest = iConfig.getUntrackedParameter<std::vector<std::string> >("dump", std::vector<std::string>());
89  if (mDumpRequest.empty()) {
90  throw cms::Exception("Bad Config") << "CastorDumpConditions: No record to dump.";
91  }
92 }
93 
94 //
95 // member functions
96 //
97 
98 // ------------ method called to for each event ------------
100  using namespace edm;
101 
102  {
103  edm::LogAbsolute log("CastorDumpConditions");
104  log << "I AM IN THE RUN " << iEvent.id().run() << "\n";
105  log << "What to dump? " << std::endl;
106  if (mDumpRequest.empty()) {
107  log << "CastorDumpConditions: Empty request \n";
108  return;
109  }
110  }
111 
112  for (std::vector<std::string>::const_iterator it = mDumpRequest.begin(); it != mDumpRequest.end(); it++)
113  LogAbsolute("CastorDumpConditions") << *it << "\n";
114 
115  // dumpIt called for all possible ValueMaps. The function checks if the dump is actually requested.
116  dumpIt<CastorElectronicsMap, CastorElectronicsMapRcd>(mDumpRequest, iEvent, iSetup, "ElectronicsMap");
117  dumpIt<CastorQIEData, CastorQIEDataRcd>(mDumpRequest, iEvent, iSetup, "QIEData");
118  dumpIt<CastorPedestals, CastorPedestalsRcd>(mDumpRequest, iEvent, iSetup, "Pedestals");
119  dumpIt<CastorPedestalWidths, CastorPedestalWidthsRcd>(mDumpRequest, iEvent, iSetup, "PedestalWidths");
120  dumpIt<CastorGains, CastorGainsRcd>(mDumpRequest, iEvent, iSetup, "Gains");
121  dumpIt<CastorGainWidths, CastorGainWidthsRcd>(mDumpRequest, iEvent, iSetup, "GainWidths");
122  dumpIt<CastorChannelQuality, CastorChannelQualityRcd>(mDumpRequest, iEvent, iSetup, "ChannelQuality");
123  dumpIt<CastorRecoParams, CastorRecoParamsRcd>(mDumpRequest, iEvent, iSetup, "RecoParams");
124  dumpIt<CastorSaturationCorrs, CastorSaturationCorrsRcd>(mDumpRequest, iEvent, iSetup, "SaturationCorrs");
125 }
126 
127 template <class S, class SRcd>
128 void CastorDumpConditions::dumpIt(const std::vector<std::string>& mDumpRequest,
129  const edm::Event& e,
130  const edm::EventSetup& context,
131  const std::string name) {
132  if (std::find(mDumpRequest.begin(), mDumpRequest.end(), name) != mDumpRequest.end()) {
133  int myrun = e.id().run();
134  edm::ESGetToken<S, SRcd> tok = esConsumes<S, SRcd>();
135  const S& myobject = context.getData(tok);
136 
137  std::ostringstream file;
138  file << file_prefix << name.c_str() << "_Run" << myrun << ".txt";
139  std::ofstream outStream(file.str().c_str());
140  CastorDbASCIIIO::dumpObject(outStream, myobject);
141  }
142 }
143 
144 //define this as a plug-in
RunNumber_t run() const
Definition: EventID.h:38
T getUntrackedParameter(std::string const &, T const &) const
static std::vector< std::string > checklist log
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void analyze(const edm::Event &, const edm::EventSetup &) override
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
bool getData(T &iHolder) const
Definition: EventSetup.h:128
int iEvent
Definition: GenABIO.cc:224
std::vector< std::string > mDumpRequest
void dumpIt(const std::vector< std::string > &mDumpRequest, const edm::Event &e, const edm::EventSetup &context, const std::string name)
bool dumpObject(std::ostream &fOutput, const CastorPedestals &fObject)
CastorDumpConditions(const edm::ParameterSet &)
edm::EventID id() const
Definition: EventBase.h:59
Log< level::System, true > LogAbsolute