CMS 3D CMS Logo

DQMXMLFileEventSetupAnalyzer.cc
Go to the documentation of this file.
1 // C++ common header
2 #include <iostream>
3 #include <memory>
4 #include <vector>
5 #include <fstream>
6 
20 
21 namespace edmtest {
23  public:
25  explicit DQMXMLFileEventSetupAnalyzer(int i);
27  void analyze(const edm::Event& event, const edm::EventSetup& setup) override;
28  void beginRun(edm::Run const&, edm::EventSetup const&) override ;
29  private:
30  bool init_ ;
32  };
33 
35  init_ = false ;
36  //std::cout << "DQMXMLFileEventSetupAnalyzer(const edm::ParameterSet &ps)" << std::endl;
37  }
38 
40  init_ = false ;
41  //std::cout << "DQMXMLFileEventSetupAnalyzer(int i) " << i << std::endl;
42  }
43 
45  {
46  init_ = false ;
47  //std::cout << "~DQMXMLFileEventSetupAnalyzer" << std::endl;
48  }
49 
51  {
52  return ;
53  }
54 
56  {
57  //std::cout << "DQMXMLFileEventSetupAnalyzer::beginRun()" << std::endl;
58  if(!init_)
59  {
60  init_ = true ;
63  throw cms::Exception ("Record not found") << "Record \"DQMXMLFileRcd"
64  << "\" does not exist!" << std::endl;
65  }
67  iSetup.get<DQMXMLFileRcd>().get(labelToGet_,rootgeo);
68  //std::cout<<"XML FILE IN MEMORY 1 with label " << labelToGet_ <<std::endl;
69  std::unique_ptr<std::vector<unsigned char> > tb1( (*rootgeo).getUncompressedBlob() );
70  //here you can implement the stream for putting the TFile on disk...
71  std::string outfile1("XML1_retrieved.xml") ;
72  std::ofstream output1(outfile1.c_str()) ;
73  output1.write((const char *)&(*tb1)[0], tb1->size());
74  output1.close() ;
75 
76 // iSetup.get<DQMXMLFileRcd>().get("XML2_mio",rootgeo);
77 // std::cout<<"ROOT FILE IN MEMORY 2"<<std::endl;
78 // std::unique_ptr<std::vector<unsigned char> > tb2( (*rootgeo).getUncompressedBlob() );
79 // //here you can implement the stream for putting the TFile on disk...
80 // std::string outfile2("XML2_retrieved.xml") ;
81 // std::ofstream output2(outfile2.c_str()) ;
82 // output2.write((const char *)&(*tb2)[0], tb2->size());
83 // output2.close() ;
84  // std::unique_ptr<std::vector<unsigned char> > tb( (*rootgeo).getUncompressedBlob() );
85  }
86  }
87 
89 }
void beginRun(edm::Run const &, edm::EventSetup const &) override
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
static HCTypeTag findType(char const *iTypeName)
find a type based on the types name, if not found will return default HCTypeTag
return((rh^lh)&mask)
DQMXMLFileEventSetupAnalyzer(const edm::ParameterSet &pset)
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void analyze(const edm::Event &event, const edm::EventSetup &setup) override
heterocontainer::HCTypeTag TypeTag
T get() const
Definition: EventSetup.h:71
Definition: event.py:1
Definition: Run.h:45