Skip to content

Commit

Permalink
Fix for the Streams' names to be monitored and protection for paths w…
Browse files Browse the repository at this point in the history
…ith zero filters
  • Loading branch information
arcidiac committed Sep 28, 2015
1 parent 35ea98d commit bacd441
Showing 1 changed file with 106 additions and 79 deletions.
185 changes: 106 additions & 79 deletions DQMOffline/Trigger/src/GeneralHLTOffline.cc
Expand Up @@ -83,6 +83,8 @@ class GeneralHLTOffline : public DQMEDAnalyzer {
std::string hlt_menu_;
std::vector< std::vector<std::string> > PDsVectorPathsVector;
std::vector<std::string> AddedDatasets;
std::vector<std::string> DataSetNames;
std::map< std::string, std::vector<std::string> > PathModules;
edm::EDGetTokenT <edm::TriggerResults> triggerResultsToken;
edm::EDGetTokenT <trigger::TriggerEventWithRefs> triggerSummaryTokenRAW;
edm::EDGetTokenT <trigger::TriggerEvent> triggerSummaryTokenAOD;
Expand Down Expand Up @@ -164,20 +166,20 @@ GeneralHLTOffline::analyze(const edm::Event& iEvent,
}

if (streamA_found_) {
const std::vector<std::string> &datasetNames = hlt_config_.streamContent("A");
const std::vector<std::string> &datasetNames = DataSetNames;
// Loop over PDs
for (unsigned int iPD = 0; iPD < datasetNames.size(); iPD++) {
// Loop over Paths in each PD
for (unsigned int iPath = 0;
iPath < PDsVectorPathsVector[iPD].size(); iPath++) {
std::string &pathName = PDsVectorPathsVector[iPD][iPath];
unsigned int index = hlt_config_.triggerIndex(pathName);
if (debugPrint) {
if (debugPrint) {
std::cout << "Looking at path " << pathName << std::endl;
std::cout << "Index = " << index
<< " triggerResults->size() = " << triggerResults->size()
<< std::endl;
}
}

// fill the histos with empty weights......
const std::string &label = datasetNames[iPD];
Expand Down Expand Up @@ -230,16 +232,10 @@ GeneralHLTOffline::dqmBeginRun(edm::Run const& iRun,

PDsVectorPathsVector.clear();
AddedDatasets.clear();
}
DataSetNames.clear();
PathModules.clear();


// ------------ method called to book histograms before starting event loop ------------
void GeneralHLTOffline::bookHistograms(DQMStore::IBooker & iBooker,
edm::Run const & iRun,
edm::EventSetup const & iSetup)
{
iBooker.setCurrentFolder(plotDirectoryName) ;

bool changed = true;
if (!hlt_config_.init(iRun, iSetup, hltTag, changed)) {
if (debugPrint) {
Expand All @@ -257,41 +253,49 @@ void GeneralHLTOffline::bookHistograms(DQMStore::IBooker & iBooker,
if (hlt_menu_[n] == '/' || hlt_menu_[n] == '.')
hlt_menu_[n] = '_';

//////////// Book a simple ME

iBooker.setCurrentFolder("HLT/GeneralHLTOffline/");
iBooker.bookString("hltMenuName", hlt_menu_.c_str());
cppath_ = iBooker.book1D("cppath" + hlt_menu_,
"Counts/Path",
hlt_config_.size(), 0, hlt_config_.size());

const std::vector<std::string> &nameStreams = hlt_config_.streamNames();
std::vector<std::string>::const_iterator si = nameStreams.begin();
std::vector<std::string>::const_iterator se = nameStreams.end();
std::vector<std::string> datasetNames;

for ( ; si != se; ++si) {
if ((*si) == "A") {
if (debugPrint) std::cout << "This is stream " << *si << std::endl;

if ( ((*si).find("Physics") != std::string::npos) ||((*si).find("Scouting") != std::string::npos) ||((*si).find("Parking") != std::string::npos) || (*si) == "A") {
streamA_found_ = true;
break;

std::vector<std::string> datasetperStream = hlt_config_.streamContent(*si);

for (auto const & di: datasetperStream) {
datasetNames.push_back(di);
}
}
}

if (debugPrint) std::cout << "Number of total datasets " << datasetNames.size() << std::endl;


if (streamA_found_) {
const std::vector<std::string> &datasetNames = hlt_config_.streamContent("A");

DataSetNames = datasetNames;

if (debugPrint)
std::cout << "Number of Stream A datasets "
std::cout << "Number of datasets to be monitored "
<< datasetNames.size() << std::endl;

for (unsigned int i = 0; i < datasetNames.size(); i++) {
const std::vector<std::string> &datasetPaths = hlt_config_.datasetContent(datasetNames[i]);
if (debugPrint) {
std::cout << "This is dataset " << datasetNames[i]
<< "datasetPaths.size() = " << datasetPaths.size() << std::endl;
for (unsigned int iPath = 0;
iPath < datasetPaths.size(); iPath++) {
std::cout << "Before setupHltMatrix - MET dataset "
std::cout << "Paths in begin job "
<< datasetPaths[iPath] << std::endl;
}
}

// Check if dataset has been added - if not add it
// need to loop through AddedDatasets and compare
bool foundDataset = false;
Expand All @@ -306,7 +310,7 @@ void GeneralHLTOffline::bookHistograms(DQMStore::IBooker & iBooker,
break;
}
}

if (!foundDataset) {
if (debugPrint)
std::cout << " Fill trigger paths for dataset "
Expand All @@ -326,7 +330,7 @@ void GeneralHLTOffline::bookHistograms(DQMStore::IBooker & iBooker,
<< "trigger paths per dataset " << std::endl;
// Loop over correct path of PDsVectorPathsVector
bool found = false;

// Loop over triggers in the path
for (unsigned int iTrig = 0; iTrig < datasetPaths.size(); iTrig++) {
if (debugPrint)
Expand All @@ -341,7 +345,7 @@ void GeneralHLTOffline::bookHistograms(DQMStore::IBooker & iBooker,
<< " " << PDsVectorPathsVector[datasetNum][od] << std::endl;
// Compare, see if match is found
if (hlt_config_.removeVersion(datasetPaths[iTrig]).compare(
hlt_config_.removeVersion(PDsVectorPathsVector[datasetNum][od])) == 0) {
hlt_config_.removeVersion(PDsVectorPathsVector[datasetNum][od])) == 0) {
found = true;
if (debugPrint)
std::cout << " FOUND " << datasetPaths[iTrig] << std::endl;
Expand Down Expand Up @@ -371,11 +375,72 @@ void GeneralHLTOffline::bookHistograms(DQMStore::IBooker & iBooker,

if (debugPrint)
std::cout <<"Found PD: " << datasetNames[i] << std::endl;

setupHltMatrix(iBooker, datasetNames[i], i);
} // end of loop over dataset names
} // if stream A found
} // end of beginRun



std::vector<std::string> triggerNames = hlt_config_.triggerNames();

for( unsigned int iPath=0; iPath<triggerNames.size(); iPath++ ){
std::string pathName = triggerNames[iPath];

const std::vector<std::string>& moduleLabels = hlt_config_.moduleLabels(pathName);
int NumModules = int( moduleLabels.size() );

if( !(pathName.find("HLT_") != std::string::npos) ) continue;
if( (pathName.find("HLT_Physics")!=std::string::npos) ||
(pathName.find("HLT_Random")!=std::string::npos) ) continue;

std::string prefix("hltPre");

std::vector<std::string> good_module_names;
good_module_names.clear();
for( int iMod=0; iMod<NumModules; iMod++ ){
std::string moduleType = hlt_config_.moduleType(moduleLabels[iMod]);
std::string moduleEDMType = hlt_config_.moduleEDMType(moduleLabels[iMod]);
if( !(moduleEDMType == "EDFilter") ) continue;
if( moduleType.find("Selector")!= std::string::npos ) continue;
if( moduleType == "HLTTriggerTypeFilter" ||
moduleType == "HLTBool" ||
moduleType == "PrimaryVertexObjectFilter" ||
moduleType == "JetVertexChecker" ||
moduleType == "HLTRHemisphere" ||
moduleType == "DetectorStateFilter" ) continue;

if( moduleLabels[iMod].compare(0, prefix.length(), prefix) == 0 ) continue;
good_module_names.push_back(moduleLabels[iMod]);
}
PathModules[pathName] = good_module_names;
} // loop over paths

} // if stream A or Physics streams found


}


// ------------ method called to book histograms before starting event loop ------------
void GeneralHLTOffline::bookHistograms(DQMStore::IBooker & iBooker,
edm::Run const & iRun,
edm::EventSetup const & iSetup)
{
iBooker.setCurrentFolder(plotDirectoryName) ;

//////////// Book a simple ME

iBooker.setCurrentFolder("HLT/GeneralHLTOffline/");
iBooker.bookString("hltMenuName", hlt_menu_.c_str());
cppath_ = iBooker.book1D("cppath" + hlt_menu_,
"Counts/Path",
hlt_config_.size(), 0, hlt_config_.size());

if (streamA_found_) {

for (unsigned int iPD = 0; iPD < DataSetNames.size(); iPD++)
setupHltMatrix(iBooker, DataSetNames[iPD], iPD);

} // if stream A or Physics streams are found
} // end of bookHistograms


void GeneralHLTOffline::setupHltMatrix(DQMStore::IBooker & iBooker, const std::string & label, int iPD) {
Expand Down Expand Up @@ -418,52 +483,28 @@ void GeneralHLTOffline::setupHltMatrix(DQMStore::IBooker & iBooker, const std::s
}

std::string pathNameVer = PDsVectorPathsVector[iPD][iPath];
const std::vector<std::string>& moduleLabels = hlt_config_.moduleLabels(pathNameVer);
int NumModules = int( moduleLabels.size() );

if( !(pathNameVer.find("HLT_") != std::string::npos) ) continue;
if( (pathNameVer.find("HLT_Physics")!=std::string::npos) ||
(pathNameVer.find("HLT_Random")!=std::string::npos) ) continue;

std::string prefix("hltPre");

std::vector<std::string> good_module_names;
for( int iMod=0; iMod<NumModules; iMod++ ){
std::string moduleType = hlt_config_.moduleType(moduleLabels[iMod]);
std::string moduleEDMType = hlt_config_.moduleEDMType(moduleLabels[iMod]);
if( !(moduleEDMType == "EDFilter") ) continue;
if( moduleType.find("Selector")!= std::string::npos ) continue;
if( moduleType == "HLTTriggerTypeFilter" ||
moduleType == "HLTBool" ||
moduleType == "PrimaryVertexObjectFilter" ||
moduleType == "JetVertexChecker" ||
moduleType == "HLTRHemisphere" ||
moduleType == "DetectorStateFilter" ) continue;

if( moduleLabels[iMod].compare(0, prefix.length(), prefix) == 0 ) continue;
good_module_names.push_back(moduleLabels[iMod]);
}

int NumGoodModules = int( good_module_names.size() );
std::vector<std::string> moduleLabels = PathModules[pathNameVer];
int NumModules = int( moduleLabels.size() );

if( NumGoodModules==0 ) continue;
if( NumModules==0 ) continue;

std::string pathName_dataset = "cpfilt_" + label + "_" + pathName;

cpfilt_mini_[pathName_dataset] = iBooker.book1D(pathName_dataset.c_str(),
pathName.c_str(),
NumGoodModules,
NumModules,
0,
NumGoodModules);
NumModules);

if( cpfilt_mini_[pathName_dataset] )
hist_cpfilt_mini_[pathName_dataset] = cpfilt_mini_[pathName_dataset]->getTH1F();

for( int iMod=0; iMod<NumGoodModules; iMod++ ){
for( int iMod=0; iMod<NumModules; iMod++ ){
if( cpfilt_mini_[pathName_dataset] && hist_cpfilt_mini_[pathName_dataset] ){
TAxis * axis = hist_cpfilt_mini_[pathName_dataset]->GetXaxis();
if (axis)
axis->SetBinLabel(iMod+1,good_module_names[iMod].c_str());
axis->SetBinLabel(iMod+1,moduleLabels[iMod].c_str());
}
}

Expand Down Expand Up @@ -510,9 +551,6 @@ void GeneralHLTOffline::fillHltMatrix(const std::string & label,
if( hasRawTriggerEvent && triggerEventRAW.isValid() ) triggerEventSize = triggerEventRAW->size();
else if( triggerEventAOD.isValid() ) triggerEventSize = triggerEventAOD->sizeFilters();

const std::vector<std::string>& moduleLabels = hlt_config_.moduleLabels(path);
int NumModules = int( moduleLabels.size() );

std::string pathName_dataset = "cpfilt_" + label + "_" + pathNameNoVer;

TH1F * hist_cpfilt_mini = NULL;
Expand All @@ -522,22 +560,11 @@ void GeneralHLTOffline::fillHltMatrix(const std::string & label,
hist_cpfilt_mini = ME_cpfilt_mini->getTH1F();
}

std::string prefix("hltPre");

for( int iMod=0; iMod<NumModules; iMod++ ){
std::string moduleType = hlt_config_.moduleType(moduleLabels[iMod]);
std::string moduleEDMType = hlt_config_.moduleEDMType(moduleLabels[iMod]);
if( !(moduleEDMType == "EDFilter") ) continue;
if( moduleType.find("Selector")!= std::string::npos ) continue;
if( moduleType == "HLTTriggerTypeFilter" ||
moduleType == "HLTBool" ||
moduleType == "PrimaryVertexObjectFilter" ||
moduleType == "JetVertexChecker" ||
moduleType == "HLTRHemisphere" ||
moduleType == "DetectorStateFilter" ) continue;

if( moduleLabels[iMod].compare(0, prefix.length(), prefix) == 0 ) continue;
std::vector<std::string> moduleLabels = PathModules[path];
int NumModules = int( moduleLabels.size() );

for( int iMod=0; iMod<NumModules; iMod++ ){
edm::InputTag moduleWhoseResultsWeWant(moduleLabels[iMod],
"",
hltTag);
Expand Down

0 comments on commit bacd441

Please sign in to comment.