-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8250 from venturia/sistripmonitorclient_75x
New macro and script to extract SiStrip occupancy plots from official DQM files
- Loading branch information
Showing
4 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
###Macros and Scripts | ||
####moduleOccupancyPlots | ||
`moduleOccupancyPlots.sh <Datataking_period> <Dataset_type> <runnumber> <modulelistfile> <user certificate file> <user key file>` | ||
|
||
This script produces a root file and png files of the occupancy plots of the modules selected with the file | ||
`<modulelistfile>` which contains a list of detid from run `<runnumber>` as found in the official DQM file. The | ||
`<Datataking_period>` and the `<Dataset_type>` have to match the names used in this site: | ||
https://cmsweb.cern.ch/dqm/offline/data/browse/ROOT/OfflineData/ | ||
|
||
To access the DQM file a valid certificate and key has to be provided to the script |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
#include <iostream> | ||
#include <fstream> | ||
#include <sstream> | ||
#include <string> | ||
|
||
#include "TFile.h" | ||
#include "TH1D.h" | ||
#include "TCanvas.h" | ||
|
||
#define NOISEPREFIX "Profile_NoiseFromCondDB__det__" | ||
#define PEDESTALPREFIX "Profile_PedestalFromCondDB__det__" | ||
#define OCCUPANCYPREFIX "ClusterDigiPosition__det__" | ||
|
||
void printPlot(TH1D* hist, char* prefix, char* postfix); | ||
|
||
int main(int argc, char *argv[]) { | ||
|
||
char* rootfilename; | ||
char* modulelistname; | ||
int pnbits; | ||
char* prefix; | ||
char* postfix; | ||
|
||
if(argc==6) { | ||
rootfilename = argv[1]; | ||
modulelistname = argv[2]; | ||
pnbits = atoi(argv[3]); | ||
prefix = argv[4]; | ||
postfix = argv[5]; | ||
} | ||
else { | ||
std::cout << "Wrong number of parameters " << argc << std::endl; | ||
return 1; | ||
} | ||
|
||
std::cout << "ready to go " << rootfilename << ' ' << modulelistname << std::endl; | ||
|
||
TFile* rootfile = new TFile(rootfilename,"READ"); | ||
if(!rootfile) { | ||
std::cout << "Problems with input root file" << std::endl; | ||
return 2; | ||
} | ||
int detid; | ||
std::ifstream modulelist(modulelistname); | ||
|
||
std::stringstream outrootfilename; | ||
outrootfilename << prefix << "SummaryFile" << postfix << ".root"; | ||
TFile* outrootfile = new TFile(outrootfilename.str().c_str(),"CREATE"); | ||
|
||
while (modulelist >> detid) { | ||
std::cout << " ready to go with detid " << detid << " " << pnbits << std::endl; | ||
// bit 0: noise | ||
if(pnbits & 1) { | ||
std::stringstream histoname; | ||
histoname << NOISEPREFIX << detid; | ||
std::cout << " ready to go with histogram " << histoname.str() << std::endl; | ||
TH1D* hist = (TH1D*)rootfile->FindObjectAny(histoname.str().c_str()); | ||
if(hist) { | ||
std:: cout << histoname.str() << " found!" << std::endl; | ||
printPlot(hist,prefix,postfix); | ||
hist->Write(); | ||
} else { | ||
std:: cout << histoname.str() << " NOT found..." << std::endl; | ||
} | ||
} | ||
// bit 1: pedestal | ||
if(pnbits & 2) { | ||
std::stringstream histoname; | ||
histoname << PEDESTALPREFIX << detid; | ||
std::cout << " ready to go with histogram " << histoname.str() << std::endl; | ||
TH1D* hist = (TH1D*)rootfile->FindObjectAny(histoname.str().c_str()); | ||
if(hist) { | ||
std:: cout << histoname.str() << " found!" << std::endl; | ||
printPlot(hist,prefix,postfix); | ||
hist->Write(); | ||
} else { | ||
std:: cout << histoname.str() << " NOT found..." << std::endl; | ||
} | ||
} | ||
// bit 2: pedestal | ||
if(pnbits & 4) { | ||
std::stringstream histoname; | ||
histoname << OCCUPANCYPREFIX << detid; | ||
std::cout << " ready to go with histogram " << histoname.str() << std::endl; | ||
TH1D* hist = (TH1D*)rootfile->FindObjectAny(histoname.str().c_str()); | ||
if(hist) { | ||
std:: cout << histoname.str() << " found!" << std::endl; | ||
printPlot(hist,prefix,postfix); | ||
hist->Write(); | ||
} else { | ||
std:: cout << histoname.str() << " NOT found..." << std::endl; | ||
} | ||
} | ||
} | ||
|
||
outrootfile->Close(); | ||
|
||
return 0; | ||
|
||
} | ||
|
||
void printPlot(TH1D* hist, char* prefix, char* postfix) { | ||
|
||
TCanvas* cc= new TCanvas; | ||
hist->Draw(); | ||
std::stringstream filename; | ||
filename << prefix << hist->GetName() << postfix << ".png"; | ||
cc->Print(filename.str().c_str()); | ||
delete cc; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
|
||
#export PATH=/afs/cern.ch/cms/common:${PATH} | ||
if [[ "$#" == "0" ]]; then | ||
echo "usage: 'moduleOccupancyPlots.sh RootFileDirectory Dataset RunNumber ModuleListFile UserCertFile UserKeyFile'"; | ||
exit 1; | ||
fi | ||
|
||
nnn=`echo $3 | awk '{print substr($0,0,4)}'` | ||
curl -k --cert $5 --key $6 -X GET 'https://cmsweb.cern.ch/dqm/offline/data/browse/ROOT/OfflineData/'$1'/'$2'/000'${nnn}'xx/' > index.html | ||
dqmFileNames=`cat index.html | grep $3 | grep "_DQM.root" | egrep "Prompt|Express" | sed 's/.*>\(.*\)<\/a.*/\1/' ` | ||
dqmFileName=`expr "$dqmFileNames" : '\(DQM[A-Za-z0-9_/.\-]*root\)'` | ||
echo ' dqmFileNames = '$dqmFileNames | ||
echo ' dqmFileName = ['$dqmFileName']' | ||
curl -k --cert $5 --key $6 -X GET https://cmsweb.cern.ch/dqm/offline/data/browse/ROOT/OfflineData/$1/$2/000${nnn}xx/${dqmFileName} > /tmp/${dqmFileName} | ||
|
||
moduleOccupancyPlots /tmp/${dqmFileName} $4 4 "$2_" "_run_$3" |