13 #ifndef Pythia8_SLHA_H
14 #define Pythia8_SLHA_H
16 #include "Pythia8/PythiaStdlib.h"
26 template <
class T>
class LHblock {
31 LHblock<T>() : idnow(0) {} ;
34 bool exists() {
return int(entry.size()) == 0 ?
false :
true ; };
36 void clear() { entry.clear(); };
43 int set(
int iIn,T valIn) {
44 int alreadyexisting=exists(iIn)?1:0;
46 return alreadyexisting;
49 int set(istringstream& linestream,
bool indexed=
true) {
51 if (indexed) linestream >> i >> val;
52 else linestream >> val;
53 return linestream ? set(i,val) : -1;
56 int set(
int iIn,istringstream& linestream) {
58 return linestream ? set(iIn,val) : -1;
61 void set(T valIn) { entry[0]=valIn; };
64 bool exists(
int iIn) {
return entry.find(iIn) != entry.end()
69 if (exists(0)) {
return entry[0];}
else {T dummy(0);
return dummy;};
71 T operator()(
int iIn) {
72 if (exists(iIn)) {
return entry[iIn];}
else {T dummy(0);
return dummy;};
76 int size() {
return int(entry.size());};
79 int first() { idnow = entry.begin()->first;
return idnow; };
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;
93 cout <<
" "<< i <<
" " << entry[i] <<endl;
95 if (i == ibegin) finished=
true;
100 void setq(
double qIn) { qDRbar=qIn; }
101 double q() {
return qDRbar; }
115 class LHgenericBlock :
public LHblock<string> {
120 LHgenericBlock() { } ;
123 int set(
string lineIn) {
124 entry[entry.size()] = lineIn;
132 template <
int size>
class LHmatrixBlock {
135 LHmatrixBlock<size>() {
137 for (i=1;i<=size;i++) {
138 for (j=1;j<=size;j++) {
145 LHmatrixBlock& operator=(
const LHmatrixBlock& m) {
147 for (i=0;i<size;i++)
for (j=0;j<=size;j++) entry[i][j] = m(i,j);
149 initialized = m.initialized;
154 bool exists() {
return initialized; };
156 void clear() { initialized=
false; };
159 int set(
int iIn,
int jIn,
double valIn) {
160 if (iIn>0 && jIn>0 && iIn<=size && jIn<=size) {
161 entry[iIn][jIn]=valIn;
170 int set(istringstream& linestream) {
171 linestream >> i >> j >> val;
172 return linestream ? set(i,j,val) : -1;
176 double operator()(
int iIn,
int jIn)
const {
177 return (iIn <= size && jIn <= size && iIn > 0 && jIn > 0) ?
178 entry[iIn][jIn] : 0.0;
182 void setq(
double qIn) { qDRbar=qIn; }
183 double q() {
return qDRbar; }
187 for (i=1;i<=size;i++) {
188 cout <<
" "<<i <<
" " ;
189 for (j=1;j<=size;j++) cout << entry[i][j] <<
" ";
196 double entry[size+1][size+1];
205 template <
int size>
class LHtensor3Block {
208 LHtensor3Block<size>() {
210 for (i=1;i<=size;i++) {
211 for (j=1;j<=size;j++) {
212 for (k=1;k<=size;k++) {
220 LHtensor3Block& operator=(
const LHtensor3Block& 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);
225 initialized = m.initialized;
230 bool exists() {
return initialized; };
232 void clear() { initialized=
false; };
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;
246 int set(istringstream& linestream) {
247 linestream >> i >> j >> k >> val;
248 return linestream ? set(i,j,k,val) : -1;
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;
258 void setq(
double qIn) { qDRbar=qIn; }
259 double q() {
return qDRbar; }
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] <<
" ";
276 double entry[size+1][size+1][size+1];
285 class LHdecayChannel {
288 LHdecayChannel() : brat(0.0) {};
289 LHdecayChannel(
double bratIn,
int nDaIn, vector<int> idDaIn,
290 string cIn=
"") { setChannel(bratIn,nDaIn,idDaIn,cIn);
294 void setChannel(
double bratIn,
int nDaIn, vector<int> idDaIn,
297 for (
int i=0; i<=nDaIn; i++) {
298 if (i <
int(idDaIn.size())) idDa.push_back(idDaIn[i]);
302 void setBrat(
double bratIn) {brat=bratIn;}
303 void setIdDa(vector<int> idDaIn) {idDa = idDaIn;}
306 double getBrat() {
return brat;}
307 int getNDa() {
return int(idDa.size());}
308 vector<int> getIdDa() {
return idDa;}
309 string getComment() {
return comment;}
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) {};
326 int getId() {
return id;}
327 double getWidth() {
return width;}
330 void setId(
int idIn) {
id = idIn;}
331 void setWidth(
double widthIn) {width=widthIn;}
334 void reset(
double widthIn=0.0) {table.resize(0); width=widthIn;}
337 void addChannel(LHdecayChannel channelIn) {table.push_back(channelIn);}
338 void addChannel(
double bratIn,
int nDaIn, vector<int> idDaIn,
340 LHdecayChannel newChannel(bratIn, nDaIn, idDaIn, cIn);
341 table.push_back(newChannel);
345 int size() {
return int(table.size());}
348 double getBrat(
int iChannel) {
349 if (iChannel >= 0 && iChannel <
int(table.size())) {
350 return table[iChannel].getBrat();
356 vector<int> getIdDa(
int iChannel) {
357 if (iChannel >= 0 && iChannel <
int(table.size())) {
358 return table[iChannel].getIdDa();
365 LHdecayChannel getChannel(
int iChannel) {
366 if (iChannel >= 0 && iChannel <
int(table.size())) {
367 return table[iChannel];
377 vector<LHdecayChannel> table;
383 class SusyLesHouches {
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);};
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);
407 void listSpectrum(
int ifail=0);
420 Entry() : isIntP(false), isDoubleP(false),
421 isStringP(false), n(0), d(0.0), s(
""), commentP(
"") {}
424 bool isInt(){
return isIntP;}
425 bool isDouble(){
return isDoubleP;}
426 bool isString(){
return isStringP;}
429 Entry& operator=(
double& val) {
430 d=val;isIntP=
false;isDoubleP=
true;isStringP=
false;
433 Entry& operator=(
int& val) {
434 n=val;isIntP=
true;isDoubleP=
false;isStringP=
false;
437 Entry& operator=(
string& val) {
438 s=val;isIntP=
false;isDoubleP=
false;isStringP=
true;
443 void setComment(
string comment) {commentP=comment;}
444 void getComment(
string comment) {comment=commentP;}
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;}
452 bool isIntP, isDoubleP, isStringP;
463 LHblock<int> modsel21;
464 LHblock<double> modsel12;
465 LHblock<double> minpar;
466 LHblock<double> extpar;
467 LHblock<double> sminputs;
469 LHblock<string> spinfo;
470 LHblock<string> spinfo3;
471 LHblock<string> spinfo4;
473 LHblock<string> dcinfo;
474 LHblock<string> dcinfo3;
475 LHblock<string> dcinfo4;
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;
496 vector<LHdecayTable> decays;
497 map<int,int> decayIndices;
500 vector< LHblock<int> > qnumbers;
501 vector< string > qnumbersName;
502 vector< string > qnumbersAntiName;
506 LHblock<double> qextpar;
509 LHblock<double> vckmin;
510 LHblock<double> upmnsin;
511 LHmatrixBlock<3> msq2in;
512 LHmatrixBlock<3> msu2in;
513 LHmatrixBlock<3> msd2in;
514 LHmatrixBlock<3> msl2in;
515 LHmatrixBlock<3> mse2in;
516 LHmatrixBlock<3> tuin;
517 LHmatrixBlock<3> tdin;
518 LHmatrixBlock<3> tein;
520 LHmatrixBlock<3> vckm;
521 LHmatrixBlock<3> upmns;
522 LHmatrixBlock<3> msq2;
523 LHmatrixBlock<3> msu2;
524 LHmatrixBlock<3> msd2;
525 LHmatrixBlock<3> msl2;
526 LHmatrixBlock<3> mse2;
530 LHmatrixBlock<6> usqmix;
531 LHmatrixBlock<6> dsqmix;
532 LHmatrixBlock<6> selmix;
533 LHmatrixBlock<3> snumix;
534 LHmatrixBlock<3> snsmix;
535 LHmatrixBlock<3> snamix;
538 LHtensor3Block<3> rvlamllein;
539 LHtensor3Block<3> rvlamlqdin;
540 LHtensor3Block<3> rvlamuddin;
541 LHtensor3Block<3> rvtllein;
542 LHtensor3Block<3> rvtlqdin;
543 LHtensor3Block<3> rvtuddin;
544 LHblock<double> rvkappain;
545 LHblock<double> rvdin;
546 LHblock<double> rvm2lh1in;
547 LHblock<double> rvsnvevin;
549 LHtensor3Block<3> rvlamlle;
550 LHtensor3Block<3> rvlamlqd;
551 LHtensor3Block<3> rvlamudd;
552 LHtensor3Block<3> rvtlle;
553 LHtensor3Block<3> rvtlqd;
554 LHtensor3Block<3> rvtudd;
555 LHblock<double> rvkappa;
557 LHblock<double> rvm2lh1;
558 LHblock<double> rvsnvev;
559 LHmatrixBlock<7> rvnmix;
560 LHmatrixBlock<5> rvumix;
561 LHmatrixBlock<5> rvvmix;
562 LHmatrixBlock<5> rvhmix;
563 LHmatrixBlock<5> rvamix;
564 LHmatrixBlock<8> rvlmix;
567 LHblock<double> imminpar;
568 LHblock<double> imextpar;
570 LHmatrixBlock<4> cvhmix;
571 LHmatrixBlock<4> imcvhmix;
572 LHmatrixBlock<3> imau,imad,imae;
573 LHblock<double> imhmix;
574 LHblock<double> immsoft;
577 LHmatrixBlock<3> immsq2in;
578 LHmatrixBlock<3> immsu2in;
579 LHmatrixBlock<3> immsd2in;
580 LHmatrixBlock<3> immsl2in;
581 LHmatrixBlock<3> immse2in;
582 LHmatrixBlock<3> imtuin,imtdin,imtein;
584 LHmatrixBlock<3> imvckm;
585 LHmatrixBlock<3> imupmns;
586 LHmatrixBlock<3> immsq2;
587 LHmatrixBlock<3> immsu2;
588 LHmatrixBlock<3> immsd2;
589 LHmatrixBlock<3> immsl2;
590 LHmatrixBlock<3> immse2;
591 LHmatrixBlock<3> imtu,imtd,imte;
592 LHmatrixBlock<6> imusqmix;
593 LHmatrixBlock<6> imdsqmix;
594 LHmatrixBlock<6> imselmix;
595 LHmatrixBlock<3> imsnumix;
596 LHmatrixBlock<4> imnmix;
597 LHmatrixBlock<4> imumix;
598 LHmatrixBlock<4> imvmix;
603 LHblock<double> nmssmrun;
604 LHmatrixBlock<3> nmhmix;
605 LHmatrixBlock<3> nmamix;
606 LHmatrixBlock<5> nmnmix;
607 LHmatrixBlock<5> imnmnmix;
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);
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&);
628 int verbose() {
return verboseSav;}
629 void verbose(
int verboseIn) {verboseSav = verboseIn;}
632 void message(
int,
string,
string ,
int line=0);
638 bool headerPrinted, footerPrinted, filePrinted;
639 bool slhaRead, lhefRead, lhefSlha, useDecay;
647 template <
class T>
int SusyLesHouches::set(
string blockName, T val) {
650 toLowerRep(blockName);
653 if (genericBlocks.find(blockName) == genericBlocks.end()) {
654 LHgenericBlock gBlock;
655 genericBlocks[blockName]=gBlock;
659 ostringstream lineStream;
661 return genericBlocks[blockName].set(lineStream.str());
665 template <
class T>
int SusyLesHouches::set(
string blockName,
int indx, T val) {
668 toLowerRep(blockName);
671 if (genericBlocks.find(blockName) == genericBlocks.end()) {
672 LHgenericBlock gBlock;
673 genericBlocks[blockName]=gBlock;
677 ostringstream lineStream;
678 lineStream << indx<<
" "<<val;
679 return genericBlocks[blockName].set(lineStream.str());
683 template <
class T>
int SusyLesHouches::set(
string blockName,
int indx,
687 toLowerRep(blockName);
690 if (genericBlocks.find(blockName) == genericBlocks.end()) {
691 LHgenericBlock gBlock;
692 genericBlocks[blockName]=gBlock;
696 ostringstream lineStream;
697 lineStream << indx<<
" "<<jndx<<
" "<<val;
698 return genericBlocks[blockName].set(lineStream.str());
702 template <
class T>
int SusyLesHouches::set(
string blockName,
int indx,
703 int jndx,
int kndx, T val) {
706 toLowerRep(blockName);
709 if (genericBlocks.find(blockName) == genericBlocks.end()) {
710 LHgenericBlock gBlock;
711 genericBlocks[blockName]=gBlock;
715 ostringstream lineStream;
716 lineStream << indx<<
" "<<jndx<<
" "<<kndx<<
" "<<val;
717 return genericBlocks[blockName].set(lineStream.str());
723 template <
class T>
bool SusyLesHouches::getEntry(
string blockName, T& val) {
726 toLowerRep(blockName);
729 if (genericBlocks.find(blockName) == genericBlocks.end()) {
730 message(1,
"getEntry",
"attempting to extract entry from non-existent block "
734 if (genericBlocks[blockName].size() == 0) {
735 message(1,
"getEntry",
"attempting to extract entry from zero-size block "
739 if (genericBlocks[blockName].size() >= 2) {
740 message(1,
"getEntry",
"attempting to extract un-indexed entry "
741 "from multi-entry block "+blockName);
745 LHgenericBlock block = genericBlocks[blockName];
746 istringstream linestream(block(0));
749 message(1,
"getEntry",
"problem extracting un-indexed entry "
750 "from block "+blockName);
758 template <
class T>
bool SusyLesHouches::getEntry(
string blockName,
int indx,
762 toLowerRep(blockName);
765 if (genericBlocks.find(blockName) == genericBlocks.end()) {
766 message(1,
"getEntry",
"attempting to extract entry from non-existent block "
770 if (genericBlocks[blockName].size() == 0) {
771 message(1,
"getEntry",
"attempting to extract entry from zero-size block "
776 LHgenericBlock block = genericBlocks[blockName];
778 for (
int jEntry = 0; jEntry < block.size(); jEntry++) {
779 istringstream linestream(block(jEntry));
783 linestream >> indxNow >> valNow;
785 if (linestream && indxNow == indx) {
791 message(1,
"getEntry",
"problem extracting indexed entry from block "
796 template <
class T>
bool SusyLesHouches::getEntry(
string blockName,
int indx,
800 toLowerRep(blockName);
803 if (genericBlocks.find(blockName) == genericBlocks.end()) {
804 message(1,
"getEntry",
"attempting to extract entry from non-existent block "
808 if (genericBlocks[blockName].size() == 0) {
809 message(1,
"getEntry",
"attempting to extract entry from zero-size block "
814 LHgenericBlock block = genericBlocks[blockName];
816 for (
int jEntry = 0; jEntry < block.size(); jEntry++) {
817 istringstream linestream(block(jEntry));
819 int indxNow, jndxNow;
821 linestream >> indxNow >> jndxNow >> valNow;
823 if (linestream && indxNow == indx && jndxNow == jndx) {
829 message(1,
"getEntry",
"problem extracting matrix-indexed entry from block "
834 template <
class T>
bool SusyLesHouches::getEntry(
string blockName,
int indx,
835 int jndx,
int kndx, T& val) {
838 toLowerRep(blockName);
841 if (genericBlocks.find(blockName) == genericBlocks.end()) {
842 message(1,
"getEntry",
"attempting to extract entry from non-existent block "
846 if (genericBlocks[blockName].size() == 0) {
847 message(1,
"getEntry",
"attempting to extract entry from zero-size block "
852 LHgenericBlock block = genericBlocks[blockName];
854 for (
int jEntry = 0; jEntry < block.size(); jEntry++) {
855 istringstream linestream(block(jEntry));
857 int indxNow, jndxNow, kndxNow;
859 linestream >> indxNow >> jndxNow >> kndxNow >> valNow;
861 if (linestream && indxNow == indx && jndxNow == jndx && kndxNow == kndx) {
867 message(1,
"getEntry",
"problem extracting tensor-indexed entry from block "
877 #endif // end Pythia8_SLHA_H