void FitterUtils::prepare_PDFs(string trigStr, string BDTVar, double BDTcut, string signalfile, string partrecofile, string combfile, string JpsiLeakfile, double minBMass, double maxBMass, string signaltree, string partrecotree, string combtree, string JpsiLeaktree) { //***********Get the datasets TFile* fSignal = new TFile(signalfile.c_str()); TTree* tSignal = (TTree*)fSignal->Get(signaltree.c_str()); TFile* fPartReco = new TFile(partrecofile.c_str()); TTree* tPartReco = (TTree*)fPartReco->Get(partrecotree.c_str()); TFile* fComb = new TFile(combfile.c_str()); TTree* tComb = (TTree*)fComb->Get(combtree.c_str()); TFile* fJpsiLeak = new TFile(JpsiLeakfile.c_str()); TTree* tJpsiLeak = (TTree*)fJpsiLeak->Get(JpsiLeaktree.c_str()); //**********Define variables RooRealVar trigVar(trigStr.c_str(), trigStr.c_str(), -10, 10); RooRealVar BDTRooRealVar(BDTVar.c_str(), BDTVar.c_str(), -1,1); RooRealVar B_plus_M("B_plus_M", "M_{visible}", minBMass, maxBMass, "MeV"); RooRealVar misPT("misPT", "p_{#perp}", 0, 5000, "MeV"); RooRealVar B_plus_DTFM_M_zero("B_plus_DTFM_M_zero", "M_{constr}", 0, 20000, "MeV"); RooRealVar e_plus_BremMultiplicity("e_plus_BremMultiplicity","e_plus_BremMultiplicity", -1,2); RooRealVar e_minus_BremMultiplicity("e_minus_BremMultiplicity","e_minus_BremMultiplicity", -1,2); RooRealVar weightPartReco("weightPartReco", "weightPartReco", 0, 10); RooRealVar weightLeakage("weightLeakage", "weightLeakage", 0, 10); RooRealVar dataMCWeightee("DataMCWeightee", "DataMCWeightee",0, 30); //***********Set only variables needed tSignal->SetBranchStatus("*", 0); tSignal->SetBranchStatus("B_plus_M", 1); tSignal->SetBranchStatus("misPT", 1); tSignal->SetBranchStatus("B_plus_DTFM_M_zero", 1); tSignal->SetBranchStatus(BDTVar.c_str(),1); tSignal->SetBranchStatus("e_plus_BremMultiplicity", 1); tSignal->SetBranchStatus("e_minus_BremMultiplicity", 1); tSignal->SetBranchStatus(trigStr.c_str()); tSignal->SetBranchStatus("DataMCWeightee",1); tPartReco->SetBranchStatus("*", 0); tPartReco->SetBranchStatus("B_plus_M", 1); tPartReco->SetBranchStatus("misPT", 1); tPartReco->SetBranchStatus("B_plus_DTFM_M_zero", 1);tPartReco->SetBranchStatus(BDTVar.c_str(),1); tPartReco->SetBranchStatus("e_plus_BremMultiplicity", 1); tPartReco->SetBranchStatus("e_minus_BremMultiplicity", 1); tPartReco->SetBranchStatus(trigStr.c_str()); tPartReco->SetBranchStatus("weightPartReco",1); tComb->SetBranchStatus("*", 0); tComb->SetBranchStatus("B_plus_M", 1); tComb->SetBranchStatus("misPT", 1); tComb->SetBranchStatus("B_plus_DTFM_M_zero", 1);tComb->SetBranchStatus(BDTVar.c_str(),1); tComb->SetBranchStatus("e_plus_BremMultiplicity", 1); tComb->SetBranchStatus("e_minus_BremMultiplicity", 1); tComb->SetBranchStatus(trigStr.c_str()); tJpsiLeak->SetBranchStatus("*", 0); tJpsiLeak->SetBranchStatus("B_plus_M", 1); tJpsiLeak->SetBranchStatus("misPT", 1); tJpsiLeak->SetBranchStatus("B_plus_DTFM_M_zero", 1);tJpsiLeak->SetBranchStatus(BDTVar.c_str(),1); tJpsiLeak->SetBranchStatus("e_plus_BremMultiplicity", 1); tJpsiLeak->SetBranchStatus("e_minus_BremMultiplicity", 1); tJpsiLeak->SetBranchStatus(trigStr.c_str()); tJpsiLeak->SetBranchStatus("weightLeakage",1); //***********Set Binning RooBinning defaultMBins(floor((maxBMass-minBMass)/(40.)), B_plus_M.getMin(), B_plus_M.getMax() ); RooBinning defaultMisPTBins(floor(40), misPT.getMin(), misPT.getMax()); RooBinning broaderMBins(floor((maxBMass-minBMass)/(80.)), B_plus_M.getMin(), B_plus_M.getMax()); RooBinning broaderMisPTBins(floor(40), misPT.getMin(), misPT.getMax()); B_plus_M.setBinning( defaultMBins); misPT.setBinning( defaultMisPTBins ); B_plus_M.setBinning( broaderMBins, "broaderBins"); misPT.setBinning( broaderMisPTBins, "broaderBins" ); B_plus_DTFM_M_zero.setBins(100); RooArgSet argset(BDTRooRealVar, B_plus_DTFM_M_zero, misPT, B_plus_M, trigVar, e_plus_BremMultiplicity, e_minus_BremMultiplicity); RooArgSet argsetPartReco(BDTRooRealVar, B_plus_DTFM_M_zero, misPT, B_plus_M, trigVar, e_plus_BremMultiplicity, e_minus_BremMultiplicity, weightPartReco); RooArgSet argsetLeakage(BDTRooRealVar, B_plus_DTFM_M_zero, misPT, B_plus_M, trigVar, e_plus_BremMultiplicity, e_minus_BremMultiplicity, weightLeakage); RooArgSet argsetSignal(BDTRooRealVar, B_plus_DTFM_M_zero, misPT, B_plus_M, trigVar, e_plus_BremMultiplicity, e_minus_BremMultiplicity, dataMCWeightee); cout<<"getting the datasets:"<<endl; RooDataSet* dataSetSignalZeroGamma; RooDataSet* dataSetSignalOneGamma; RooDataSet* dataSetSignalTwoGamma; RooDataSet* dataSetPartReco; RooDataSet* dataSetJpsiLeak; RooDataSet* dataSetComb; TFile* fw(NULL); string BDTCutString( ("("+BDTVar+">"+d2s(BDTcut)+")").c_str() ); dataSetSignalZeroGamma = new RooDataSet("dataSetSignalZeroGamma", "dataSetSignalZeroGamma", argsetSignal, Import(*tSignal), Cut(( " ("+trigStr+" > 0.9) && "+BDTCutString+" && ((e_plus_BremMultiplicity+e_minus_BremMultiplicity) > -0.5) && ((e_plus_BremMultiplicity+e_minus_BremMultiplicity) < 0.5) && B_plus_M > "+d2s(minBMass)+" && B_plus_M < "+d2s(maxBMass)).c_str()), WeightVar("DataMCWeightee") ); dataSetSignalOneGamma = new RooDataSet("dataSetSignalOneGamma", "dataSetSignalOneGamma", argsetSignal, Import(*tSignal), Cut(( " ("+trigStr+" > 0.9) && "+BDTCutString+" && ((e_plus_BremMultiplicity+e_minus_BremMultiplicity) > 0.5) && ((e_plus_BremMultiplicity+e_minus_BremMultiplicity) < 1.5) && B_plus_M > "+d2s(minBMass)+" && B_plus_M < "+d2s(maxBMass)).c_str()), WeightVar("DataMCWeightee") ); dataSetSignalTwoGamma = new RooDataSet("dataSetSignalTwoGamma", "dataSetSignalTwoGamma", argsetSignal, Import(*tSignal), Cut(( " ("+trigStr+" > 0.9) && "+BDTCutString+" && ((e_plus_BremMultiplicity+e_minus_BremMultiplicity) > 1.5) && ((e_plus_BremMultiplicity+e_minus_BremMultiplicity) < 2.5) && B_plus_M > "+d2s(minBMass)+" && B_plus_M < "+d2s(maxBMass)).c_str()), WeightVar("DataMCWeightee") ); dataSetPartReco = new RooDataSet("dataSetPartReco", "dataSetPartReco", argsetPartReco, Import(*tPartReco),Cut(("("+trigStr+" > 0.9) && "+BDTCutString+ " && B_plus_M > "+d2s(minBMass)+" && B_plus_M < "+d2s(maxBMass)).c_str()), WeightVar("weightPartReco")); dataSetJpsiLeak = new RooDataSet("dataSetJpsiLeak", "dataSetJpsiLeak", argsetLeakage, Import(*tJpsiLeak),Cut(("B_plus_M > "+d2s(minBMass)+" && B_plus_M < "+d2s(maxBMass)).c_str()), WeightVar("weightLeakage")); // dataSetComb = new RooDataSet("dataSetComb", "dataSetComb", tComb, argset, ("("+trigStr+" > 0.9) && (UBDT3R > "+d2s(BDTcut-0.03)+") && B_plus_M > "+d2s(minBMass)+" && B_plus_M < "+d2s(maxBMass)).c_str()); dataSetComb = new RooDataSet("dataSetComb", "dataSetComb", tComb, argset, ("("+trigStr+" > 0.9) && "+BDTCutString+" && B_plus_M > "+d2s(minBMass)+" && B_plus_M < "+d2s(maxBMass)).c_str()); cout<<"Number of zero: "<< dataSetSignalZeroGamma->sumEntries()<<endl; cout<<"Number of one: "<< dataSetSignalOneGamma->sumEntries()<<endl; cout<<"Number of two: "<< dataSetSignalTwoGamma->sumEntries()<<endl; cout<<"Number of PartReco: "<< dataSetPartReco->sumEntries()<<endl; cout<<"Number of Jpsi leaking:"<< dataSetJpsiLeak->sumEntries()<<endl; cout<<"Number of combinatorial events:"<< dataSetComb->sumEntries()<<endl; cout<<"binning the datasets:"<<endl; RooArgSet argset2(B_plus_M); if (fit2D) argset2.add(misPT); RooDataHist dataHistSignalZeroGamma("dataHistSignalZeroGamma", "dataHistSignalZeroGamma", argset2, *dataSetSignalZeroGamma); RooDataHist dataHistSignalOneGamma("dataHistSignalOneGamma", "dataHistSignalOneGamma", argset2, *dataSetSignalOneGamma); RooDataHist dataHistSignalTwoGamma("dataHistSignalTwoGamma", "dataHistSignalTwoGamma", argset2, *dataSetSignalTwoGamma); RooDataHist dataHistComb("dataHistComb", "dataHistComb", argset2, *dataSetComb); RooDataHist dataHistPartReco("dataHistPartReco", "dataHistPartReco", argset2, *dataSetPartReco); RooDataHist dataHistJpsiLeak("dataHistJpsiLeak", "dataHistJpsiLeak", argset2, "broaderBins"); dataHistJpsiLeak.add(*dataSetJpsiLeak); //*************** Compute Error on J/psi leak double ErrorJpsi(0); if(dataSetJpsiLeak->sumEntries(("("+trigStr+" > 0.9) && "+BDTCutString+" && B_plus_M > "+d2s(minBMass)+" && B_plus_M < "+d2s(maxBMass)).c_str()) > 0) ErrorJpsi = 1./sqrt(dataSetJpsiLeak->sumEntries(("("+trigStr+" > 0.9) && "+BDTCutString+" && B_plus_M > "+d2s(minBMass)+" && B_plus_M < "+d2s(maxBMass)).c_str())); RooRealVar fractionalErrorJpsiLeak("fractionalErrorJpsiLeak", "fractionalErrorJpsiLeak", ErrorJpsi); cout<<"JPSI LEAK: "<<dataSetJpsiLeak->sumEntries(("("+trigStr+" > 0.9) && "+BDTCutString+" && B_plus_M > "+d2s(minBMass)+" && B_plus_M < "+d2s(maxBMass)).c_str()); cout<<"JPSI LEAK fractional Error: "<<ErrorJpsi<<endl; //***************Create 2D histogram estimates from data cout<<"Preparing the 3 2D histPdf: 1"; // RooArgSet argset2(B_plus_M); RooHistPdf histPdfSignalZeroGamma("histPdfSignalZeroGamma", "histPdfSignalZeroGamma", argset2, dataHistSignalZeroGamma,2); cout<<" 2"; RooHistPdf histPdfSignalOneGamma("histPdfSignalOneGamma", "histPdfSignalOneGamma", argset2, dataHistSignalOneGamma,2); cout<<" 3"; RooHistPdf histPdfSignalTwoGamma("histPdfSignalTwoGamma", "histPdfSignalTwoGamma", argset2, dataHistSignalTwoGamma,2); cout<<" 4"; RooHistPdf histPdfPartReco("histPdfPartReco", "histPdfPartReco", argset2, dataHistPartReco,2); cout<<" 5"; RooHistPdf histPdfJpsiLeak("histPdfJpsiLeak", "histPdfJpsiLeak", argset2, dataHistJpsiLeak,2); cout<<" 6"; //***************Create combinatorial from fit to data RooRealVar expoConst("expoConst", "expoConst", -1e-3, -1, 1); RooRealVar T("T", "T", 97, 0, 200); RooRealVar n("n", "n", 3.5, 1., 5.5); RooAbsPdf *combPDF; if (fit2D) { combPDF = new RooPTMVis("PTMVis", "PTMVis", misPT, B_plus_M, T, n, expoConst); } else { combPDF = new RooExponential("histPdfComb", "histPdfComb", B_plus_M, expoConst); } combPDF->fitTo(*dataSetComb); // if (fit2D) { T.setConstant(true); n.setConstant(true); std::cout<<"T generated is: "<<T.getVal()<<std::endl; } RooRealVar trueExp("trueExp","trueExp", expoConst.getVal(), -1000, 1000); trueExp.setError(expoConst.getError()); RooRealVar trueT("trueT","trueT", T.getVal(), -1000, 1000); trueT.setError(T.getError()); RooRealVar trueN("trueN","trueN", n.getVal(), -1000, 1000); trueN.setError(n.getError()); //***************Save everything on a workspace RooWorkspace workspace("workspace", "workspace"); workspace.import(B_plus_DTFM_M_zero); workspace.import(B_plus_M); workspace.import(misPT); workspace.import(expoConst); workspace.import(trueExp); workspace.import(T); workspace.import(n); workspace.import(*dataSetSignalZeroGamma); workspace.import(*dataSetSignalOneGamma); workspace.import(*dataSetSignalTwoGamma); workspace.import(*dataSetPartReco); workspace.import(*dataSetComb); workspace.import(*dataSetJpsiLeak); workspace.import(histPdfSignalZeroGamma); workspace.import(histPdfSignalOneGamma); workspace.import(histPdfSignalTwoGamma); workspace.import(histPdfPartReco); workspace.import(histPdfJpsiLeak); workspace.import(fractionalErrorJpsiLeak); workspace.import(trueT); workspace.import(trueN); workspace.writeToFile(workspacename.c_str()); delete fComb; delete fSignal; delete fPartReco; if(fw!=0 && fw != NULL) delete fw; delete combPDF; delete dataSetSignalZeroGamma; delete dataSetSignalOneGamma; delete dataSetSignalTwoGamma; delete dataSetPartReco; delete dataSetJpsiLeak; delete dataSetComb; }
void CEneH0102NightSpider::SeqCrash() { //----------------------------------------------------- //破壊された //----------------------------------------------------- Sint32 ax,ay; if( m_bDead ) { m_bDisp = gxFalse; } if( m_sCrashSeq == 0 ) { m_pEffFire = new CEffFire( m_Pos.x , m_Pos.y-8*100 , PRIO_BG2+1); viiMus::PlaySound( enSoundExplosionMiddle ); viiMus::PlaySound( enSoundExplosionLarge ); } if( m_pEffFire ) { m_pEffFire->m_Pos.x = m_Pos.x; m_pEffFire->m_Pos.y = m_Pos.y; m_pEffFire->m_Pos.z = PRIO_ENEMY; } if( m_sCrashSeq <= 96 ) { new CEffectBlackFire ( m_Pos.x + (-64+viiSub::Rand()%128)*100, m_Pos.y + (-32+viiSub::Rand()%64)*100, NULL ); m_pEnemyAnime->PosCalc(); Gimmick(); m_stObj.mov.x += (0-m_stObj.mov.x)/30; m_stObj.pos.x += m_stObj.mov.x; m_stObj.pos.y += m_stObj.mov.y; m_Pos.x = m_stObj.pos.x; m_Pos.y = m_stObj.pos.y; m_HitShield[3].SetHantei( ID_ENEMY_DEF , &m_Pos ); m_HitKurai.SetHantei( ID_ENEMY_DEF , &m_Pos ); if(m_sCrashSeq%8==0) { ax = m_Pos.x +(-8+viiSub::Rand()%16)*1400; ay = m_Pos.y-128*100 +(-8+viiSub::Rand()%16)*800; for(Sint32 n=0; n<4; n++ ) { viiEff::SetBombDeluxe( ax , ay , 1 , 1+viiSub::Rand()%2 ); //EffectMakeBigBomb( ax+(-32+viiSub::Rand()%64)*100, ay+(-32+viiSub::Rand()%64)*100 ); } viiMus::PlaySound( enSoundExplosionMiddle ); } } if( m_sCrashSeq == 96 ) { //どかーーーん if( !m_bDead ) { ax = m_Pos.x; ay = m_Pos.y-128*100; viiEff::Set(EFF_BIGBOMB , m_Pos.x, m_Pos.y , argset(5)); for(Sint32 ii=0; ii<enMax ;ii++) { StPartsInfo *p = m_pEnemyAnime->GetParts( ii ); _opt_[0] = 0;//(Sint32)&SprCEneH0102NightSpider[ p->sDispSprite ]; //64bitポインタ対応 _opt_[1] = (m_sDirection==DIR_LEFT)? ATR_FLIP_X : ATR_DFLT; _opt_[2] = ARGB_DFLT; _opt_[3] = p->dr; _opt_[4] = 100; _opt_[5] = 1; viiEff::Set( EFF_DAMAGE_PARTS,m_Pos.x+p->dx*100*m_sDirection , m_Pos.y + p->dy*100 +m_Offset.y , _opt_ ,&SprCEneH0102NightSpider[ p->sDispSprite ] ); viiEff::SetBombSimple( m_Pos.x+p->dx*100*m_sDirection , m_Pos.y + p->dy*100 +m_Offset.y , 1 , 9 ); } viiEff::SetBombDeluxe( ax , ay , 1 , 1+viiSub::Rand()%2 ); CEffectDmgprt *p; p = new CEffectDmgprt( ax, ay -1600, 180+15 , 800 ); p = new CEffectDmgprt( ax, ay -1600, 180+65 , 600 ); p = new CEffectDmgprt( ax, ay -1600, -60 , 800 ); p = new CEffectDmgprt( ax, ay -1600, -20 , 700 ); p = new CEffectDmgprt( ax, ay -1600, 180-15 , 800/2 ); p = new CEffectDmgprt( ax, ay -1600, 180-65 , 600/2 ); p = new CEffectDmgprt( ax, ay -1600, 60 , 800/2 ); p = new CEffectDmgprt( ax, ay -1600, 20 , 700/2 ); delete m_pEffFire; m_pEffFire = NULL; pGame->QuakeOn( 32 ); viiMus::PlaySound( enSoundCrashA ); ScorePlus( enScore ); } m_bDead = gxTrue; } if( m_bClear ) { SetActionSeq( enActionSeqEnd ); } m_sCrashSeq ++; }
void CEneEx0006Tank::LogicAI() { //----------------------------------------------------- //移動ロジック //----------------------------------------------------- if( viiSub::GameCounter()%4 == 0 ) { viiEff::Set(EFF_ENERGYBALL , m_Pos.x , m_Pos.y , argset(300,120,0,200)); } if( m_sAtackWait > 0 ) { m_sAtackWait --; } else { Atack(); } switch( m_sSeq ){ case enPhase1: //通常 m_bDamage = gxFalse; m_fRotation += m_fRotationAdd; break; case enPhase2: //コア { Float32 fRot = ZERO; if( m_fRotationAdd > 0.f ) { m_fRotationAdd -= 0.01f; if( m_fRotationAdd < 0.5f ) { m_fRotationAdd = 0.5f; } } fRot = m_fRotationAdd; CEffectBlackFire *pBlack; Sint32 ax,ay; ax = m_Pos.x+(-40+viiSub::Rand()%80)*100; ay = m_Pos.y+(-40+viiSub::Rand()%80)*100; //煙出しとく if( m_bDamage )//|| viiSub::Rand()%16 == 0 ) { fRot = -1.f; pBlack = new CEffectBlackFire( ax , ay , NULL ); pBlack->m_Pos.z = PRIO_BG2+1; } // m_bDamage = gxFalse; m_fRotation += fRot; } break; } Gimmick(); }
void CEneH0102NightSpider::GimmickLegOpen() { //---------------------------------------------------- // 脚部制御 //---------------------------------------------------- if( m_bLegOpen ) { if( m_fLegKakudo < 100 ) { m_fLegKakudo += (100-m_fLegKakudo)/10; if( m_fLegKakudo > 100 ) { m_fLegKakudo = 100; } } } else { if( m_fLegKakudo > 0 ) { m_fLegKakudo += (0-m_fLegKakudo)/10; if( m_fLegKakudo < 0 ) { m_fLegKakudo = 0; } } } Sint32 sOpenKaku[3]; //前足 sOpenKaku[0] = s_cast<Sint32>(-10*m_fLegKakudo/100); //真ん中 sOpenKaku[1] = s_cast<Sint32>(5+10*m_fLegKakudo/100); //後ろ sOpenKaku[2] = s_cast<Sint32>(10+10*m_fLegKakudo/100); m_pEnemyAnime->GetParts( enMAEASI )->dr += sOpenKaku[0]; m_pEnemyAnime->GetParts( enUSIROASI1 )->dr += sOpenKaku[1]; m_pEnemyAnime->GetParts( enUSIROASI2 )->dr += sOpenKaku[2]; Sint32 sRot; Sint32 sDst; Sint32 dx,dy; Sint32 ox,oy; Sint32 sObj; for(Sint32 jj=0;jj<3;jj++) { sRot = m_stTire[jj].rot+sOpenKaku[jj]; sDst = m_stTire[jj].dist; sObj = enSTER11+jj; //親の表示座標 ox = m_pEnemyAnime->GetParent( sObj )->dx; oy = m_pEnemyAnime->GetParent( sObj )->dy; //子の表示座標を計算 dx = ( viiMath::Cos100( sRot )*sDst )/100; dy = ( viiMath::Sin100( sRot )*sDst )/100; m_pEnemyAnime->GetParts( sObj )->dx = ox+dx; m_pEnemyAnime->GetParts( sObj )->dy = oy+dy; m_PosTire[jj].x = m_Pos.x+m_Offset.x; m_PosTire[jj].y = m_Pos.y+m_Offset.y; m_pEnemyAnime->GetPos( &m_PosTire[jj] , enSTER11+jj , m_sDirection ); } m_Offset.y = s_cast<Sint32>( (viiSub::Rand()%4+-128+(16*m_fLegKakudo/100))*100 ); m_sTireRot += m_sTireAdd; m_sTireRot = (36000+m_sTireRot)%36000; if( ( m_Add.x > -220 && m_sControl&JOY_L) || ( m_Add.x < 220 && m_sControl&JOY_R)) { for(Sint32 ii=0; ii<3; ii++ ) { new CEffDashStorm( m_PosTire[ii].x+(-32+viiSub::Rand()%64)*100 , m_sGround, 180 , 60 ); } viiEff::Set(EFF_FIREFLOWER , m_PosTire[0].x , m_PosTire[0].y , argset( viiSub::Rand()%360) ); viiEff::Set(EFF_FIREFLOWER , m_PosTire[1].x , m_PosTire[1].y , argset( viiSub::Rand()%360) ); viiEff::Set(EFF_FIREFLOWER , m_PosTire[2].x , m_PosTire[2].y , argset( viiSub::Rand()%360) ); } }