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 
21 // system include files
22 #include <memory>
23 #include <iostream>
24 #include <fstream>
25 #include <sstream>
26 #include <string>
27 
28 // user include files
32 
36 
39 
51 
53 //
54 // class decleration
55 //
56 
58  public:
59  explicit CastorDumpConditions(const edm::ParameterSet&);
60 
61  template<class S, class SRcd> 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 
97 //
98 // member functions
99 //
100 
101 // ------------ method called to for each event ------------
102 void
104 {
105  using namespace edm;
106 
107  {
108  edm::LogAbsolute log("CastorDumpConditions");
109  log << "I AM IN THE RUN " << iEvent.id().run() << "\n";
110  log << "What to dump? "<< std::endl;
111  if (mDumpRequest.empty()) {
112  log<< "CastorDumpConditions: Empty request \n";
113  return;
114  }
115  }
116 
117  for(std::vector<std::string>::const_iterator it=mDumpRequest.begin();it!=mDumpRequest.end();it++)
118  LogAbsolute("CastorDumpConditions") << *it << "\n";
119 
120  // dumpIt called for all possible ValueMaps. The function checks if the dump is actually requested.
121  dumpIt<CastorElectronicsMap , CastorElectronicsMapRcd> (mDumpRequest, iEvent,iSetup,"ElectronicsMap" );
122  dumpIt<CastorQIEData , CastorQIEDataRcd> (mDumpRequest, iEvent,iSetup,"QIEData" );
123  dumpIt<CastorPedestals , CastorPedestalsRcd> (mDumpRequest, iEvent,iSetup,"Pedestals" );
124  dumpIt<CastorPedestalWidths , CastorPedestalWidthsRcd> (mDumpRequest, iEvent,iSetup,"PedestalWidths" );
125  dumpIt<CastorGains , CastorGainsRcd> (mDumpRequest, iEvent,iSetup,"Gains" );
126  dumpIt<CastorGainWidths , CastorGainWidthsRcd> (mDumpRequest, iEvent,iSetup,"GainWidths" );
127  dumpIt<CastorChannelQuality , CastorChannelQualityRcd> (mDumpRequest, iEvent,iSetup,"ChannelQuality" );
128  dumpIt<CastorRecoParams , CastorRecoParamsRcd> (mDumpRequest, iEvent,iSetup,"RecoParams" );
129  dumpIt<CastorSaturationCorrs, CastorSaturationCorrsRcd>(mDumpRequest, iEvent,iSetup,"SaturationCorrs");
130 }
131 
132 
133 template<class S, class SRcd>
134 void CastorDumpConditions::dumpIt(const std::vector<std::string>& mDumpRequest,
135  const edm::Event& e,
136  const edm::EventSetup& context,
137  const std::string name) {
138  if (std::find (mDumpRequest.begin(), mDumpRequest.end(), name) != mDumpRequest.end())
139  {
140  int myrun = e.id().run();
142  context.get<SRcd>().get(p);
143  S myobject(*p.product());
144 
145  std::ostringstream file;
146  file << file_prefix << name.c_str() << "_Run" << myrun << ".txt";
147  std::ofstream outStream(file.str().c_str() );
148  CastorDbASCIIIO::dumpObject (outStream, myobject );
149  }
150 }
151 
152 //define this as a plug-in
RunNumber_t run() const
Definition: EventID.h:39
T getUntrackedParameter(std::string const &, T const &) const
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:20
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
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
HLT enums.
T get() const
Definition: EventSetup.h:71
T const * product() const
Definition: ESHandle.h:86