本文整理汇总了C++中TParticle::Pt方法的典型用法代码示例。如果您正苦于以下问题:C++ TParticle::Pt方法的具体用法?C++ TParticle::Pt怎么用?C++ TParticle::Pt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TParticle
的用法示例。
在下文中一共展示了TParticle::Pt方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Process
//_____________________________________________________________________________
Bool_t ProofPythia::Process(Long64_t entry)
{
// Main event loop
fPythia->GenerateEvent();
if (entry < 2)
fPythia->EventListing();
fPythia->ImportParticles(fP, "All");
Int_t nTot = fPythia->GetN();
fPythia->ImportParticles(fP, "All");
Int_t np = fP->GetEntriesFast();
// Particle loop
Int_t nCharged = 0;
for (Int_t ip = 0; ip < np; ip++) {
TParticle* part = (TParticle*) fP->At(ip);
Int_t ist = part->GetStatusCode();
Int_t pdg = part->GetPdgCode();
if (ist != 1) continue;
Float_t charge = TDatabasePDG::Instance()->GetParticle(pdg)->Charge();
if (charge == 0.) continue;
nCharged++;
Float_t eta = part->Eta();
Float_t pt = part->Pt();
if (pt > 0.) fPt->Fill(pt);
if ((eta > -10) && (eta < 10)) fEta->Fill(eta);
}
fHist->Fill(nCharged);
fTot->Fill(nTot);
return kTRUE;
}
示例2: CountPrimaries
void CountPrimaries(TH1F *hMultCount) {
if (hMultCount==0) hMultCount = new TH1F("mult","averaged multiplicity (charg. prim)",80,-4.,4.);
AliRunLoader *rl = AliRunLoader::Open("galice.root");
rl->SetKineFileName("Kinematics.root");
rl->LoadHeader();
rl->LoadKinematics();
Int_t nEvents = rl->GetNumberOfEvents();
cout<< "N events "<<nEvents<<endl;
for(Int_t iEv=0; iEv<nEvents; iEv++){
rl->GetEvent(iEv);
AliStack *s = rl->Stack();
for(Int_t iP=0; iP<s->GetNtrack(); iP++ ){
TParticle *p = s->Particle(iP);
if (!(s->IsPhysicalPrimary(iP))) continue;
Float_t eta = p->Eta();
if (p->Pt()>0.06) {
hMultCount->Fill(eta);
}
}
}
hMultCount->DrawCopy();
rl->UnloadHeader();
rl->UnloadKinematics();
delete rl;
}
示例3: kine_daughters
void kine_daughters(IlcEveTrack* parent, IlcStack* stack,
Double_t min_pt, Double_t min_p,
Bool_t pdg_col, Bool_t recurse)
{
TParticle *p = stack->Particle(parent->GetLabel());
if (p->GetNDaughters() > 0)
{
TEveTrackPropagator* rs = parent->GetPropagator();
for (int d=p->GetFirstDaughter(); d>0 && d<=p->GetLastDaughter(); ++d)
{
TParticle* dp = stack->Particle(d);
if (dp->Pt() < min_pt && dp->P() < min_p) continue;
IlcEveTrack* dtrack = new IlcEveTrack(dp, d, rs);
char form[1000];
sprintf(form,"%s [%d]", dp->GetName(), d);
dtrack->SetName(form);
dtrack->SetStdTitle();
set_track_color(dtrack, pdg_col);
gEve->AddElement(dtrack, parent);
if (recurse)
kine_daughters(dtrack, stack, min_pt, min_p, pdg_col, recurse);
}
}
}
示例4: pythia8
void pythia8(Int_t nev = 100, Int_t ndeb = 1)
{
const char *p8dataenv = gSystem->Getenv("PYTHIA8DATA");
if (!p8dataenv) {
const char *p8env = gSystem->Getenv("PYTHIA8");
if (!p8env) {
Error("pythia8.C",
"Environment variable PYTHIA8 must contain path to pythia directory!");
return;
}
TString p8d = p8env;
p8d += "/xmldoc";
gSystem->Setenv("PYTHIA8DATA", p8d);
}
const char* path = gSystem->ExpandPathName("$PYTHIA8DATA");
if (gSystem->AccessPathName(path)) {
Error("pythia8.C",
"Environment variable PYTHIA8DATA must contain path to $PYTHIA8/xmldoc directory !");
return;
}
// Load libraries
#ifndef G__WIN32 // Pythia8 is a static library on Windows
if (gSystem->Getenv("PYTHIA8")) {
gSystem->Load("$PYTHIA8/lib/libpythia8");
} else {
gSystem->Load("libpythia8");
}
#endif
gSystem->Load("libEG");
gSystem->Load("libEGPythia8");
// Histograms
TH1F* etaH = new TH1F("etaH", "Pseudorapidity", 120, -12., 12.);
TH1F* ptH = new TH1F("ptH", "pt", 50, 0., 10.);
// Array of particles
TClonesArray* particles = new TClonesArray("TParticle", 1000);
// Create pythia8 object
TPythia8* pythia8 = new TPythia8();
// Configure
pythia8->ReadString("HardQCD:all = on");
// Initialize
pythia8->Initialize(2212 /* p */, 2212 /* p */, 14000. /* TeV */);
// Event loop
for (Int_t iev = 0; iev < nev; iev++) {
pythia8->GenerateEvent();
if (iev < ndeb) pythia8->EventListing();
pythia8->ImportParticles(particles,"All");
Int_t np = particles->GetEntriesFast();
// Particle loop
for (Int_t ip = 0; ip < np; ip++) {
TParticle* part = (TParticle*) particles->At(ip);
Int_t ist = part->GetStatusCode();
// Positive codes are final particles.
if (ist <= 0) continue;
Int_t pdg = part->GetPdgCode();
Float_t charge = TDatabasePDG::Instance()->GetParticle(pdg)->Charge();
if (charge == 0.) continue;
Float_t eta = part->Eta();
Float_t pt = part->Pt();
etaH->Fill(eta);
if (pt > 0.) ptH->Fill(pt, 1./(2. * pt));
}
}
pythia8->PrintStatistics();
TCanvas* c1 = new TCanvas("c1","Pythia8 test example",800,800);
c1->Divide(1, 2);
c1->cd(1);
etaH->Scale(5./Float_t(nev));
etaH->Draw();
etaH->SetXTitle("#eta");
etaH->SetYTitle("dN/d#eta");
c1->cd(2);
gPad->SetLogy();
ptH->Scale(5./Float_t(nev));
ptH->Draw();
ptH->SetXTitle("p_{t} [GeV/c]");
ptH->SetYTitle("dN/dp_{t}^{2} [GeV/c]^{-2}");
}
示例5: FinishEvent
//________________________________________________________________________________
void StarMCHits::FinishEvent() {
static const Double_t pEMax = 1 - 1.e-10;
TDataSet *m_DataSet = StarMCHits::instance()->GetHitHolder();
if (! m_DataSet) return;
St_g2t_event *g2t_event = new St_g2t_event("g2t_event",1);
m_DataSet->Add(g2t_event);
g2t_event_st event;
memset (&event, 0, sizeof(g2t_event_st));
fEventNumber++;
event.n_event = fEventNumber;//IHEAD(2)
event.ge_rndm[0] = fSeed;//IHEAD(3)
event.ge_rndm[1] = 0;//IHEAD(4)
event.n_run = 1;
event.n_track_eg_fs = StarVMCApplication::Instance()->GetStack()->GetNtrack();
event.n_track_prim = StarVMCApplication::Instance()->GetStack()->GetNprimary();
event.prim_vertex_p = 1;
event.b_impact = 99;
event.phi_impact = 0.5;
g2t_event->AddAt(&event);
Int_t NoVertex = 1;
St_g2t_vertex *g2t_vertex = new St_g2t_vertex("g2t_vertex",NoVertex);
m_DataSet->Add(g2t_vertex);
g2t_vertex_st vertex;
Int_t NTracks = StarVMCApplication::Instance()->GetStack()->GetNtrack();
St_g2t_track *g2t_track = new St_g2t_track ("g2t_track",NTracks);
m_DataSet->Add(g2t_track);
g2t_track_st track;
StarMCParticle *particle = 0;
Int_t iv = 0;
TLorentzVector oldV(0,0,0,0);
TLorentzVector newV(0,0,0,0);
TLorentzVector devV(0,0,0,0);
for (Int_t it = 0; it <NTracks; it++) {
memset(&track, 0, sizeof(g2t_track_st));
particle = (StarMCParticle*) StarVMCApplication::Instance()->GetStack()->GetParticle(it);
TParticle *part = (TParticle *) particle->GetParticle();
part->ProductionVertex(newV);
devV = newV - oldV;
if (iv == 0 || devV.Mag() > 1.e-7) {
if (iv > 0) g2t_vertex->AddAt(&vertex);
memset (&vertex, 0, sizeof(g2t_vertex_st));
iv++;
vertex.id = iv ;// primary key
vertex.event_p = 0 ;// pointer to event
vertex.eg_label = 0 ;// generator label (0 if GEANT)
vertex.eg_tof = 0 ;// vertex production time
vertex.eg_proc = 0 ;// event generator mechanism
memcpy(vertex.ge_volume," ",4); ;// GEANT volume name
vertex.ge_medium = 0 ;// GEANT Medium
vertex.ge_tof = 0 ;// GEANT vertex production time
vertex.ge_proc = 0 ;// GEANT mechanism (0 if eg)
vertex.ge_x[0] = newV.X() ;// GEANT vertex coordinate
vertex.ge_x[1] = newV.Y() ;
vertex.ge_x[2] = newV.Z() ;
vertex.ge_tof = newV.T() ;
vertex.n_parent = 0 ;// number of parent tracks
vertex.parent_p = 0 ;// first parent track
vertex.is_itrmd = 0 ;// flags intermediate vertex
vertex.next_itrmd_p = 0 ;// next intermedate vertex
vertex.next_prim_v_p= 0 ;// next primary vertex
oldV = newV;
}
vertex.n_daughter++;
track.id = it+1;
track.eg_label = particle->GetIdGen();
track.eg_pid = part->GetPdgCode();
track.ge_pid = gMC->IdFromPDG(track.eg_pid);
track.start_vertex_p = iv;
track.p[0] = part->Px();
track.p[1] = part->Py();
track.p[2] = part->Pz();
track.ptot = part->P();
track.e = part->Energy();
track.charge = part->GetPDG()->Charge()/3;
Double_t ratio = part->Pz()/part->Energy();
ratio = TMath::Min(1.-1e-10,TMath::Max(-1.+1e-10, ratio));
track.rapidity = TMath::ATanH(ratio);
track.pt = part->Pt();
ratio = part->Pz()/part->P();
ratio = TMath::Min(pEMax,TMath::Max(-pEMax, ratio));
track.eta = TMath::ATanH(ratio);
g2t_track->AddAt(&track);
}
g2t_vertex->AddAt(&vertex);
}
示例6: CheckESD
Bool_t CheckESD(const char* gAliceFileName = "galice.root",
const char* esdFileName = "AliESDs.root")
{
// check the content of the ESD
// check values
Int_t checkNGenLow = 1;
Double_t checkEffLow = 0.5;
Double_t checkEffSigma = 3;
Double_t checkFakeHigh = 0.5;
Double_t checkFakeSigma = 3;
Double_t checkResPtInvHigh = 5;
Double_t checkResPtInvSigma = 3;
Double_t checkResPhiHigh = 10;
Double_t checkResPhiSigma = 3;
Double_t checkResThetaHigh = 10;
Double_t checkResThetaSigma = 3;
Double_t checkPIDEffLow = 0.5;
Double_t checkPIDEffSigma = 3;
Double_t checkResTOFHigh = 500;
Double_t checkResTOFSigma = 3;
Double_t checkPHOSNLow = 5;
Double_t checkPHOSEnergyLow = 0.3;
Double_t checkPHOSEnergyHigh = 1.0;
Double_t checkEMCALNLow = 50;
Double_t checkEMCALEnergyLow = 0.05;
Double_t checkEMCALEnergyHigh = 1.0;
Double_t checkMUONNLow = 1;
Double_t checkMUONPtLow = 0.5;
Double_t checkMUONPtHigh = 10.;
Double_t cutPtV0 = 0.3;
Double_t checkV0EffLow = 0.02;
Double_t checkV0EffSigma = 3;
Double_t cutPtCascade = 0.5;
Double_t checkCascadeEffLow = 0.01;
Double_t checkCascadeEffSigma = 3;
// open run loader and load gAlice, kinematics and header
AliRunLoader* runLoader = AliRunLoader::Open(gAliceFileName);
if (!runLoader) {
Error("CheckESD", "getting run loader from file %s failed",
gAliceFileName);
return kFALSE;
}
runLoader->LoadgAlice();
gAlice = runLoader->GetAliRun();
if (!gAlice) {
Error("CheckESD", "no galice object found");
return kFALSE;
}
runLoader->LoadKinematics();
runLoader->LoadHeader();
// open the ESD file
TFile* esdFile = TFile::Open(esdFileName);
if (!esdFile || !esdFile->IsOpen()) {
Error("CheckESD", "opening ESD file %s failed", esdFileName);
return kFALSE;
}
AliESDEvent * esd = new AliESDEvent;
TTree* tree = (TTree*) esdFile->Get("esdTree");
if (!tree) {
Error("CheckESD", "no ESD tree found");
return kFALSE;
}
esd->ReadFromTree(tree);
// efficiency and resolution histograms
Int_t nBinsPt = 15;
Float_t minPt = 0.1;
Float_t maxPt = 3.1;
TH1F* hGen = CreateHisto("hGen", "generated tracks",
nBinsPt, minPt, maxPt, "p_{t} [GeV/c]", "N");
TH1F* hRec = CreateHisto("hRec", "reconstructed tracks",
nBinsPt, minPt, maxPt, "p_{t} [GeV/c]", "N");
Int_t nGen = 0;
Int_t nRec = 0;
Int_t nFake = 0;
TH1F* hResPtInv = CreateHisto("hResPtInv", "", 100, -10, 10,
"(p_{t,rec}^{-1}-p_{t,sim}^{-1}) / p_{t,sim}^{-1} [%]", "N");
TH1F* hResPhi = CreateHisto("hResPhi", "", 100, -20, 20,
"#phi_{rec}-#phi_{sim} [mrad]", "N");
TH1F* hResTheta = CreateHisto("hResTheta", "", 100, -20, 20,
"#theta_{rec}-#theta_{sim} [mrad]", "N");
// PID
Int_t partCode[AliPID::kSPECIES] =
{kElectron, kMuonMinus, kPiPlus, kKPlus, kProton};
const char* partName[AliPID::kSPECIES+1] =
{"electron", "muon", "pion", "kaon", "proton", "other"};
Double_t partFrac[AliPID::kSPECIES] =
{0.01, 0.01, 0.85, 0.10, 0.05};
Int_t identified[AliPID::kSPECIES+1][AliPID::kSPECIES];
//.........这里部分代码省略.........
示例7: createGlauberTree
void createGlauberTree(Int_t nEvents,
const char *outFileName)
{
AliPDG::AddParticlesToPdgDataBase();
TDatabasePDG::Instance();
// Run loader
TFolder *folder = new TFolder("myfolder","myfolder");
AliRunLoader* rl = new AliRunLoader(folder);
rl->MakeHeader();
rl->MakeStack();
AliStack* stack = rl->Stack();
//AliHeader* rheader = rl->GetHeader();
AliGenHijing *genHi = new AliGenHijing(-1);
genHi->SetStack(stack);
genHi->SetEnergyCMS(2760);
genHi->SetReferenceFrame("CMS");
genHi->SetProjectile("A", 208, 82);
genHi->SetTarget ("A", 208, 82);
genHi->SetPtHardMin (2.3);
genHi->SetImpactParameterRange(0.,30);
genHi->SetJetQuenching(0); // enable jet quenching
genHi->SetShadowing(1); // enable shadowing
genHi->SetDecaysOff(1); // neutral pion and heavy particle decays switched off
genHi->Init();
MyHeader *myheader = new MyHeader;
MyResponse *myresp = new MyResponse;
TFile *outFile = TFile::Open(outFileName, "RECREATE");
outFile->SetCompressionLevel(5);
TDirectory::TContext context(outFile);
TTree *tree = new TTree("glaubertree", "Glauber tree");
tree->Branch("header",&myheader, 32*1024, 99);
tree->Branch("response",&myresp, 32*1024, 99);
TNtuple *ntuple = new TNtuple("gnt", "Glauber ntuple", "npart:ncoll:b");
Double_t etas[] = {-10,-5,-4,-3,-2,-1,0,1,2,3,4,5,10};
TH1D *hNEta = new TH1D("hNeta","",12,etas);
TH1D *hEtEta = new TH1D("hEteta","",12,etas);
// create events and fill them
for (Int_t iEvent = 0; iEvent < nEvents; ++iEvent) {
cout << "Event " << iEvent+1 << "/" << nEvents << endl;;
stack->Reset();
hNEta->Reset();
hEtEta->Reset();
genHi->Generate();
AliStack *s = genHi->GetStack();
const TObjArray *parts = s->Particles();
Int_t nents = parts->GetEntries();
for (Int_t i = 0; i<nents; ++i) {
TParticle *p = (TParticle*)parts->At(i);
//p->Print();
TParticlePDG *pdg = p->GetPDG(1);
Int_t c = (Int_t)(TMath::Abs(pdg->Charge()));
if (c!=0) {
hNEta->Fill(p->Eta());
hEtEta->Fill(p->Eta(),p->Pt());
}
}
AliGenHijingEventHeader *h = (AliGenHijingEventHeader*)genHi->CollisionGeometry();
myheader->fNATT = nents;
myheader->fEATT = h->TotalEnergy();
myheader->fJATT = h->HardScatters();
myheader->fNT = h->TargetParticipants();
myheader->fNP = h->ProjectileParticipants();
myheader->fN00 = h->NwNw();
myheader->fN01 = h->NwN();
myheader->fN10 = h->NNw();
myheader->fN11 = h->NN();
myheader->fBB = h->ImpactParameter();
myheader->fRP = h->ReactionPlaneAngle();
myheader->fPSn = h->ProjSpectatorsn();
myheader->fPSp = h->ProjSpectatorsp();
myheader->fTSn = h->TargSpectatorsn();
myheader->fTSp = h->TargSpectatorsn();
myresp->fEtch0p = hEtEta->GetBinContent(hEtEta->FindBin(0.5));
myresp->fEtch1p = hEtEta->GetBinContent(hEtEta->FindBin(1.5));
myresp->fEtch2p = hEtEta->GetBinContent(hEtEta->FindBin(2.5));
myresp->fEtch3p = hEtEta->GetBinContent(hEtEta->FindBin(3.5));
myresp->fEtch4p = hEtEta->GetBinContent(hEtEta->FindBin(4.5));
myresp->fEtch5p = hEtEta->GetBinContent(hEtEta->FindBin(5.5));
myresp->fEtchrp = hEtEta->GetBinContent(hEtEta->FindBin(10.5));
myresp->fEtch0n = hEtEta->GetBinContent(hEtEta->FindBin(-0.5));
myresp->fEtch1n = hEtEta->GetBinContent(hEtEta->FindBin(-1.5));
myresp->fEtch2n = hEtEta->GetBinContent(hEtEta->FindBin(-2.5));
myresp->fEtch3n = hEtEta->GetBinContent(hEtEta->FindBin(-3.5));
myresp->fEtch4n = hEtEta->GetBinContent(hEtEta->FindBin(-4.5));
myresp->fEtch5n = hEtEta->GetBinContent(hEtEta->FindBin(-5.5));
myresp->fEtchrn = hEtEta->GetBinContent(hEtEta->FindBin(-10.5));
myresp->fNch0p = hNEta->GetBinContent(hNEta->FindBin(0.5));
myresp->fNch1p = hNEta->GetBinContent(hNEta->FindBin(1.5));
//.........这里部分代码省略.........
示例8: pythia6_gammagamma_leptons_parents
//.........这里部分代码省略.........
if ( passEvtSelection(pythia)==false ) { ///Cut on W!!!!!!!!!!!!!!!
exclEvts++;
continue;
}
// Loop over particles and fill histos
particlesArray = (TClonesArray*)pythia->GetListOfParticles();
int N = particlesArray->GetEntriesFast();
//cout << "<I> PYTHIA particles in event: " << N << " " << flush;
TMCParticle *part;
TParticle *partic;
Int_t n_leptons = 0;
for (int ip = 0; ip < N; ip++ ) {
part = (TMCParticle*)particlesArray->At(ip);
int status = part->GetKS();
if (status!=1) continue; // Only consider final-state particles
int parent_id = part->GetParent();
//if (parent_id != 22) continue; //Only consider particles coming from photons
int pdg = part->GetKF();
double charge = PDG->GetParticle(pdg)->Charge();
if(charge==0) continue; // only charged particles
//if ( abs(pdg)!=11 && abs(pdg)!=13 ) continue;// only leptons
if ( abs(pdg)!=13 ) continue;// only muons
partic = (TParticle*)TMCParticle2TParticle(part);
double ptPartic = partic->Pt();
double etaPartic = partic->Eta();
//phiPartic = partic->Phi();
//if ( ptPartic<0.15 ) continue; //cut on Pt!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//if (abs(etaPartic)>1.5) continue; //Fill only if |eta|<1.5!!!!!!!!!!!!!!!!!!!!!
// Histo filling
h_id_part->Fill(abs(pdg));
hdsigmadeta->Fill(etaPartic);
hdsigmadpT->Fill(ptPartic);
n_leptons++; //Count the total number of charged hadrons in this event
delete partic;
// if (TMath::Abs(etaPartic)<1.) Nch++;
} // End loop over all particles in event
h_lep_per_ev->Fill(n_leptons);
n_lepton_total += n_leptons;
} // END EVENT GENERATION LOOP
myfile.close();
// **********************************************************************************
// FINAL GENERATION MESSAGES:
示例9: ExtractOutputHistos
void ExtractOutputHistos(Bool_t onlyPrims=0,Bool_t onlyPion=0,Int_t plotFlag=0) {
// gROOT->SetStyle("Plain");
gStyle->SetPalette(1);
const Int_t nbins=20;
Double_t ptmin=0.06;//04;
Double_t ptmax=2.0;//GeV
Double_t logxmin = TMath::Log10(ptmin);
Double_t logxmax = TMath::Log10(ptmax);
Double_t binwidth = (logxmax-logxmin)/(nbins+1);
enum {nb=nbins+1};
Double_t xbins[nb];
xbins[0] = ptmin;
for (Int_t i=1;i<=nbins;i++) {
xbins[i] = ptmin + TMath::Power(10,logxmin+(i)*binwidth);
// cout<<xbins[i]<<endl;
}
// TH1F *h = new TH1F("h","hist with log x axis",nbins,xbins);
TH1F *hMultCount = new TH1F("mult","averaged multiplicity (charg. prim)",80,-4.,4.);
hMultCount->GetXaxis()->SetTitle("eta");
hMultCount->GetYaxis()->SetTitle("N/d#eta");
TH1F *hAllMC = new TH1F("allMC","All Tracks MC primaries",nbins,xbins);
TH1F *hAllFound = new TH1F("allFound","All Tracks found",nbins,xbins);
TH1F *hImperfect = new TH1F("imperfect","Imperfect tracks",nbins,xbins);
TH1F *hPerfect = new TH1F("perfect","Perfect tracks",nbins,xbins);
TH1F *hEff = new TH1F("efficiency","Efficiency (Perfect tracks in \"ALL MC\")",nbins,xbins);
TH1F *hFake = new TH1F("fake","Fake tracks (Inperfect tracks in \"ALL MC\")",nbins,xbins);
TH1F *hPurity = new TH1F("purity","Purity (Perfect tracks in \"All Found\")",nbins,xbins);
TH1F *hAnna = new TH1F("annaEff","AnnalisaEff ",nbins,xbins);
TH1F *hNoMCTrack = new TH1F("noMCtrack","noMCtrack ",nbins,xbins);
TH1F *hEta = new TH1F("","",50,-2,2);
// TH1F *hEtaMC = new TH1F("","",50,-2,2);
TH2D *h2Ddca = new TH2D("dca2D","DCAvsPt2D",nbins,xbins,50,-0.05,0.05);
TH2D *h2Dpt = new TH2D("dPt2D","dPtdvsPt2D",nbins,xbins,50,-25,25);
// open run loader and load gAlice, kinematics and header
AliRunLoader* runLoader = AliRunLoader::Open("galice.root");
if (!runLoader) {
Error("Check kine", "getting run loader from file %s failed",
"galice.root");
return;
}
runLoader->LoadgAlice();
gAlice = runLoader->GetAliRun();
if (!gAlice) {
Error("Check kine", "no galice object found");
return;
}
runLoader->LoadHeader();
runLoader->LoadKinematics();
TFile* esdFile = TFile::Open("AliESDs.root");
if (!esdFile || !esdFile->IsOpen()) {
Error("CheckESD", "opening ESD file %s failed", "AliESDs.root");
return;
}
AliESDEvent *esd = new AliESDEvent();
TTree* tree = (TTree*) esdFile->Get("esdTree");
if (!tree) {
Error("CheckESD", "no ESD tree found");
return;
}
esd->ReadFromTree(tree);
Int_t nTrackTotalMC = 0;
Int_t nTrackFound = 0;
Int_t nTrackImperfect = 0;
Int_t nTrackPerfect = 0;
Int_t nNoMCTrack = 0;
for(Int_t iEv =0; iEv<tree->GetEntries(); iEv++){
tree->GetEvent(iEv);
runLoader->GetEvent(iEv);
printf("+++ event %i (of %lld) +++++++++++++++++++++++ # ESDtracks: %d \n",iEv,tree->GetEntries()-1,esd->GetNumberOfTracks());
Int_t nESDtracks = esd->GetNumberOfTracks();
for (Int_t iTrack = 0; iTrack < nESDtracks; iTrack++) {
AliESDtrack* track = esd->GetTrack(iTrack);
if (!(iTrack%1000)) printf("event %i: ESD track count %d (of %d)\n",iEv,iTrack,nESDtracks);
Int_t label = track->GetLabel();
Int_t idx[12];
// Int_t ncl = track->GetITSclusters(idx);
if(label<0) {
// cout<< " ESD track label " << label;
// cout<<" ---> imperfect track (label "<<label<<"<0) !! -> track Pt: "<< track->Pt() << endl;
}
AliStack* stack = runLoader->Stack();
// nTrackTotalMC += stack->GetNprimary();
//.........这里部分代码省略.........
示例10: CountTrackableMCs
void CountTrackableMCs(TH1F *hAllMC, Bool_t onlyPrims,Bool_t onlyPion) {
gSystem->Load("libITSUpgradeBase");
gSystem->Load("libITSUpgradeSim");
// open run loader and load gAlice, kinematics and header
AliRunLoader* runLoader = AliRunLoader::Open("galice.root");
if (!runLoader) {
Error("Check kine", "getting run loader from file %s failed",
"galice.root");
return;
}
runLoader->LoadHeader();
runLoader->LoadKinematics();
runLoader->LoadTrackRefs();
AliLoader *dl = runLoader->GetDetectorLoader("ITS");
//Trackf
TTree *trackRefTree = 0x0;
TClonesArray *trackRef = new TClonesArray("AliTrackReference",1000);
// TH1F *hRef = new TH1F("","",100,0,100);
TH1F *hR = new TH1F("","",100,0,100);
if (hAllMC==0) hAllMC = new TH1F("","",100,0.1,2);
Float_t ptmin = hAllMC->GetBinCenter(1)-hAllMC->GetBinWidth(1)/2;
Float_t ptmax = hAllMC->GetBinCenter(hAllMC->GetNbinsX())+hAllMC->GetBinWidth(hAllMC->GetNbinsX())/2;
// Int_t nAllMC = 0;
// Detector geometry
TArrayD rmin(0); TArrayD rmax(0);
GetDetectorRadii(&rmin,&rmax);
TArrayI nLaySigs(rmin.GetSize());
printf("Counting trackable MC tracks ...\n");
for(Int_t iEv =0; iEv<runLoader->GetNumberOfEvents(); iEv++){
Int_t nTrackableTracks = 0;
runLoader->GetEvent(iEv);
AliStack* stack = runLoader->Stack();
printf("+++ event %i (of %d) +++++++++++++++++++++++ # total MCtracks: %d \n",iEv,runLoader->GetNumberOfEvents()-1,stack->GetNtrack());
trackRefTree=runLoader->TreeTR();
TBranch *br = trackRefTree->GetBranch("TrackReferences");
if(!br) {
printf("no TR branch available , exiting \n");
return;
}
br->SetAddress(&trackRef);
// init the trackRef tree
trackRefTree=runLoader->TreeTR();
trackRefTree->SetBranchAddress("TrackReferences",&trackRef);
// Count trackable MC tracks
for (Int_t iMC=0; iMC<stack->GetNtrack(); iMC++) {
TParticle* particle = stack->Particle(iMC);
if (TMath::Abs(particle->Eta())>etaCut) continue;
if (onlyPrims && !stack->IsPhysicalPrimary(iMC)) continue;
if (onlyPion && TMath::Abs(particle->GetPdgCode())!=211) continue;
Bool_t isTrackable = 0;
nLaySigs.Reset(0);
trackRefTree->GetEntry(stack->TreeKEntry(iMC));
Int_t nref=trackRef->GetEntriesFast();
for(Int_t iref =0; iref<nref; iref++){
AliTrackReference *trR = (AliTrackReference*)trackRef->At(iref);
if(!trR) continue;
if(trR->DetectorId()!=AliTrackReference::kITS) continue;
Float_t radPos = trR->R();
hR->Fill(radPos);
for (Int_t il=0; il<rmin.GetSize();il++) {
if (radPos>=rmin.At(il)-0.1 && radPos<=rmax.At(il)+0.1) {
// cout<<" in Layer "<<il<<" "<<radPos;
nLaySigs.AddAt(1.,il);
// cout<<" "<<nLaySigs.At(il)<<endl;
}
}
}
if (nLaySigs.GetSum()>=3) {
isTrackable =1;
// cout<<nLaySigs.GetSum()<<endl;
}
if (isTrackable) {
Double_t ptMC = particle->Pt();
// Double_t etaMC = particle->Eta();
// if (ptMC>ptmin&&ptMC<ptmax) {nTrackableTracks++;hAllMC->Fill(ptMC);}
if (ptMC>ptmin) {nTrackableTracks++;hAllMC->Fill(ptMC);}
}
} // entries tracks MC
printf(" -> trackable MC tracks: %d (%d)\n",nTrackableTracks,hAllMC->GetEntries());
}//entries Events
//.........这里部分代码省略.........
示例11: compClusHitsMod2
//.........这里部分代码省略.........
GetHistoClSize(clsize,kDR,&histoArr)->Fill((rht-rcl)*1e4);
if (cl->TestBit(kSplit)) {
if (col%2) GetHistoClSize(clsize,kDTXoddSPL,&histoArr)->Fill((txyzH[0]-xyzClTr[0])*1e4);
else GetHistoClSize(clsize,kDTXevenSPL,&histoArr)->Fill((txyzH[0]-xyzClTr[0])*1e4);
GetHistoClSize(clsize,kDTZSPL,&histoArr)->Fill((txyzH[2]-xyzClTr[2])*1e4);
GetHistoClSize(0,kNPixSPL,&histoArr)->Fill(clsize);
}
if (col%2) GetHistoClSize(clsize,kDTXodd,&histoArr)->Fill((txyzH[0]-xyzClTr[0])*1e4);
else GetHistoClSize(clsize,kDTXeven,&histoArr)->Fill((txyzH[0]-xyzClTr[0])*1e4);
GetHistoClSize(clsize,kDTZ,&histoArr)->Fill((txyzH[2]-xyzClTr[2])*1e4);
GetHistoClSize(0,kNPixAll,&histoArr)->Fill(clsize);
//
cSum.evID = iEvent;
cSum.volID = cl->GetVolumeId();
cSum.lrID = ilr;
cSum.clID = icl;
cSum.nPix = cl->GetNPix();
cSum.nX = cl->GetNx();
cSum.nZ = cl->GetNz();
cSum.q = cl->GetQ();
cSum.split = cl->TestBit(kSplit);
cSum.dX = (txyzH[0]-xyzClTr[0])*1e4;
cSum.dY = (txyzH[1]-xyzClTr[1])*1e4;
cSum.dZ = (txyzH[2]-xyzClTr[2])*1e4;
cSum.nRowPatt = cl-> GetPatternRowSpan();
cSum.nColPatt = cl-> GetPatternColSpan();
int label = cl->GetLabel(0);
TParticle* part = 0;
if (label>=0 && (part=stack->Particle(label)) ) {
cSum.pdg = part->GetPdgCode();
cSum.eta = part->Eta();
cSum.pt = part->Pt();
cSum.phi = part->Phi();
cSum.prim = stack->IsPhysicalPrimary(label);
}
cSum.ntr = 0;
for (int ilb=0;ilb<3;ilb++) if (cl->GetLabel(ilb)>=0) cSum.ntr++;
for (int i=0;i<3;i++) cSum.xyz[i] = xyzClGloF[i];
//
trOut->Fill();
/*
if (clsize==5) {
printf("\nL%d(%c) Mod%d, Cl:%d | %+5.1f %+5.1f (%d/%d)|H:%e %e %e | C:%e %e %e\n",ilr,cl->TestBit(kSplit) ? 'S':'N',
modID,icl,(txyzH[0]-xyzClTr[0])*1e4,(txyzH[2]-xyzClTr[2])*1e4, row,col,
gxyzH[0],gxyzH[1],gxyzH[2],xyzClGlo[0],xyzClGlo[1],xyzClGlo[2]);
cl->Print();
pHit->Print();
//
double a0,b0,c0,a1,b1,c1,e0;
pHit->GetPositionL0(a0,b0,c0,e0);
pHit->GetPositionL(a1,b1,c1);
float cloc[3];
cl->GetLocalXYZ(cloc);
printf("LocH: %e %e %e | %e %e %e\n",a0,b0,c0,a1,b1,c1);
printf("LocC: %e %e %e | %e %e %e\n",cloc[0],cloc[1],cloc[2],xyzClTr[0],xyzClTr[1],xyzClTr[2]);
}
*/
//
}
}
}
// layerClus.Clear();
//
示例12: MatchComparison
void MatchComparison()
{
//
// Initialize AliRun manager
//
//
// Initialize run loader and load Kinematics
//
AliRunLoader *runLoader = AliRunLoader::Open("galice.root");
if (!runLoader) return;
runLoader->LoadgAlice();
gAlice = runLoader->GetAliRun();
runLoader->LoadKinematics();
//
// Initialize histograms with their error computation
//
TH1D *hgood = new TH1D("hgood", "Well matched tracks", 40, 0.0, 40.0);
TH1D *hfake = new TH1D("hfake", "Fake matched tracks", 40, 0.0, 40.0);
TH1D *htrue = new TH1D("htrue", "True matches" , 40, 0.0, 40.0);
TH1D *hfound = new TH1D("hfound","Found matches" , 40, 0.0, 40.0);
hgood->Sumw2();
hfake->Sumw2();
htrue->Sumw2();
hfound->Sumw2();
//
// Open file containing true matches,
// retrieve the Tree and link to a cursor.
//
TFile *fileTrue = TFile::Open("true-matches.root");
match_t trueMatch;
//
// Open file of found matches,
// link the modified ESD container.
//
TFile *fileFound = TFile::Open("matchESD.root");
TTree *treeFound = (TTree*)fileFound->Get("esdTree");
AliESDEvent* esd = new AliESDEvent();
esd->ReadFromTree(treeFound);
Long64_t nEvents = treeFound->GetEntries();
//
// Loop on all events
//
Int_t im, it, ic, nTrueMatches, nTracks;
Int_t label, trkLabel, cluLabel;
for (Long64_t iev = 0; iev < nEvents; iev++) {
// get true matches tree of given event
TTree *treeTrue = (TTree*)fileTrue->Get(Form("tm_%d", iev));
treeTrue->SetBranchAddress("matches", &trueMatch);
nTrueMatches = treeTrue->GetEntries();
// set TTree pointers to selected event
runLoader->GetEvent(iev);
treeFound->GetEntry(iev);
AliStack *stack = runLoader->Stack();
nTracks = esd->GetNumberOfTracks();
// read all true pairs
for (im = 0; im < nTrueMatches; im++) {
treeTrue->GetEntry(im);
AliESDtrack *track = esd->GetTrack(trueMatch.indexT);
if (!track) continue;
label = TMath::Abs(track->GetLabel());
TParticle *p = stack->Particle(label);
htrue->Fill(p->Pt());
cout <<"filling true"<< endl;
}
// compare found matches
for (Int_t it = 0; it < nTracks; it++) {
AliESDtrack *track = esd->GetTrack(it);
ic = track->GetEMCALcluster();
if (ic == AliEMCALTracker::kUnmatched) continue;
ic = TMath::Abs(ic);
AliESDCaloCluster *cl = esd->GetCaloCluster(ic);
if (!cl) continue;
if (!cl->IsEMCAL()) continue ;
trkLabel = TMath::Abs(track->GetLabel());
cluLabel = cl->GetLabel();
if (trkLabel == cluLabel && trkLabel >= 0) {
TParticle *p = stack->Particle(TMath::Abs(trkLabel));
hgood->Fill(p->Pt());
hfound->Fill(p->Pt());
cout <<"filling GOOD, pt:" << p->Pt()<< endl;
}
else {
TParticle *p = stack->Particle(TMath::Abs(trkLabel));
hfake->Fill(p->Pt());
hfound->Fill(p->Pt());
cout <<"filling FAKE" << endl;
}
}
}
//.........这里部分代码省略.........
示例13: Error
TEveTrackList*
kine_tracks(Double_t min_pt, Double_t min_p,
Bool_t pdg_col, Bool_t recurse,
Bool_t use_track_refs)
{
IlcRunLoader* rl = IlcEveEventManager::AssertRunLoader();
rl->LoadKinematics();
IlcStack* stack = rl->Stack();
if (!stack)
{
Error("kine_tracks", "can not get kinematics.");
return 0;
}
gEve->DisableRedraw();
TEveTrackList* cont = new TEveTrackList("Kine Tracks");
cont->SetMainColor(3);
TEveTrackPropagator* trkProp = cont->GetPropagator();
kine_track_propagator_setup(trkProp);
gEve->AddElement(cont);
Int_t count = 0;
Int_t Np = stack->GetNprimary();
for (Int_t i = 0; i < Np; ++i)
{
TParticle* p = stack->Particle(i);
if (p->GetStatusCode() <= 1)
{
if (p->Pt() < min_pt && p->P() < min_p) continue;
++count;
IlcEveTrack* track = new IlcEveTrack(p, i, trkProp);
//PH The line below is replaced waiting for a fix in Root
//PH which permits to use variable siza arguments in CINT
//PH on some platforms (alphalinuxgcc, solariscc5, etc.)
//PH track->SetName(Form("%s [%d]", p->GetName(), i));
char form[1000];
sprintf(form,"%s [%d]", p->GetName(), i);
track->SetName(form);
track->SetStdTitle();
Int_t ml = p->GetMother(0);
if (ml != -1)
{
track->SetTitle(Form("%s\nMother label=%d\nMother Pdg=%d",
track->GetElementTitle(),
ml, stack->Particle(ml)->GetPdgCode()));
}
set_track_color(track, pdg_col);
gEve->AddElement(track, cont);
if (recurse)
kine_daughters(track, stack, min_pt, min_p, pdg_col, recurse);
}
}
// set path marks
IlcEveKineTools kt;
kt.SetDaughterPathMarks(cont, stack, recurse);
if (use_track_refs && rl->LoadTrackRefs() == 0)
{
kt.SetTrackReferences(cont, rl->TreeTR(), recurse);
trkProp->SetEditPathMarks(kTRUE);
}
kt.SortPathMarks(cont, recurse);
//PH const Text_t* tooltip = Form("min pT=%.2lf, min P=%.2lf), N=%d", min_pt, min_p, count);
char tooltip[1000];
sprintf(tooltip,"min pT=%.2lf, min P=%.2lf), N=%d", min_pt, min_p, count);
cont->SetTitle(tooltip); // Not broadcasted automatically ...
cont->MakeTracks(recurse);
gEve->EnableRedraw();
gEve->Redraw3D();
return cont;
}