StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
SusyLesHouches.h
1 // SusyLesHouches.h is a part of the PYTHIA event generator.
2 // Copyright (C) 2018 Torbjorn Sjostrand.
3 // Main authors of this file: N. Desai, P. Skands
4 // PYTHIA is licenced under the GNU GPL v2 or later, see COPYING for details.
5 // Please respect the MCnet Guidelines, see GUIDELINES for details.
6 
7 // Header file for SUSY Les Houches Accord functionality
8 // This part of the SLHA interface basically contains the Pythia-independent
9 // SLHA read/write and processing utilities, which would be common to any
10 // SLHA interface.
11 // (The Pythia-specific components reside in the SLHAinterface class.)
12 
13 #ifndef Pythia8_SLHA_H
14 #define Pythia8_SLHA_H
15 
16 #include "Pythia8/PythiaStdlib.h"
17 
18 namespace Pythia8 {
19 
20 //==========================================================================
21 
22 //************************* SLHA AUX CLASSES *****************************//
23 
24  //class LHblock: the generic SLHA block (see below for matrices)
25  //Explicit typing required, e.g. block<double> minpar;
26  template <class T> class LHblock {
27 
28  public:
29 
30  //Constructor.
31  LHblock<T>() : idnow(0) {} ;
32 
33  //Does block exist?
34  bool exists() { return int(entry.size()) == 0 ? false : true ; };
35  //Clear block
36  void clear() { entry.clear(); };
37 
38  //set: set block entry values.
39  //Possible return values from set:
40  // 0: normal return. Entry did not previously exist and has been created.
41  // 1: normal return. Entry did previously exist and has been overwritten.
42  //-1: failure.
43  int set(int iIn,T valIn) {
44  int alreadyexisting=exists(iIn)?1:0;
45  entry[iIn]=valIn;
46  return alreadyexisting;
47  };
48  // Read index and value from SLHA data line
49  int set(istringstream& linestream, bool indexed=true) {
50  i = 0;
51  if (indexed) linestream >> i >> val;
52  else linestream >> val;
53  return linestream ? set(i,val) : -1;
54  };
55  // With i already given, read value from remaining SLHA data line
56  int set(int iIn,istringstream& linestream) {
57  linestream >> val;
58  return linestream ? set(iIn,val) : -1;
59  };
60  // Shorthand for entry[0]. Used e.g. for block ALPHA.
61  void set(T valIn) { entry[0]=valIn; };
62 
63  // Does entry i already exist in this block?
64  bool exists(int iIn) {return entry.find(iIn) != entry.end()
65  ? true : false;};
66 
67  // Indexing with (). Output only.
68  T operator()() {
69  if (exists(0)) {return entry[0];} else {T dummy(0); return dummy;};
70  };
71  T operator()(int iIn) {
72  if (exists(iIn)) {return entry[iIn];} else {T dummy(0); return dummy;};
73  };
74 
75  // Size of map
76  int size() {return int(entry.size());};
77 
78  // First and next key code
79  int first() { idnow = entry.begin()->first; return idnow; };
80  int next() {
81  typename map<int,T>::iterator itnow;
82  itnow = ++entry.find(idnow);
83  if ( itnow == entry.end() ) itnow=entry.begin();
84  return idnow = itnow->first;
85  };
86 
87  // Simple print utility
88  void list() {
89  bool finished=false;
90  int ibegin=first();
91  i=ibegin;
92  while (!finished) {
93  cout << " "<< i << " " << entry[i] <<endl;
94  i=next();
95  if (i == ibegin) finished=true;
96  };
97  };
98 
99  // Special for DRbar running blocks.
100  void setq(double qIn) { qDRbar=qIn; }
101  double q() { return qDRbar; }
102 
103  protected:
104  map<int,T> entry;
105 
106  private:
107  int idnow;
108  double qDRbar;
109  //Auxiliary vars
110  int i;
111  T val;
112  };
113 
114  // Derived class for generic blocks containing vectors of strings.
115  class LHgenericBlock : public LHblock<string> {
116 
117  public:
118 
119  //Constructor.
120  LHgenericBlock() { } ;
121 
122  // Read index and value from SLHA data line
123  int set(string lineIn) {
124  entry[entry.size()] = lineIn;
125  return 0;
126  };
127 
128  };
129 
130  // class LHmatrixBlock: the generic SLHA matrix
131  // Explicit sizing required, e.g.LHmatrixBlock<4> nmix;
132  template <int size> class LHmatrixBlock {
133  public:
134  //Constructor. Set uninitialized and explicitly zero.
135  LHmatrixBlock<size>() {
136  initialized=false;
137  for (i=1;i<=size;i++) {
138  for (j=1;j<=size;j++) {
139  entry[i][j]=0.0;
140  };
141  };
142  };
143 
144  // Assignment
145  LHmatrixBlock& operator=(const LHmatrixBlock& m) {
146  if (this != &m) {
147  for (i=0;i<size;i++) for (j=0;j<=size;j++) entry[i][j] = m(i,j);
148  qDRbar = m.qDRbar;
149  initialized = m.initialized;
150  }
151  return *this; };
152 
153  // Does this matrix contain any entries?
154  bool exists() { return initialized; };
155  // Clear initialized flag
156  void clear() { initialized=false; };
157 
158  // Set matrix entry
159  int set(int iIn,int jIn, double valIn) {
160  if (iIn>0 && jIn>0 && iIn<=size && jIn<=size) {
161  entry[iIn][jIn]=valIn;
162  initialized=true;
163  return 0;
164  } else {
165  return -1;
166  };
167  };
168 
169  // Set entry from linestream (used during file read)
170  int set(istringstream& linestream) {
171  linestream >> i >> j >> val;
172  return linestream ? set(i,j,val) : -1;
173  };
174 
175  // () Overloading: Get entry
176  double operator()(int iIn, int jIn) const {
177  return (iIn <= size && jIn <= size && iIn > 0 && jIn > 0) ?
178  entry[iIn][jIn] : 0.0;
179  };
180 
181  // Set and get scale for DRbar running LHblocks.
182  void setq(double qIn) { qDRbar=qIn; }
183  double q() { return qDRbar; }
184 
185  // Simple print utility, to be elaborated on.
186  void list() {
187  for (i=1;i<=size;i++) {
188  cout << " "<<i << " " ;
189  for (j=1;j<=size;j++) cout << entry[i][j] << " ";
190  cout << endl;
191  };
192  };
193 
194  private:
195  bool initialized;
196  double entry[size+1][size+1];
197  double qDRbar;
198  //Auxiliary vars
199  int i,j;
200  double val;
201  };
202 
203  // class tensorBlock: the generic SLHA tensor
204  // Explicit sizing required, e.g. tensorBlock<3> rvlam;
205  template <int size> class LHtensor3Block {
206  public:
207  //Constructor. Set uninitialized and explicitly zero.
208  LHtensor3Block<size>() {
209  initialized=false;
210  for (i=1;i<=size;i++) {
211  for (j=1;j<=size;j++) {
212  for (k=1;k<=size;k++) {
213  entry[i][j][k]=0.0;
214  };
215  };
216  };
217  };
218 
219  // Assignment
220  LHtensor3Block& operator=(const LHtensor3Block& m) {
221  if (this != &m) {
222  for (i=0;i<size;i++) for (j=0;j<=size;j++) for (k=0;k<=size;k++)
223  entry[i][j][k] = m(i,j,k);
224  qDRbar = m.qDRbar;
225  initialized = m.initialized;
226  }
227  return *this; };
228 
229  // Does this matrix contain any entries?
230  bool exists() { return initialized; };
231  // Clear initialized flag
232  void clear() { initialized=false; };
233 
234  // Set matrix entry
235  int set(int iIn,int jIn, int kIn, double valIn) {
236  if (iIn>0 && jIn>0 && kIn>0 && iIn<=size && jIn<=size && kIn<=size) {
237  entry[iIn][jIn][kIn]=valIn;
238  initialized=true;
239  return 0;
240  } else {
241  return -1;
242  };
243  };
244 
245  // Set entry from linestream (used during file read)
246  int set(istringstream& linestream) {
247  linestream >> i >> j >> k >> val;
248  return linestream ? set(i,j,k,val) : -1;
249  };
250 
251  // () Overloading: Get entry
252  double operator()(int iIn, int jIn, int kIn) const {
253  return (iIn <= size && jIn <= size && kIn <= size && iIn > 0
254  && jIn > 0 && kIn > 0) ? entry[iIn][jIn][kIn] : 0.0;
255  };
256 
257  // Set and get scale for DRbar running LHblocks.
258  void setq(double qIn) { qDRbar=qIn; }
259  double q() { return qDRbar; }
260 
261  // Simple print utility, to be elaborated on.
262  void list() {
263  for (i=1;i<=size;i++) {
264  for (j=1;j<=size;j++) {
265  cout << " "<<i << " "<<j << " " ;
266  for (k=1;k<=size;k++) {
267  cout << entry[i][j][k] << " ";
268  cout << endl;
269  };
270  };
271  };
272  };
273 
274  private:
275  bool initialized;
276  double entry[size+1][size+1][size+1];
277  double qDRbar;
278  //Auxiliary vars
279  int i,j,k;
280  double val;
281  };
282 
283  //*************************** DECAY TABLES ***************************//
284 
285  class LHdecayChannel {
286  public:
287 
288  LHdecayChannel() : brat(0.0) {};
289  LHdecayChannel(double bratIn, int nDaIn, vector<int> idDaIn,
290  string cIn="") { setChannel(bratIn,nDaIn,idDaIn,cIn);
291  }
292 
293  // Functions to set decay channel information
294  void setChannel(double bratIn, int nDaIn, vector<int> idDaIn,
295  string cIn="") {
296  brat = bratIn;
297  for (int i=0; i<=nDaIn; i++) {
298  if (i < int(idDaIn.size())) idDa.push_back(idDaIn[i]);
299  comment = cIn;
300  }
301  }
302  void setBrat(double bratIn) {brat=bratIn;}
303  void setIdDa(vector<int> idDaIn) {idDa = idDaIn;}
304 
305  // Functions to get decay channel information
306  double getBrat() {return brat;}
307  int getNDa() {return int(idDa.size());}
308  vector<int> getIdDa() {return idDa;}
309  string getComment() {return comment;}
310 
311  private:
312  double brat;
313  vector<int> idDa;
314  string comment;
315 
316  };
317 
318  class LHdecayTable {
319  public:
320 
321  LHdecayTable() : id(0), width(0.0) {};
322  LHdecayTable(int idIn) : id(idIn), width(0.0) {};
323  LHdecayTable(int idIn, double widthIn) : id(idIn), width(widthIn) {};
324 
325  // Functions to get PDG code (id) and width
326  int getId() {return id;}
327  double getWidth() {return width;}
328 
329  // Functions to set PDG code (id) and width
330  void setId(int idIn) {id = idIn;}
331  void setWidth(double widthIn) {width=widthIn;}
332 
333  // Function to reset size and width (width -> 0 by default)
334  void reset(double widthIn=0.0) {table.resize(0); width=widthIn;}
335 
336  // Function to add another decay channel
337  void addChannel(LHdecayChannel channelIn) {table.push_back(channelIn);}
338  void addChannel(double bratIn, int nDaIn, vector<int> idDaIn,
339  string cIn="") {
340  LHdecayChannel newChannel(bratIn, nDaIn, idDaIn, cIn);
341  table.push_back(newChannel);
342  }
343 
344  // Function to return number of decay channels
345  int size() {return int(table.size());}
346 
347  // Function to return a branching ratio
348  double getBrat(int iChannel) {
349  if (iChannel >= 0 && iChannel < int(table.size())) {
350  return table[iChannel].getBrat();
351  } else {
352  return 0.0;
353  }
354  }
355  // Function to return daughter PDG codes
356  vector<int> getIdDa(int iChannel) {
357  if (iChannel >= 0 && iChannel < int(table.size())) {
358  return table[iChannel].getIdDa();
359  } else {
360  vector<int> dum;
361  return dum;
362  }
363  }
364  // Function to return a decay channel
365  LHdecayChannel getChannel(int iChannel) {
366  if (iChannel >= 0 && iChannel < int(table.size())) {
367  return table[iChannel];
368  } else {
369  LHdecayChannel dum;
370  return dum;
371  }
372  }
373 
374  private:
375  int id;
376  double width;
377  vector<LHdecayChannel> table;
378 
379  };
380 
381 //==========================================================================
382 
383 class SusyLesHouches {
384 
385 public:
386 
387  //Constructor, with and without filename.
388  SusyLesHouches(int verboseIn=1) : verboseSav(verboseIn),
389  headerPrinted(false), footerPrinted(false), filePrinted(false),
390  slhaRead(false), lhefRead(false), lhefSlha(false), useDecay(true) {};
391  SusyLesHouches(string filename, int verboseIn=1) : verboseSav(verboseIn),
392  headerPrinted(false), footerPrinted(false), filePrinted(false),
393  slhaRead(true), lhefRead(false), lhefSlha(false), useDecay(true)
394  {readFile(filename);};
395 
396  //***************************** SLHA FILE I/O *****************************//
397  // Read and write SLHA files
398  int readFile(string slhaFileIn="slha.spc",int verboseIn=1,
399  bool useDecayIn=true);
400  int readFile(istream& ,int verboseIn=1,
401  bool useDecayIn=true);
402  //int writeFile(string filename): write SLHA file on filename
403 
404  //Output utilities
405  void listHeader(); // print Header
406  void listFooter(); // print Footer
407  void listSpectrum(int ifail=0); // print Spectrum
408 
409  // Check spectrum and decays
410  int checkSpectrum();
411 
412  // File Name (can be either SLHA or LHEF)
413  string slhaFile;
414 
415  // Class for SLHA data entry
416  class Entry {
417 
418  public:
419  //Constructor.
420  Entry() : isIntP(false), isDoubleP(false),
421  isStringP(false), n(0), d(0.0), s(""), commentP("") {}
422 
423  // Generic functions to inquire whether an int, double, or string
424  bool isInt(){return isIntP;}
425  bool isDouble(){return isDoubleP;}
426  bool isString(){return isStringP;}
427 
428  // = Overloading: Set entry to int, double, or string
429  Entry& operator=(double& val) {
430  d=val;isIntP=false;isDoubleP=true;isStringP=false;
431  return *this;
432  };
433  Entry& operator=(int& val) {
434  n=val;isIntP=true;isDoubleP=false;isStringP=false;
435  return *this;
436  };
437  Entry& operator=(string& val) {
438  s=val;isIntP=false;isDoubleP=false;isStringP=true;
439  return *this;
440  };
441 
442  // Set and Get comment
443  void setComment(string comment) {commentP=comment;}
444  void getComment(string comment) {comment=commentP;}
445 
446  // Generic functions to get value
447  bool get(int& val) {val=n; return isIntP;}
448  bool get(double& val) {val=d; return isDoubleP;}
449  bool get(string& val) {val=s; return isStringP;}
450 
451  private:
452  bool isIntP, isDoubleP, isStringP;
453  int n;
454  double d;
455  string s;
456  string commentP;
457 
458  };
459 
460  //*************************** THE SLHA1 BLOCKS ***************************//
461  //Blocks for model definition:
462  LHblock<int> modsel;
463  LHblock<int> modsel21;
464  LHblock<double> modsel12;
465  LHblock<double> minpar;
466  LHblock<double> extpar;
467  LHblock<double> sminputs;
468  //Blocks for RGE program specific output
469  LHblock<string> spinfo;
470  LHblock<string> spinfo3;
471  LHblock<string> spinfo4;
472  //Blocks for DCY program specific output
473  LHblock<string> dcinfo;
474  LHblock<string> dcinfo3;
475  LHblock<string> dcinfo4;
476  //Blocks for mass and coupling spectrum
477  LHblock<double> mass;
478  LHmatrixBlock<4> nmix;
479  LHmatrixBlock<2> umix;
480  LHmatrixBlock<2> vmix;
481  LHmatrixBlock<2> stopmix;
482  LHmatrixBlock<2> sbotmix;
483  LHmatrixBlock<2> staumix;
484  LHblock<double> alpha;
485  LHblock<double> hmix;
486  LHblock<double> gauge;
487  LHblock<double> msoft;
488  LHmatrixBlock<3> au;
489  LHmatrixBlock<3> ad;
490  LHmatrixBlock<3> ae;
491  LHmatrixBlock<3> yu;
492  LHmatrixBlock<3> yd;
493  LHmatrixBlock<3> ye;
494 
495  //************************ THE SLHA1 DECAY TABLES ************************//
496  vector<LHdecayTable> decays;
497  map<int,int> decayIndices;
498 
499  //********************* THE BSM-SLHA QNUMBERS BLOCKS *********************//
500  vector< LHblock<int> > qnumbers; // Zero'th entry is PDG code
501  vector< string > qnumbersName;
502  vector< string > qnumbersAntiName;
503 
504  //*************************** THE SLHA2 BLOCKS ***************************//
505  //Additions to SLHA1
506  LHblock<double> qextpar;
507 
508  //FLV Input
509  LHblock<double> vckmin; // The input CKM Wolfenstein parms.
510  LHblock<double> upmnsin; // The input PMNS PDG parms.
511  LHmatrixBlock<3> msq2in; // The input upper off-diagonal msq2
512  LHmatrixBlock<3> msu2in; // The input upper off-diagonal msu2
513  LHmatrixBlock<3> msd2in; // The input upper off-diagonal msd2
514  LHmatrixBlock<3> msl2in; // The input upper off-diagonal msl2
515  LHmatrixBlock<3> mse2in; // The input upper off-diagonal mse2
516  LHmatrixBlock<3> tuin; // The input upper off-diagonal TU
517  LHmatrixBlock<3> tdin; // The input upper off-diagonal TD
518  LHmatrixBlock<3> tein; // The input upper off-diagonal TE
519  //FLV Output
520  LHmatrixBlock<3> vckm; // The output DRbar running Re{VCKM} at Q
521  LHmatrixBlock<3> upmns; // The output DRbar running Re{UPMNS} at Q
522  LHmatrixBlock<3> msq2; // The output DRbar running msq2 at Q
523  LHmatrixBlock<3> msu2; // The output DRbar running msu2 at Q
524  LHmatrixBlock<3> msd2; // The output DRbar running msd2 at Q
525  LHmatrixBlock<3> msl2; // The output DRbar running msl2 at Q
526  LHmatrixBlock<3> mse2; // The output DRbar running mse2 at Q
527  LHmatrixBlock<3> tu; // The output DRbar running TU at Q
528  LHmatrixBlock<3> td; // The output DRbar running TD at Q
529  LHmatrixBlock<3> te; // The output DRbar running TE at Q
530  LHmatrixBlock<6> usqmix; // The Re{} up squark mixing matrix
531  LHmatrixBlock<6> dsqmix; // The Re{} down squark mixing matrix
532  LHmatrixBlock<6> selmix; // The Re{} selectron mixing matrix
533  LHmatrixBlock<3> snumix; // The Re{} sneutrino mixing matrix
534  LHmatrixBlock<3> snsmix; // The scalar sneutrino mixing matrix
535  LHmatrixBlock<3> snamix; // The pseudoscalar neutrino mixing matrix
536 
537  //RPV Input
538  LHtensor3Block<3> rvlamllein; // The input LNV lambda couplings
539  LHtensor3Block<3> rvlamlqdin; // The input LNV lambda' couplings
540  LHtensor3Block<3> rvlamuddin; // The input BNV lambda'' couplings
541  LHtensor3Block<3> rvtllein; // The input LNV T couplings
542  LHtensor3Block<3> rvtlqdin; // The input LNV T' couplings
543  LHtensor3Block<3> rvtuddin; // The input BNV T'' couplings
544  LHblock<double> rvkappain; // The input LNV kappa couplings
545  LHblock<double> rvdin; // The input LNV D terms
546  LHblock<double> rvm2lh1in; // The input LNV m2LH1 couplings
547  LHblock<double> rvsnvevin; // The input LNV sneutrino vevs
548  //RPV Output
549  LHtensor3Block<3> rvlamlle; // The output LNV lambda couplings
550  LHtensor3Block<3> rvlamlqd; // The output LNV lambda' couplings
551  LHtensor3Block<3> rvlamudd; // The output BNV lambda'' couplings
552  LHtensor3Block<3> rvtlle; // The output LNV T couplings
553  LHtensor3Block<3> rvtlqd; // The output LNV T' couplings
554  LHtensor3Block<3> rvtudd; // The output BNV T'' couplings
555  LHblock<double> rvkappa; // The output LNV kappa couplings
556  LHblock<double> rvd; // The output LNV D terms
557  LHblock<double> rvm2lh1; // The output LNV m2LH1 couplings
558  LHblock<double> rvsnvev; // The output LNV sneutrino vevs
559  LHmatrixBlock<7> rvnmix; // The RPV neutralino mixing matrix
560  LHmatrixBlock<5> rvumix; // The RPV chargino L mixing matrix
561  LHmatrixBlock<5> rvvmix; // The RPV chargino R mixing matrix
562  LHmatrixBlock<5> rvhmix; // The RPV neutral scalar mixing matrix
563  LHmatrixBlock<5> rvamix; // The RPV neutral pseudoscalar mixing matrix
564  LHmatrixBlock<8> rvlmix; // The RPV charged fermion mixing matrix
565 
566  //CPV Input
567  LHblock<double> imminpar;
568  LHblock<double> imextpar;
569  //CPV Output
570  LHmatrixBlock<4> cvhmix; // The CPV Higgs mixing matrix
571  LHmatrixBlock<4> imcvhmix; // Optional: imaginary components
572  LHmatrixBlock<3> imau,imad,imae; // Im{} of AU, AD, AE
573  LHblock<double> imhmix;
574  LHblock<double> immsoft;
575 
576  //CPV + FLV Input
577  LHmatrixBlock<3> immsq2in; // The Im{} input upper off-diagonal msq2
578  LHmatrixBlock<3> immsu2in; // The Im{} input upper off-diagonal msu2
579  LHmatrixBlock<3> immsd2in; // The Im{} input upper off-diagonal msd2
580  LHmatrixBlock<3> immsl2in; // The Im{} input upper off-diagonal msl2
581  LHmatrixBlock<3> immse2in; // The Im{} input upper off-diagonal mse2
582  LHmatrixBlock<3> imtuin,imtdin,imtein; // The Im{} input upper off-diagonal T
583  //CPV + FLV Output
584  LHmatrixBlock<3> imvckm; // The output DRbar running Im{VCKM} at Q
585  LHmatrixBlock<3> imupmns; // The output DRbar running Im{UPMNS} at Q
586  LHmatrixBlock<3> immsq2; // The output DRbar running msq2 at Q
587  LHmatrixBlock<3> immsu2; // The output DRbar running msu2 at Q
588  LHmatrixBlock<3> immsd2; // The output DRbar running msd2 at Q
589  LHmatrixBlock<3> immsl2; // The output DRbar running msl2 at Q
590  LHmatrixBlock<3> immse2; // The output DRbar running mse2 at Q
591  LHmatrixBlock<3> imtu,imtd,imte; // Im{} of TU, TD, TE
592  LHmatrixBlock<6> imusqmix;// The Im{} up squark mixing matrix
593  LHmatrixBlock<6> imdsqmix; // The Im{} down squark mixing matrix
594  LHmatrixBlock<6> imselmix; // The Im{} selectron mixing matrix
595  LHmatrixBlock<3> imsnumix; // The Im{} sneutrino mixing matrix
596  LHmatrixBlock<4> imnmix; // The Im{} neutralino mixing matrix
597  LHmatrixBlock<4> imumix; // The Im{} chargino L mixing matrix
598  LHmatrixBlock<4> imvmix; // The Im{} chargino R mixing matrix
599 
600  //NMSSM Input
601  // All input is in EXTPAR
602  //NMSSM Output
603  LHblock<double> nmssmrun; // The LHblock of NMSSM running parameters
604  LHmatrixBlock<3> nmhmix; // The NMSSM scalar Higgs mixing
605  LHmatrixBlock<3> nmamix; // The NMSSM pseudoscalar Higgs mixing
606  LHmatrixBlock<5> nmnmix; // The NMSSM neutralino mixing
607  LHmatrixBlock<5> imnmnmix; // Im{} (for future use)
608 
609  //*************************** SET BLOCK VALUE ****************************//
610  template <class T> int set(string,T);
611  template <class T> int set(string,int,T);
612  template <class T> int set(string,int,int,T);
613  template <class T> int set(string,int,int,int,T);
614 
615  //********************* GENERIC/USER-DEFINED BLOCKS **********************//
616  // bool getEntry(name, indices, value)
617  // = true if LHblock and entry exists (value returned in value,
618  // typecast by user in call)
619  // = false otherwise
620  map<string, LHgenericBlock> genericBlocks;
621  template <class T> bool getEntry(string, T&);
622  template <class T> bool getEntry(string, int, T&);
623  template <class T> bool getEntry(string, int, int, T&);
624  template <class T> bool getEntry(string, int, int, int, T&);
625  template <class T> bool getEntry(string, vector<int>, T&);
626 
627  // Access/change verbose setting
628  int verbose() {return verboseSav;}
629  void verbose(int verboseIn) {verboseSav = verboseIn;}
630 
631  // Output of messages from SLHA interface
632  void message(int, string,string ,int line=0);
633 
634  //***************************** SLHA PRIVATE *****************************//
635 private:
636  //SLHA I/O
637  int verboseSav;
638  bool headerPrinted, footerPrinted, filePrinted;
639  bool slhaRead, lhefRead, lhefSlha, useDecay;
640 
641 };
642 
643 //--------------------------------------------------------------------------
644 
645 // utilities to set generic blocks
646 
647 template <class T> int SusyLesHouches::set(string blockName, T val) {
648 
649  // Make sure everything is interpreted as lower case (for safety)
650  toLowerRep(blockName);
651 
652  // Add new generic block if not already existing
653  if (genericBlocks.find(blockName) == genericBlocks.end()) {
654  LHgenericBlock gBlock;
655  genericBlocks[blockName]=gBlock;
656  }
657 
658  // Convert input value to string
659  ostringstream lineStream;
660  lineStream << val;
661  return genericBlocks[blockName].set(lineStream.str());
662 
663 }
664 
665 template <class T> int SusyLesHouches::set(string blockName, int indx, T val) {
666 
667  // Make sure everything is interpreted as lower case (for safety)
668  toLowerRep(blockName);
669 
670  // Add new generic block if not already existing
671  if (genericBlocks.find(blockName) == genericBlocks.end()) {
672  LHgenericBlock gBlock;
673  genericBlocks[blockName]=gBlock;
674  }
675 
676  // Convert input value to string
677  ostringstream lineStream;
678  lineStream << indx<<" "<<val;
679  return genericBlocks[blockName].set(lineStream.str());
680 
681 }
682 
683 template <class T> int SusyLesHouches::set(string blockName, int indx,
684  int jndx, T val) {
685 
686  // Make sure everything is interpreted as lower case (for safety)
687  toLowerRep(blockName);
688 
689  // Add new generic block if not already existing
690  if (genericBlocks.find(blockName) == genericBlocks.end()) {
691  LHgenericBlock gBlock;
692  genericBlocks[blockName]=gBlock;
693  }
694 
695  // Convert input value to string
696  ostringstream lineStream;
697  lineStream << indx<<" "<<jndx<<" "<<val;
698  return genericBlocks[blockName].set(lineStream.str());
699 
700 }
701 
702 template <class T> int SusyLesHouches::set(string blockName, int indx,
703  int jndx, int kndx, T val) {
704 
705  // Make sure everything is interpreted as lower case (for safety)
706  toLowerRep(blockName);
707 
708  // Add new generic block if not already existing
709  if (genericBlocks.find(blockName) == genericBlocks.end()) {
710  LHgenericBlock gBlock;
711  genericBlocks[blockName]=gBlock;
712  }
713 
714  // Convert input value to string
715  ostringstream lineStream;
716  lineStream << indx<<" "<<jndx<<" "<<kndx<<" "<<val;
717  return genericBlocks[blockName].set(lineStream.str());
718 
719 }
720 
721 // utilities to read generic blocks
722 
723 template <class T> bool SusyLesHouches::getEntry(string blockName, T& val) {
724 
725  // Make sure everything is interpret as lower case (for safety)
726  toLowerRep(blockName);
727 
728  // Safety checks
729  if (genericBlocks.find(blockName) == genericBlocks.end()) {
730  message(1,"getEntry","attempting to extract entry from non-existent block "
731  +blockName);
732  return false;
733  }
734  if (genericBlocks[blockName].size() == 0) {
735  message(1,"getEntry","attempting to extract entry from zero-size block "
736  +blockName);
737  return false;
738  }
739  if (genericBlocks[blockName].size() >= 2) {
740  message(1,"getEntry","attempting to extract un-indexed entry "
741  "from multi-entry block "+blockName);
742  return false;
743  }
744  // Attempt to extract value as class T
745  LHgenericBlock block = genericBlocks[blockName];
746  istringstream linestream(block(0));
747  linestream >> val;
748  if ( !linestream ) {
749  message(1,"getEntry","problem extracting un-indexed entry "
750  "from block "+blockName);
751  return false;
752  }
753  // If made it all the way here, value was successfully extracted.
754  // Return true.
755  return true;
756 }
757 
758 template <class T> bool SusyLesHouches::getEntry(string blockName, int indx,
759  T& val) {
760 
761  // Make sure everything is interpret as lower case (for safety)
762  toLowerRep(blockName);
763 
764  // Safety checks
765  if (genericBlocks.find(blockName) == genericBlocks.end()) {
766  message(1,"getEntry","attempting to extract entry from non-existent block "
767  +blockName);
768  return false;
769  }
770  if (genericBlocks[blockName].size() == 0) {
771  message(1,"getEntry","attempting to extract entry from zero-size block "
772  +blockName);
773  return false;
774  }
775  // Attempt to extract indexed value as class T
776  LHgenericBlock block = genericBlocks[blockName];
777  // Loop over block contents, search for indexed entry with index i
778  for (int jEntry = 0; jEntry < block.size(); jEntry++) {
779  istringstream linestream(block(jEntry));
780  // Buffer line according to format selected by T
781  int indxNow;
782  T valNow;
783  linestream >> indxNow >> valNow;
784  // If index found and value was readable, return true
785  if (linestream && indxNow == indx) {
786  val = valNow;
787  return true;
788  }
789  }
790  // If index not found or unreadable, return false
791  message(1,"getEntry","problem extracting indexed entry from block "
792  +blockName);
793  return false;
794 }
795 
796 template <class T> bool SusyLesHouches::getEntry(string blockName, int indx,
797  int jndx, T& val) {
798 
799  // Make sure everything is interpret as lower case (for safety)
800  toLowerRep(blockName);
801 
802  // Safety checks
803  if (genericBlocks.find(blockName) == genericBlocks.end()) {
804  message(1,"getEntry","attempting to extract entry from non-existent block "
805  +blockName);
806  return false;
807  }
808  if (genericBlocks[blockName].size() == 0) {
809  message(1,"getEntry","attempting to extract entry from zero-size block "
810  +blockName);
811  return false;
812  }
813  // Attempt to extract matrix-indexed value as class T
814  LHgenericBlock block = genericBlocks[blockName];
815  // Loop over block contents, search for indexed entry with indices i, j
816  for (int jEntry = 0; jEntry < block.size(); jEntry++) {
817  istringstream linestream(block(jEntry));
818  // Buffer line according to format selected by T
819  int indxNow, jndxNow;
820  T valNow;
821  linestream >> indxNow >> jndxNow >> valNow;
822  // If index found and value was readable, return true
823  if (linestream && indxNow == indx && jndxNow == jndx) {
824  val = valNow;
825  return true;
826  }
827  }
828  // If index not found or unreadable, return false
829  message(1,"getEntry","problem extracting matrix-indexed entry from block "
830  +blockName);
831  return false;
832 }
833 
834 template <class T> bool SusyLesHouches::getEntry(string blockName, int indx,
835  int jndx, int kndx, T& val) {
836 
837  // Make sure everything is interpret as lower case (for safety)
838  toLowerRep(blockName);
839 
840  // Safety checks
841  if (genericBlocks.find(blockName) == genericBlocks.end()) {
842  message(1,"getEntry","attempting to extract entry from non-existent block "
843  +blockName);
844  return false;
845  }
846  if (genericBlocks[blockName].size() == 0) {
847  message(1,"getEntry","attempting to extract entry from zero-size block "
848  +blockName);
849  return false;
850  }
851  // Attempt to extract tensor-indexed value as class T
852  LHgenericBlock block = genericBlocks[blockName];
853  // Loop over block contents, search for indexed entry with indices i, j, k
854  for (int jEntry = 0; jEntry < block.size(); jEntry++) {
855  istringstream linestream(block(jEntry));
856  // Buffer line according to format selected by T
857  int indxNow, jndxNow, kndxNow;
858  T valNow;
859  linestream >> indxNow >> jndxNow >> kndxNow >> valNow;
860  // If index found and value was readable, return true
861  if (linestream && indxNow == indx && jndxNow == jndx && kndxNow == kndx) {
862  val = valNow;
863  return true;
864  }
865  }
866  // If index not found or unreadable, return false
867  message(1,"getEntry","problem extracting tensor-indexed entry from block "
868  +blockName);
869  return false;
870  }
871 
872 //==========================================================================
873 
874 
875 } // end of namespace Pythia8
876 
877 #endif // end Pythia8_SLHA_H