// todo non recursive void buildBranch(BVDynTree* node, BVDynTree* leafs, int numLeafs, BVDynTree** head) { node->type = NodeType::BRANCH; node->aabb = { vec3(0, 0, 0), vec3(-FLT_MAX, -FLT_MAX, -FLT_MAX) }; node->left = nullptr; node->right = nullptr; // create aabb for (int i = 0; i < numLeafs; ++i) { mergeAABBAABB(&node->aabb, &leafs[i].aabb); } int axis = (node->aabb.e.x > node->aabb.e.y && node->aabb.e.x > node->aabb.e.z) ? 0 : node->aabb.e.y > node->aabb.e.z ? 1 : 2; // seperate leafs int i = 0, mid = numLeafs; while (i < mid) { if (leafs[i].aabb.c[axis] < node->aabb.c[axis]) ++i; else std::swap(leafs[i], leafs[--mid]); } // if all leafs lie on one side seperate them in their middle if (mid == 0 || mid == numLeafs) mid = numLeafs / 2; // build new branches if (mid > 1) { node->left = (*head)++; buildBranch(node->left, leafs, mid, head); } else { node->left = leafs; } if (numLeafs - mid > 1) { node->right = (*head)++; buildBranch(node->right, leafs + mid, numLeafs - mid, head); } else { node->right = leafs + mid; } }
////////////////////////////////////////////////////////////////////// // build the leader chain ////////////////////////////////////////////////////////////////////// void DAG::buildLeader(int bottomHit) { _bottomHit = bottomHit; // get pointer to bottommost node map<int, NODE*>::iterator iter = _hash.find(bottomHit); NODE* child = (*iter).second; // crawl up the tree while (child != NULL) { // tag segment child->leader = true; child->secondary = false; // look for side branches for (int x = 0; x < child->neighbors.size(); x++) if (!(child->neighbors[x]->leader)) buildBranch(child->neighbors[x], 1); // advance child child = child->parent; } buildIntensity(_root); }
void constructBVTree(Collider* collider, int numCollider, BVTree* tree) { BVDynTree* dynTree = new BVDynTree[numCollider + (numCollider - 1)]; Collider* c = collider; for (int i = 0; i < numCollider; ++i) { assert(c != nullptr); dynTree[i].type = NodeType::LEAF; dynTree[i].aabb = c->getAABB(); dynTree[i].collider = c; c = c->getNext(); } BVDynTree* head = dynTree + numCollider + 1; buildBranch(head - 1, dynTree, numCollider, &head); constructStaticBVTree(tree, dynTree + numCollider); delete[] dynTree; }
BVH::BVH(Shape** shapes, int num_shapes) { if (num_shapes == 1) {*this = BVH(shapes[0], shapes[0]);} else if (num_shapes == 2) {*this = BVH(shapes[0], shapes[1]);} //find midpoint of bbox to use as qsplit pivot bbox = shapes[0] -> boundingBox(0.0f, 0.0f); for (int i = 1; i < num_shapes; i++) { bbox = surround(bbox, shapes[i] -> boundingBox(0.0f, 0.0f)); } Vector3 pivot = (bbox.max() + bbox.min()) / 2.0f; int midpt = QSplit::qsplit(shapes, num_shapes, pivot.x(), 0); //create new bounding volume left = buildBranch(shapes, midpt, 1); right = buildBranch(&shapes[midpt], num_shapes - midpt, 1); }
Shape* BVH::buildBranch(Shape** shapes, int shape_size, int axis) { if (shape_size == 1) {return shapes[0];} else if (shape_size == 2) {return new BVH(shapes[0], shapes[1]);} //find midpoint of bbox to use as qsplit pivot BBox box = shapes[0] -> boundingBox(0.0f, 0.0f); for (int i = 1; i < shape_size; i++) { box = surround(box, shapes[i] -> boundingBox(0.0f, 0.0f)); } Vector3 pivot = (box.max() + box.min()) / 2.0f; //split according to correct axis int midpt = QSplit::qsplit(shapes, shape_size, pivot[axis], axis); //create new bounding volume Shape* left = buildBranch(shapes, midpt, (axis + 1) % 3); Shape* right = buildBranch(&shapes[midpt], shape_size - midpt, (axis + 1) %3); return new BVH(left, right, box); }
////////////////////////////////////////////////////////////////////// // build the side branch ////////////////////////////////////////////////////////////////////// void DAG::buildBranch(NODE* node, int depth) { node->depth = depth; node->leader = false; // look for side branches for (int x = 0; x < node->neighbors.size(); x++) if (!(node->neighbors[x]->leader)) buildBranch(node->neighbors[x], depth + 1); }
void buildBranch(BranchNode& node, const ChunkState& chunkState) { auto next([this, &node](const ChunkState& chunkState, bool exists) { if (exists) { buildBranch(node[chunkState.chunkId()], chunkState); } }); recurse(next, chunkState); }
template<typename F> void tree(const F& f, const ChunkState& chunkState) { const std::size_t coldDepth(m_structure.coldDepthBegin()); if (chunkState.depth() < coldDepth) { auto next([this, &f](const ChunkState& chunkState, bool exists) { if (exists) tree(f, chunkState); }); recurse(next, chunkState); } else if (chunkState.depth() == coldDepth) { Branch branch(chunkState.chunkId(), coldDepth); buildBranch(branch.node(), chunkState); f(branch); } else { throw std::runtime_error("Invalid nominal chunk depth"); } }
int loop(TString infile="/store/group/phys_heavyions/velicanu/forest/Run2015E/ExpressPhysics/Merged/HiForestExpress_baobab.root", TString outfile="/data/wangj/Data2015/Bntuple/ntB_20151130_HiForestExpress_baobab.root", Bool_t REAL=true, Bool_t isPbPb=false, Int_t startEntries=0, Bool_t skim=false, Bool_t gskim=true, Bool_t checkMatching=false) { void fillTree(TVector3* bP, TVector3* bVtx, TLorentzVector* b4P, Int_t j, Int_t typesize, Double_t track_mass1, Double_t track_mass2, Bool_t REAL); bool signalGen(Int_t Btype, Int_t j); cout<<endl; if(REAL) cout<<"--- Processing - REAL DATA"<<endl; else cout<<"--- Processing - MC"<<endl; TString ifname; if(iseos) ifname = Form("root://eoscms.cern.ch//eos/cms%s",infile.Data()); else ifname = infile; TFile* f = TFile::Open(ifname); TTree* root = (TTree*)f->Get("Bfinder/root"); TTree* hltroot = (TTree*)f->Get("hltanalysis/HltTree"); TTree* hiroot = (TTree*)f->Get("hiEvtAnalyzer/HiTree"); TFile* outf = new TFile(outfile,"recreate"); setBBranch(root); setHltBranch(hltroot); if(isPbPb) setHiTreeBranch(hiroot); int ifchannel[7]; ifchannel[0] = 1; //jpsi+Kp ifchannel[1] = 1; //jpsi+pi ifchannel[2] = 1; //jpsi+Ks(pi+,pi-) ifchannel[3] = 1; //jpsi+K*(K+,pi-) ifchannel[4] = 1; //jpsi+K*(K-,pi+) ifchannel[5] = 1; //jpsi+phi(K+,K-) ifchannel[6] = 1; //jpsi+pi pi <= psi', X(3872), Bs->J/psi f0 cout<<"--- Building trees"<<endl; TTree* nt0 = new TTree("ntKp",""); buildBranch(nt0); TTree* nt1 = new TTree("ntpi",""); buildBranch(nt1); TTree* nt2 = new TTree("ntKs",""); buildBranch(nt2); TTree* nt3 = new TTree("ntKstar",""); buildBranch(nt3); TTree* nt5 = new TTree("ntphi",""); buildBranch(nt5); TTree* nt6 = new TTree("ntmix",""); buildBranch(nt6); TTree* ntGen = new TTree("ntGen",""); buildGenBranch(ntGen); TTree* ntHlt = hltroot->CloneTree(0); TTree* ntHi = hiroot->CloneTree(0); cout<<"--- Building trees finished"<<endl; Long64_t nentries = root->GetEntries(); TVector3* bP = new TVector3; TVector3* bVtx = new TVector3; TLorentzVector* b4P = new TLorentzVector; TLorentzVector* b4Pout = new TLorentzVector; TLorentzVector* bGen = new TLorentzVector; cout<<"--- Check the number of events for two trees"<<endl; cout<<root->GetEntries()<<" "<<hltroot->GetEntries(); if(isPbPb) cout<<" "<<hiroot->GetEntries(); cout<<endl; cout<<"--- Processing events"<<endl; //nentries=1000; for(Int_t i=startEntries;i<nentries;i++) { root->GetEntry(i); hltroot->GetEntry(i); if(isPbPb) hiroot->GetEntry(i); if(i%100000==0) cout<<setw(8)<<i<<" / "<<nentries<<endl; if(checkMatching) { if((Int_t)Bf_HLT_Event!=EvtInfo_EvtNo||Bf_HLT_Run!=EvtInfo_RunNo||Bf_HLT_LumiBlock!=EvtInfo_LumiNo || (isPbPb&&(Bf_HiTree_Evt!=EvtInfo_EvtNo||Bf_HiTree_Run!=EvtInfo_RunNo||Bf_HiTree_Lumi!=EvtInfo_LumiNo))) { cout<<"Error: not matched "<<i<<" | "; cout<<"EvtNo("<<Bf_HLT_Event<<","<<EvtInfo_EvtNo<<") RunNo("<<Bf_HLT_Run<<","<<EvtInfo_RunNo<<") LumiNo("<<Bf_HLT_LumiBlock<<","<<EvtInfo_LumiNo<<") | EvtNo("<<Bf_HiTree_Evt<<","<<EvtInfo_EvtNo<<") RunNo("<<Bf_HiTree_Run<<","<<EvtInfo_RunNo<<") LumiNo("<<Bf_HiTree_Lumi<<","<<EvtInfo_LumiNo<<")"<<endl; continue; } } Int_t Btypesize[7]={0,0,0,0,0,0,0}; Int_t ptflag=-1,ptMatchedflag=-1,probflag=-1,probMatchedflag=-1,tktkflag=-1,tktkMatchedflag=-1; Double_t pttem=0,ptMatchedtem=0,probtem=0,probMatchedtem=0,tktktem=0,tktkMatchedtem=0; for(Int_t t=0;t<7;t++) { Int_t tidx = t-1; if(t!=4) { tidx = t; Bsize = 0; ptflag = -1; pttem = 0; ptMatchedflag = -1; ptMatchedtem = 0; probflag = -1; probtem = 0; probMatchedflag = -1; probMatchedtem = 0; tktkflag = -1; tktktem = 1000000.; tktkMatchedflag = -1; tktkMatchedtem = 1000000.; } if(ifchannel[t]==1) { for(int j=0;j<BInfo_size;j++) { if(BInfo_type[j]==(t+1)) { fillTree(bP,bVtx,b4P,j,Btypesize[tidx],tk1mass[t],tk2mass[t],REAL); if(BInfo_pt[j]>pttem) { ptflag = Btypesize[tidx]; pttem = BInfo_pt[j]; } if(TMath::Prob(BInfo_vtxchi2[j],BInfo_vtxdof[j])>probtem) { probflag = Btypesize[tidx]; probtem = TMath::Prob(BInfo_vtxchi2[j],BInfo_vtxdof[j]); } if(BInfo_type[j]>2&&BInfo_type[j]<7) { if(TMath::Abs(BInfo_tktk_mass[j]-midmass[t])<tktktem) { tktkflag = Btypesize[tidx]; tktktem = TMath::Abs(BInfo_tktk_mass[j]-midmass[t]); } } if((!REAL&&(Bgen[Btypesize[tidx]]==23333||Bgen[Btypesize[tidx]]==41000))||REAL)////////////////////////////// { if(BInfo_pt[j]>ptMatchedtem) { ptMatchedflag = Btypesize[tidx]; ptMatchedtem = BInfo_pt[j]; } if(TMath::Prob(BInfo_vtxchi2[j],BInfo_vtxdof[j])>probMatchedtem) { probMatchedflag = Btypesize[tidx]; probMatchedtem = TMath::Prob(BInfo_vtxchi2[j],BInfo_vtxdof[j]); } if(BInfo_type[j]>2&&BInfo_type[j]<7) { if(TMath::Abs(BInfo_tktk_mass[j]-midmass[t])<tktkMatchedtem) { tktkMatchedflag = Btypesize[tidx]; tktkMatchedtem = TMath::Abs(BInfo_tktk_mass[j]-midmass[t]); } } } Btypesize[tidx]++; } } if(t!=3) { if(ptflag>=0) Bmaxpt[ptflag] = true; if(probflag>=0) Bmaxprob[probflag] = true; if(tktkflag>=0) Bbesttktkmass[tktkflag] = true; if(ptMatchedflag>=0) BmaxptMatched[ptMatchedflag] = true; if(probMatchedflag>=0) BmaxprobMatched[probMatchedflag] = true; if(tktkMatchedflag>=0) BbesttktkmassMatched[tktkMatchedflag] = true; } if(t==0) nt0->Fill(); else if(t==1) nt1->Fill(); else if(t==2) nt2->Fill(); else if(t==4) nt3->Fill(); else if(t==5) nt5->Fill(); else if(t==6) nt6->Fill(); } } ntHlt->Fill(); if(isPbPb) ntHi->Fill(); if(!REAL) { Int_t gt=0,sigtype=0; Int_t gsize=0; Gsize = 0; for(int j=0;j<GenInfo_size;j++) { if((TMath::Abs(GenInfo_pdgId[j])!=BPLUS_PDGID&&TMath::Abs(GenInfo_pdgId[j])!=BZERO_PDGID&&TMath::Abs(GenInfo_pdgId[j])!=BSUBS_PDGID) && gskim) continue; Gsize = gsize+1; Gpt[gsize] = GenInfo_pt[j]; Geta[gsize] = GenInfo_eta[j]; Gphi[gsize] = GenInfo_phi[j]; GpdgId[gsize] = GenInfo_pdgId[j]; bGen->SetPtEtaPhiM(GenInfo_pt[j],GenInfo_eta[j],GenInfo_phi[j],GenInfo_mass[j]); Gy[gsize] = bGen->Rapidity(); sigtype=0; for(gt=1;gt<8;gt++) { if(signalGen(gt,j)) { sigtype=gt; break; } } GisSignal[gsize] = sigtype; Gmu1pt[gsize] = -1; Gmu1eta[gsize] = -20; Gmu1phi[gsize] = -20; Gmu1p[gsize] = -1; Gmu2pt[gsize] = -1; Gmu2eta[gsize] = -20; Gmu2phi[gsize] = -20; Gmu2p[gsize] = -1; Gtk1pt[gsize] = -1; Gtk1eta[gsize] = -20; Gtk1phi[gsize] = -20; Gtk2pt[gsize] = -1; Gtk2eta[gsize] = -20; Gtk2phi[gsize] = -20; if(sigtype!=0) { Gmu1pt[gsize] = GenInfo_pt[GenInfo_da1[GenInfo_da1[j]]]; Gmu1eta[gsize] = GenInfo_eta[GenInfo_da1[GenInfo_da1[j]]]; Gmu1phi[gsize] = GenInfo_phi[GenInfo_da1[GenInfo_da1[j]]]; Gmu1p[gsize] = Gmu1pt[gsize]*cosh(Gmu1eta[gsize]); Gmu2pt[gsize] = GenInfo_pt[GenInfo_da2[GenInfo_da1[j]]]; Gmu2eta[gsize] = GenInfo_eta[GenInfo_da2[GenInfo_da1[j]]]; Gmu2phi[gsize] = GenInfo_phi[GenInfo_da2[GenInfo_da1[j]]]; Gmu2p[gsize] = Gmu2pt[gsize]*cosh(Gmu2eta[gsize]); if(sigtype==1||sigtype==2) { Gtk1pt[gsize] = GenInfo_pt[GenInfo_da2[j]]; Gtk1eta[gsize] = GenInfo_eta[GenInfo_da2[j]]; Gtk1phi[gsize] = GenInfo_phi[GenInfo_da2[j]]; } else { Gtk1pt[gsize] = GenInfo_pt[GenInfo_da1[GenInfo_da2[j]]]; Gtk1eta[gsize] = GenInfo_eta[GenInfo_da1[GenInfo_da2[j]]]; Gtk1phi[gsize] = GenInfo_phi[GenInfo_da1[GenInfo_da2[j]]]; Gtk2pt[gsize] = GenInfo_pt[GenInfo_da2[GenInfo_da2[j]]]; Gtk2eta[gsize] = GenInfo_eta[GenInfo_da2[GenInfo_da2[j]]]; Gtk2phi[gsize] = GenInfo_phi[GenInfo_da2[GenInfo_da2[j]]]; } } gsize++; } ntGen->Fill(); } } outf->Write(); outf->Close(); return 1; }
void loopNonpromptBzero(string infile="/mnt/hadoop/cms/store/user/jwang/Bfinder_BoostedMC_20140418_Hijing_PPb502_MinimumBias_HIJINGemb_inclBtoPsiMuMu_5TeV.root", string outfile="../../output/myoutputBzero.root", bool REAL=0){ //////////////////////////////////////////////////////////Phi // This file has been automatically generated // (Thu Nov 21 13:34:42 2013 by ROOT version5.27/06b) // from TTree root/root // found on file: merged_pPbData_20131114.root ////////////////////////////////////////////////////////// const char* infname; const char* outfname; if(REAL) cout<<"--- REAL DATA ---"<<endl; else cout<<"--- MC ---"<<endl; infname = infile.c_str(); outfname = outfile.c_str(); //File type TFile *f = new TFile(infname); TTree *root = (TTree*)f->Get("demo/root"); TTree *hlt = (TTree*)f->Get("hltanalysis/HltTree"); if (root->GetEntries()!=hlt->GetEntries()) { cout <<"Inconsistent number of entries!!!"<<endl; cout <<"HLT tree: "<<hlt->GetEntries()<<endl; cout <<"Bfinder tree: "<<root->GetEntries()<<endl; } //Chain type //TChain* root = new TChain("demo/root"); //root->Add("/mnt/hadoop/cms/store/user/wangj/HI_Btuple/20140213_PAMuon_HIRun2013_PromptReco_v1/Bfinder_all_100_1_dXJ.root"); //root->Add("/mnt/hadoop/cms/store/user/wangj/HI_Btuple/20140213_PAMuon_HIRun2013_PromptReco_v1/Bfinder_all_101_1_kuy.root"); //root->Add("/mnt/hadoop/cms/store/user/wangj/HI_Btuple/20140213_PAMuon_HIRun2013_PromptReco_v1/Bfinder_all_10_1_ZkX.root"); //root->Add("/mnt/hadoop/cms/store/user/wangj/HI_Btuple/20140213_PAMuon_HIRun2013_PromptReco_v1/Bfinder_all_102_1_NyI.root"); TFile *outf = new TFile(outfname,"recreate"); setBranch(root); setHltBranch(hlt); int ifchannel[7]; ifchannel[0] = 1; //jpsi+Kp ifchannel[1] = 1; //jpsi+pi ifchannel[2] = 1; //jpsi+Ks(pi+,pi-) ifchannel[3] = 1; //jpsi+K*(K+,pi-) ifchannel[4] = 1; //jpsi+K*(K-,pi+) ifchannel[5] = 1; //jpsi+phi ifchannel[6] = 1; //jpsi+pi pi <= psi', X(3872), Bs->J/psi f0 TTree* nt0 = new TTree("ntKp",""); buildBranch(nt0); TTree* nt1 = new TTree("ntpi",""); buildBranch(nt1); TTree* nt2 = new TTree("ntKs",""); buildBranch(nt2); TTree* nt3 = new TTree("ntKstar",""); buildBranch(nt3); TTree* nt5 = new TTree("ntphi",""); buildBranch(nt5); TTree* nt6 = new TTree("ntmix",""); buildBranch(nt6); TTree* ntGen = new TTree("ntGen",""); buildGenBranch(ntGen); cout<<"--- Tree building finished ---"<<endl; Long64_t nentries = root->GetEntries(); nentries = 100000; Long64_t nbytes = 0; TVector3* bP = new TVector3; TVector3* bVtx = new TVector3; TLorentzVector* b4P = new TLorentzVector; TLorentzVector* b4Pout = new TLorentzVector; TLorentzVector bGen; int type,flag; int flagEvt=0; int offsetHltTree=0; int testevent=0,testcand=0; for (Long64_t i=0; i<nentries;i++) { nbytes += root->GetEntry(i); flagEvt=0; while (flagEvt==0) { hlt->GetEntry(i+offsetHltTree); //cout <<offsetHltTree<<" "<<Bfr_HLT_Event<<" "<<EvtInfo_EvtNo<<endl; if (Bfr_HLT_Event==EvtInfo_EvtNo && Bfr_HLT_Run==EvtInfo_RunNo) flagEvt=1; else offsetHltTree++; } if (i%10000==0) cout <<i<<" / "<<nentries<<" offset HLT:"<<offsetHltTree<<endl; int type1size=0,type2size=0,type3size=0,type4size=0,type5size=0,type6size=0,type7size=0; float best,best2,temy; int bestindex,best2index; size=0; best=-1; bestindex=-1; best2=10000.; best2index=-1; for (int j=0;j<BInfo_size;j++) { if(BInfo_type[j]>7) continue; if (ifchannel[BInfo_type[j]-1]!=1) continue; //skim{{{ b4Pout->SetXYZM(BInfo_px[j],BInfo_py[j],BInfo_pz[j],BInfo_mass[j]); temy = b4Pout->Rapidity(); if(REAL) { if(!(((EvtInfo_RunNo>=210498&&EvtInfo_RunNo<=211256&&abs(temy+0.465)<1.93)||(EvtInfo_RunNo>=211313&&EvtInfo_RunNo<=211631&&abs(temy-0.465)<1.93)))) continue; } else { if(abs(temy+0.465)>=1.93) continue; } if(BInfo_mass[j]<5 || BInfo_mass[j]>6) continue; if(BInfo_pt[j]<10.) continue; //}}} if(BInfo_type[j]==1) { //if(TrackInfo_pt[BInfo_rftk1_index[j]]<0.9) continue; fillTree(bP,bVtx,b4P,j,type1size,KAON_MASS,0,REAL); if(chi2cl[type1size]>best) { best = chi2cl[type1size]; bestindex = type1size; } type1size++; } } if(size>0) { bestchi2 = bestindex; isbestchi2[bestindex] = 1; } nt0->Fill(); size=0; best=-1; bestindex=-1; best2=10000.; best2index=-1; for (int j=0;j<BInfo_size;j++) { if(BInfo_type[j]>7) continue; if (ifchannel[BInfo_type[j]-1]!=1) continue; //skim{{{ b4Pout->SetXYZM(BInfo_px[j],BInfo_py[j],BInfo_pz[j],BInfo_mass[j]); temy = b4Pout->Rapidity(); if(REAL) { if(!(((EvtInfo_RunNo>=210498&&EvtInfo_RunNo<=211256&&abs(temy+0.465)<1.93)||(EvtInfo_RunNo>=211313&&EvtInfo_RunNo<=211631&&abs(temy-0.465)<1.93)))) continue; } else { if(abs(temy+0.465)>=1.93) continue; } if(BInfo_mass[j]<5 || BInfo_mass[j]>6) continue; if(BInfo_pt[j]<10.) continue; //}}} if(BInfo_type[j]==2) { fillTree(bP,bVtx,b4P,j,type2size,PION_MASS,0,REAL); if(chi2cl[type2size]>best) { best = chi2cl[type2size]; bestindex = type2size; } type2size++; } } if(size>0) { bestchi2 = bestindex; isbestchi2[bestindex] = 1; } nt1->Fill(); size=0; best=-1; bestindex=-1; best2=10000.; best2index=-1; for (int j=0;j<BInfo_size;j++) { if(BInfo_type[j]>7) continue; if (ifchannel[BInfo_type[j]-1]!=1) continue; //skim{{{ b4Pout->SetXYZM(BInfo_px[j],BInfo_py[j],BInfo_pz[j],BInfo_mass[j]); temy = b4Pout->Rapidity(); if(REAL) { if(!(((EvtInfo_RunNo>=210498&&EvtInfo_RunNo<=211256&&abs(temy+0.465)<1.93)||(EvtInfo_RunNo>=211313&&EvtInfo_RunNo<=211631&&abs(temy-0.465)<1.93)))) continue; } else { if(abs(temy+0.465)>=1.93) continue; } if(BInfo_mass[j]<5 || BInfo_mass[j]>6) continue; if(BInfo_pt[j]<10.) continue; //}}} if(BInfo_type[j]==3) { fillTree(bP,bVtx,b4P,j,type3size,PION_MASS,PION_MASS,REAL); if(chi2cl[type3size]>best) { best = chi2cl[type3size]; bestindex = type3size; } if(abs(tktkmass[type3size]-KSHORT_MASS)<best2) { best2 = abs(tktkmass[type3size]-KSHORT_MASS); best2index = type3size; } type3size++; } } if(size>0) { bestchi2 = bestindex; isbestchi2[bestindex] = 1; besttktkmass = best2index; isbesttktkmass[best2index] = 1; } nt2->Fill(); size=0; best=-1; bestindex=-1; best2=10000.; best2index=-1; for (int j=0;j<BInfo_size;j++) { if(BInfo_type[j]>7) continue; if (ifchannel[BInfo_type[j]-1]!=1) continue; //skim{{{ b4Pout->SetXYZM(BInfo_px[j],BInfo_py[j],BInfo_pz[j],BInfo_mass[j]); temy = b4Pout->Rapidity(); if(REAL) { if(!(((EvtInfo_RunNo>=210498&&EvtInfo_RunNo<=211256&&abs(temy+0.465)<1.93)||(EvtInfo_RunNo>=211313&&EvtInfo_RunNo<=211631&&abs(temy-0.465)<1.93)))) continue; } else { if(abs(temy+0.465)>=1.93) continue; } if(BInfo_mass[j]<5 || BInfo_mass[j]>6) continue; if(BInfo_pt[j]<10.) continue; //}}} if(BInfo_type[j]==4 || BInfo_type[j]==5) { fillTree(bP,bVtx,b4P,j,type4size,KAON_MASS,PION_MASS,REAL); if(chi2cl[type4size]>best) { best = chi2cl[type4size]; bestindex = type4size; } if(abs(tktkmass[type4size]-KSTAR_MASS)<best2) { best2 = abs(tktkmass[type4size]-KSTAR_MASS); best2index = type4size; } type4size++; } } if(size>0) { bestchi2 = bestindex; isbestchi2[bestindex] = 1; besttktkmass = best2index; isbesttktkmass[best2index] = 1; } nt3->Fill(); size=0; best=-1; bestindex=-1; best2=10000.; best2index=-1; for (int j=0;j<BInfo_size;j++) { if(BInfo_type[j]>7) continue; if (ifchannel[BInfo_type[j]-1]!=1) continue; //skim{{{ b4Pout->SetXYZM(BInfo_px[j],BInfo_py[j],BInfo_pz[j],BInfo_mass[j]); temy = b4Pout->Rapidity(); if(REAL) { if(!(((EvtInfo_RunNo>=210498&&EvtInfo_RunNo<=211256&&abs(temy+0.465)<1.93)||(EvtInfo_RunNo>=211313&&EvtInfo_RunNo<=211631&&abs(temy-0.465)<1.93)))) continue; } else { if(abs(temy+0.465)>=1.93) continue; } if(BInfo_mass[j]<5 || BInfo_mass[j]>6) continue; if(BInfo_pt[j]<10.) continue; //}}} if(BInfo_type[j]==6) { //if(TrackInfo_pt[BInfo_rftk1_index[j]]<0.7) continue; //if(TrackInfo_pt[BInfo_rftk2_index[j]]<0.7) continue; fillTree(bP,bVtx,b4P,j,type6size,KAON_MASS,KAON_MASS,REAL); if(chi2cl[type6size]>best) { best = chi2cl[type6size]; bestindex = type6size; } if(abs(tktkmass[type6size]-PHI_MASS)<best2) { best2 = abs(tktkmass[type6size]-PHI_MASS); best2index = type6size; } type6size++; } } if(size>0) { bestchi2 = bestindex; isbestchi2[bestindex] = 1; besttktkmass = best2index; isbesttktkmass[best2index] = 1; } nt5->Fill(); size=0; best=-1; bestindex=-1; best2=10000.; best2index=-1; for (int j=0;j<BInfo_size;j++) { if(BInfo_type[j]>7) continue; if (ifchannel[BInfo_type[j]-1]!=1) continue; //skim{{{ b4Pout->SetXYZM(BInfo_px[j],BInfo_py[j],BInfo_pz[j],BInfo_mass[j]); temy = b4Pout->Rapidity(); if(REAL) { if(!(((EvtInfo_RunNo>=210498&&EvtInfo_RunNo<=211256&&abs(temy+0.465)<1.93)||(EvtInfo_RunNo>=211313&&EvtInfo_RunNo<=211631&&abs(temy-0.465)<1.93)))) continue; } else { if(abs(temy+0.465)>=1.93) continue; } if(BInfo_mass[j]<5 || BInfo_mass[j]>6) continue; if(BInfo_pt[j]<10.) continue; //}}} if(BInfo_type[j]==7) { fillTree(bP,bVtx,b4P,j,type7size,PION_MASS,PION_MASS,REAL); if(chi2cl[type7size]>best) { best = chi2cl[type7size]; bestindex = type7size; } type7size++; } } if(size>0) { bestchi2 = bestindex; isbestchi2[bestindex] = 1; } nt6->Fill(); if(!REAL) { Gensize = 0; for (int j=0;j<GenInfo_size;j++) { bGen.SetPtEtaPhiM(GenInfo_pt[j],GenInfo_eta[j],GenInfo_phi[j],GenInfo_mass[j]); flag=0; for(type=1;type<8;type++) { if (signalGen(type,j)) { flag=type; break; } } Genmu1pt[j] = -1; Genmu1eta[j] = -20; Genmu1phi[j] = -20; Genmu1p[j] = -1; Genmu2pt[j] = -1; Genmu2eta[j] = -20; Genmu2phi[j] = -20; Genmu2p[j] = -1; Gentk1pt[j] = -1; Gentk1eta[j] = -20; Gentk1phi[j] = -20; Gentk2pt[j] = -1; Gentk2eta[j] = -20; Gentk2phi[j] = -20; if(flag!=0) { Genmu1pt[j] = GenInfo_pt[GenInfo_da1[GenInfo_da1[j]]]; Genmu1eta[j] = GenInfo_eta[GenInfo_da1[GenInfo_da1[j]]]; Genmu1phi[j] = GenInfo_phi[GenInfo_da1[GenInfo_da1[j]]]; Genmu1p[j] = Genmu1pt[j]*cosh(Genmu1eta[j]); Genmu2pt[j] = GenInfo_pt[GenInfo_da2[GenInfo_da1[j]]]; Genmu2eta[j] = GenInfo_eta[GenInfo_da2[GenInfo_da1[j]]]; Genmu2phi[j] = GenInfo_phi[GenInfo_da2[GenInfo_da1[j]]]; Genmu2p[j] = Genmu2pt[j]*cosh(Genmu2eta[j]); if(flag==1||flag==2) { Gentk1pt[j] = GenInfo_pt[GenInfo_da2[j]]; Gentk1eta[j] = GenInfo_eta[GenInfo_da2[j]]; Gentk1phi[j] = GenInfo_phi[GenInfo_da2[j]]; } else { Gentk1pt[j] = GenInfo_pt[GenInfo_da1[GenInfo_da2[j]]]; Gentk1eta[j] = GenInfo_eta[GenInfo_da1[GenInfo_da2[j]]]; Gentk1phi[j] = GenInfo_phi[GenInfo_da1[GenInfo_da2[j]]]; Gentk2pt[j] = GenInfo_pt[GenInfo_da2[GenInfo_da2[j]]]; Gentk2eta[j] = GenInfo_eta[GenInfo_da2[GenInfo_da2[j]]]; Gentk2phi[j] = GenInfo_phi[GenInfo_da2[GenInfo_da2[j]]]; } } Gensize = GenInfo_size; Geny[j] = bGen.Rapidity(); Geneta[j] = bGen.Eta(); Genphi[j] = bGen.Phi(); Genpt[j] = bGen.Pt(); GenpdgId[j] = GenInfo_pdgId[j]; GenisSignal[j] = flag; } ntGen->Fill(); } } outf->Write(); outf->Close(); }