ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
VP1BatchUtilities Class Reference

#include <VP1BatchUtilities.h>

Collaboration diagram for VP1BatchUtilities:

Public Member Functions

 VP1BatchUtilities (const std::vector< std::string > &files)
 
 ~VP1BatchUtilities ()
 
std::string getRandomConfigFile ()
 

Static Public Member Functions

static void overlayATLASlogo ()
 
static void overlayEventDetails (unsigned long runNumber, unsigned long eventNumber, const std::string &humanTimestamp)
 

Private Attributes

std::vector< std::string > m_files
 
int m_indexFile
 
int m_lastIndexFile
 

Detailed Description

Definition at line 24 of file VP1BatchUtilities.h.

Constructor & Destructor Documentation

◆ VP1BatchUtilities()

VP1BatchUtilities::VP1BatchUtilities ( const std::vector< std::string > &  files)

Definition at line 27 of file VP1BatchUtilities.cxx.

27  :
28  m_files(files),
29  m_indexFile(0),
31 {
32  std::cout << "Got vector of " << files.size() << " items" << std::endl;
33  // Iterate and print values of vector
34  for(const std::string& n : m_files) {
35  std::cout << n << '\n';
36  }
37 }

◆ ~VP1BatchUtilities()

VP1BatchUtilities::~VP1BatchUtilities ( )
inline

Definition at line 28 of file VP1BatchUtilities.h.

28 {};

Member Function Documentation

◆ getRandomConfigFile()

std::string VP1BatchUtilities::getRandomConfigFile ( )

Definition at line 40 of file VP1BatchUtilities.cxx.

41 {
42  std::cout <<"VP1BatchUtilities::getRandomConfigFile()" << std::endl;
43 
44  std::string configFile;
45 
46 
47  int nConfigFiles = m_files.size();
48  std::cout << " ===> # config files: " << nConfigFiles << std::endl;
49 
50  // setup random generator in [0, nConfigFiles]
51  int nPositions = nConfigFiles - 1;
52  auto seed = std::random_device{}();
53  auto randomDist = std::bind(std::uniform_int_distribution<int>(0, nPositions ),
54  std::mt19937(seed));
55 
56  // get a random index,
57  m_indexFile = randomDist();
58  // avoiding having the same index in a row
59  while ( m_indexFile == m_lastIndexFile ) {
60  m_indexFile = randomDist();
61  }
63  std::cout << " ===> random index: " << m_indexFile << std::endl;
64 
66  std::cout << " ===> random file: " << configFile << std::endl;
67 
68  return configFile;
69 
70 }

◆ overlayATLASlogo()

void VP1BatchUtilities::overlayATLASlogo ( )
static

Definition at line 73 of file VP1BatchUtilities.cxx.

74 {
75  /*
76  * different example commands for logo overlay:
77  *
78  * std::string commandStr = "convert -composite `cat latest_vp1image` $TestArea/InstallArea/share/ATLAS-Logo-New_300pixels.png -geometry 150x150+0+0 -depth 8 test.png"; // this set the logo size to 150px and it draws it at (0,0)px
79  * std::string commandStr = "convert -composite `cat latest_vp1image` $TestArea/InstallArea/share/ATLAS-Logo-New_300pixels.png -geometry +10+10 -depth 8 test.png"; // this uses the original logo size and it draws it at (10,10)px
80  */
81 
82  std::string commandStr = "convert -composite `cat latest_vp1image` $TestArea/InstallArea/share/ATLAS-Logo-New_300pixels.png -geometry +10+10 -depth 8 `cat latest_vp1image`";
83 
84  std::cout << " ===> overlay the ATLAS logo: " << commandStr << std::endl;
85  try {
86  system(commandStr.c_str());
87  } catch (std::runtime_error& err) {
88  std::cout << "Exception caught: " << err.what() << std::endl;
89  std::cout << "Unable to run 'convert'!" << std::endl;
90  }
91 }

◆ overlayEventDetails()

void VP1BatchUtilities::overlayEventDetails ( unsigned long  runNumber,
unsigned long  eventNumber,
const std::string &  humanTimestamp 
)
static

Definition at line 95 of file VP1BatchUtilities.cxx.

96 {
97 
98  std::string nRun = std::to_string(runNumber);
99  std::string nEvent = std::to_string(eventNumber);
100 
101  /*
102  * example of different bash command for event details overlay:
103  *
104  * nRun=0; nEvent=4; img=`cat latest_vp1image`; width=$(identify -format %W ${img}); width=$(( ${width} * 3 / 10 )); convert -background '#0008' -gravity west -fill white -size ${width}x80 -font Courier -density 72 -pointsize 18 -interline-spacing 4 caption:'Run number: '${nRun}'\nEvent number: '${nEvent}'\n2015-02-02, 15:10:00' ${img} +swap -gravity SouthEast -composite ${img}-30
105  * nRun=0; nEvent=4; timestamp='ciao'; img=`cat latest_vp1image`; width=$(identify -format %W ${img}); width=$(( ${width} * 3 / 10 )); convert -background '#0008' -gravity west -fill white -size ${width}x80 -font Courier -density 72 -pointsize 18 -interline-spacing 4 caption:'Run number: '${nRun}'\nEvent number: '${nEvent}'\n'${timestamp} ${img} +swap -gravity SouthEast -composite ${img}-31
106  * nRun=0; nEvent=4; timestamp='2015-02-02T10:10:00'; img=`cat latest_vp1image`; width=$(identify -format %W ${img}); width=$(( ${width} * 3 / 10 )); convert -background '#0008' -gravity west -fill white -size ${width}x80 -font Courier -density 72 -pointsize 18 -interline-spacing 4 caption:'Run number: '${nRun}'\nEvent number: '${nEvent}'\n'${timestamp} ${img} +swap -gravity SouthEast -composite ${img}-36
107  */
108 
109  std::string commandStr;
110 
111  // setting bash variables
112  commandStr += "nRun="+nRun+"; ";
113  commandStr += "nEvent="+nEvent+"; ";
114  if (humanTimestamp != "0") commandStr += "timestamp='"+humanTimestamp+"'; "; // 'timestamp' must not have white spaces
115 
116  // get input image
117  commandStr += "img=`cat latest_vp1image`; "; // get the filename of the latest image produced
118  commandStr += "width=$(identify -format %W ${img}); "; // get the width of the image
119  commandStr += "width=$(( ${width} * 3 / 10 )); "; // set the caption width as a fraction of the image width
120 
121  // ImageMagik 'convert' command settings. (ImageMagik is installed by default on SLC LXPLUS machines)
122  commandStr = commandStr
123  + "convert "
124  + "-background '#0008' " // semi-transparent grey bkg
125  + "-geometry +20+20 " // set an offset to the label position
126  + "-gravity West " // set text position inside the caption space (justification)
127  + "-fill white " // text font color
128  + "-size ${width}x80 " // set text size relative to 'width'
129 
130  + "-font Courier " // text font
131  + "-density 72 " // dots-per-inch resolution
132  + "-pointsize 18 " // text size in points
133  //+ "-interline-spacing 4 " // additional number of pixels between lines of text (only with ImageMagik >= 6.5.5-8!!! Lxplus has 6.7 but not all SLC6 machines...)
134 
135  //+ "caption:'Run number: ${nRun}' " // set the caption text
136  //+ (m_timeStamp > 0 ? "caption:'Run number: '${nRun}'\\nEvent number: '${nEvent}'\\n'${timestamp} " : "caption:'Run number: '${nRun}'\\nEvent number: '${nEvent}'\\n'${timestamp} ") // set the caption text; '\n' needs to be double-escaped while passed to system()
137  + "caption:'Run number: '${nRun}'\\nEvent number: '${nEvent}'\\n'${timestamp} " // set the caption text; '\n' needs to be double-escaped while passed to system()
138 
139  + "${img} " // imput image
140  + "+swap "
141  + "-gravity SouthEast " // set overall caption position
142  + "-composite "
143  + "${img}"; // output image: here we replace the original image
144 
145 
146  std::cout << " ===> overlay the event details: " << commandStr << std::endl;
147  try {
148  system(commandStr.c_str());
149  } catch (std::runtime_error& err) {
150  std::cout << "Exception caught: " << err.what() << std::endl;
151  std::cout << "Unable to run 'convert'!" << std::endl;
152  }
153 }

Member Data Documentation

◆ m_files

std::vector<std::string> VP1BatchUtilities::m_files
private

Definition at line 36 of file VP1BatchUtilities.h.

◆ m_indexFile

int VP1BatchUtilities::m_indexFile
private

Definition at line 37 of file VP1BatchUtilities.h.

◆ m_lastIndexFile

int VP1BatchUtilities::m_lastIndexFile
private

Definition at line 38 of file VP1BatchUtilities.h.


The documentation for this class was generated from the following files:
VP1BatchUtilities::m_indexFile
int m_indexFile
Definition: VP1BatchUtilities.h:37
taskman.configFile
configFile
Definition: taskman.py:311
VP1BatchUtilities::m_files
std::vector< std::string > m_files
Definition: VP1BatchUtilities.h:36
Generate_dsid_ranseed.seed
seed
Definition: Generate_dsid_ranseed.py:10
dqt_zlumi_pandas.err
err
Definition: dqt_zlumi_pandas.py:193
beamspotman.n
n
Definition: beamspotman.py:731
generateReferenceFile.files
files
Definition: generateReferenceFile.py:12
xAOD::eventNumber
eventNumber
Definition: EventInfo_v1.cxx:124
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
VP1BatchUtilities::m_lastIndexFile
int m_lastIndexFile
Definition: VP1BatchUtilities.h:38
DeMoAtlasDataLoss.runNumber
string runNumber
Definition: DeMoAtlasDataLoss.py:64