6 #include "fastnlotk/fastNLOConstants.h" 13 template<
typename T>
int ReadVector( std::vector<T>& v, std::istream& table ,
double nevts = 1);
14 int ReadVector( std::vector<double>& v, std::istream& table ,
double nevts = 1);
16 template<
typename T>
int ReadFlexibleVector(std::vector<T>& v, std::istream& table,
int nProcLast=0 ,
double nevts = 1);
17 int ReadFlexibleVector( std::vector<std::string >& v, std::istream& table ,
int nProcLast = 0 ,
double nevts = 1 );
18 int ReadFlexibleVector( std::vector<double >& v, std::istream& table ,
int nProcLast = 0 ,
double nevts = 1 );
19 int ReadFlexibleVector( std::vector<int >& v, std::istream& table ,
int nProcLast = 0 ,
double nevts = 1 );
20 int ReadFlexibleVector( std::vector<unsigned long long >& v, std::istream& table ,
int nProcLast = 0 ,
double nevts = 1 );
21 int ReadUnused( std::istream& table );
24 template<
typename T>
void ResizeFlexibleVector(std::vector<T>& v,
const std::vector<T>& nom);
25 void ResizeFlexibleVector( std::vector<double >& v,
const std::vector<double >& nom);
26 void ResizeFlexibleVector( std::vector<unsigned long long >& v,
const std::vector<double >& nom);
29 template<
typename T>
void ClearVector(std::vector<std::vector<T > >& v);
30 template<
typename T>
void ClearVector(std::vector<T>& v);
33 void ResizeVector( fastNLO::v1d& v,
int dim0 );
34 void ResizeVector( fastNLO::v2d& v,
int dim0 ,
int dim1 );
35 void ResizeVector( fastNLO::v3d& v,
int dim0 ,
int dim1,
int dim2 );
36 void ResizeVector( fastNLO::v4d& v,
int dim0 ,
int dim1,
int dim2,
int dim3 );
37 void ResizeVector( fastNLO::v5d& v,
int dim0 ,
int dim1,
int dim2,
int dim3,
int dim4 );
38 void ResizeVector( fastNLO::v6d& v,
int dim0 ,
int dim1,
int dim2,
int dim3,
int dim4,
int dim5 );
39 void ResizeVector( fastNLO::v7d& v,
int dim0 ,
int dim1,
int dim2,
int dim3,
int dim4,
int dim5,
int dim6 );
42 template<
typename T>
bool IsEmptyVector(
const std::vector<std::vector<T > >& v);
43 template<
typename T>
bool IsEmptyVector(
const std::vector<T>& v);
48 template<
typename T>
int WriteVector(
const std::vector<T>& v, std::ostream& table ,
double nevts=1 );
49 template<
typename T>
int _Write1DVectorByN(
const std::vector<T>& v, std::ostream& table ,
double nevts );
50 template<
typename T>
int _Write1DVector(
const std::vector<T>& v, std::ostream& table);
51 int WriteVector(
const std::vector<double >& v, std::ostream& table ,
double nevts=1 );
52 int WriteVector(
const std::vector<std::string >& v, std::ostream& table ,
double nevts=1 );
53 int WriteVector(
const std::vector<int >& v, std::ostream& table ,
double nevts=1 ) ;
54 int WriteVector(
const std::vector<unsigned long long >& v, std::ostream& table ,
double nevts=1 );
56 template<
typename T>
int WriteFlexibleVector(
const std::vector<T>& v, std::ostream& table,
int nProcLast = 0,
double nevts=1 );
57 int WriteFlexibleVector(
const std::vector<double >& v, std::ostream& table,
int nProcLast = 0 ,
double nevts=1 );
58 int WriteFlexibleVector(
const std::vector<std::string >& v, std::ostream& table,
int nProcLast = 0 ,
double nevts=1 );
59 int WriteFlexibleVector(
const std::vector<int >& v, std::ostream& table,
int nProcLast = 0 ,
double nevts=1 );
60 int WriteFlexibleVector(
const std::vector<unsigned long long >& v, std::ostream& table,
int nProcLast = 0 ,
double nevts=1 );
63 template<
typename T>
void AddVectors( std::vector<T>& vSum,
const std::vector<T>& vAdd,
double w1 = 1,
double w2 = 1 );
64 template<
typename T>
void _DoAddVectors( std::vector<T>& vSum,
const std::vector<T>& vAdd,
double w1 = 1,
double w2 = 1 );
65 void AddVectors( std::vector<double >& vSum,
const std::vector<double >& vAdd,
double w1 = 1,
double w2 = 1 ) ;
66 void AddVectors( std::vector<int >& vSum,
const std::vector<int >& vAdd,
double w1 = 1,
double w2 = 1 ) ;
67 void AddVectors( std::vector<unsigned long long >& vSum,
const std::vector<unsigned long long >& vAdd,
double w1=1,
double w2=1 ) ;
70 void StripWhitespace(std::string& s);
73 template<
typename T>
void PrintVector(
const std::vector<T>& v, std::string name, std::string prefix=
"");
76 bool CheckVersion(
int version);
78 bool ReadMagicNo(std::istream& table);
79 void PutBackMagicNo(std::istream& table);
88 int fastNLOTools::ReadVector( std::vector<T>& v, std::istream& table ,
double nevts){
92 for(
unsigned int i=0 ; i<v.size() ; i++ ){
93 nn += ReadVector(v[i],table, nevts);
100 int fastNLOTools::ReadFlexibleVector(std::vector<T>& v, std::istream& table,
int nProcLast,
double nevts ){
105 for(
unsigned int i0=0;i0<v.size();i0++){
106 nn += ReadFlexibleVector(v[i0],table,nProcLast,nevts);
114 void fastNLOTools::ResizeFlexibleVector(std::vector<T>& v,
const std::vector<T>& nom) {
115 v.resize(nom.size());
116 for (
unsigned int i = 0 ; i<v.size() ; i++) {
117 ResizeFlexibleVector(v[i],nom[i]);
125 void fastNLOTools::ClearVector(std::vector<std::vector<T > >& v) {
126 for (
unsigned int i = 0 ; i<v.size() ; i++) {
132 void fastNLOTools::ClearVector(std::vector<T >& v) {
133 for (
unsigned int i = 0 ; i<v.size() ; i++) {
142 bool fastNLOTools::IsEmptyVector(
const std::vector<std::vector<T > >& v){
144 if ( v.empty() )
return true;
145 for (
unsigned int i = 0 ; i<v.size() ; i++) {
146 if ( !IsEmptyVector(v[i]) )
return false;
152 bool fastNLOTools::IsEmptyVector(
const std::vector<T>& v){
154 if ( v.empty() )
return true;
155 for (
unsigned int i = 0 ; i<v.size() ; i++) {
156 if ( v[i] != 0 )
return false;
165 int fastNLOTools::WriteVector(
const std::vector<T>& v, std::ostream& table ,
double nevts) {
168 for(
unsigned int i=0;i<v.size();i++)
169 nn += WriteVector( v[i] , table , nevts );
174 int fastNLOTools::_Write1DVectorByN(
const std::vector<T>& v, std::ostream& table ,
double nevts) {
175 if( nevts == 0)
return -1000;
176 for(
unsigned int i0=0;i0<v.size();i0++)
177 table << v[i0] / nevts << fastNLO::sep;
182 int fastNLOTools::_Write1DVector(
const std::vector<T>& v, std::ostream& table ) {
183 for(
unsigned int i0=0;i0<v.size();i0++)
184 table << v[i0] << fastNLO::sep;
190 int fastNLOTools::WriteFlexibleVector(
const std::vector<T>& v, std::ostream& table,
int nProcLast ,
double nevts ) {
192 say::error[
"fastNLOTools::WriteFlexibleVector"]<<
"Cannot divide by zero."<<std::endl;
196 table << v.size() << fastNLO::sep;
197 for(
unsigned int i0=0;i0<v.size();i0++){
198 nn += WriteFlexibleVector( v[i0] , table , nProcLast , nevts );
207 void fastNLOTools::AddVectors( std::vector<T>& vSum,
const std::vector<T>& vAdd,
double w1,
double w2 ) {
211 if ( vSum.size() != vAdd.size() ) {
212 say::error[
"fastNLOTools::AddVectors"]
213 <<
"Cannot add tables with different size. s1=" 214 <<vSum.size()<<
", s2="<<vAdd.size()<<std::endl;
217 for (
unsigned int i = 0 ; i<vSum.size() ; i++ )
218 AddVectors( vSum[i], vAdd[i], w1 , w2 );
222 void fastNLOTools::_DoAddVectors( std::vector<T>& vSum,
const std::vector<T>& vAdd,
double w1,
double w2 ) {
224 if ( vSum.size() != vAdd.size() ) {
225 say::error[
"fastNLOTools::_DoAddVectors"]
226 <<
"Cannot add tables with different size. s1=" 227 <<vSum.size()<<
", s2="<<vAdd.size()<<std::endl;
230 if ( w1==1. && w2==1. )
231 for (
unsigned int i = 0 ; i<vSum.size() ; i++ )
234 for (
unsigned int i = 0 ; i<vSum.size() ; i++ )
235 vSum[i] = w1*vSum[i] + w2*vAdd[i];
239 void fastNLOTools::PrintVector(
const std::vector<T>& v, std::string name, std::string prefix){
240 std::cout<<
" "<<prefix<<
" "<<name<<std::endl;
241 for(
unsigned int i=0;i<v.size();i++){
242 std::cout<<
" "<<prefix<<
" "<<i<<
"\t"<<v[i]<<std::endl;