//-------------------------------------------------------------------------- // // Environment: // This software is part of the EvtGen package developed jointly // for the BaBar and CLEO collaborations. If you use all or part // of it, please give an appropriate acknowledgement. // // Copyright Information: See EvtGen/COPYRIGHT // Copyright (C) 1998 Caltech, UCSB // // Module: EvtGen/EvtGenericDalitz.hh // // Description: Model to describe a generic dalitz decay // // Modification history: // // DCC 16 December, 2011 Module created // //------------------------------------------------------------------------ #include "EvtGenModels/EvtDalitzTable.hh" #include "EvtGenBase/EvtReport.hh" #include "EvtGenBase/EvtParserXml.hh" #include "EvtGenBase/EvtPDL.hh" #include "EvtGenBase/EvtSpinType.hh" #include "EvtGenBase/EvtDalitzPlot.hh" #include "EvtGenBase/EvtCyclic3.hh" #include #include using std::endl; using std::fstream; using std::ifstream; EvtDalitzTable::EvtDalitzTable() { _dalitztable.clear(); _readFiles.clear(); } EvtDalitzTable::~EvtDalitzTable() { _dalitztable.clear(); _readFiles.clear(); } EvtDalitzTable* EvtDalitzTable::getInstance(const std::string dec_name, bool verbose) { static EvtDalitzTable* theDalitzTable = 0; if(theDalitzTable == 0) { theDalitzTable = new EvtDalitzTable(); } if(!theDalitzTable->fileHasBeenRead(dec_name)) { theDalitzTable->readXMLDecayFile(dec_name,verbose); } return theDalitzTable; } bool EvtDalitzTable::fileHasBeenRead(const std::string dec_name) { std::vector::iterator i = _readFiles.begin(); for( ; i!=_readFiles.end(); i++) { if((*i).compare(dec_name) == 0) { return true; } } return false; } void EvtDalitzTable::readXMLDecayFile(const std::string dec_name, bool verbose){ if (verbose) { report(INFO,"EvtGen")<<"EvtDalitzTable: Reading in xml parameter file "< > angAndResPairs; std::string shape(""); EvtSpinType::spintype spinType(EvtSpinType::SCALAR); double mass(0.), width(0.), FFp(0.), FFr(0.); std::vector flatteParams; //Nonres parameters double alpha(0.); //LASS parameters double aLass(0.), rLass(0.), BLass(0.), phiBLass(0.), RLass(0.), phiRLass(0.), cutoffLass(-1.); EvtParserXml parser; parser.open(dec_name); bool endReached = false; while(parser.readNextTag()) { //TAGS FOUND UNDER DATA if(parser.getParentTagTitle() == "data") { if(parser.getTagTitle() == "dalitzDecay") { int nDaughters = 0; decayParent = parser.readAttribute("particle"); daugStr = parser.readAttribute("daughters"); probMax = parser.readAttributeDouble("probMax",-1); checkParticle(decayParent); ipar=EvtPDL::getId(decayParent); std::istringstream daugStream(daugStr); std::string daugh; while(std::getline(daugStream, daugh, ' ')) { checkParticle(daugh); daughter[nDaughters++] = EvtPDL::getId(daugh); } if(nDaughters!=3) { report(ERROR,"EvtGen") << "Expected to find three daughters for dalitzDecay of "< >::iterator it = angAndResPairs.begin(); for( ; it != angAndResPairs.end(); it++) { std::pair pairs = *it; EvtDalitzReso resonance = getResonance(shape, dp, pairs.first, pairs.second, spinType, mass, width, FFp, FFr, alpha, aLass, rLass, BLass, phiBLass, RLass, phiRLass, cutoffLass); dalitzDecay->addResonance(cAmp,resonance); } } } else if(parser.getTagTitle() == "/dalitzDecay") { if(probMax < 0) { report(INFO,"EvtGen") << "probMax is not defined for " << decayParent << " -> " << daugStr << endl; report(INFO,"EvtGen") << "Will now estimate probMax. This may take a while. Once probMax is calculated, update the XML file to skip this step in future." << endl; probMax = calcProbMax(dp,dalitzDecay); } dalitzDecay->setProbMax(probMax); addDecay(ipar, *dalitzDecay); delete dalitzDecay; dalitzDecay = 0; } else if(verbose) { report(INFO,"EvtGen") << "Unexpected tag "< >::iterator it = angAndResPairs.begin(); for( ; it != angAndResPairs.end(); it++) { std::pair pairs = *it; EvtDalitzReso resonance = getResonance(shape, dp, pairs.first, pairs.second, spinType, mass, width, FFp, FFr, alpha, aLass, rLass, BLass, phiBLass, RLass, phiRLass, cutoffLass); std::vector::iterator flatteIt = flatteParams.begin(); for( ; flatteIt != flatteParams.end(); flatteIt++) { resonance.addFlatteParam((*flatteIt)); } dalitzDecay->addResonance(cAmp,resonance); } } } } if(!endReached) { report(ERROR,"EvtGen") << "Either the decay file ended prematurely or the file is badly formed.\n" <<"Error occured near line"< copyTable = getDalitzTable(copy); std::vector::iterator i = copyTable.begin(); for( ; i != copyTable.end(); i++) { EvtId daughter1 = (*i).daughter1(); EvtId daughter2 = (*i).daughter2(); EvtId daughter3 = (*i).daughter3(); if((copyd[0] == daughter1 && copyd[1] == daughter2 && copyd[2] == daughter3) || (copyd[0] == daughter1 && copyd[1] == daughter3 && copyd[2] == daughter2) || (copyd[0] == daughter2 && copyd[1] == daughter1 && copyd[2] == daughter3) || (copyd[0] == daughter2 && copyd[1] == daughter3 && copyd[2] == daughter1) || (copyd[0] == daughter3 && copyd[1] == daughter1 && copyd[2] == daughter2) || (copyd[0] == daughter3 && copyd[1] == daughter2 && copyd[2] == daughter1)) { decay.setProbMax((*i).getProbMax()); std::vector >::const_iterator j = (*i).getResonances().begin(); for( ; j != (*i).getResonances().end(); j++) { decay.addResonance((*j)); } addDecay(parent,decay); return; } } //if we get here then there was no match report(ERROR,"EvtGen") << "Did not find dalitz decays for particle:" < EvtDalitzTable::getDalitzTable(const EvtId& parent) { std::vector table; if ( _dalitztable.find(parent)!=_dalitztable.end() ) { table=_dalitztable[parent]; } if (table.empty()){ report(ERROR,"EvtGen") << "Did not find dalitz decays for particle:" < >& angAndResPairs) { int n(0); if(resDaughter[0]==daughter[0] && resDaughter[1]==daughter[1]) { angAndResPairs.push_back(std::make_pair(EvtCyclic3::BC,EvtCyclic3::AB)); n++; } else if(resDaughter[0]==daughter[1] && resDaughter[1]==daughter[0]) { angAndResPairs.push_back(std::make_pair(EvtCyclic3::CA,EvtCyclic3::AB)); n++; } if(resDaughter[0]==daughter[1] && resDaughter[1]==daughter[2]) { angAndResPairs.push_back(std::make_pair(EvtCyclic3::CA,EvtCyclic3::BC)); n++; } else if(resDaughter[0]==daughter[2] && resDaughter[1]==daughter[1]) { angAndResPairs.push_back(std::make_pair(EvtCyclic3::AB,EvtCyclic3::BC)); n++; } if(resDaughter[0]==daughter[2] && resDaughter[1]==daughter[0]) { angAndResPairs.push_back(std::make_pair(EvtCyclic3::AB,EvtCyclic3::CA)); n++; } else if(resDaughter[0]==daughter[0] && resDaughter[1]==daughter[2]) { angAndResPairs.push_back(std::make_pair(EvtCyclic3::BC,EvtCyclic3::CA)); n++; } return n; } double EvtDalitzTable::calcProbMax(EvtDalitzPlot dp, EvtDalitzDecayInfo* model) { double factor = 1.2; //factor to increase our final answer by int nStep(1000); //number of steps - total points will be 3*nStep*nStep double maxProb(0); double min(0), max(0), step(0), min2(0), max2(0), step2(0); //first do AB, BC min = dp.qAbsMin(EvtCyclic3::AB); max = dp.qAbsMax(EvtCyclic3::AB); step = (max-min)/nStep; for(int i=0; i maxProb) maxProb = prob; } } //next do BC, CA min = dp.qAbsMin(EvtCyclic3::BC); max = dp.qAbsMax(EvtCyclic3::BC); step = (max-min)/nStep; for(int i=0; i maxProb) maxProb = prob; } } //finally do CA, AB min = dp.qAbsMin(EvtCyclic3::CA); max = dp.qAbsMax(EvtCyclic3::CA); step = (max-min)/nStep; for(int i=0; i maxProb) maxProb = prob; } } report(INFO,"EvtGen") << "Largest probability found was " << maxProb << endl; report(INFO,"EvtGen") << "Setting probMax to " << factor*maxProb << endl; return factor*maxProb; } double EvtDalitzTable::calcProb(EvtDalitzPoint point, EvtDalitzDecayInfo* model) { std::vector > resonances = model->getResonances(); EvtComplex amp(0,0); std::vector >::iterator i = resonances.begin(); for( ; i!= resonances.end(); i++) { std::pair res = (*i); amp += res.first * res.second.evaluate( point ); } return abs2(amp); }