Skip to content
Snippets Groups Projects
Commit b60b3f63 authored by Bertram Kopf's avatar Bertram Kopf
Browse files

few modifications in PwaUtils/PwaGen.cc

parent b68a9acc
No related branches found
No related tags found
No related merge requests found
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include "PwaUtils/StreamFitParmsBase.hh" #include "PwaUtils/StreamFitParmsBase.hh"
#include "PwaUtils/PwaFcnBase.hh" #include "PwaUtils/PwaFcnBase.hh"
#include "PwaUtils/PwaCovMatrix.hh" #include "PwaUtils/PwaCovMatrix.hh"
#include "PwaUtils/PwaGen.hh"
#include "Utils/PawianCollectionUtils.hh" #include "Utils/PawianCollectionUtils.hh"
#include "Utils/ErrLogUtils.hh" #include "Utils/ErrLogUtils.hh"
#include "pbarpUtils/pbarpEnv.hh" #include "pbarpUtils/pbarpEnv.hh"
...@@ -202,6 +203,14 @@ int main(int __argc,char *__argv[]){ ...@@ -202,6 +203,14 @@ int main(int __argc,char *__argv[]){
fitParams theStartparams=theParamStreamer.getFitParamVal(); fitParams theStartparams=theParamStreamer.getFitParamVal();
fitParams theErrorparams=theParamStreamer.getFitParamErr(); fitParams theErrorparams=theParamStreamer.getFitParamErr();
if (mode=="gen"){
boost::shared_ptr<PwaGen> pwaGenPtr(new PwaGen(pbarpEnv::instance()));
pwaGenPtr->generate(theLhPtr, theStartparams);
theFitParamBase->printParams(theStartparams);
return 1;
}
PwaFcnBase theFcn(theLhPtr, theFitParamBase, outputFileNameSuffix); PwaFcnBase theFcn(theLhPtr, theFitParamBase, outputFileNameSuffix);
MnUserParameters upar; MnUserParameters upar;
theFitParamBase->setMnUsrParams(upar, theStartparams, theErrorparams); theFitParamBase->setMnUsrParams(upar, theStartparams, theErrorparams);
......
...@@ -58,12 +58,40 @@ PwaGen::PwaGen(AbsEnv* theEnv) : ...@@ -58,12 +58,40 @@ PwaGen::PwaGen(AbsEnv* theEnv) :
,_finalStateParticles(theEnv->finalStateParticles()) ,_finalStateParticles(theEnv->finalStateParticles())
,_stream(new std::ofstream("evtGen.dat")) ,_stream(new std::ofstream("evtGen.dat"))
,_genWithModel(true) ,_genWithModel(true)
,_unitScaleFactor(1.)
,_energyFirst(false)
,_useEvtWeight(theEnv->parser()->useEvtWeight())
{ {
_theTFile=new TFile("EvtGen.root","recreate"); _theTFile=new TFile("EvtGen.root","recreate");
inv01MassH1=new TH1F("inv01MassH1","inv01MassH1",500, 0., 3.); inv01MassH1=new TH1F("inv01MassH1","inv01MassH1",500, 0., 3.);
inv02MassH1=new TH1F("inv02MassH1","inv02MassH1",500, 0., 3.); inv02MassH1=new TH1F("inv02MassH1","inv02MassH1",500, 0., 3.);
inv12MassH1=new TH1F("inv12MassH1","inv12MassH1",500, 0., 3.); inv12MassH1=new TH1F("inv12MassH1","inv12MassH1",500, 0., 3.);
_genWithModel=theEnv->parser()->generateWithModel(); _genWithModel=theEnv->parser()->generateWithModel();
std::string unit=theEnv->parser()->unitInFile();
if(unit=="GEV"){
_unitScaleFactor=1.;
}
else if(unit=="MEV"){
_unitScaleFactor=1000.;
}
else{
Alert << "unit " << unit << " does not exist!!!" <<endmsg;
exit(0);
}
std::string order =theEnv->parser()->orderInFile();
if(order=="E Px Py Pz"){
_energyFirst=true;
}
else if(order=="Px Py Pz E"){
_energyFirst=false;
}
else{
Alert << "order " << order << " does not exist!!!" <<endmsg;
exit(0);
}
} }
PwaGen::~PwaGen() PwaGen::~PwaGen()
...@@ -125,7 +153,6 @@ void PwaGen::generate(boost::shared_ptr<AbsLh> theLh, fitParams& theFitParams){ ...@@ -125,7 +153,6 @@ void PwaGen::generate(boost::shared_ptr<AbsLh> theLh, fitParams& theFitParams){
} }
currentEvtList.rewind(); currentEvtList.rewind();
std::cout << "currentEvtList.size():\t" << currentEvtList.size() << std::endl;
boost::shared_ptr<EvtDataBaseList> eventListPtr(new EvtDataBaseList(_absEnv)); boost::shared_ptr<EvtDataBaseList> eventListPtr(new EvtDataBaseList(_absEnv));
...@@ -133,8 +160,6 @@ void PwaGen::generate(boost::shared_ptr<AbsLh> theLh, fitParams& theFitParams){ ...@@ -133,8 +160,6 @@ void PwaGen::generate(boost::shared_ptr<AbsLh> theLh, fitParams& theFitParams){
double evtWeightSum=0.; double evtWeightSum=0.;
eventListPtr->read4Vecs(currentEvtList, dataList, evtWeightSum, 100000, noOfAllGenEvts-100000); eventListPtr->read4Vecs(currentEvtList, dataList, evtWeightSum, 100000, noOfAllGenEvts-100000);
std::cout << "dataList.size():\t" << dataList.size() << std::endl;
theLh->updateFitParams(theFitParams); theLh->updateFitParams(theFitParams);
std::vector<EvtData*>::const_iterator itEvt; std::vector<EvtData*>::const_iterator itEvt;
...@@ -157,7 +182,7 @@ void PwaGen::generate(boost::shared_ptr<AbsLh> theLh, fitParams& theFitParams){ ...@@ -157,7 +182,7 @@ void PwaGen::generate(boost::shared_ptr<AbsLh> theLh, fitParams& theFitParams){
while(itEvt!=dataList.end()) while(itEvt!=dataList.end())
{ {
double fitWeight= theLh->calcEvtIntensity( *itEvt, theFitParams ); double fitWeight= theLh->calcEvtIntensity( *itEvt, theFitParams );
std::cout << (*itEvt)->evtNo << "\tfitWeight:\t" << fitWeight << std::endl; DebugMsg << (*itEvt)->evtNo << "\tfitWeight:\t" << fitWeight << endmsg;
if (maxFitWeight< fitWeight) maxFitWeight=fitWeight; if (maxFitWeight< fitWeight) maxFitWeight=fitWeight;
++itEvt; ++itEvt;
} }
...@@ -199,11 +224,17 @@ void PwaGen::addEvt(EventList& evtList, EvtVector4R* evt4Vec4Rs,int evtNumber){ ...@@ -199,11 +224,17 @@ void PwaGen::addEvt(EventList& evtList, EvtVector4R* evt4Vec4Rs,int evtNumber){
void PwaGen::dumpAscii(EvtData* evtData){ void PwaGen::dumpAscii(EvtData* evtData){
if (_useEvtWeight) *_stream << 1.000 << std::endl;
std::vector<Particle* > fsParticles = _absEnv->finalStateParticles(); std::vector<Particle* > fsParticles = _absEnv->finalStateParticles();
std::vector<Particle* >::const_iterator fspIter = fsParticles.begin(); std::vector<Particle* >::const_iterator fspIter = fsParticles.begin();
for( ; fspIter != fsParticles.end(); ++fspIter ) { for( ; fspIter != fsParticles.end(); ++fspIter ) {
Vector4<double> tmp4vec = evtData->FourVecsString[ (*fspIter)->name() ]; Vector4<double> tmp4vec = evtData->FourVecsString[ (*fspIter)->name() ];
*_stream << std::setprecision(8) << tmp4vec.Px() << "\t" << tmp4vec.Py() << "\t" << tmp4vec.Pz() << "\t" << tmp4vec.E() << std::endl; if(_energyFirst){
*_stream << std::setprecision(8) << tmp4vec.E()*_unitScaleFactor << tmp4vec.Px()*_unitScaleFactor << "\t" << tmp4vec.Py()*_unitScaleFactor << "\t" << tmp4vec.Pz()*_unitScaleFactor << "\t" << std::endl;
}
else{
*_stream << std::setprecision(8) << tmp4vec.Px()*_unitScaleFactor << "\t" << tmp4vec.Py()*_unitScaleFactor << "\t" << tmp4vec.Pz()*_unitScaleFactor << "\t" << tmp4vec.E()*_unitScaleFactor << std::endl;
}
} }
} }
...@@ -74,4 +74,7 @@ protected: ...@@ -74,4 +74,7 @@ protected:
TH1F* inv02MassH1; TH1F* inv02MassH1;
TH1F* inv12MassH1; TH1F* inv12MassH1;
bool _genWithModel; bool _genWithModel;
double _unitScaleFactor;
bool _energyFirst;
bool _useEvtWeight;
}; };
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment