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), qDRbar(), i(), val() {} ;
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;
133 template <
int size>
class LHmatrixBlock {
136 LHmatrixBlock<size>() : entry(), qDRbar(), val() {
138 for (i=1;i<=size;i++) {
139 for (j=1;j<=size;j++) {
146 LHmatrixBlock(
const LHmatrixBlock& m) : val(m.val) {
147 for (i=1;i<=size;i++)
for (j=1;j<=size;j++) entry[i][j] = m(i,j);
149 initialized = m.initialized; }
152 LHmatrixBlock& operator=(
const LHmatrixBlock& m) {
154 for (i=1;i<=size;i++)
for (j=1;j<=size;j++) entry[i][j] = m(i,j);
156 initialized = m.initialized;
161 bool exists() {
return initialized; };
163 void clear() { initialized=
false; };
166 int set(
int iIn,
int jIn,
double valIn) {
167 if (iIn>0 && jIn>0 && iIn<=size && jIn<=size) {
168 entry[iIn][jIn]=valIn;
177 int set(istringstream& linestream) {
178 linestream >> i >> j >> val;
179 return linestream ? set(i,j,val) : -1;
183 double operator()(
int iIn,
int jIn)
const {
184 return (iIn <= size && jIn <= size && iIn > 0 && jIn > 0) ?
185 entry[iIn][jIn] : 0.0;
189 void setq(
double qIn) { qDRbar=qIn; }
190 double q() {
return qDRbar; }
194 for (i=1;i<=size;i++) {
195 cout <<
" "<<i <<
" " ;
196 for (j=1;j<=size;j++) cout << entry[i][j] <<
" ";
203 double entry[size+1][size+1];
212 template <
int size>
class LHtensor3Block {
215 LHtensor3Block<size>() : entry(), qDRbar(), val() {
217 for (i=1;i<=size;i++) {
218 for (j=1;j<=size;j++) {
219 for (k=1;k<=size;k++) {
227 LHtensor3Block(
const LHtensor3Block& m) : val(m.val) {
228 for (i=0;i<size;i++)
for (j=0;j<=size;j++)
for (k=0;k<=size;k++)
229 entry[i][j][k] = m(i,j,k);
231 initialized = m.initialized; };
234 LHtensor3Block& operator=(
const LHtensor3Block& m) {
236 for (i=0;i<size;i++)
for (j=0;j<=size;j++)
for (k=0;k<=size;k++)
237 entry[i][j][k] = m(i,j,k);
239 initialized = m.initialized;
244 bool exists() {
return initialized; };
246 void clear() { initialized=
false; };
249 int set(
int iIn,
int jIn,
int kIn,
double valIn) {
250 if (iIn>0 && jIn>0 && kIn>0 && iIn<=size && jIn<=size && kIn<=size) {
251 entry[iIn][jIn][kIn]=valIn;
260 int set(istringstream& linestream) {
261 linestream >> i >> j >> k >> val;
262 return linestream ? set(i,j,k,val) : -1;
266 double operator()(
int iIn,
int jIn,
int kIn)
const {
267 return (iIn <= size && jIn <= size && kIn <= size && iIn > 0
268 && jIn > 0 && kIn > 0) ? entry[iIn][jIn][kIn] : 0.0;
272 void setq(
double qIn) { qDRbar=qIn; }
273 double q() {
return qDRbar; }
277 for (i=1;i<=size;i++) {
278 for (j=1;j<=size;j++) {
279 cout <<
" "<<i <<
" "<<j <<
" " ;
280 for (k=1;k<=size;k++) {
281 cout << entry[i][j][k] <<
" ";
290 double entry[size+1][size+1][size+1];
299 class LHdecayChannel {
302 LHdecayChannel() : brat(0.0) {};
303 LHdecayChannel(
double bratIn,
int nDaIn, vector<int> idDaIn,
304 string cIn=
"") : brat() { setChannel(bratIn,nDaIn,idDaIn,cIn);
308 void setChannel(
double bratIn,
int nDaIn, vector<int> idDaIn,
311 for (
int i=0; i<=nDaIn; i++) {
312 if (i <
int(idDaIn.size())) idDa.push_back(idDaIn[i]);
316 void setBrat(
double bratIn) {brat=bratIn;}
317 void setIdDa(vector<int> idDaIn) {idDa = idDaIn;}
320 double getBrat() {
return brat;}
321 int getNDa() {
return int(idDa.size());}
322 vector<int> getIdDa() {
return idDa;}
323 string getComment() {
return comment;}
335 LHdecayTable() : id(0), width(0.0) {};
336 LHdecayTable(
int idIn) : id(idIn), width(0.0) {};
337 LHdecayTable(
int idIn,
double widthIn) : id(idIn), width(widthIn) {};
340 int getId() {
return id;}
341 double getWidth() {
return width;}
344 void setId(
int idIn) {
id = idIn;}
345 void setWidth(
double widthIn) {width=widthIn;}
348 void reset(
double widthIn=0.0) {table.resize(0); width=widthIn;}
351 void addChannel(LHdecayChannel channelIn) {table.push_back(channelIn);}
352 void addChannel(
double bratIn,
int nDaIn, vector<int> idDaIn,
354 LHdecayChannel newChannel(bratIn, nDaIn, idDaIn, cIn);
355 table.push_back(newChannel);
359 int size() {
return int(table.size());}
362 double getBrat(
int iChannel) {
363 if (iChannel >= 0 && iChannel <
int(table.size())) {
364 return table[iChannel].getBrat();
370 vector<int> getIdDa(
int iChannel) {
371 if (iChannel >= 0 && iChannel <
int(table.size())) {
372 return table[iChannel].getIdDa();
379 LHdecayChannel getChannel(
int iChannel) {
380 if (iChannel >= 0 && iChannel <
int(table.size())) {
381 return table[iChannel];
391 vector<LHdecayChannel> table;
397 class SusyLesHouches {
402 SusyLesHouches(
int verboseIn=1) : verboseSav(verboseIn),
403 headerPrinted(false), footerPrinted(false), filePrinted(false),
404 slhaRead(false), lhefRead(false), lhefSlha(false), useDecay(true) {};
405 SusyLesHouches(
string filename,
int verboseIn=1) : verboseSav(verboseIn),
406 headerPrinted(false), footerPrinted(false), filePrinted(false),
407 slhaRead(true), lhefRead(false), lhefSlha(false), useDecay(true)
408 {readFile(filename);};
412 int readFile(
string slhaFileIn=
"slha.spc",
int verboseIn=1,
413 bool useDecayIn=
true);
414 int readFile(istream& ,
int verboseIn=1,
415 bool useDecayIn=
true);
421 void listSpectrum(
int ifail=0);
434 Entry() : isIntP(false), isDoubleP(false),
435 isStringP(false), n(0), d(0.0), s(
""), commentP(
"") {}
438 bool isInt(){
return isIntP;}
439 bool isDouble(){
return isDoubleP;}
440 bool isString(){
return isStringP;}
443 Entry& operator=(
double& val) {
444 d=val;isIntP=
false;isDoubleP=
true;isStringP=
false;
447 Entry& operator=(
int& val) {
448 n=val;isIntP=
true;isDoubleP=
false;isStringP=
false;
451 Entry& operator=(
string& val) {
452 s=val;isIntP=
false;isDoubleP=
false;isStringP=
true;
457 void setComment(
string comment) {commentP=comment;}
458 void getComment(
string& comment) {comment=commentP;}
461 bool get(
int& val) {val=n;
return isIntP;}
462 bool get(
double& val) {val=d;
return isDoubleP;}
463 bool get(
string& val) {val=s;
return isStringP;}
466 bool isIntP, isDoubleP, isStringP;
477 LHblock<int> modsel21;
478 LHblock<double> modsel12;
479 LHblock<double> minpar;
480 LHblock<double> extpar;
481 LHblock<double> sminputs;
483 LHblock<string> spinfo;
484 LHblock<string> spinfo3;
485 LHblock<string> spinfo4;
487 LHblock<string> dcinfo;
488 LHblock<string> dcinfo3;
489 LHblock<string> dcinfo4;
491 LHblock<double> mass;
492 LHmatrixBlock<4> nmix;
493 LHmatrixBlock<2> umix;
494 LHmatrixBlock<2> vmix;
495 LHmatrixBlock<2> stopmix;
496 LHmatrixBlock<2> sbotmix;
497 LHmatrixBlock<2> staumix;
498 LHblock<double> alpha;
499 LHblock<double> hmix;
500 LHblock<double> gauge;
501 LHblock<double> msoft;
510 vector<LHdecayTable> decays;
511 map<int,int> decayIndices;
514 vector< LHblock<double> > qnumbers;
515 vector< string > qnumbersName;
516 vector< string > qnumbersAntiName;
520 LHblock<double> qextpar;
523 LHblock<double> vckmin;
524 LHblock<double> upmnsin;
525 LHmatrixBlock<3> msq2in;
526 LHmatrixBlock<3> msu2in;
527 LHmatrixBlock<3> msd2in;
528 LHmatrixBlock<3> msl2in;
529 LHmatrixBlock<3> mse2in;
530 LHmatrixBlock<3> tuin;
531 LHmatrixBlock<3> tdin;
532 LHmatrixBlock<3> tein;
534 LHmatrixBlock<3> vckm;
535 LHmatrixBlock<3> upmns;
536 LHmatrixBlock<3> msq2;
537 LHmatrixBlock<3> msu2;
538 LHmatrixBlock<3> msd2;
539 LHmatrixBlock<3> msl2;
540 LHmatrixBlock<3> mse2;
544 LHmatrixBlock<6> usqmix;
545 LHmatrixBlock<6> dsqmix;
546 LHmatrixBlock<6> selmix;
547 LHmatrixBlock<3> snumix;
548 LHmatrixBlock<3> snsmix;
549 LHmatrixBlock<3> snamix;
552 LHtensor3Block<3> rvlamllein;
553 LHtensor3Block<3> rvlamlqdin;
554 LHtensor3Block<3> rvlamuddin;
555 LHtensor3Block<3> rvtllein;
556 LHtensor3Block<3> rvtlqdin;
557 LHtensor3Block<3> rvtuddin;
558 LHblock<double> rvkappain;
559 LHblock<double> rvdin;
560 LHblock<double> rvm2lh1in;
561 LHblock<double> rvsnvevin;
563 LHtensor3Block<3> rvlamlle;
564 LHtensor3Block<3> rvlamlqd;
565 LHtensor3Block<3> rvlamudd;
566 LHtensor3Block<3> rvtlle;
567 LHtensor3Block<3> rvtlqd;
568 LHtensor3Block<3> rvtudd;
569 LHblock<double> rvkappa;
571 LHblock<double> rvm2lh1;
572 LHblock<double> rvsnvev;
573 LHmatrixBlock<7> rvnmix;
574 LHmatrixBlock<5> rvumix;
575 LHmatrixBlock<5> rvvmix;
576 LHmatrixBlock<5> rvhmix;
577 LHmatrixBlock<5> rvamix;
578 LHmatrixBlock<8> rvlmix;
581 LHblock<double> imminpar;
582 LHblock<double> imextpar;
584 LHmatrixBlock<4> cvhmix;
585 LHmatrixBlock<4> imcvhmix;
586 LHmatrixBlock<3> imau,imad,imae;
587 LHblock<double> imhmix;
588 LHblock<double> immsoft;
591 LHmatrixBlock<3> immsq2in;
592 LHmatrixBlock<3> immsu2in;
593 LHmatrixBlock<3> immsd2in;
594 LHmatrixBlock<3> immsl2in;
595 LHmatrixBlock<3> immse2in;
596 LHmatrixBlock<3> imtuin,imtdin,imtein;
598 LHmatrixBlock<3> imvckm;
599 LHmatrixBlock<3> imupmns;
600 LHmatrixBlock<3> immsq2;
601 LHmatrixBlock<3> immsu2;
602 LHmatrixBlock<3> immsd2;
603 LHmatrixBlock<3> immsl2;
604 LHmatrixBlock<3> immse2;
605 LHmatrixBlock<3> imtu,imtd,imte;
606 LHmatrixBlock<6> imusqmix;
607 LHmatrixBlock<6> imdsqmix;
608 LHmatrixBlock<6> imselmix;
609 LHmatrixBlock<3> imsnumix;
610 LHmatrixBlock<4> imnmix;
611 LHmatrixBlock<4> imumix;
612 LHmatrixBlock<4> imvmix;
617 LHblock<double> nmssmrun;
618 LHmatrixBlock<3> nmhmix;
619 LHmatrixBlock<3> nmamix;
620 LHmatrixBlock<5> nmnmix;
621 LHmatrixBlock<5> imnmnmix;
624 template <
class T>
int set(
string,T);
625 template <
class T>
int set(
string,
int,T);
626 template <
class T>
int set(
string,
int,
int,T);
627 template <
class T>
int set(
string,
int,
int,
int,T);
634 map<string, LHgenericBlock> genericBlocks;
635 template <
class T>
bool getEntry(
string, T&);
636 template <
class T>
bool getEntry(
string,
int, T&);
637 template <
class T>
bool getEntry(
string,
int,
int, T&);
638 template <
class T>
bool getEntry(
string,
int,
int,
int, T&);
639 template <
class T>
bool getEntry(
string, vector<int>, T&);
642 int verbose() {
return verboseSav;}
643 void verbose(
int verboseIn) {verboseSav = verboseIn;}
646 void message(
int,
string,
string ,
int line=0);
652 bool headerPrinted, footerPrinted, filePrinted;
653 bool slhaRead, lhefRead, lhefSlha, useDecay;
661 template <
class T>
int SusyLesHouches::set(
string blockName, T val) {
664 toLowerRep(blockName);
667 if (genericBlocks.find(blockName) == genericBlocks.end()) {
668 LHgenericBlock gBlock;
669 genericBlocks[blockName]=gBlock;
673 ostringstream lineStream;
675 return genericBlocks[blockName].set(lineStream.str());
679 template <
class T>
int SusyLesHouches::set(
string blockName,
int indx, T val) {
682 toLowerRep(blockName);
685 if (genericBlocks.find(blockName) == genericBlocks.end()) {
686 LHgenericBlock gBlock;
687 genericBlocks[blockName]=gBlock;
691 ostringstream lineStream;
692 lineStream << indx<<
" "<<val;
693 return genericBlocks[blockName].set(lineStream.str());
697 template <
class T>
int SusyLesHouches::set(
string blockName,
int indx,
701 toLowerRep(blockName);
704 if (genericBlocks.find(blockName) == genericBlocks.end()) {
705 LHgenericBlock gBlock;
706 genericBlocks[blockName]=gBlock;
710 ostringstream lineStream;
711 lineStream << indx<<
" "<<jndx<<
" "<<val;
712 return genericBlocks[blockName].set(lineStream.str());
716 template <
class T>
int SusyLesHouches::set(
string blockName,
int indx,
717 int jndx,
int kndx, T val) {
720 toLowerRep(blockName);
723 if (genericBlocks.find(blockName) == genericBlocks.end()) {
724 LHgenericBlock gBlock;
725 genericBlocks[blockName]=gBlock;
729 ostringstream lineStream;
730 lineStream << indx<<
" "<<jndx<<
" "<<kndx<<
" "<<val;
731 return genericBlocks[blockName].set(lineStream.str());
737 template <
class T>
bool SusyLesHouches::getEntry(
string blockName, T& val) {
740 toLowerRep(blockName);
743 if (genericBlocks.find(blockName) == genericBlocks.end()) {
744 message(1,
"getEntry",
"attempting to extract entry from non-existent block "
748 if (genericBlocks[blockName].size() == 0) {
749 message(1,
"getEntry",
"attempting to extract entry from zero-size block "
753 if (genericBlocks[blockName].size() >= 2) {
754 message(1,
"getEntry",
"attempting to extract un-indexed entry "
755 "from multi-entry block "+blockName);
759 LHgenericBlock block = genericBlocks[blockName];
760 istringstream linestream(block(0));
763 message(1,
"getEntry",
"problem extracting un-indexed entry "
764 "from block "+blockName);
772 template <
class T>
bool SusyLesHouches::getEntry(
string blockName,
int indx,
776 toLowerRep(blockName);
779 if (genericBlocks.find(blockName) == genericBlocks.end()) {
780 message(1,
"getEntry",
"attempting to extract entry from non-existent block "
784 if (genericBlocks[blockName].size() == 0) {
785 message(1,
"getEntry",
"attempting to extract entry from zero-size block "
790 LHgenericBlock block = genericBlocks[blockName];
792 for (
int jEntry = 0; jEntry < block.size(); jEntry++) {
793 istringstream linestream(block(jEntry));
797 linestream >> indxNow >> valNow;
799 if (linestream && indxNow == indx) {
805 message(1,
"getEntry",
"problem extracting indexed entry from block "
810 template <
class T>
bool SusyLesHouches::getEntry(
string blockName,
int indx,
814 toLowerRep(blockName);
817 if (genericBlocks.find(blockName) == genericBlocks.end()) {
818 message(1,
"getEntry",
"attempting to extract entry from non-existent block "
822 if (genericBlocks[blockName].size() == 0) {
823 message(1,
"getEntry",
"attempting to extract entry from zero-size block "
828 LHgenericBlock block = genericBlocks[blockName];
830 for (
int jEntry = 0; jEntry < block.size(); jEntry++) {
831 istringstream linestream(block(jEntry));
833 int indxNow, jndxNow;
835 linestream >> indxNow >> jndxNow >> valNow;
837 if (linestream && indxNow == indx && jndxNow == jndx) {
843 message(1,
"getEntry",
"problem extracting matrix-indexed entry from block "
848 template <
class T>
bool SusyLesHouches::getEntry(
string blockName,
int indx,
849 int jndx,
int kndx, T& val) {
852 toLowerRep(blockName);
855 if (genericBlocks.find(blockName) == genericBlocks.end()) {
856 message(1,
"getEntry",
"attempting to extract entry from non-existent block "
860 if (genericBlocks[blockName].size() == 0) {
861 message(1,
"getEntry",
"attempting to extract entry from zero-size block "
866 LHgenericBlock block = genericBlocks[blockName];
868 for (
int jEntry = 0; jEntry < block.size(); jEntry++) {
869 istringstream linestream(block(jEntry));
871 int indxNow, jndxNow, kndxNow;
873 linestream >> indxNow >> jndxNow >> kndxNow >> valNow;
875 if (linestream && indxNow == indx && jndxNow == jndx && kndxNow == kndx) {
881 message(1,
"getEntry",
"problem extracting tensor-indexed entry from block "
891 #endif // end Pythia8_SLHA_H