00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include <stdexcept>
00015 #include <string>
00016 #include <iostream>
00017 #include <fstream>
00018 #include <sstream>
00019 #include <map>
00020 #include "FWCore/Framework/interface/EDAnalyzer.h"
00021 #include "FWCore/Framework/interface/Event.h"
00022 #include "FWCore/Framework/interface/ESHandle.h"
00023 #include "FWCore/Framework/interface/MakerMacros.h"
00024
00025 #include "FWCore/Framework/interface/EventSetup.h"
00026 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00027
00028 #include "CondFormats/DataRecord/interface/HcalAllRcds.h"
00029
00030 #include "CalibCalorimetry/HcalAlgos/interface/HcalDbASCIIIO.h"
00031
00032 #include "CalibFormats/HcalObjects/interface/HcalDbService.h"
00033 #include "CalibFormats/HcalObjects/interface/HcalDbRecord.h"
00034
00035 #include "FWCore/Framework/interface/IOVSyncValue.h"
00036 #include "CondFormats/HcalObjects/interface/AllObjects.h"
00037
00038 namespace edmtest
00039 {
00040 class HcalDumpConditions : public edm::EDAnalyzer
00041 {
00042 public:
00043 explicit HcalDumpConditions(edm::ParameterSet const& p)
00044 {
00045 front = p.getUntrackedParameter<std::string>("outFilePrefix","Dump");
00046 mDumpRequest = p.getUntrackedParameter <std::vector <std::string> > ("dump", std::vector<std::string>());
00047 }
00048
00049 explicit HcalDumpConditions(int i)
00050 { }
00051 virtual ~ HcalDumpConditions() { }
00052 virtual void analyze(const edm::Event& e, const edm::EventSetup& c);
00053
00054 template<class S, class SRcd> void dumpIt(S* myS, SRcd* mySRcd, const edm::Event& e, const edm::EventSetup& context, std::string name);
00055
00056 private:
00057 std::string front;
00058 std::vector<std::string> mDumpRequest;
00059 };
00060
00061
00062 template<class S, class SRcd>
00063 void HcalDumpConditions::dumpIt(S* myS, SRcd* mySRcd, const edm::Event& e, const edm::EventSetup& context, std::string name)
00064 {
00065 int myrun = e.id().run();
00066 edm::ESHandle<S> p;
00067 context.get<SRcd>().get(p);
00068 S* myobject = new S(*p.product());
00069
00070 std::ostringstream file;
00071 file << front << name.c_str() << "_Run" << myrun << ".txt";
00072 std::ofstream outStream(file.str().c_str() );
00073 std::cout << "HcalDumpConditions: ---- Dumping " << name.c_str() << " ----" << std::endl;
00074 HcalDbASCIIIO::dumpObject (outStream, (*myobject) );
00075
00076 if ( context.get<HcalPedestalsRcd>().validityInterval().first() == edm::IOVSyncValue::invalidIOVSyncValue() )
00077 std::cout << "error: invalid IOV sync value !" << std::endl;
00078
00079 }
00080
00081
00082 void
00083 HcalDumpConditions::analyze(const edm::Event& e, const edm::EventSetup& context)
00084 {
00085 using namespace edm::eventsetup;
00086 std::cout <<"HcalDumpConditions::analyze-> I AM IN RUN NUMBER "<<e.id().run() <<std::endl;
00087
00088 if (mDumpRequest.empty()) return;
00089
00090 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("ElectronicsMap")) != mDumpRequest.end())
00091 dumpIt(new HcalElectronicsMap, new HcalElectronicsMapRcd, e,context,"ElectronicsMap");
00092 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("QIEData")) != mDumpRequest.end())
00093 dumpIt(new HcalQIEData, new HcalQIEDataRcd, e,context,"QIEData");
00094 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("Pedestals")) != mDumpRequest.end())
00095 dumpIt(new HcalPedestals(false), new HcalPedestalsRcd, e,context,"Pedestals");
00096 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("PedestalWidths")) != mDumpRequest.end())
00097 dumpIt(new HcalPedestalWidths(false), new HcalPedestalWidthsRcd, e,context,"PedestalWidths");
00098 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("Gains")) != mDumpRequest.end())
00099 dumpIt(new HcalGains, new HcalGainsRcd, e,context,"Gains");
00100 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("GainWidths")) != mDumpRequest.end())
00101 dumpIt(new HcalGainWidths, new HcalGainWidthsRcd, e,context,"GainWidths");
00102 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("ChannelQuality")) != mDumpRequest.end())
00103 dumpIt(new HcalChannelQuality, new HcalChannelQualityRcd, e,context,"ChannelQuality");
00104 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("RespCorrs")) != mDumpRequest.end())
00105 dumpIt(new HcalRespCorrs, new HcalRespCorrsRcd, e,context,"RespCorrs");
00106 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("ZSThresholds")) != mDumpRequest.end())
00107 dumpIt(new HcalZSThresholds, new HcalZSThresholdsRcd, e,context,"ZSThresholds");
00108 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("L1TriggerObjects")) != mDumpRequest.end())
00109 dumpIt(new HcalL1TriggerObjects, new HcalL1TriggerObjectsRcd, e,context,"L1TriggerObjects");
00110 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("TimeCorrs")) != mDumpRequest.end())
00111 dumpIt(new HcalTimeCorrs, new HcalTimeCorrsRcd, e,context,"TimeCorrs");
00112 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("LUTCorrs")) != mDumpRequest.end())
00113 dumpIt(new HcalLUTCorrs, new HcalLUTCorrsRcd, e,context,"LUTCorrs");
00114 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("PFCorrs")) != mDumpRequest.end())
00115 dumpIt(new HcalPFCorrs, new HcalPFCorrsRcd, e,context,"PFCorrs");
00116 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("ValidationCorrs")) != mDumpRequest.end())
00117 dumpIt(new HcalValidationCorrs, new HcalValidationCorrsRcd, e,context,"ValidationCorrs");
00118 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("LutMetadata")) != mDumpRequest.end())
00119 dumpIt(new HcalLutMetadata, new HcalLutMetadataRcd, e,context,"LutMetadata");
00120 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("DcsValues")) != mDumpRequest.end())
00121 dumpIt(new HcalDcsValues, new HcalDcsRcd, e,context,"DcsValues");
00122 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("DcsMap")) != mDumpRequest.end())
00123 dumpIt(new HcalDcsMap, new HcalDcsMapRcd, e,context,"DcsMap");
00124 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("CholeskyMatrices")) != mDumpRequest.end())
00125 dumpIt(new HcalCholeskyMatrices, new HcalCholeskyMatricesRcd, e,context,"CholeskyMatrices");
00126 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("RecoParams")) != mDumpRequest.end())
00127 dumpIt(new HcalRecoParams, new HcalRecoParamsRcd, e,context,"RecoParams");
00128 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("LongRecoParams")) != mDumpRequest.end())
00129 dumpIt(new HcalLongRecoParams, new HcalLongRecoParamsRcd, e,context,"LongRecoParams");
00130 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("MCParams")) != mDumpRequest.end())
00131 dumpIt(new HcalMCParams, new HcalMCParamsRcd, e,context,"MCParams");
00132
00133 }
00134 DEFINE_FWK_MODULE(HcalDumpConditions);
00135 }