Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multithread-safe version which uses HistoJ for vectors #5655

Merged
merged 1 commit into from Oct 7, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
103 changes: 84 additions & 19 deletions HLTrigger/JSONMonitoring/interface/TriggerJSONMonitoring.h
@@ -1,5 +1,5 @@
#ifndef HLTcore_TriggerJSONMonitoring_h
#define HLTcore_TriggerJSONMonitoring_h
#ifndef JSONMonitoring_TriggerJSONMonitoring_h
#define JSONMonitoring_TriggerJSONMonitoring_h

/** \class TriggerJSONMonitoring
*
Expand All @@ -15,7 +15,7 @@

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/LuminosityBlock.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/stream/EDAnalyzer.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"

Expand All @@ -30,38 +30,103 @@

#include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"

namespace hltJson {
//Struct for storing variables that must be written and reset every lumi section
struct lumiVars {
HistoJ<unsigned int> *processed; // # of events processed

HistoJ<unsigned int> *hltWasRun; // # of events where HLT[i] was run
HistoJ<unsigned int> *hltL1s; // # of events after L1 seed
HistoJ<unsigned int> *hltPre; // # of events after HLT prescale
HistoJ<unsigned int> *hltAccept; // # of events accepted by HLT[i]
HistoJ<unsigned int> *hltReject; // # of events rejected by HLT[i]
HistoJ<unsigned int> *hltErrors; // # of events with error in HLT[i]

HistoJ<unsigned int> *hltDatasets; // # of events accepted by each dataset

//Names and directories aren't changed at lumi section boundaries,
//but they need to be in this struct to be write JSON files at the end
HistoJ<std::string> *hltNames; // list of HLT path names
HistoJ<std::string> *datasetNames; // list of dataset names

std::string baseRunDir; //Base directory from EvFDaqDirector
std::string jsonRateDefFile; //Definition file name for JSON with rates
std::string jsonLegendDefFile; //Definition file name for JSON with legend of names
};
}//End hltJson namespace

//
// class declaration
//
class TriggerJSONMonitoring : public edm::EDAnalyzer {
class TriggerJSONMonitoring : public edm::stream::EDAnalyzer <edm::LuminosityBlockSummaryCache<hltJson::lumiVars>>
{
public:
explicit TriggerJSONMonitoring(const edm::ParameterSet&);
~TriggerJSONMonitoring();
static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
virtual void analyze(const edm::Event&, const edm::EventSetup&);
virtual void beginRun(edm::Run const&, edm::EventSetup const&);
virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);

void reset(bool changed = false); // reset all counters
void analyze(edm::Event const&,
edm::EventSetup const&);

private:
boost::shared_ptr<jsoncollector::FastMonitor> jsonMonitor_;
DataPointDefinition outJson_;
IntJ processed_;
void beginRun(edm::Run const&,
edm::EventSetup const&);

void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);

static std::shared_ptr<hltJson::lumiVars> globalBeginLuminosityBlockSummary(edm::LuminosityBlock const&,
edm::EventSetup const&,
LuminosityBlockContext const*);

std::string baseRunDir;
void endLuminosityBlockSummary(edm::LuminosityBlock const&,
edm::EventSetup const&,
hltJson::lumiVars*) const;

std::vector<std::string> hltNames_; // name of each HLT algorithm
std::vector<IntJ> hltPaths_; // stores name and # of event accepted by HLT paths

std::string jsonDefinitionFile; // JSON definition file name
static void globalEndLuminosityBlockSummary(edm::LuminosityBlock const&,
edm::EventSetup const&,
LuminosityBlockContext const*,
hltJson::lumiVars*);

void resetRun(bool changed); //Reset run-related info
void resetLumi(); //Reset all counters

void writeDefJson(std::string path);
void writeDefLegJson(std::string path);

//Variables from cfg and associated tokens
edm::InputTag triggerResults_; // Input tag for TriggerResults
edm::EDGetTokenT<edm::TriggerResults> triggerResultsToken_; // Token for TriggerResults


//Variables that change at most once per run
HLTConfigProvider hltConfig_; // to get configuration for HLT

std::string baseRunDir_; //Base directory from EvFDaqDirector

// hltIndex_[ds][p] stores the hltNames_ index of the p-th path of the ds-th dataset
std::vector<std::vector<unsigned int> > hltIndex_;
std::vector<std::string> hltNames_; // list of HLT path names
std::vector<std::string> datasetNames_; // list of dataset names
std::vector<std::vector<std::string> > datasetContents_; // list of path names for each dataset

std::vector<int> posL1s_; // pos # of last L1 seed
std::vector<int> posPre_; // pos # of last HLT prescale

std::string jsonRateDefFile_; //Definition file name for JSON with rates
std::string jsonLegendDefFile_; //Definition file name for JSON with legend of names

//Variables that need to be reset at lumi section boundaries
unsigned int processed_; // # of events processed

std::vector<unsigned int> hltWasRun_; // # of events where HLT[i] was run
std::vector<unsigned int> hltL1s_; // # of events after L1 seed
std::vector<unsigned int> hltPre_; // # of events after HLT prescale
std::vector<unsigned int> hltAccept_; // # of events accepted by HLT[i]
std::vector<unsigned int> hltReject_; // # of events rejected by HLT[i]
std::vector<unsigned int> hltErrors_; // # of events with error in HLT[i]

std::vector<unsigned int> hltDatasets_; // # of events accepted by each dataset

private:

};
#endif