CMS 3D CMS Logo

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
CastorChannelQualityRcd.h
CastorPedestalsRcd.h
EDAnalyzer.h
MessageLogger.h
CastorQIEDataRcd.h
edm
HLT enums.
Definition: AlignableModifier.h:19
AllObjects.h
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::one::EDAnalyzer
Definition: EDAnalyzer.h:30
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
CastorGainWidthsRcd.h
visDQMUpload.context
context
Definition: visDQMUpload.py:37
CastorDumpConditions::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: CastorDumpConditions.cc:99
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
CastorDumpConditions::file_prefix
std::string file_prefix
Definition: CastorDumpConditions.cc:66
CastorElectronicsMapRcd.h
CastorPedestalWidthsRcd.h
geometryDiff.file
file
Definition: geometryDiff.py:13
CastorDbASCIIIO::dumpObject
bool dumpObject(std::ostream &fOutput, const CastorPedestals &fObject)
Definition: CastorDbASCIIIO.cc:320
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
CastorRecoParamsRcd.h
CastorDumpConditions::mDumpRequest
std::vector< std::string > mDumpRequest
Definition: CastorDumpConditions.cc:67
CastorGainsRcd.h
iEvent
int iEvent
Definition: GenABIO.cc:224
CastorDumpConditions::CastorDumpConditions
CastorDumpConditions(const edm::ParameterSet &)
Definition: CastorDumpConditions.cc:84
edm::LogAbsolute
Log< level::System, true > LogAbsolute
Definition: MessageLogger.h:134
edm::EventSetup
Definition: EventSetup.h:58
edm::ESGetToken
Definition: EventSetup.h:48
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
CastorDumpConditions::dumpIt
void dumpIt(const std::vector< std::string > &mDumpRequest, const edm::Event &e, const edm::EventSetup &context, const std::string name)
Definition: CastorDumpConditions.cc:128
CastorDbASCIIIO.h
Frameworkfwd.h
Exception
Definition: hltDiff.cc:245
CastorDumpConditions
Definition: CastorDumpConditions.cc:55
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
EventSetup.h
Exception.h
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
S
Definition: CSCDBL1TPParametersExtended.h:16
ParameterSet.h
edm::Event
Definition: Event.h:73
edm::Log
Definition: MessageLogger.h:70
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
CastorSaturationCorrsRcd.h