Skip to content

Commit

Permalink
Merged tkdqmoffline-script-update-74X from repository vdutta
Browse files Browse the repository at this point in the history
Conflicts:
	DQM/SiStripMonitorClient/scripts/TkMap_script_automatic_DB.sh
	DQM/SiStripMonitorClient/test/SiStripDQM_OfflineTkMap_Template_cfg_DB.py
  • Loading branch information
vdutta committed Aug 13, 2015
2 parents f79fef9 + 6bbfc57 commit 910ffca
Show file tree
Hide file tree
Showing 8 changed files with 181 additions and 26 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
5 changes: 5 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,10 +47,12 @@ 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);

TrackerMap* trackerMap_;
std::string sRunNumber;
std::string tkMapName_;
std::string stripTopLevelDir_;

Expand All @@ -64,6 +68,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;
int32_t numTopModules;
Expand Down
35 changes: 29 additions & 6 deletions DQM/SiStripMonitorClient/scripts/TkMap_script_automatic_DB.sh
Expand Up @@ -6,6 +6,17 @@ if [[ "$#" == "0" ]]; then
exit 1;
fi

FORCE=0
echo "OPTIND starts at $OPTIND"
while getopts ":f" optname
do
case $optname in
f) FORCE=1
;;
esac
done
shift $(($OPTIND - 1))

export WORKINGDIR=${CMSSW_BASE}/src

cd ${WORKINGDIR}
Expand All @@ -19,10 +30,15 @@ do
if [ "$Run_numb" == "$1" ]; then continue; fi

#2015 Commissioning period (since January)
if [ $Run_numb -gt 232881 ]; then
if [ $Run_numb -gt 246841 ]; then
DataLocalDir='Data2015'
DataOfflineDir='Commissioning2015'
DataOfflineDir='Run2015'
else
#2015 Commissioning period (since January)
if [ $Run_numb -gt 232881 ]; then
DataLocalDir='Data2015'
DataOfflineDir='Commissioning2015'
else
#2013 pp run (2.76 GeV)
if [ $Run_numb -gt 211658 ]; then
DataLocalDir='Data2013'
Expand Down Expand Up @@ -74,8 +90,10 @@ do

file_path="/tmp/"

if [ $FORCE == 0 ]; then
check_runcomplete ${file_path}/$dqmFileName
if [ $? -ne 0 ]; then continue; fi
fi

echo Process ${file_path}/$dqmFileName

Expand Down Expand Up @@ -105,6 +123,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 @@ -122,14 +141,16 @@ do
fi

#Temporary fix to remove hidden ASCII characters
GLOBALTAG=`echo $GLOBALTAG | cut -c 9-16`
# echo $GLOBALTAG
GLOBALTAG=`echo $GLOBALTAG | cut -c 9-${#GLOBALTAG}`
# GLOBALTAG=`sed -i 's/[\d128-\d255]//g' <<< "${GLOBALTAG}"`
# GLOBALTAG=`echo $GLOBALTAG | sed 's/[\d128-\d255]//'`
# echo `expr length $GLOBALTAG`

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 @@ -192,9 +213,11 @@ do
rm -f *.xml
rm -f *svg

# mkdir -p /data/users/event_display/${DataLocalDir}/${dest}/${nnn}/${Run_numb}/$thisDataset #2> /dev/null
# 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"
#include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
Expand Down Expand Up @@ -30,6 +31,7 @@ SiStripActionExecutor::SiStripActionExecutor(edm::ParameterSet const& ps):pSet_(
tkMapCreator_ = 0;
qualityChecker_ = 0;
configWriter_ = 0;
detInfoFileReader_ = 0;
}
//
// -- Destructor
Expand All @@ -40,6 +42,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 @@ -114,7 +117,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
18 changes: 16 additions & 2 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,19 @@ 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_ = 0;
edm::Service<TFileService> fs;

if(createTkInfoFile_) tkinfoTree_ = fs->make<TTree>("TkDetIdInfo", "");

}
/**
* @brief
Expand Down Expand Up @@ -201,16 +210,21 @@ 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)) {
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 Down
87 changes: 85 additions & 2 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 @@ -147,8 +148,16 @@ void SiStripTrackerMapCreator::createForOffline(const edm::ParameterSet & tkmapP
bool tkMapPSU = tkmapPset.getUntrackedParameter<bool>("psuMap",false);
bool tkMapFED = tkmapPset.getUntrackedParameter<bool>("fedMap",false);
std::string namesuffix = tkmapPset.getUntrackedParameter<std::string>("mapSuffix","");

std::string tmap_title = " Tracker Map from " + map_type;
unsigned long long runNumber_ = tkmapPset.getUntrackedParameter<unsigned long long>("RunNumber",0);

std::stringstream ss;
ss << runNumber_;
sRunNumber = ss.str();
//std::string tmap_title;
//if (runNumber_>0) { tmap_title = " Run: " + sRunNumber + ", Tracker Map from " + map_type; }
//else { tmap_title = " Tracker Map from " + map_type; }
trackerMap_->setTitle(tmap_title);

if(tkmapPset.exists("TopModules"))
Expand Down Expand Up @@ -277,7 +286,7 @@ void SiStripTrackerMapCreator::printBadModuleList(std::map<unsigned int,std::str
}
}

edm::LogVerbatim("BadModuleList") << "Number of bad modules in total:";
edm::LogVerbatim("BadModuleList") << "Run: " << sRunNumber << ", Number of bad modules in total:";
edm::LogVerbatim("BadModuleList") << "--------------------------------------------------------------";
edm::LogVerbatim("BadModuleList") << "TIB: " << ntib;
edm::LogVerbatim("BadModuleList") << "TID/MINUS: " << ntids1;
Expand Down Expand Up @@ -346,6 +355,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 @@ -589,3 +600,75 @@ 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();
}
}

}

}

0 comments on commit 910ffca

Please sign in to comment.