ATLAS Offline Software
Functions
selectblock.cxx File Reference
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
Include dependency graph for selectblock.cxx:

Go to the source code of this file.

Functions

template<typename T >
std::ostream & operator<< (std::ostream &s, std::vector< T > &v)
 
void replace (std::vector< std::string > b, int position, const std::string &regex, const std::string &pattern)
 
bool comparitor (std::vector< std::string > &b)
 
int main (int argc, char **argv)
 

Function Documentation

◆ comparitor()

bool comparitor ( std::vector< std::string > &  b)

Definition at line 60 of file selectblock.cxx.

60  {
61  // for ( size_t i=0 ; i<b.size() ; i++ ) if ( b[i].find("TIDAcomparitor")!=std::string::npos ) return true;
62  for ( size_t i=0 ; i<b.size() ; i++ ) if ( b[i].find("TIDArun")!=std::string::npos ) return true;
63  return false;
64 }

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 67 of file selectblock.cxx.

67  {
68 
69  if ( argc<2 ) return -1;
70 
71  std::ifstream file( argv[1] );
72 
73  std::vector<std::vector<std::string> > block(1,std::vector<std::string>() );
74 
75  bool start = false;
76 
77  std::string line;
78 
79  std::vector<int> position(1, 0);
80 
81  int iblock = 0;
82 
83  while( getline( file, line ) && !file.fail() ) {
84 
85  if ( line.find("action")!=std::string::npos ) {
86  if ( line.find("/action")==std::string::npos ) {
87  start = true;
88  std::string tmp = line;
89  size_t pos = tmp.find("\"");
90  std::string p = tmp.substr( pos+1, tmp.size()-pos-1 );
91  pos = p.find("\"");
92  if (pos!=std::string::npos) p.resize( pos );
93  // position[iblock] = std::atoi( p.c_str() );
94 
95  // std::cout << "pos: " << position << std::endl;
96 
97  if ( iblock==0 ) {
98  iblock++;
99  block.push_back(std::vector<std::string>());
100  position.push_back( 0 );
101  }
102  position[iblock] = std::atoi( p.c_str() );
103  }
104  }
105 
106  block[iblock].push_back(line);
107 
108 
109  if ( line.find("/action")!=std::string::npos ) {
110  start = false;
111  iblock++;
112  block.push_back(std::vector<std::string>());
113  position.push_back( 0 );
114  }
115 
116  }
117 
118  // std::cout << "\nBLOCKS " << block.size() << "\t" << position.size() << std::endl;
119 
120 
121  int maxblock = 0;
122 
123  for ( size_t i=0 ; i<block.size() ; i++ ) {
124  if ( comparitor(block[i]) && position[i]>position[maxblock] ) maxblock = i;
125  }
126 
127  int lastblock = 0;
128 
129  for ( size_t i=0 ; i<block.size() ; i++ ) if ( position[i]>0 ) lastblock = i;
130 
131  // std::cout << "maxblock " << maxblock << std::endl;
132 
133  for ( size_t i=0 ; i<=lastblock ; i++ ) {
134  if ( !comparitor( block[i] ) ) std::cout << block[i] << std::endl;
135  }
136 
137  int nblock = position[maxblock]+1;
138 
139  // for ( size_t i=0 ; i<block.size() ; i++ ) {
140  // if ( comparitor(block[i]) && position[i]>0 ) {
141  // replace( block[i], nblock++, "TIDAcomparitor.exe", "TIDArun.sh" );
142  // }
143  // }
144 
145  for ( size_t i=lastblock+1 ; i<block.size() ; i++ ) std::cout << block[i] << std::endl;
146 
147 
148  return 0;
149 }

◆ operator<<()

template<typename T >
std::ostream& operator<< ( std::ostream &  s,
std::vector< T > &  v 
)

Definition at line 15 of file selectblock.cxx.

15  {
16  for ( size_t i=0 ; i<v.size() ; i++ ) s << v[i] << std::endl;
17  return s;
18 }

◆ replace()

void replace ( std::vector< std::string >  b,
int  position,
const std::string &  regex,
const std::string &  pattern 
)

Definition at line 21 of file selectblock.cxx.

21  {
22  for ( int i=0 ; i<b.size() ; i++ ) {
23 
24  size_t p0 = b[i].find( "position=" );
25 
26  std::string newline;
27 
28  if ( p0!=std::string::npos ) {
29  char nl[128];
30 
31  sprintf( nl, b[i].substr( 0, p0 ).c_str() );
32 
33  std::string ns=nl;
34  ns+="position=\"%02d\">";
35 
36  sprintf( nl, ns.c_str(), position );
37 
38 
39  newline = nl;
40  }
41  else {
42 
43  size_t p = b[i].find( regex );
44 
45  if ( p!=std::string::npos ) {
46  newline = b[i].replace( p, regex.size(), pattern );
47  }
48  else newline = b[i];
49  }
50 
51  if ( newline.find("-plots")!=std::string::npos ) {
52  newline.replace( newline.find("-plots"), 6, "-test-plots" );
53  }
54 
55  std::cout << newline << std::endl;
56  }
57 }
mergePhysValFiles.pattern
pattern
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:26
checkFileSG.line
line
Definition: checkFileSG.py:75
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
PrepareReferenceFile.regex
regex
Definition: PrepareReferenceFile.py:43
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
lumiFormat.i
int i
Definition: lumiFormat.py:85
LArCellNtuple.argv
argv
Definition: LArCellNtuple.py:152
file
TFile * file
Definition: tile_monitor.h:29
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
python.PyAthena.v
v
Definition: PyAthena.py:154
python.SystemOfUnits.ns
int ns
Definition: SystemOfUnits.py:130
CxxUtils::atoi
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
Definition: Control/CxxUtils/Root/StringUtils.cxx:85
comparitor
bool comparitor(std::vector< std::string > &b)
Definition: selectblock.cxx:60
calibdata.newline
newline
Definition: calibdata.py:526
TRTCalib_cfilter.p0
p0
Definition: TRTCalib_cfilter.py:129