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
31 
35 
38 
50 
52 //
53 // class decleration
54 //
55 
57 public:
58  explicit CastorDumpConditions(const edm::ParameterSet&);
59 
60  template <class S, class SRcd>
61  void dumpIt(const std::vector<std::string>& mDumpRequest,
62  const edm::Event& e,
63  const edm::EventSetup& context,
64  const std::string name);
65 
66 private:
68  std::vector<std::string> mDumpRequest;
69  void analyze(const edm::Event&, const edm::EventSetup&) override;
70 
71  // ----------member data ---------------------------
72 };
73 
74 //
75 // constants, enums and typedefs
76 //
77 
78 //
79 // static data member definitions
80 //
81 
82 //
83 // constructors and destructor
84 //
86 
87 {
88  file_prefix = iConfig.getUntrackedParameter<std::string>("outFilePrefix", "Dump");
89  mDumpRequest = iConfig.getUntrackedParameter<std::vector<std::string> >("dump", std::vector<std::string>());
90  if (mDumpRequest.empty()) {
91  throw cms::Exception("Bad Config") << "CastorDumpConditions: No record to dump.";
92  }
93 }
94 
95 //
96 // member functions
97 //
98 
99 // ------------ method called to for each event ------------
101  using namespace edm;
102 
103  {
104  edm::LogAbsolute log("CastorDumpConditions");
105  log << "I AM IN THE RUN " << iEvent.id().run() << "\n";
106  log << "What to dump? " << std::endl;
107  if (mDumpRequest.empty()) {
108  log << "CastorDumpConditions: Empty request \n";
109  return;
110  }
111  }
112 
113  for (std::vector<std::string>::const_iterator it = mDumpRequest.begin(); it != mDumpRequest.end(); it++)
114  LogAbsolute("CastorDumpConditions") << *it << "\n";
115 
116  // dumpIt called for all possible ValueMaps. The function checks if the dump is actually requested.
117  dumpIt<CastorElectronicsMap, CastorElectronicsMapRcd>(mDumpRequest, iEvent, iSetup, "ElectronicsMap");
118  dumpIt<CastorQIEData, CastorQIEDataRcd>(mDumpRequest, iEvent, iSetup, "QIEData");
119  dumpIt<CastorPedestals, CastorPedestalsRcd>(mDumpRequest, iEvent, iSetup, "Pedestals");
120  dumpIt<CastorPedestalWidths, CastorPedestalWidthsRcd>(mDumpRequest, iEvent, iSetup, "PedestalWidths");
121  dumpIt<CastorGains, CastorGainsRcd>(mDumpRequest, iEvent, iSetup, "Gains");
122  dumpIt<CastorGainWidths, CastorGainWidthsRcd>(mDumpRequest, iEvent, iSetup, "GainWidths");
123  dumpIt<CastorChannelQuality, CastorChannelQualityRcd>(mDumpRequest, iEvent, iSetup, "ChannelQuality");
124  dumpIt<CastorRecoParams, CastorRecoParamsRcd>(mDumpRequest, iEvent, iSetup, "RecoParams");
125  dumpIt<CastorSaturationCorrs, CastorSaturationCorrsRcd>(mDumpRequest, iEvent, iSetup, "SaturationCorrs");
126 }
127 
128 template <class S, class SRcd>
129 void CastorDumpConditions::dumpIt(const std::vector<std::string>& mDumpRequest,
130  const edm::Event& e,
131  const edm::EventSetup& context,
132  const std::string name) {
133  if (std::find(mDumpRequest.begin(), mDumpRequest.end(), name) != mDumpRequest.end()) {
134  int myrun = e.id().run();
136  context.get<SRcd>().get(p);
137  S myobject(*p.product());
138 
139  std::ostringstream file;
140  file << file_prefix << name.c_str() << "_Run" << myrun << ".txt";
141  std::ofstream outStream(file.str().c_str());
142  CastorDbASCIIIO::dumpObject(outStream, myobject);
143  }
144 }
145 
146 //define this as a plug-in
CastorChannelQualityRcd.h
CastorPedestalsRcd.h
EDAnalyzer.h
MessageLogger.h
ESHandle.h
CastorQIEDataRcd.h
edm
HLT enums.
Definition: AlignableModifier.h:19
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
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
CastorDumpConditions::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: CastorDumpConditions.cc:100
MakerMacros.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ESHandle
Definition: DTSurvey.h:22
CastorDumpConditions::file_prefix
std::string file_prefix
Definition: CastorDumpConditions.cc:67
CastorElectronicsMapRcd.h
CastorPedestalWidthsRcd.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
CastorDbASCIIIO::dumpObject
bool dumpObject(std::ostream &fOutput, const CastorPedestals &fObject)
Definition: CastorDbASCIIIO.cc:323
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
CastorRecoParamsRcd.h
CastorDumpConditions::mDumpRequest
std::vector< std::string > mDumpRequest
Definition: CastorDumpConditions.cc:68
CastorGainsRcd.h
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
iEvent
int iEvent
Definition: GenABIO.cc:224
CastorDumpConditions::CastorDumpConditions
CastorDumpConditions(const edm::ParameterSet &)
Definition: CastorDumpConditions.cc:85
edm::LogAbsolute
Log< level::System, true > LogAbsolute
Definition: MessageLogger.h:134
edm::EventSetup
Definition: EventSetup.h:57
get
#define get
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:129
CastorDbASCIIIO.h
Frameworkfwd.h
Exception
Definition: hltDiff.cc:246
CastorDumpConditions
Definition: CastorDumpConditions.cc:56
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