/
githubmirror
/
cmssw
Обзор
Документация
Войти
/
githubmirror
/
cmssw
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
CommonTools/UtilAlgos/test/TestTFileServiceAnalyzer.cc
59 строк
2 KB
mmusich
remove deprecation warnings from CommonTools/UtilAlgos
16 мар 2022, 11:10
16 мар 2022, 11:10
32a45f6
Код
Авторство
О чём код?
#include "CommonTools/UtilAlgos/interface/TFileService.h" #include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/ServiceRegistry/interface/Service.h" #include "TH1.h" #include "TTree.h" class TestTFileServiceAnalyzer : public edm::one::EDAnalyzer<edm::one::SharedResources> { public: /// constructor TestTFileServiceAnalyzer(const edm::ParameterSet&); private: /// process one event void analyze(const edm::Event&, const edm::EventSetup&) override; /// histograms TH1F *h_test1, *h_test2; /// TTree TTree* tree_test; /// entry for TTree test int testInt; /// sub-directory name std::string dir1_, dir2_; }; #include "FWCore/ParameterSet/interface/ParameterSet.h" using namespace edm; using namespace std; TestTFileServiceAnalyzer::TestTFileServiceAnalyzer(const ParameterSet& cfg) : dir1_(cfg.getParameter<string>("dir1")), dir2_(cfg.getParameter<string>("dir2")) { usesResource(TFileService::kSharedResource); edm::Service<TFileService> fs; if (dir1_.empty()) { h_test1 = fs->make<TH1F>("test1", "test histogram #1", 100, 0., 100.); } else { TFileDirectory dir1 = fs->mkdir(dir1_); h_test1 = dir1.make<TH1F>("test1", "test histogram #1", 100, 0., 100.); } if (dir2_.empty()) { h_test2 = fs->make<TH1F>("test2", "test histogram #2", 100, 0., 100.); } else { TFileDirectory dir2 = fs->mkdir(dir2_); h_test2 = dir2.make<TH1F>("test2", "test histogram #2", 100, 0., 100.); } tree_test = fs->make<TTree>("Test", "Test Tree", 1); tree_test->Branch("TestBranch", &testInt, "testInt/I"); } void TestTFileServiceAnalyzer::analyze(const Event& evt, const EventSetup&) { h_test1->Fill(50.); h_test2->Fill(60.); // fill test TTree testInt = 70; tree_test->Fill(); } #include "FWCore/Framework/interface/MakerMacros.h" DEFINE_FWK_MODULE(TestTFileServiceAnalyzer);