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