CMS 3D CMS Logo

DQMReferenceHistogramRootFileEventSetupAnalyzer.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:
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_ ;
31  };
32 
34  init_ = false ;
35  //std::cout << "DQMReferenceHistogramRootFileEventSetupAnalyzer(const edm::ParameterSet &ps)" << std::endl;
36  }
37 
39  init_ = false ;
40  //std::cout << "DQMReferenceHistogramRootFileEventSetupAnalyzer(int i) " << i << std::endl;
41  }
42 
44  {
45  init_ = false ;
46  //std::cout << "~DQMReferenceHistogramRootFileEventSetupAnalyzer" << std::endl;
47  }
48 
50  {
51  return ;
52  }
53 
55  {
56  //std::cout << "DQMReferenceHistogramRootFileEventSetupAnalyzer::beginRun()" << std::endl;
57  if(!init_)
58  {
59  init_ = true ;
62  throw cms::Exception ("Record not found") << "Record \"DQMReferenceHistogramRootFileRcd"
63  << "\" does not exist!" << std::endl;
64  }
66  iSetup.get<DQMReferenceHistogramRootFileRcd>().get(rootgeo);
67  //std::cout<<"ROOT FILE IN MEMORY"<<std::endl;
68  std::unique_ptr<std::vector<unsigned char> > tb( (*rootgeo).getUncompressedBlob() );
69  // char filename[128];
70  // sprintf(filename, "mem:%p,%ul", &(*tb)[0], (unsigned long) tb->size());
71  // edm::Service<DQMStore>()->open(filename, false, "", "Reference");
72 
73  //here you can implement the stream for putting the TFile on disk...
74  std::string outfile("dqmreference.root") ;
75  std::ofstream output(outfile.c_str()) ;
76  output.write((const char *)&(*tb)[0], tb->size());
77  output.close() ;
78 
80  dqm->open(outfile, false, "", "Reference");
81  remove(outfile.c_str());
82 
83  std::vector<MonitorElement *> mes = dqm->getAllContents("");
84  // for (std::vector<MonitorElement *>::iterator i = mes.begin(), e = mes.end(); i != e; ++i)
85  // std::cout << "ME '" << (*i)->getFullname() << "'\n";
86 
87  //std::cout<<"SIZE FILE = "<<tb->size()<<std::endl;
88  }
89  }
90 
92 }
void analyze(const edm::Event &event, const edm::EventSetup &setup) 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)
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
bool open(std::string const &filename, bool overwrite=false, std::string const &path="", std::string const &prepend="", OpenRunDirs stripdirs=KeepRunDirs, bool fileMustExist=true)
Definition: DQMStore.cc:2883
heterocontainer::HCTypeTag TypeTag
T get() const
Definition: EventSetup.h:71
std::vector< MonitorElement * > getAllContents(std::string const &path, uint32_t runNumber=0, uint32_t lumi=0) const
Definition: DQMStore.cc:1767
Definition: event.py:1
Definition: Run.h:45