File indexing completed on 2024-04-06 12:11:04
0001
0002 #include "FWCore/ServiceRegistry/interface/Service.h"
0003 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0004 #include "FWCore/Framework/interface/Event.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0006
0007
0008
0009 #include "TFile.h"
0010 #include "TTree.h"
0011
0012 class SiStripModuleTimer : public edm::one::EDAnalyzer<> {
0013 public:
0014 SiStripModuleTimer(const edm::ParameterSet&);
0015 ~SiStripModuleTimer();
0016
0017 void analyze(const edm::Event&, const edm::EventSetup&);
0018 void endJob();
0019
0020 private:
0021 std::vector<std::string> moduleLabels_;
0022 std::vector<double> times_;
0023 TFile* file_;
0024 TTree* tree_;
0025 };
0026
0027 using namespace std;
0028 using namespace edm;
0029
0030 SiStripModuleTimer::SiStripModuleTimer(const ParameterSet& pset)
0031 : moduleLabels_(pset.getUntrackedParameter<vector<string> >("ModuleLabels")),
0032 times_(moduleLabels_.size()),
0033 file_(0),
0034 tree_(0) {
0035 file_ = new TFile(pset.getUntrackedParameter<string>("FileName", "SiStripTiming.root").c_str(), "UPDATE");
0036 tree_ = new TTree(pset.getUntrackedParameter<string>("TreeName", "Tree").c_str(), "");
0037 for (unsigned short i = 0; i < moduleLabels_.size(); i++) {
0038 std::string label = moduleLabels_[i];
0039 std::string type = moduleLabels_[i] + "/D";
0040 tree_->Branch(label.c_str(), ×_[i], type.c_str());
0041 }
0042 }
0043
0044 SiStripModuleTimer::~SiStripModuleTimer() {
0045 if (tree_)
0046 delete tree_;
0047 file_->Close();
0048 }
0049
0050 void SiStripModuleTimer::endJob() {
0051 file_->cd();
0052 tree_->Write();
0053 }
0054
0055 void SiStripModuleTimer::analyze(const Event& iEvent, const EventSetup& iSetup) {
0056 times_.assign(moduleLabels_.size(), 0.);
0057
0058
0059
0060
0061
0062
0063
0064 tree_->Fill();
0065 }
0066
0067 #include "FWCore/PluginManager/interface/ModuleDef.h"
0068 #include "FWCore/Framework/interface/MakerMacros.h"
0069 DEFINE_FWK_MODULE(SiStripModuleTimer);