Skip to content

Commit

Permalink
Merge pull request #14232 from vdutta/tkdqmoffline-tkcommissioner-inp…
Browse files Browse the repository at this point in the history
…uts-80X

Input files for offline TkCommissioner tool, 80X
  • Loading branch information
cmsbuild committed May 31, 2016
2 parents d74708f + 90d8a39 commit f9dacee
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 17 deletions.
5 changes: 5 additions & 0 deletions DQM/SiStripMonitorClient/interface/SiStripActionExecutor.h
Expand Up @@ -12,6 +12,7 @@
#include <map>
#include <vector>
#include <string>
#include <TTree.h>

class SiStripSummaryCreator;
class DQMStore;
Expand All @@ -21,6 +22,7 @@ class SiStripQualityChecker;
class SiStripFedCabling;
class SiStripDetCabling;
class SiStripConfigWriter;
class SiStripDetInfoFileReader;

class SiStripActionExecutor {

Expand All @@ -41,6 +43,7 @@ class SiStripActionExecutor {
DQMStore* dqm_store, std::string& map_type, const edm::EventSetup& eSetup);
void createOfflineTkMap(const edm::ParameterSet & tkmapPset,
DQMStore* dqm_store, std::string& map_type, const edm::EventSetup& eSetup);
void createTkInfoFile(std::vector<std::string> tkhmap_names, TTree* tkinfo_tree, DQMStore* dqm_store);

void createStatus(DQMStore* dqm_store);
void fillDummyStatus();
Expand All @@ -65,6 +68,8 @@ class SiStripActionExecutor {

SiStripConfigWriter* configWriter_;

SiStripDetInfoFileReader* detInfoFileReader_;

edm::ParameterSet pSet_;

};
Expand Down
3 changes: 3 additions & 0 deletions DQM/SiStripMonitorClient/interface/SiStripOfflineDQM.h
Expand Up @@ -33,6 +33,7 @@
#include <string>
#include <vector>
#include <map>
#include <TTree.h>

class DQMStore;
class SiStripActionExecutor;
Expand Down Expand Up @@ -78,13 +79,15 @@ class SiStripOfflineDQM: public edm::EDAnalyzer {
SiStripActionExecutor* actionExecutor_;

bool createSummary_;
bool createTkInfoFile_;
std::string inputFileName_;
std::string outputFileName_;
int globalStatusFilling_;
bool usedWithEDMtoMEConverter_;
int nEvents_;
bool trackerFEDsFound_;
bool printFaultyModuleList_;
TTree* tkinfoTree_;

edm::ParameterSet configPar_;

Expand Down
4 changes: 4 additions & 0 deletions DQM/SiStripMonitorClient/interface/SiStripTrackerMapCreator.h
Expand Up @@ -12,6 +12,7 @@
#include <map>
#include <vector>
#include <string>
#include <TTree.h>

class DQMStore;
class TkDetMap;
Expand All @@ -33,6 +34,7 @@ class SiStripTrackerMapCreator {
DQMStore* dqm_store, std::string& htype, const edm::EventSetup& eSetup);
void createForOffline(const edm::ParameterSet & tkmapPset,
DQMStore* dqm_store, std::string& htype, const edm::EventSetup& eSetup);
void createInfoFile(std::vector<std::string> map_names, TTree* tkinfo_tree, DQMStore* dqm_store, std::vector<uint32_t> detidList);


private:
Expand All @@ -45,6 +47,7 @@ class SiStripTrackerMapCreator {
void setTkMapRange(std::string& map_type);
void setTkMapRangeOffline();
uint16_t getDetectorFlagAndComment(DQMStore* dqm_store, uint32_t det_id, const TrackerTopology* tTopo, std::ostringstream& comment);
uint16_t getDetectorFlag(uint32_t det_id) { return detflag_.find(det_id) != detflag_.end() ? detflag_[det_id] : 0; }
void printBadModuleList(std::map<unsigned int,std::string>* badmodmap, const edm::EventSetup& eSetup);
void printTopModules(std::vector<std::pair<float,uint32_t> >* topNmodVec, const edm::EventSetup& eSetup);

Expand All @@ -66,6 +69,7 @@ class SiStripTrackerMapCreator {
// SiStripPsuDetIdMap psumap_;
uint32_t cached_detid;
int16_t cached_layer;
std::map<uint32_t, uint16_t> detflag_;
TkLayerMap::XYbin cached_XYbin;
bool topModules;
uint32_t numTopModules;
Expand Down
Expand Up @@ -112,6 +112,7 @@ do
rm -f *.log
rm -f *.txt
rm -f *.html
rm -f *.root

# Determine the GlobalTag name used to process the data and the DQM

Expand All @@ -136,7 +137,9 @@ do

echo " Creating the TrackerMap.... "

cmsRun ${CMSSW_BASE}/src/DQM/SiStripMonitorClient/test/SiStripDQM_OfflineTkMap_Template_cfg_DB.py print globalTag=${GLOBALTAG} runNumber=${Run_numb} dqmFile=${file_path}/$dqmFileName # update GlobalTag
detIdInfoFileName=`echo "file://TkDetIdInfo_Run${Run_numb}_${thisDataset}.root"`

cmsRun ${CMSSW_BASE}/src/DQM/SiStripMonitorClient/test/SiStripDQM_OfflineTkMap_Template_cfg_DB.py print globalTag=${GLOBALTAG} runNumber=${Run_numb} dqmFile=${file_path}/$dqmFileName detIdInfoFile=${detIdInfoFileName} # update GlobalTag

# rename bad module list file

Expand Down Expand Up @@ -213,6 +216,10 @@ do
# mkdir -p /data/users/event_display/${DataLocalDir}/${dest}/${nnn}/${Run_numb}/$thisDataset #2> /dev/null
# cp -r ${Run_numb}/$thisDataset /data/users/event_display/Data2011/${dest}/${nnn}/${Run_numb}/
# cp -r ${Run_numb}/$thisDataset /data/users/event_display/${DataLocalDir}/${dest}/${nnn}/${Run_numb}/$thisDataset
ssh cctrack@vocms061 "mkdir -p /data/users/event_display/TkCommissioner_runs/${DataLocalDir}/${dest} 2> /dev/null"
scp *.root cctrack@vocms061:/data/users/event_display/TkCommissioner_runs/${DataLocalDir}/${dest}
rm *.root

ssh cctrack@vocms061 "mkdir -p /data/users/event_display/${DataLocalDir}/${dest}/${nnn}/${Run_numb}/$thisDataset 2> /dev/null"
scp -r * cctrack@vocms061:/data/users/event_display/${DataLocalDir}/${dest}/${nnn}/${Run_numb}/$thisDataset

Expand Down
14 changes: 13 additions & 1 deletion DQM/SiStripMonitorClient/src/SiStripActionExecutor.cc
Expand Up @@ -3,6 +3,7 @@
#include "DQMServices/Core/interface/DQMStore.h"

#include "CalibFormats/SiStripObjects/interface/SiStripDetCabling.h"
#include "CalibTracker/SiStripCommon/interface/SiStripDetInfoFileReader.h"

#include "DataFormats/SiStripDetId/interface/StripSubdetector.h"

Expand All @@ -28,6 +29,7 @@ SiStripActionExecutor::SiStripActionExecutor(edm::ParameterSet const& ps):pSet_(
tkMapCreator_ = 0;
qualityChecker_ = 0;
configWriter_ = 0;
detInfoFileReader_ = 0;
}
//
// -- Destructor
Expand All @@ -38,6 +40,7 @@ SiStripActionExecutor::~SiStripActionExecutor() {
if (summaryCreator_) delete summaryCreator_;
if (tkMapCreator_) delete tkMapCreator_;
if (qualityChecker_) delete qualityChecker_;
if (detInfoFileReader_) delete detInfoFileReader_;
}
//
// -- Read Configurationn File
Expand Down Expand Up @@ -112,7 +115,16 @@ void SiStripActionExecutor::createOfflineTkMap(const edm::ParameterSet & tkmapPs
const edm::EventSetup& eSetup) {
if (tkMapCreator_) tkMapCreator_->createForOffline(tkmapPset, dqm_store, map_type, eSetup);
}

//
// -- create root file with detId info from tracker maps
//
void SiStripActionExecutor::createTkInfoFile(std::vector<std::string> map_names, TTree* tkinfo_tree, DQMStore* dqm_store) {
if (tkMapCreator_) {
detInfoFileReader_ = edm::Service<SiStripDetInfoFileReader>().operator->();
std::vector<uint32_t> detidList = detInfoFileReader_->getAllDetIds();
tkMapCreator_->createInfoFile(map_names, tkinfo_tree, dqm_store, detidList);
}
}
//
// -- Create Status Monitor Elements
//
Expand Down
41 changes: 27 additions & 14 deletions DQM/SiStripMonitorClient/src/SiStripOfflineDQM.cc
Expand Up @@ -24,6 +24,8 @@
#include "FWCore/ParameterSet/interface/FileInPath.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "CommonTools/UtilAlgos/interface/TFileService.h"

#include "DataFormats/FEDRawData/interface/FEDNumbering.h"

#include "DQMServices/Core/interface/DQMStore.h"
Expand Down Expand Up @@ -68,12 +70,21 @@ SiStripOfflineDQM::SiStripOfflineDQM(edm::ParameterSet const& pSet) : configPar_

usedWithEDMtoMEConverter_= configPar_.getUntrackedParameter<bool>("UsedWithEDMtoMEConverter",false);
createSummary_ = configPar_.getUntrackedParameter<bool>("CreateSummary",false);
createTkInfoFile_ = configPar_.getUntrackedParameter<bool>("CreateTkInfoFile",false);
inputFileName_ = configPar_.getUntrackedParameter<std::string>("InputFileName","");
outputFileName_ = configPar_.getUntrackedParameter<std::string>("OutputFileName","");
globalStatusFilling_ = configPar_.getUntrackedParameter<int>("GlobalStatusFilling", 1);
printFaultyModuleList_ = configPar_.getUntrackedParameter<bool>("PrintFaultyModuleList", false);

nEvents_ = 0;

tkinfoTree_ = nullptr;

if(createTkInfoFile_) {
edm::Service<TFileService> fs;
tkinfoTree_ = fs->make<TTree>("TkDetIdInfo", "");
}

}
/**
* @brief
Expand Down Expand Up @@ -127,9 +138,9 @@ void SiStripOfflineDQM::beginRun(edm::Run const& run, edm::EventSetup const& eSe

std::vector<int> FedsInIds= sumFED->m_fed_in;
for(unsigned int it = 0; it < FedsInIds.size(); ++it) {
int fedID = FedsInIds[it];
if(fedID>=siStripFedIdMin && fedID<=siStripFedIdMax) ++nFEDs;
int fedID = FedsInIds[it];
if(fedID>=siStripFedIdMin && fedID<=siStripFedIdMax) ++nFEDs;
}
}
}
Expand Down Expand Up @@ -201,14 +212,19 @@ void SiStripOfflineDQM::endRun(edm::Run const& run, edm::EventSetup const& eSetu
if (create_tkmap) {
std::vector<edm::ParameterSet> tkMapOptions = configPar_.getUntrackedParameter< std::vector<edm::ParameterSet> >("TkMapOptions" );
if (actionExecutor_->readTkMapConfiguration(eSetup)) {

for(std::vector<edm::ParameterSet>::iterator it = tkMapOptions.begin(); it != tkMapOptions.end(); ++it) {
edm::ParameterSet tkMapPSet = *it;
std::string map_type = it->getUntrackedParameter<std::string>("mapName","");
tkMapPSet.augment(configPar_.getUntrackedParameter<edm::ParameterSet>("TkmapParameters"));
edm::LogInfo("TkMapParameters") << tkMapPSet;
actionExecutor_->createOfflineTkMap(tkMapPSet, dqmStore_, map_type, eSetup);
}
std::vector<std::string> map_names;

for(std::vector<edm::ParameterSet>::iterator it = tkMapOptions.begin(); it != tkMapOptions.end(); ++it) {
edm::ParameterSet tkMapPSet = *it;
std::string map_type = it->getUntrackedParameter<std::string>("mapName","");
map_names.push_back(map_type);
tkMapPSet.augment(configPar_.getUntrackedParameter<edm::ParameterSet>("TkmapParameters"));
edm::LogInfo("TkMapParameters") << tkMapPSet;
actionExecutor_->createOfflineTkMap(tkMapPSet, dqmStore_, map_type, eSetup);
}
if(createTkInfoFile_) {
actionExecutor_->createTkInfoFile(map_names, tkinfoTree_, dqmStore_);
}
}
}
}
Expand All @@ -228,9 +244,6 @@ void SiStripOfflineDQM::endJob() {
actionExecutor_->printFaultyModuleList(dqmStore_, str_val);
std::cout << str_val.str() << std::endl;
}
// Save Output file
dqmStore_->cd();
dqmStore_->save(outputFileName_, "","","");
}
}
/**
Expand Down
80 changes: 80 additions & 0 deletions DQM/SiStripMonitorClient/src/SiStripTrackerMapCreator.cc
@@ -1,6 +1,7 @@
#include "CommonTools/TrackerMap/interface/TrackerMap.h"
#include "CalibTracker/SiStripCommon/interface/TkDetMap.h"
#include "DQM/SiStripCommon/interface/SiStripFolderOrganizer.h"
#include "DQM/SiStripCommon/interface/TkHistoMap.h"
#include "DQM/SiStripMonitorClient/interface/SiStripUtility.h"
#include "DQM/SiStripMonitorClient/interface/SiStripConfigParser.h"
#include "DQMServices/Core/interface/DQMStore.h"
Expand Down Expand Up @@ -363,6 +364,8 @@ void SiStripTrackerMapCreator::paintTkMapFromAlarm(uint32_t det_id, const Tracke
trackerMap_->setText(det_id, comment.str());
trackerMap_->fillc(det_id, rval, gval, bval);
if(badmodmap && (flag!=0 || isBad)) (*badmodmap)[det_id] = comment.str();

detflag_[det_id] = flag;
}

//
Expand Down Expand Up @@ -610,3 +613,80 @@ uint16_t SiStripTrackerMapCreator::getDetectorFlagAndComment(DQMStore* dqm_store
}
return flag;
}
//
// -- create branches for root file with tracker map values by detId and fill it
//
void SiStripTrackerMapCreator::createInfoFile(std::vector<std::string> map_names, TTree* tkinfo_tree, DQMStore* dqm_store, std::vector<uint32_t> detidList) {

std::map<std::string, float> tkhmap_value;
int qtalarm_flag = 0;
uint32_t det_id = 0;

if(!tkinfo_tree) {
edm::LogError("SiStripTrackerMapCreator::createInfoFile") << "Tree not found!";
}
else {
tkinfo_tree->Branch("DetId",&det_id,"DetId/i");
for(std::vector<std::string>::const_iterator in = map_names.begin(); in != map_names.end(); ++in) {
std::string mapname = (*in);
if(mapname == "QTestAlarm") {
qtalarm_flag = 0;
tkinfo_tree->Branch(mapname.c_str(),&qtalarm_flag,std::string(mapname+"/I").c_str());
} else {
tkhmap_value[mapname] = -1.0;
tkinfo_tree->Branch(mapname.c_str(),&tkhmap_value[mapname],std::string(mapname+"/F").c_str());
}
}

std::string dirname = "";

std::string mdir = "MechanicalView";
dqm_store->cd();
if (!SiStripUtility::goToDir(dqm_store, mdir)) {
edm::LogError("SiStripTrackerMapCreator::createInfoFile") << "I cannot find the SiStrip top level directory in the DQM file";
}
else {
std::string mechanicalview_dir = dqm_store->pwd();
dirname=mechanicalview_dir.substr(0,mechanicalview_dir.find_last_of("/"));
edm::LogInfo("SiStripTrackerMapCreator::createInfoFile") << "SiStrip top level directory is " << dirname;
}
dqm_store->cd();

std::vector<TkHistoMap*> tkHMaps;

uint32_t nHists = map_names.size();

for(uint32_t ih = 0; ih < nHists; ++ih) {
tkHMaps.push_back(new TkHistoMap());
if(map_names.at(ih) != "QTestAlarm") {
std::string tkhmap_name = "TkHMap_" + map_names.at(ih);
tkHMaps.at(ih)->loadTkHistoMap(dirname, tkhmap_name, true);
}
}

for(std::vector<uint32_t>::const_iterator idet = detidList.begin(); idet != detidList.end(); ++idet) {
det_id = (*idet);
for(uint32_t ih = 0; ih < nHists; ++ih) {
if(map_names.at(ih) == "QTestAlarm") {
std::ostringstream comment;
qtalarm_flag = getDetectorFlag(det_id);
} else {
tkhmap_value[map_names.at(ih)] = tkHMaps.at(ih)->getValue(det_id);
}
}
if(!tkinfo_tree) {
edm::LogError("SiStripTrackerMapCreator::createInfoFile") << "Tree not found!";
}
else {
tkinfo_tree->Fill();
}
}

// delete pointers
for(uint32_t ih = 0; ih < nHists; ++ih) {
delete tkHMaps.at(ih);
}

}

}
Expand Up @@ -23,6 +23,11 @@
VarParsing.VarParsing.multiplicity.singleton, # singleton or list
VarParsing.VarParsing.varType.int, # string, int, or float
"run number")
options.register ('detIdInfoFile',
"",
VarParsing.VarParsing.multiplicity.singleton, # singleton or list
VarParsing.VarParsing.varType.string, # string, int, or float
"File to store information by det_id")

options.parseArguments()

Expand Down Expand Up @@ -97,6 +102,7 @@
InputFileName = cms.untracked.string(options.dqmFile),
OutputFileName = cms.untracked.string("/tmp/testRunNum.root"),
CreateTkMap = cms.untracked.bool(True),
CreateTkInfoFile = cms.untracked.bool(True),
TkmapParameters = cms.untracked.PSet(
loadFedCabling = cms.untracked.bool(True),
trackerdatPath = cms.untracked.string('CommonTools/TrackerMap/data/'),
Expand Down Expand Up @@ -125,9 +131,12 @@
)
)

# Services needed for TkHistoMap
# Services needed for TkHistoMap / DetIdInfoFile
process.TkDetMap = cms.Service("TkDetMap")
process.SiStripDetInfoFileReader = cms.Service("SiStripDetInfoFileReader")
process.TFileService = cms.Service('TFileService',
fileName = cms.string(options.detIdInfoFile)
)

# Configuration of the SiStripQuality object for the map of bad channels

Expand Down

0 comments on commit f9dacee

Please sign in to comment.