本文整理汇总了C++中TProfile::SetDirectory方法的典型用法代码示例。如果您正苦于以下问题:C++ TProfile::SetDirectory方法的具体用法?C++ TProfile::SetDirectory怎么用?C++ TProfile::SetDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TProfile
的用法示例。
在下文中一共展示了TProfile::SetDirectory方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
TVector3 vLje; vLje.SetPtEtaPhi(sortedJets[0].pt(), sortedJets[0].eta(), sortedJets[0].phi());
TVector3 vJet;
int kJrl = -1; double dJrl = -1.;
int kTrl = -1; double dTrl = -1.;
for (int j=0; j<sortedJets.size(); j++) {
double dJet = sortedJets[j].pt();
sortedJets[j].set_user_index(-1);
vJet.SetPtEtaPhi(dJet, sortedJets[j].eta(), sortedJets[j].phi());
if (TMath::Abs(vJet.DeltaPhi(vLje))>dCut) { sortedJets[j].set_user_index(1); if (dJet>dJrl) { dJrl = dJet; kJrl = j; } }
if (TMath::Abs(vJet.DeltaPhi(vLtk))>dCut) { sortedJets[j].set_user_index(2); if (dJet>dTrl) { dTrl = dJet; kTrl = j; } }
}
//=============================================================================
TVector3 v1sj, v2sj;
for (int j=0; j<sortedJets.size(); j++) {
Float_t dVar[kVar]; for (Int_t i=0; i<kVar; i++) dVar[i] = -1.;
dVar[kWgt] = 1.; dVar[kXsc] = 1.;
vJet.SetPtEtaPhi(sortedJets[j].pt(), sortedJets[j].eta(), sortedJets[j].phi());
//=============================================================================
dVar[kLje] = vLje.Pt(); if (sortedJets[j].user_index()==1) { dVar[kLjr] = ((kJrl==j) ? 1.5 : 0.5); }
dVar[kLtk] = vLtk.Pt(); if (sortedJets[j].user_index()==2) { dVar[kLtr] = ((kTrl==j) ? 1.5 : 0.5); }
//=============================================================================
dVar[kJet] = sortedJets[j].pt();
dVar[kAje] = sortedJets[j].area();
dVar[kMje] = sortedJets[j].m();
//=============================================================================
fastjet::Filter trimmer(subjDef, fastjet::SelectorPtFractionMin(0.));
fastjet::PseudoJet trimmdJet = trimmer(sortedJets[j]);
std::vector<fastjet::PseudoJet> trimmdSj = trimmdJet.pieces();
double d1sj = -1.; int k1sj = -1;
double d2sj = -1.; int k2sj = -1;
for (int i=0; i<trimmdSj.size(); i++) {
double dIsj = trimmdSj[i].pt(); if (dIsj<0.001) continue;
if (dIsj>d1sj) {
d2sj = d1sj; k2sj = k1sj;
d1sj = dIsj; k1sj = i;
} else if (dIsj>d2sj) {
d2sj = dIsj; k2sj = i;
}
}
//=============================================================================
if (d1sj>0.) {
v1sj.SetPtEtaPhi(d1sj, trimmdSj[k1sj].eta(), trimmdSj[k1sj].phi());
dVar[k1sz] = d1sj;
dVar[k1sA] = trimmdSj[k1sj].area();
dVar[k1sm] = trimmdSj[k1sj].m();
dVar[k1sr] = v1sj.DeltaR(vJet);
}
if (d2sj>0.) {
v2sj.SetPtEtaPhi(d2sj, trimmdSj[k2sj].eta(), trimmdSj[k2sj].phi());
dVar[k2sz] = d2sj;
dVar[k2sA] = trimmdSj[k2sj].area();
dVar[k2sm] = trimmdSj[k2sj].m();
dVar[k2sr] = v2sj.DeltaR(vJet);
}
if ((d1sj>0.) && (d2sj>0.)) dVar[kDsr] = v2sj.DeltaR(v1sj);
nt->Fill(dVar);
}
}
//=============================================================================
delete evt;
ascii_in >> evt;
}
//=============================================================================
file->cd(); nt->Write(); file->Close();
//=============================================================================
TString sXsec = sFile; sXsec.ReplaceAll("out", "xsecs");
file = TFile::Open(Form("%s/xsecs/%s.root",sPath.Data(),sXsec.Data()), "READ");
TH1D *hPtHat = (TH1D*)file->Get("hPtHat"); hPtHat->SetDirectory(0);
TH1D *hWeightSum = (TH1D*)file->Get("hWeightSum"); hWeightSum->SetDirectory(0);
TProfile *hSigmaGen = (TProfile*)file->Get("hSigmaGen"); hSigmaGen->SetDirectory(0);
file->Close();
//=============================================================================
sFile.ReplaceAll("out", "wgt");
file = TFile::Open(Form("%s.root",sFile.Data()), "NEW");
hPtHat->Write();
hWeightSum->Write();
hSigmaGen->Write();
file->Close();
//=============================================================================
cout << "DONE" << endl;
//=============================================================================
return 0;
}
示例2: main
//.........这里部分代码省略.........
std::vector<fastjet::PseudoJet> fjInput;
const double dMass = TDatabasePDG::Instance()->GetParticle(211)->Mass();
//=============================================================================
TList *list = new TList();
TH1D *hJet = new TH1D("hJet", "", 1000, 0., 1000.); hJet->Sumw2(); list->Add(hJet);
enum { kJet, kMje, kDsz, kIsm, kZsm, kDsr, kVar };
const TString sHist[] = { "aJet", "aMje", "aDsz", "aIsm", "aZsm", "aDsr" };
const Int_t nv[] = { 1000, 150, 120, 150, 150, 500 };
const Double_t dMin[] = { 0., 0., 0., 0., 0., 0. };
const Double_t dMax[] = { 1000., 150., 1.2, 150., 1.5, 5. };
THnSparseD *hs = new THnSparseD("hs", "", kVar, nv, dMin, dMax); hs->Sumw2();
for (Int_t i=0; i<kVar; i++) hs->GetAxis(i)->SetName(sHist[i].Data()); list->Add(hs);
//=============================================================================
HepMC::IO_GenEvent ascii_in(Form("%s/%s.hepmc",sPath.Data(),sFile.Data()), std::ios::in);
HepMC::GenEvent *evt = ascii_in.read_next_event();
while (evt) {
fjInput.resize(0);
TLorentzVector vPar;
for (HepMC::GenEvent::particle_const_iterator p=evt->particles_begin(); p!=evt->particles_end(); ++p) if ((*p)->status()==1) {
vPar.SetPtEtaPhiM((*p)->momentum().perp(), (*p)->momentum().eta(), (*p)->momentum().phi(), dMass);
if ((TMath::Abs(vPar.Eta())<dCutEtaMax)) {
fjInput.push_back(fastjet::PseudoJet(vPar.Px(), vPar.Py(), vPar.Pz(), vPar.E()));
}
}
//=============================================================================
fastjet::ClusterSequenceArea clustSeq(fjInput, jetsDef, areaDef);
std::vector<fastjet::PseudoJet> includJets = clustSeq.inclusive_jets(dJetsPtMin);
// std::vector<fastjet::PseudoJet> subtedJets = bkgSubtractor(includJets);
std::vector<fastjet::PseudoJet> selectJets = selectJet(includJets);
// std::vector<fastjet::PseudoJet> sortedJets = fastjet::sorted_by_pt(selectJets);
for (int j=0; j<selectJets.size(); j++) {
double dJet = selectJets[j].pt();
hJet->Fill(dJet);
//=============================================================================
fastjet::Filter trimmer(subjDef, fastjet::SelectorPtFractionMin(0.));
fastjet::PseudoJet trimmdJet = trimmer(selectJets[j]);
std::vector<fastjet::PseudoJet> trimmdSj = trimmdJet.pieces();
double d1sj = -1.; int k1sj = -1;
double d2sj = -1.; int k2sj = -1;
for (int i=0; i<trimmdSj.size(); i++) {
double dIsj = trimmdSj[i].pt(); if (dIsj<0.001) continue;
if (dIsj>d1sj) {
d2sj = d1sj; k2sj = k1sj;
d1sj = dIsj; k1sj = i;
} else if (dIsj>d2sj) {
d2sj = dIsj; k2sj = i;
}
}
if ((d1sj>0.) && (d2sj>0.)) {
TLorentzVector v1sj; v1sj.SetPtEtaPhiM(d1sj, trimmdSj[k1sj].eta(), trimmdSj[k1sj].phi(), trimmdSj[k1sj].m());
TLorentzVector v2sj; v2sj.SetPtEtaPhiM(d2sj, trimmdSj[k2sj].eta(), trimmdSj[k2sj].phi(), trimmdSj[k2sj].m());
TLorentzVector vIsj = v1sj + v2sj;
Double_t dIsm = vIsj.M();
Double_t dMje = selectJets[j].m();
Double_t dVar[] = { dJet, dMje, (d1sj-d2sj)/dJet, dIsm, dIsm/dMje, v1sj.DeltaR(v2sj)/2./dJetR };
hs->Fill(dVar);
}
}
//=============================================================================
delete evt;
ascii_in >> evt;
}
//=============================================================================
TString sXsec = sFile; sXsec.ReplaceAll("out", "xsecs");
TFile *file = TFile::Open(Form("%s/xsecs/%s.root",sPath.Data(),sXsec.Data()), "READ");
TH1D *hPtHat = (TH1D*)file->Get("hPtHat"); hPtHat->SetDirectory(0);
TH1D *hWeightSum = (TH1D*)file->Get("hWeightSum"); hWeightSum->SetDirectory(0);
TProfile *hSigmaGen = (TProfile*)file->Get("hSigmaGen"); hSigmaGen->SetDirectory(0);
file->Close();
//=============================================================================
file = TFile::Open(Form("%s.root",sFile.Data()), "NEW");
hPtHat->Write();
hWeightSum->Write();
hSigmaGen->Write();
list->Write();
file->Close();
//=============================================================================
cout << "DONE" << endl;
return 0;
}
示例3: FillVZEROEPOADBFull
void FillVZEROEPOADBFull(const char* filename = "AOD083.txt", Bool_t mbOnly = kFALSE)
{
gSystem->Load("libCore");
gSystem->Load("libTree");
gSystem->Load("libGeom");
gSystem->Load("libVMC");
gSystem->Load("libPhysics");
gSystem->Load("libMinuit");
gSystem->Load("libSTEERBase");
gSystem->Load("libESD");
gSystem->Load("libAOD");
gSystem->Load("libANALYSIS");
gSystem->Load("libANALYSISalice");
gSystem->Load("libOADB");
AliOADBContainer * oadbCont = new AliOADBContainer("vzeroEP");
{
TList *defaultList = new TList;
defaultList->SetName("Default");
TProfile *profHisto = NULL;
TFile fInputDefault("minbias/VZERO.EPFlatenning.PS.LHC11h_AOD083_000170162.root");
TList *inputList = (TList*)fInputDefault.Get("coutput");
for(Int_t i = 0; i < 11; ++i) {
profHisto = (TProfile*)inputList->FindObject(Form("fX2_%d",i))->Clone(Form("fX2_%d",i));
profHisto->SetDirectory(0);
defaultList->Add(profHisto);
profHisto = (TProfile*)inputList->FindObject(Form("fY2_%d",i))->Clone(Form("fY2_%d",i));
profHisto->SetDirectory(0);
defaultList->Add(profHisto);
profHisto = (TProfile*)inputList->FindObject(Form("fX2Y2_%d",i))->Clone(Form("fX2Y2_%d",i));
profHisto->SetDirectory(0);
defaultList->Add(profHisto);
profHisto = (TProfile*)inputList->FindObject(Form("fCos8Psi_%d",i))->Clone(Form("fCos8Psi_%d",i));
profHisto->SetDirectory(0);
defaultList->Add(profHisto);
}
fInputDefault.Close();
oadbCont->AddDefaultObject(defaultList);
printf("Run 170162 filled\n");
}
{
TList *list1 = new TList;
TProfile *profHisto = NULL;
TFile fInput1("minbias/VZERO.EPFlatenning.PS.LHC11h_AOD083_000169683.root");
TList *inputList = (TList*)fInput1.Get("coutput");
for(Int_t i = 0; i < 11; ++i) {
profHisto = (TProfile*)inputList->FindObject(Form("fX2_%d",i))->Clone(Form("fX2_%d",i));
profHisto->SetDirectory(0);
list1->Add(profHisto);
profHisto = (TProfile*)inputList->FindObject(Form("fY2_%d",i))->Clone(Form("fY2_%d",i));
profHisto->SetDirectory(0);
list1->Add(profHisto);
profHisto = (TProfile*)inputList->FindObject(Form("fX2Y2_%d",i))->Clone(Form("fX2Y2_%d",i));
profHisto->SetDirectory(0);
list1->Add(profHisto);
profHisto = (TProfile*)inputList->FindObject(Form("fCos8Psi_%d",i))->Clone(Form("fCos8Psi_%d",i));
profHisto->SetDirectory(0);
list1->Add(profHisto);
}
oadbCont->AppendObject(list1, 169683, 169683);
printf("Run 169683 filled\n");
}
// loop of over all other runs
Int_t runList[500];
ifstream *fruns = new ifstream (filename);
if (!*fruns) return;
TString strLine;
Int_t count = 0;
while (strLine.ReadLine(*fruns)) {
runList[count++] = strLine.Atoi();
}
delete fruns;
for(Int_t irun = 0; irun < count; ++irun) {
TList *list2 = new TList;
TProfile *profHisto = NULL;
TFile fInput2(Form("csemi/VZERO.EPFlatenning.PS.LHC11h_AOD083_000%d.root",runList[irun]));
TList *inputList = (TList*)fInput2.Get("coutput");
TFile fInput3(Form("cpbi2/VZERO.EPFlatenning.PS.LHC11h_AOD083_000%d.root",runList[irun]));
TList *inputListBis = (TList*)fInput3.Get("coutput");
for(Int_t i = 0; i < 11; ++i) {
profHisto = (TProfile*)inputList->FindObject(Form("fX2_%d",i))->Clone(Form("fX2_%d",i));
profHisto->SetDirectory(0);
Int_t ibin = profHisto->FindBin(62.5);
profHisto->SetBinContent(ibin,0);
profHisto->SetBinError(ibin,0);
profHisto->SetBinEntries(ibin,0);
if (mbOnly) {
profHisto = (TProfile*)inputListBis->FindObject(Form("fX2_%d",i))->Clone(Form("fX2_%d",i));
profHisto->SetDirectory(0);
}
else
profHisto->Add((TProfile*)inputListBis->FindObject(Form("fX2_%d",i)));
list2->Add(profHisto);
profHisto = (TProfile*)inputList->FindObject(Form("fY2_%d",i))->Clone(Form("fY2_%d",i));
profHisto->SetDirectory(0);
//.........这里部分代码省略.........
示例4: main
//.........这里部分代码省略.........
TH2D *hL1j2sz = new TH2D("hL1j2sz", "", 2000, 0., 1000., 120, 0., 1.2); hL1j2sz->Sumw2(); list->Add(hL1j2sz);
TH2D *hL1jDsz = new TH2D("hL1jDsz", "", 2000, 0., 1000., 120, 0., 1.2); hL1jDsz->Sumw2(); list->Add(hL1jDsz);
TH2D *hL2jIsz = new TH2D("hL2jIsz", "", 2000, 0., 1000., 120, 0., 1.2); hL2jIsz->Sumw2(); list->Add(hL2jIsz);
TH2D *hL2j1sz = new TH2D("hL2j1sz", "", 2000, 0., 1000., 120, 0., 1.2); hL2j1sz->Sumw2(); list->Add(hL2j1sz);
TH2D *hL2j2sz = new TH2D("hL2j2sz", "", 2000, 0., 1000., 120, 0., 1.2); hL2j2sz->Sumw2(); list->Add(hL2j2sz);
TH2D *hL2jDsz = new TH2D("hL2jDsz", "", 2000, 0., 1000., 120, 0., 1.2); hL2jDsz->Sumw2(); list->Add(hL2jDsz);
//=============================================================================
HepMC::IO_GenEvent ascii_in(Form("%s/%s.hepmc",sPath.Data(),sFile.Data()), std::ios::in);
HepMC::GenEvent *evt = ascii_in.read_next_event();
while (evt) {
fjInput.resize(0);
TVector3 vPar;
for (HepMC::GenEvent::particle_const_iterator p=evt->particles_begin(); p!=evt->particles_end(); ++p) if ((*p)->status()==1) {
vPar.SetXYZ((*p)->momentum().px(), (*p)->momentum().py(), (*p)->momentum().pz());
if ((TMath::Abs(vPar.Eta())<dCutEtaMax)) {
fjInput.push_back(fastjet::PseudoJet(vPar.Px(), vPar.Py(), vPar.Pz(), vPar.Mag()));
}
}
//=============================================================================
fastjet::ClusterSequenceArea clustSeq(fjInput, jetsDef, areaDef);
std::vector<fastjet::PseudoJet> includJets = clustSeq.inclusive_jets(dJetsPtMin);
// std::vector<fastjet::PseudoJet> subtedJets = bkgSubtractor(includJets);
std::vector<fastjet::PseudoJet> selectJets = selectJet(includJets);
std::vector<fastjet::PseudoJet> sortedJets = fastjet::sorted_by_pt(selectJets);
for (int j=0; j<sortedJets.size(); j++) {
double dJet = sortedJets[j].pt();
hJet->Fill(dJet);
if (j==0) hL1j->Fill(dJet);
if (j==1) hL2j->Fill(dJet); if (j>1) continue;
//=============================================================================
fastjet::Filter trimmer(subjDef, fastjet::SelectorPtFractionMin(0.));
fastjet::PseudoJet trimmdJet = trimmer(sortedJets[j]);
std::vector<fastjet::PseudoJet> trimmdSj = trimmdJet.pieces();
double nIsj = 0.;
double d1sj = -1., d2sj = -1.;
for (int i=0; i<trimmdSj.size(); i++) {
double dIsj = trimmdSj[i].pt(); if (dIsj<0.001) continue;
if (j==0) { hL1jIsj->Fill(dJet, dIsj); hL1jIsz->Fill(dJet, dIsj/dJet); }
if (j==1) { hL2jIsj->Fill(dJet, dIsj); hL2jIsz->Fill(dJet, dIsj/dJet); }
if (dIsj>d1sj) { d2sj = d1sj; d1sj = dIsj; } else if (dIsj>d2sj) { d2sj = dIsj; }
nIsj += 1.;
}
if (j==0) hL1jNsj->Fill(dJet, nIsj);
if (j==1) hL2jNsj->Fill(dJet, nIsj);
if (d1sj>0.) {
if (j==0) { hL1j1sj->Fill(dJet, d1sj); hL1j1sz->Fill(dJet, d1sj/dJet); }
if (j==1) { hL2j1sj->Fill(dJet, d1sj); hL2j1sz->Fill(dJet, d1sj/dJet); }
}
if (d2sj>0.) {
if (j==0) { hL1j2sj->Fill(dJet, d2sj); hL1j2sz->Fill(dJet, d2sj/dJet); }
if (j==1) { hL2j2sj->Fill(dJet, d2sj); hL2j2sz->Fill(dJet, d2sj/dJet); }
}
if ((d1sj>0.) && (d2sj>0.)) {
double dsj = d1sj - d2sj;
if (j==0) { hL1jDsj->Fill(dJet, dsj); hL1jDsz->Fill(dJet, dsj/dJet); }
if (j==1) { hL2jDsj->Fill(dJet, dsj); hL2jDsz->Fill(dJet, dsj/dJet); }
}
}
//=============================================================================
delete evt;
ascii_in >> evt;
}
//=============================================================================
TString sXsec = sFile; sXsec.ReplaceAll("out", "xsecs");
TFile *file = TFile::Open(Form("%s/xsecs/%s.root",sPath.Data(),sXsec.Data()), "READ");
TH1D *hPtHat = (TH1D*)file->Get("hPtHat"); hPtHat->SetDirectory(0);
TH1D *hWeightSum = (TH1D*)file->Get("hWeightSum"); hWeightSum->SetDirectory(0);
TProfile *hSigmaGen = (TProfile*)file->Get("hSigmaGen"); hSigmaGen->SetDirectory(0);
file->Close();
//=============================================================================
file = TFile::Open(Form("%s.root",sFile.Data()), "NEW");
hPtHat->Write();
hWeightSum->Write();
hSigmaGen->Write();
list->Write();
file->Close();
//=============================================================================
cout << "DONE" << endl;
return 0;
}