当前位置: 首页>>代码示例>>C++>>正文


C++ TLorentzVector::Mag方法代码示例

本文整理汇总了C++中TLorentzVector::Mag方法的典型用法代码示例。如果您正苦于以下问题:C++ TLorentzVector::Mag方法的具体用法?C++ TLorentzVector::Mag怎么用?C++ TLorentzVector::Mag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TLorentzVector的用法示例。


在下文中一共展示了TLorentzVector::Mag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: dijet_analysis_mistag_prediction_fwlite


//.........这里部分代码省略.........
      double jet2pt = jet2.pt() / corrF2;

      TLorentzVector v = v1 + v2;

      // get the tag quantities
      bool tagged1 = 
	(topMass1 >= topMassCut1 && topMass1 <= topMassCut2) &&
	(wMass1   >= wMassCut1   && wMass1   <= wMassCut2  ) &&
	(minMass1 >= minMassCut1 && minMass1 <= minMassCut2);

      bool tagged2 = 
	(topMass2 >= topMassCut1 && topMass2 <= topMassCut2) &&
	(wMass2   >= wMassCut1   && wMass2   <= wMassCut2  ) &&
	(minMass2 >= minMassCut1 && minMass2 <= minMassCut2);

//       if ( true ) {
// 	int bin1 = parameterization->FindBin(jet1.pt() );
// 	int bin2 = parameterization->FindBin(jet2.pt() );
// 	cout << "v.Mag() = " << v.Mag() << endl;
// 	cout << "jet1.p4 = " << v1 << endl;
// 	cout << "bin1    = " << bin1 << endl;
// 	cout << "rate1   = " << parameterization->GetBinContent(bin1) << " +- " << parameterization->GetBinError(bin1) << endl;
// 	cout << "jet2.p4 = " << v2 << endl;
// 	cout << "bin2    = " << bin2 << endl;
// 	cout << "rate2   = " << parameterization->GetBinContent(bin2) << " +- " << parameterization->GetBinError(bin2) << endl;
	
//       }

      if ( tagged1 ) {
	total_pred->Accumulate( 1.0, jet2pt, tagged2, fillWeight );
	jet_pt_pred->Accumulate( jet2pt, jet2pt, tagged2 , fillWeight );
	jet_eta_pred->Accumulate( jet2.eta(), jet2pt, tagged2 , fillWeight );
	jet_phi_pred->Accumulate( jet2.phi(), jet2pt, tagged2 , fillWeight );
	dijetmass_pred->Accumulate( v.Mag(), jet2pt, tagged2 , fillWeight );
      }
      
      if ( tagged2 ) {
	total_pred->Accumulate( 1.0, jet1pt, tagged1 , fillWeight);
	jet_pt_pred->Accumulate( jet1pt, jet1pt, tagged1  , fillWeight);
	jet_eta_pred->Accumulate( jet1.eta(), jet1pt, tagged1  , fillWeight);
	jet_phi_pred->Accumulate( jet1.phi(), jet1pt, tagged1  , fillWeight);
	dijetmass_pred->Accumulate( v.Mag(), jet1pt, tagged1  , fillWeight);
      }



    }

//     else if ( jets.size() == 1 && njets == 1 ) {

// //       cout << "Have 1 jet" << endl;
//       pat::Jet const & jet1 = jets[0];

//       const reco::CATopJetTagInfo * catopTag1 = dynamic_cast<CATopJetTagInfo const *> (jet1.tagInfo("CATopJetTagger"));

//       double topMass1 = catopTag1->properties().topMass;
//       double wMass1 = catopTag1->properties().wMass;
//       double minMass1 = catopTag1->properties().minMass;

//       TLorentzVector v1(jet1.px(), jet1.py(), jet1.pz(), jet1.energy() );

//       // get the tag quantities
//       bool tagged1 = 
// 	(topMass1 >= topMassCut1 && topMass1 <= topMassCut2) &&
// 	(wMass1   >= wMassCut1   && wMass1   <= wMassCut2  ) &&
// 	(minMass1 >= minMassCut1 && minMass1 <= minMassCut2);
开发者ID:dfehling,项目名称:usercode,代码行数:67,代码来源:dijet_analysis_mistag_prediction_fwlite.C

示例2: main


//.........这里部分代码省略.........
				gRecon->Add(curFileName.c_str());
				gGenVtx->Add(curFileName.c_str());
			}
		}
	}

	std::cout << "Got input file(s)." << std::endl;

	//Setup access to the Recon tree
	int NPIDs(0);  // This variable counts the number of particles per event
	int NVtxFGD1(0), NVtxFGD2(0);
        // Declare a TClonesArray to hold objects of type TGlobalPID
 	TClonesArray *globalPIDs = new TClonesArray("ND::TGlobalReconModule::TGlobalPID",50);
	TClonesArray *VtxFGD1 = new TClonesArray("ND::TTruthVerticesModule::TTruthVertex",50);    
	TClonesArray *VtxFGD2 = new TClonesArray("ND::TTruthVerticesModule::TTruthVertex",50);    
    // Associate the right branch in the TTree to the right local variable
	gRecon->SetBranchAddress("NPIDs",&NPIDs);
    gRecon->SetBranchAddress("PIDs",&globalPIDs);
	gGenVtx->SetBranchAddress("VtxFGD1", &VtxFGD1);
	gGenVtx->SetBranchAddress("NVtxFGD1", &NVtxFGD1);
	gGenVtx->SetBranchAddress("VtxFGD2", &VtxFGD2);
	gGenVtx->SetBranchAddress("NVtxFGD2", &NVtxFGD2);
	//check that truthdir and recon have the same number of entries
	if(gRecon->GetEntries() != gGenVtx->GetEntries()) 
		cout<<"not equal entries, probably wrong"<<endl;
	// Loop over the entries in the TChain.

	//========================================================
	//			Declare Graphs n stuff here
	//========================================================

	//adding tclones arrays for use with detectors
	Int_t NTPCs;
	TClonesArray *TPC;

	Int_t NFDGs;
	TClonesArray *FDG;

	Int_t NECALs;
	TClonesArray *ECAL;

	Int_t NPODs;
	TClonesArray *POD;

	Int_t NSMRDs;
	TClonesArray *SMRD;

	//adding a 2d graph general purpose, change titles each time!
	TH1D *graph1 = new TH1D("graph1","Histogram of Neutrino momentum in FGD", 100, -1.5 , 1.5);

	//========================================================
	//	end		Declare Graphs n stuff here
	//========================================================

	// Loop over the entries in the TChain. (only 1/1000 of whole entries atm)
	for(unsigned int i = 0; i < gRecon->GetEntries()*0.1; ++i) {
		if((i+1)%10000 == 0) std::cout << "Processing event: " << (i+1) << std::endl;
		//display status every 10,000 th entry

	// Get an entry for the Recon tree
		gRecon->GetEntry(i);
		gGenVtx->GetEntry(i);
		ND::TGlobalReconModule::TGlobalPID *gTrack = NULL;

		//added new loop for truth vertex
		gGenVtx->GetEntry(i);
		
		for (int j=0; j<NPIDs; j++) {
			// Get a specific track from the TClonesArray
			gTrack = (ND::TGlobalReconModule::TGlobalPID*)globalPIDs->At(j);
			//get truevertex (in example, also gets trueparticle, can add in later)
			ND::TTrueVertex vtx = gTrack->TrueParticle.Vertex;
			//get position lorrentz vector
			TLorentzVector vec = vtx.Position;
			TLorentzVector momvec = vtx.Momentum;
			if(vtx.ReactionCode.find("Weak[NC],QES;",0)!=-1){
				if(ABS(vec.X())<832.2 && ABS(vec.Y()-55)<832.2 && ((vec.Z()>123.45&&vec.Z()<446.95)||(vec.Z()>1481.45&&vec.Z()<1807.95))){	//is it in one of the FGDs?
					//graph1->Fill(vec.X(),vec.Y());
					graph1->Fill(momvec.Mag());
				}	
			}
			TClonesArray *TPCObjects = new TClonesArray("ND::TGlobalReconModule::TTPCObject",gTrack->NTPCs);
			ND::TGlobalReconModule::TObject *tpcTrack = NULL;
			for ( int k = 0 ; k < gTrack->NTPCs; k++) {
				tpcTrack = (ND::TGlobalReconModule::TObject*) TPCObjects->At(k);
				//now we can access  variables through tpcTrack->PullEle for example
			}
		}

	} // End loop over events
	cout << "done loop!" << endl;

//plotting bits at the end :D
    graph1->GetXaxis()->SetTitle("Momentum");
    graph1->GetYaxis()->SetTitle("Number");
    graph1->Draw();
	App->Run();

	return 0;
}
开发者ID:phuidn,项目名称:t2kstuff,代码行数:101,代码来源:neutrinomom.C


注:本文中的TLorentzVector::Mag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。