本文整理汇总了C++中TKey::GetTitle方法的典型用法代码示例。如果您正苦于以下问题:C++ TKey::GetTitle方法的具体用法?C++ TKey::GetTitle怎么用?C++ TKey::GetTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TKey
的用法示例。
在下文中一共展示了TKey::GetTitle方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ZinvMaker
//_______________________________________________________________________________
void ZinvMaker(string input_dir = "/home/users/bemarsh/analysis/mt2/current/MT2Analysis/MT2Looper/output/V00-10-07_combined_HEMveto"){
input_dir = "/home/users/bemarsh/analysis/mt2/current/MT2Analysis/MT2Looper/output/V00-10-16_combined";
// input_dir = "/home/users/bemarsh/analysis/mt2/current/MT2Analysis/MT2Looper/output/V00-10-11_2018fullYear_with2018MC";
// input_dir = "/home/users/bemarsh/analysis/mt2/current/MT2Analysis/MT2Looper/output/V00-10-07_pred2016withFullCR";
// input_dir = "/home/users/bemarsh/analysis/mt2/current/MT2Analysis/MT2Looper/output/V00-10-07_unblinded1718";
// string input_dir = "/home/users/olivito/MT2Analysis/MT2looper/output/V00-00-08_fullstats/";
// string input_dir = "../MT2looper/output/2015ExtendedNJets/";
//string input_dir = "../MT2looper/output/2015LowLumi/";
string output_name = input_dir+"/zinvFromGJ.root";
// ----------------------------------------
// samples definition
// ----------------------------------------
std::cout << "Writing to file: " << output_name << std::endl;
// get input files
TFile* f_data = new TFile(Form("%s/data_RunAll.root",input_dir.c_str()));
TFile* f_zinv = new TFile(Form("%s/zinv_ht_2018.root",input_dir.c_str()));
TFile* f_gjet = new TFile(Form("%s/gjets_dr0p05_ht.root",input_dir.c_str()));
//TFile* f_qcd = new TFile(Form("%s/qcd_pt.root",input_dir.c_str()));
TFile* f_dy = new TFile(Form("%s/dyjetsll_ht.root",input_dir.c_str()));
TFile* f_top = new TFile(Form("%s/top.root",input_dir.c_str()));
//TFile* f_dy = new TFile(Form("%s/dyjetsll_incl.root",input_dir.c_str()));
// if(f_zinv->IsZombie() || f_gjet->IsZombie()) {
if(f_zinv->IsZombie()) {
std::cerr << "Input file does not exist" << std::endl;
return;
}
vector<string> dirs;
//Loop through list of every directory in the signal file.
//if directory begins with "sr", excluding "srbase", add it to vector signal regions.
TIter it(f_zinv->GetListOfKeys());
TKey* k;
std::string keep = "sr";
std::string skip = "srbase";
while ((k = (TKey *)it())) {
// if (strncmp (k->GetTitle(), skip.c_str(), skip.length()) == 0) continue;
// if (strncmp (k->GetTitle(), skip.c_str(), skip.length()) != 0) continue;
if (strncmp (k->GetTitle(), keep.c_str(), keep.length()) == 0
) {//it is a signal region
std::string sr_string = k->GetTitle();
sr_string.erase(0, 2);//remove "sr" from front of string
dirs.push_back(sr_string);
}
}
// //makeZinvFromGJets( f_zinv , f_gjet , f_qcd, dirs, dirsGJ, output_name, 0 );
// makeZinvFromGJets( f_zinv , f_gjet , f_dy ,dirs, output_name, 1.23 ); // not using QCD for now
output_name = input_dir+"/zinvFromDY_2018.root";
makeZinvFromDY( f_data, f_zinv , f_dy , f_top, dirs, output_name );
}
示例2: printCutflowData
void printCutflowData(string s) {
TFile* f = TFile::Open(s.c_str());
TList * AllKeys=f->GetListOfKeys();
int NKeys = AllKeys->GetEntries();
//cout << NKeys << endl;
TIter next(AllKeys);
TKey *key;
vector<TKey* > cutflowKeys;
for(int i =0 ; i < NKeys ; i++)
{
key=(TKey*)next();
string name = key->GetTitle();
if(name.find("CutFlow") != std::string::npos)
{
cutflowKeys.push_back(key);
//cout << name << endl;
}
}
TCanvas * c1 = new TCanvas;
TH1F *h = (TH1F*)cutflowKeys[0]->ReadObj();
for(int i=1; i<cutflowKeys.size();i++)
{
TH1F *temp = (TH1F*)cutflowKeys[i]->ReadObj();
h->Add(temp);
}
int Ndecimals = 2;
enum CutEnum {
NxAOD=0, NDxAOD=1, ALLEVTS=2, DUPLICATE=3, TRIGGER=4, GRL=5, DQ=6, VERTEX=7, TWO_LOOSE_GAM=8, AMBIGUITY=9,
TRIG_MATCH=10, GAM_TIGHTID=11, GAM_ISOLATION=12, RELPTCUTS=13, MASSCUT=14, PASSALL=15 };
TString format(" %-24s%10."); format+=Ndecimals; format+="f%11.2f%%%11.2f%%\n";
int all_bin = h->FindBin(ALLEVTS);
printf(" %-24s%10s%12s%12s\n","Event selection","Nevents","Cut rej.","Tot. eff.");
for (int bin=1;bin<=h->GetNbinsX();++bin) {
double ntot=h->GetBinContent(all_bin), n=h->GetBinContent(bin), nprev=h->GetBinContent(bin-1);
TString cutName(h->GetXaxis()->GetBinLabel(bin));
cutName.ReplaceAll("#it{m}_{#gamma#gamma}","m_yy");
if (bin==1||nprev==0||n==nprev)
printf(format.Data(),cutName.Data(),n,-1e-10,n/ntot*100);
else // if the cut does something, print more information
printf(format.Data(),cutName.Data(),n,(n-nprev)/nprev*100,n/ntot*100);
}
}
示例3: ReadHist
void ReadHist(TString currFName){
TFile *currFile = TFile::Open( currFName.Data(),"READONLY" );
TIter next( gDirectory->GetListOfKeys() ); //-dir-content--
Int_t oncePRsum=0;
//--reading-flow-histograms-from-ROOT-file-------------(begin)----
TKey *key;
while( (key = (TKey*)next()) ){
//cout << " Classname " << key->GetClassName() << endl;
//cout << " Name " << key->GetName() << endl;
//cout << " Title " << key->GetTitle() << endl;
printf("Class=%s Name=%s Title=\"%s\"\n", key->GetClassName(), key->GetName(), key->GetTitle());
TObject *obj = key->ReadObj();
if ( obj->IsA()->InheritsFrom( TH1::Class() ) ) {
TH1 *h = (TH1*)obj;
//h = (TH1*)obj;
//h->Draw();
//c.Update();
sscanf(key->GetTitle(), "%s %i %s %i %s %i" , ch1, &iC, ch2, &iY, ch3, &iPt);
//printf("%s - %i - %s - %i\n", ch1, iC, ch2, iY);
TString s(key->GetName());
if( s.Contains("hPhiPRp") ){ //hPhiPRp
printf("[PR]--%s[%i]%s[%i]%s[%i]--->\n",ch1,iC, ch2,iY, ch3,iPt);
hPhiPR[iC][iY][iPt] = new TH1F;
hPhiPR[iC][iY][iPt] = (TH1F*)obj;
}
if( s.Contains("hPhiABp") ){ //hPhiABp
printf("[AB]--%s[%i]%s[%i]%s[%i]--->\n",ch1,iC, ch2,iY, ch3,iPt);
hPhiAB[iC][iY][iPt] = new TH1F;
hPhiAB[iC][iY][iPt] = (TH1F*)obj;
}
if( s.Contains("hPhiEPp") ){ //hPhiEPp
printf("[EP]--%s[%i]%s[%i]%s[%i]--->\n",ch1,iC, ch2,iY, ch3,iPt);
hPhiEP[iC][iY][iPt] = new TH1F;
hPhiEP[iC][iY][iPt] = (TH1F*)obj;
}
if( s.Contains("hMulTrp") ){ //hMulTrp
printf("[Tr]--%s[%i]%s[%i]%s[%i]--->\n",ch1,iC, ch2,iY, ch3,iPt);
hMulTr[iC][iY][iPt] = new TH1F;
hMulTr[iC][iY][iPt] = (TH1F*)obj;
}
}
}
}
示例4: nextkey
NoiseEvolution(char* path_, char* RunsList_){
GetRuns(path_,RunsList_);
//Open Reference File
sprintf(refFile,"%s/Display_PedNoise_RunNb_%d.root",path,iov[0]);
cout << "\nReference File " << refFile << endl;
refFile_= new TRFIOFile(refFile);
//Get Histo Names
refFile_->cd("Noises");
TIter nextkey(gDirectory->GetListOfKeys());
TKey *key;
while (key = (TKey*)nextkey()) {
const char * title;
title=key->GetTitle();
if (strncmp(title,"Noises_",6)==0 && strstr(title,"Cumulative")== NULL){
vHistoNames.push_back(string(title));
vHistoNBinsX.push_back(((TH1F*)key->ReadObj())->GetNbinsX());
char tmp[128];
LayerName(title,tmp);
string tmp1(tmp);
int i=0;
while (i<vLayerName.size() && tmp1!=vLayerName[i]){i++;}
if (i==vLayerName.size())
vLayerName.push_back(tmp1);
}
}
book();
for (int i=1;i<iovDim;i++){
sprintf(inFile,"%s/Display_PedNoise_RunNb_%d.root",path,iov[i]);
cout << "\nAnalyzing File " << inFile << endl;
inFile_= new TRFIOFile(inFile);
loop(iov[i]);
}
save();
}
示例5: dir
prepDataFiles(){
// TDirectory *theDr = (TDirectory*) myFile->Get("eleIDdir");///denom_pt/fit_eff_plots");
//theDr->ls();
int myIndex;
TSystemDirectory dir(thePath, thePath);
TSystemFile *file;
TString fname;
TIter next(dir.GetListOfFiles());
while ((file=(TSystemFile*)next())) {
fname = file->GetName();
if (fname.BeginsWith("TnP")&& fname.Contains("mc")) {
ofstream myfile;
TFile *myFile = new TFile(fname);
TIter nextkey(myFile->GetListOfKeys());
TKey *key;
while (key = (TKey*)nextkey()) {
TString theTypeClasse = key->GetClassName();
TString theNomClasse = key->GetTitle();
if ( theTypeClasse == "TDirectoryFile"){
TDirectory *theDr = (TDirectory*) myFile->Get(theNomClasse);
TIter nextkey2(theDr->GetListOfKeys());
TKey *key2;
while (key2 = (TKey*)nextkey2()) {
TString theTypeClasse2 = key2->GetClassName();
TString theNomClasse2 = key2->GetTitle();
myfile.open (theNomClasse2+".info");
if ( theTypeClasse == "TDirectoryFile"){
cout << "avant " << endl;
TDirectory *theDr2 = (TDirectory*) myFile->Get(theNomClasse+"/"+theNomClasse2);
cout << "apres " << endl;
TIter nextkey3(theDr2->GetListOfKeys());
TKey *key3;
while (key3 = (TKey*)nextkey3()) {
TString theTypeClasse3 = key3->GetClassName();
TString theNomClasse3 = key3->GetTitle();
if ((theNomClasse3.Contains("FromMC"))) {
TString localClasse3 = theNomClasse3;
localClasse3.ReplaceAll("__","%");
cout << "apres " << localClasse3 << endl;
TObjArray* listBin = localClasse3.Tokenize('%');
TString first = ((TObjString*)listBin->At(0))->GetString();
TString second = ((TObjString*)listBin->At(2))->GetString();
myfile << first;
myfile << " " << second << " ";
cout << "coucou la on va récupérer le rooFitResult " << endl;
RooFitResult *theResults = (RooFitResult*) myFile->Get(theNomClasse+"/"+theNomClasse2+"/"+theNomClasse3+"/fitresults");
theResults->Print();
RooArgList theParam = theResults->floatParsFinal();
int taille = theParam.getSize();
for (int m = 0 ; m < taille ; m++){
cout << "m=" << m << endl;
RooAbsArg *theArg = (RooAbsArg*) theParam.at(m);
RooAbsReal *theReal = (RooAbsReal*) theArg;
myfile << theReal->getVal() << " " ;
}
myfile << "\n";
}
}
}
myfile.close();
}
}
}
delete myFile;
}
}
}
示例6: MakePlots
void MakePlots(TString filename, float zmax=30, int nSmooth=10, TString opt="", TString energy="8TeV", TString lumi=""){
TString outDir=filename; outDir.Remove(outDir.Last('/')); outDir+="/img/"+opt;
//outDir="tmp/k5b/";
//std::map<TString, TH2F *> deltaNLL_map;
/*------------------------------ Plotto */
TCanvas *c = new TCanvas("c","c");
TFile f_in(filename, "read");
if(f_in.IsZombie()){
std::cerr << "File opening error: " << filename << std::endl;
return;
}
TList *KeyList = f_in.GetListOfKeys();
std::cout << KeyList->GetEntries() << std::endl;
for(int i =0; i < KeyList->GetEntries(); i++){
c->Clear();
TKey *key = (TKey *)KeyList->At(i);
if(TString(key->GetClassName())!="RooDataSet") continue;
RooDataSet *dataset = (RooDataSet *) key->ReadObj();
if(dataset==NULL){
std::cerr << "[WARNING] No dataset for " << key->GetName() << "\t" << key->GetTitle() << std::endl;
continue;
}
TString constTermName = dataset->GetName();
TString alphaName=constTermName; alphaName.ReplaceAll("constTerm","alpha");
if(constTermName.Contains("absEta_1_1.4442-gold")) continue;
if(constTermName.Contains("rho") || constTermName.Contains("phi")) continue;
if(constTermName.Contains("scale")) continue;
TTree *tree = dataset2tree(dataset);
TGraphErrors bestFit_ = bestFit(tree, alphaName, constTermName);
// TString binning="(241,-0.0005,0.2405,60,0.00025,0.03025)";
TString binning="(241,-0.0005,0.2405,301,-0.00005,0.03005)";
TH2F *hist = prof2d(tree, constTermName, alphaName, "nll", binning, true,nSmooth, opt);
// std::cout << "Bin width = " << hist->GetXaxis()->GetBinWidth(10) << "\t" << hist->GetYaxis()->GetBinWidth(10) << std::endl;
// std::cout << "Bin 1 center = " << hist->GetXaxis()->GetBinCenter(1) << "\t" << hist->GetYaxis()->GetBinCenter(1) << std::endl;
// std::cout << "Bin 10 center = " << hist->GetXaxis()->GetBinCenter(10) << "\t" << hist->GetYaxis()->GetBinCenter(10) << std::endl;
// return;
hist->Draw("colz");
hist->GetZaxis()->SetRangeUser(0,zmax);
hist->GetXaxis()->SetRangeUser(0,0.15);
hist->GetYaxis()->SetRangeUser(0,0.018);
hist->GetXaxis()->SetTitle("#Delta S");
hist->GetYaxis()->SetTitle("#Delta C");
Int_t iBinX, iBinY;
Double_t x,y;
hist->GetBinWithContent2(0.0002,iBinX,iBinY,1,-1,1,-1,0.0000001);
x= hist->GetXaxis()->GetBinCenter(iBinX);
y= hist->GetYaxis()->GetBinCenter(iBinY);
std::cout << "Best Fit: " << x << "\t" << y << std::endl;
TGraph nllBestFit(1,&x,&y);
TString fileName=outDir+"/"+constTermName;
fileName+="-"; fileName+=nSmooth;
nllBestFit.SetMarkerStyle(3);
nllBestFit.SetMarkerColor(kRed);
nllBestFit.Draw("P same");
std::cout << fileName << std::endl;
ofstream fout(fileName+".dat", ios_base::app);
fout << constTermName << "\t" << x << "\t" << y << std::endl;
c->SaveAs(fileName+".png");
c->SaveAs(fileName+".eps");
if(fileName.Contains("constTerm")) c->SaveAs(fileName+".C");
fileName+="-zoom";
hist->GetZaxis()->SetRangeUser(0,1);
//hist->GetXaxis()->SetRangeUser(0.00,0.12);
//hist->GetYaxis()->SetRangeUser(0,0.005);
c->SaveAs(fileName+".png");
c->SaveAs(fileName+".eps");
// hist->SaveAs(outDir+"/deltaNLL-"+constTermName+".root");
// hist->Draw("colz");
// bestFit_.Draw("P same");
// bestFit_.SetMarkerSize(2);
// nllBestFit.SetMarkerStyle(3);
// nllBestFit.SetMarkerColor(kRed);
// TList* contour68 = contourFromTH2(hist, 0.68);
// hist->Draw("colz");
// hist->GetZaxis()->SetRangeUser(0,zmax);
// //bestFit_.Draw("P same");
// nllBestFit.Draw("P same");
// //contour68->Draw("same");
delete hist;
RooAbsPdf *histPdf = NULL;
if(!opt.Contains("keys")){
//.........这里部分代码省略.........
示例7: dir
recupTheZpeak(){
// TDirectory *theDr = (TDirectory*) myFile->Get("eleIDdir");///denom_pt/fit_eff_plots");
//theDr->ls();
int myIndex;
TSystemDirectory dir(thePath, thePath);
TSystemFile *file;
TString fname;
TIter next(dir.GetListOfFiles());
while ((file=(TSystemFile*)next())) {
fname = file->GetName();
if (fname.BeginsWith("TnP")) {
if (fname.Contains("data")) kind = "data";
else kind = "mc";
bool pass = false;
for (int p = 0 ; p< nbOfIds ; p++){
if (fname.Contains(thePlotToDraw[p])) {
pass = true;
theIndex = p;
break;
}
}
if (!(pass)) continue;
TFile *myFile = new TFile(fname);
TIter nextkey(myFile->GetListOfKeys());
TKey *key;
while (key = (TKey*)nextkey()) {
TString theTypeClasse = key->GetClassName();
TString theNomClasse = key->GetTitle();
if ( theTypeClasse == "TDirectoryFile"){
TDirectory *theDr = (TDirectory*) myFile->Get(theNomClasse);
TIter nextkey2(theDr->GetListOfKeys());
TKey *key2;
while (key2 = (TKey*)nextkey2()) {
TString theTypeClasse2 = key2->GetClassName();
TString theNomClasse2 = key2->GetTitle();
if ( theTypeClasse == "TDirectoryFile"){
TDirectory *theDr2 = (TDirectory*) myFile->Get(theNomClasse+"/"+theNomClasse2);
TIter nextkey3(theDr2->GetListOfKeys());
TKey *key3;
while (key3 = (TKey*)nextkey3()) {
TString theTypeClasse3 = key3->GetClassName();
TString theNomClasse3 = key3->GetTitle();
if (((theNomClasse3.Contains("vpvPlusExpo"))||(theNomClasse3.Contains("higgsSF")))&&(!(theNomClasse3.Contains("all")))) {
TCanvas *theCanvas = (TCanvas*) myFile->Get(theNomClasse+"/"+theNomClasse2+"/"+theNomClasse3+"/fit_canvas");
theCanvas->Print(outputDir+"/"+kind+"_"+theName[theIndex]+"__"+theNomClasse3+".png");
}
}
}
}
}
}
delete myFile;
}
}
}
示例8: recupThePlots
void recupThePlots(){
// TDirectory *theDr = (TDirectory*) myFile->Get("eleIDdir");///denom_pt/fit_eff_plots");
//theDr->ls();
cout << "coucou" << theOutFileName << endl;
TFile *myOutFile = new TFile(theOutFileName,"RECREATE");
TSystemDirectory dir(thePath, thePath);
TSystemFile *file;
TString fname;
TIter next(dir.GetListOfFiles());
while (((file=(TSystemFile*)next()))) {
fname = file->GetName();
if ((fname.BeginsWith("TnP"))&&fname.Contains("data")) {
cout << "--------------------"<< "\n";
cout << fname << "\n";
TFile *myFile = new TFile(fname);
TIter nextkey(myFile->GetListOfKeys());
TKey *key;
while ((key = (TKey*)nextkey())) {
// cout << key << "\n";
TString theTypeClasse = key->GetClassName();
TString theNomClasse = key->GetTitle();
cout << "theTypeClasse: "<< theTypeClasse << " , " << theNomClasse << "\n";
if ( theTypeClasse == "TDirectoryFile" ){
// cout << "we are here 1" << "\n";
TDirectory *theDr = (TDirectory*) myFile->Get(theNomClasse);
TIter nextkey2(theDr->GetListOfKeys());
TKey *key2;
while ((key2 = (TKey*)nextkey2())) {
TString theTypeClasse2 = key2->GetClassName();
TString theNomClasse2 = key2->GetTitle();
if ( theTypeClasse == "TDirectoryFile" || theTypeClasse == "TGraphAsymmErrors" ){
TDirectory *theDr2 = (TDirectory*) myFile->Get(theNomClasse+"/"+theNomClasse2+"/fit_eff_plots");
TIter nextkey3(theDr2->GetListOfKeys());
TKey *key3;
while ((key3 = (TKey*)nextkey3())) {
TString theTypeClasse3 = key3->GetClassName();
TString theNomClasse3 = key3->GetName();
cout << "type = " << theTypeClasse3 << " nom = " << theNomClasse3 << endl;
TCanvas *theCanvas = (TCanvas*) myFile->Get(theNomClasse+"/"+theNomClasse2+"/fit_eff_plots/"+theNomClasse3);
TIter nextObject(theCanvas->GetListOfPrimitives());
TObject *obj;
while ((obj = (TObject*)nextObject())) {
if (obj->InheritsFrom("TGraphAsymmErrors")) {
cout << "histo: " << obj->GetName() << endl;
myOutFile->cd();
obj->Write(theNomClasse2+"_"+theNomClasse3);
myFile->cd();
}
if (obj->InheritsFrom("TH2F")) {
cout << "the TH2F = " << obj->GetName() << endl;
myOutFile->cd();
obj->Write(theNomClasse2+"_"+theNomClasse3);
myFile->cd();
}
}
}
}
}
}
}
delete myFile;
}
}
myOutFile->Close();
}