本文整理汇总了C++中TString::Contains方法的典型用法代码示例。如果您正苦于以下问题:C++ TString::Contains方法的具体用法?C++ TString::Contains怎么用?C++ TString::Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TString
的用法示例。
在下文中一共展示了TString::Contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gGet_Kin_Name
/*Get_Kin_Name{{{*/
TString gGet_Kin_Name(const TString& aKin){
TString aKin_Name="MM";
if(aKin.Contains("3.1"))
aKin_Name="3.1";
else if(aKin.Contains("3.2"))
aKin_Name="3.2";
else if(aKin.Contains("4.1"))
aKin_Name="4.1";
else if(aKin.Contains("4.2"))
aKin_Name="4.2";
else if(aKin.Contains("5.0")&&!aKin.Contains("5.05"))
aKin_Name="5.0";
else if(aKin.Contains("5.05"))
aKin_Name="5.05";
else if(aKin.Contains("5.1"))
aKin_Name="5.1";
else if(aKin.Contains("5.2"))
aKin_Name="5.2";
else if(aKin.Contains("6.5"))
aKin_Name="6.5";
else
cerr<<"*** I don't know the kinematics name!!!"<<endl;
return aKin_Name;
}
示例2: drawLKT
void drawLKT(TString& type, TString& ytitle, TString& xtitle, TString& head, TString &leg1, TString& leg2, TString& leg3, double miny = 0.85, double maxy = 1.02){
TCanvas *c = new TCanvas(Form("%s",type.Data()), Form("%s",type.Data()) ,5,49,400,400);
SetStyleCanvas(c);
TGraphErrors *grae1 = new TGraphErrors();
TGraphErrors *grae2 = new TGraphErrors();
TGraphErrors *grae3 = new TGraphErrors();
if( type.Contains("cEffLKTETA")){
SetEffLKTETA(grae1, grae2, grae3);
clearXErrorBar(grae1);
clearXErrorBar(grae2);
clearXErrorBar(grae3);
}else if (type.Contains("cEffLKTNCal")){
SetEffLKTNCal(grae1, grae2, grae3);
}
SetStyleGraphErrors(grae1, 2, 20, 0, 0.81, ytitle, xtitle, miny, maxy);
SetStyleGraphErrors(grae2, 1, 21, 0, 0.81, ytitle, xtitle, miny, maxy);
SetStyleGraphErrors(grae3, 4, 22, 0, 0.81, ytitle, xtitle, miny, maxy);
grae1->Draw("AP");
grae2->Draw("PSame");
grae3->Draw("PSame");
if( type.Contains("cEffLKTETA")){
SetLegend(grae1, grae2, grae3, head, leg1, leg2, leg3,"P","P","P", 0.6,0.20,0.9,0.40);
SetLabel(0.6,0.48,36);
}else if( type.Contains("cEffLKTNCal")){
SetLegend(grae1, grae2, grae3, head, leg1, leg2, leg3,"PL","PL","PL", 0.6,0.58,0.9,0.81);
SetLabel(0.6,0.88,36);
}
c->Print(Form("%s.eps",type.Data()));
}
示例3: round
TString round(double n, int e, double d){
if(d==0) return " - ";
double neg = 1; if(n*d<0) neg = -1;
double b = (int)(neg*n/d*pow(10.,(double)e)+0.5);
b /= pow(10.,(double)e)*neg;
TString result; result+= b;
result.ReplaceAll(" ","");
if(!result.Contains(".") && e != 0) result += ".";
TString afterdot = result;
afterdot.Remove(0,afterdot.First(".")+1);
for(int i=0; i<e-afterdot.Length(); i++)
result += "0";
return result;
}
示例4: FSRBinByBin
void FSRBinByBin(const char* MODE,TString datasetName, char* chunk, TString Alt) {
// directory with data
TString protocol = "file://";
//TString dirname = "/mnt/hadoop/store/user/asvyatko/DYstudy/dataAnalysis13/rootfiles/";
TString dirnameEE = "/scratch/scratch95/a/asvyatko/DY2013/rootfiles_Purdue/";
TString dirnameMuMu = "/scratch/lustreC/a/asvyatko/DY2013/rootfiles_Purdue/";
TString dirname = dirnameMuMu;
if (datasetName.Contains("EE")) dirname = dirnameEE;
TString ncores = "30";
//if (!datasetName.Contains("samp") && (chunk.Contains("_") || datasetName.Contains("00"))) ncores = "1";
if (!(datasetName.Contains("1020") || datasetName.Contains("samp"))) ncores = "3";
if (datasetName.Contains("1020")) ncores = "10";
TString beautiful = beautifulDataset(datasetName);
TFileCollection* c = loadChunks(chunk[0],protocol,dirname,datasetName,beautiful);
gSystem->Load("Muon_cc.so");
gSystem->Load("Electron_cc.so");
gSystem->Load("Dimuon_cc.so");
gSystem->Load("Dielectron_cc.so");
gEnv->SetValue("ProofLite.Sandbox", "/home/asvyatko/DYStudy/CMSSW_5_3_3_patch2/src/Analysis/DYPackage/test/FSRunfold_Purdue/proofbox/");
TProof* p = TProof::Open("workers="+ncores);
p->RegisterDataSet(datasetName+chunk, c,"OV");
p->ShowDataSets();
TObjString* mode = new TObjString(MODE);
p->AddInput(new TNamed("mode",MODE));
gROOT->Time();
p->SetParameter("PROOF_LookupOpt", "all");
p->Process(datasetName+chunk+"#/recoTree/DiLeptonTree","EventSelector_FSRUnfBBB.C+");
}
示例5: HtmlObjTable
//______________________________________________________________________________
HtmlObjTable *HtmlSummary::AddTable(const char *name, Int_t nfields,
Bool_t exp, Option_t *option)
{
// Add a new table in our list of tables.
TString opt = option;
opt.ToLower();
HtmlObjTable *table = new HtmlObjTable(name, nfields, exp);
fNTables++;
if (opt.Contains("first"))
fObjTables->AddFirst(table);
else
fObjTables->Add(table);
return table;
}
示例6: round
TString round(double n, int e, double d){
if(d==0) return " - ";
double b = (int)(n/d*pow(10,e)+0.5);
b /= pow(10,e);
TString result; result+= b;
result.ReplaceAll(" ","");
if(b<10 && e==2){
if(result.Length() == 1)
result += ".00";
if(result.Length() == 3)
result += "0";
}
if(e==1 && !result.Contains(".")) result += ".0";
return result;
}
示例7: RoundNumber
TString HiggsPlot::RoundNumber(double n, int e, double d){
if(d==0) return " - ";
double neg = 1; if(n*d<0) neg = -1;
double b = static_cast<int>(neg*n/d*pow(10.,static_cast<double>(e))+0.5);
b /= pow(10.,static_cast<double>(e))*neg;
TString result; result+= b;
result.ReplaceAll(" ","");
if(!result.Contains(".") && e != 0) result += ".";
TString afterdot = result;
afterdot.Remove(0,afterdot.First(".")+1);
for(int i=0; i<e-afterdot.Length(); i++)
result += "0";
return result;
}
示例8: getRegion
HistoTransform::Region* HistoTransform::getRegion(SubDirectory* subDir, string histName) {
KFold* kFold = getKFold(subDir, histName);
if (!kFold)
return 0;
if (kFold -> regions.size() == 1)
return kFold -> regions[0];
TString name = histName;
for (unsigned int iRegion = 0; iRegion < kFold -> regions.size(); iRegion++) {
TString stringIofK = TString::Format("_%iof%i", iRegion, (int) kFold -> regions.size());
if (name.Contains(stringIofK))
return kFold -> regions[iRegion];
}
// cout << "WARNING: region for histo '" << histName << "' not found!" << endl;
return 0;
}
示例9: AddTaskKink
AliAnalysisKinkESDat* AddTaskKink(TString lCustomName="")
{
//pp settings
AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
if (!mgr)
{
::Error("AddKinkTask", "No analysis manager to connect to.");
return NULL;
}
// Check the analysis type using the event handlers connected to the analysis manager.
//==============================================================================
if (!mgr->GetInputEventHandler())
{
::Error("AddKinkTask", "This task requires an input event handler");
return NULL;
}
TString type = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
if(type.Contains("AOD"))
{
::Error("AddKinkTask", "This task requires to run on ESD");
return NULL;
}
//TString outputFileName = AliAnalysisManager::GetCommonFileName();
//outputFileName += ":PWG2SpectraTOF";
AliAnalysisKinkESDat* task = new AliAnalysisKinkESDat("AliAnalysisKinkESDat");
//task->SetMC("kFALSE"); // 26/11/12
task->SetMulCut(0,1002);
mgr->AddTask(task);
//Attach input
AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
// mgr->ConnectInput(task,0,mgr->GetCommonInputContainer());
mgr->ConnectInput(task,0,cinput);
TString lContainerName="PWGLFKinks";
lContainerName.Append(lCustomName);
AliAnalysisDataContainer *coutput1= mgr->CreateContainer(lContainerName.Data(),TList::Class(), AliAnalysisManager::kOutputContainer,"AnalysisResults.root");
mgr->ConnectOutput(task, 1, coutput1);
return task;
}
示例10: parseWeight
void bcut::parseWeight(TString wgt){
cutTypes_.push_back(kFloat);
fWeights_.push_back(NULL);
fvWeights_.push_back(NULL);
indWeights_.push_back(-1);
constWeights_.push_back(1.);
if(wgt=="weight") fWeights_.back() = &baby_base::weight;
else if(wgt=="w_lumi") fWeights_.back() = &baby_base::w_lumi;
else if(wgt=="w_pu") fWeights_.back() = &baby_base::w_pu;
else if(wgt=="w_lep") fWeights_.back() = &baby_base::w_lep;
else if(wgt=="w_fs_lep") fWeights_.back() = &baby_base::w_fs_lep;
else if(wgt=="w_toppt") fWeights_.back() = &baby_base::w_toppt;
else if(wgt=="w_btag") fWeights_.back() = &baby_base::w_btag;
else if(wgt=="eff_trig") fWeights_.back() = &baby_base::eff_trig;
else if(wgt.Contains("[")){ // if weight is a vector element
TString index_s(wgt);
wgt.Remove(wgt.Index("["), wgt.Length());
index_s.Remove(0, index_s.Index("[")+1);
index_s.Remove(index_s.Index("]"), index_s.Length());
indWeights_.back() = index_s.Atoi();
cutTypes_.back() = kvFloat;
if(wgt=="w_pdf") fvWeights_.back() = &baby_base::w_pdf;
else if(wgt=="sys_pdf") fvWeights_.back() = &baby_base::sys_pdf;
else if(wgt=="sys_isr") fvWeights_.back() = &baby_base::sys_isr;
else if(wgt=="sys_mur") fvWeights_.back() = &baby_base::sys_mur;
else if(wgt=="sys_muf") fvWeights_.back() = &baby_base::sys_muf;
else if(wgt=="sys_murf") fvWeights_.back() = &baby_base::sys_murf;
else if(wgt=="sys_trig") fvWeights_.back() = &baby_base::sys_trig;
else if(wgt=="sys_lep") fvWeights_.back() = &baby_base::sys_lep;
else if(wgt=="sys_fs_lep") fvWeights_.back() = &baby_base::sys_fs_lep;
else if(wgt=="sys_bctag") fvWeights_.back() = &baby_base::sys_bctag;
else if(wgt=="sys_fs_bctag") fvWeights_.back() = &baby_base::sys_fs_bctag;
else if(wgt=="sys_udsgtag") fvWeights_.back() = &baby_base::sys_udsgtag;
else if(wgt=="sys_fs_udsgtag") fvWeights_.back() = &baby_base::sys_fs_udsgtag;
else {
cout<<"Weight \""<<wgt<<" not defined. Add it to bcut::parseWeight in bcut.cpp"<<endl;
exit(0);
}
}else if(wgt.Atof()>0) {
constWeights_.back() = wgt.Atof();
cutTypes_.back() = kConst;
} else {
cout<<"Weight \""<<wgt<<" not defined. Add it to bcut::parseWeight in bcut.cpp"<<endl;
exit(0);
}
}
示例11: UATAna
void UATAna(TString Cfg = "Config.cfg" , TString Steps = "R"){
Steps.ToUpper();
UATAnaConfig Config;
Config.ReadCfg(Cfg);
Config.Print();
if ( Steps.Contains ('R')
|| Steps.Contains ('T') ) {
bool bWTree = false ;
if ( Steps.Contains ('T') ) bWTree = true ;
UATAnaReader Reader;
Reader.Init (Config , bWTree );
Reader.Analyze(Config , bWTree );
Reader.End (Config , bWTree );
}
if ( Steps.Contains ('F')
|| Steps.Contains ('Y')
|| Steps.Contains ('L')
|| Steps.Contains ('C') ) {
UATAnaDisplay Display;
Display.Init (Config);
if ( Steps.Contains ('D') ) { Config.SetDrawRatio(true); Config.SetDrawBgError(true); }
if ( Steps.Contains ('E') ) Config.SetDrawBgError(true);
if ( Steps.Contains ('F') ) Display.Yields(Config,1);
if ( Steps.Contains ('Y') ) Display.Yields(Config,0,0);
if ( Steps.Contains ('C') ) {
if ( Steps.Contains ('S') ) Display.CPlot (Config,1);
else Display.CPlot (Config,0);
}
if ( Steps.Contains ('L') ) Display.LimitCard (Config);
}
}
示例12: PlotEff
void PlotEff(TString dataFileName = "DataEE_eleEndcap",
TString mcFileName = "DYJetsToEE_M-50_eleEndcap",
TString histBaseName = "ZMassEndcap") {
SetStyle();
TFile * fileData = new TFile(dataFileName+".root");
TFile * fileMC = new TFile(mcFileName+".root");
TGraphAsymmErrors * effData = (TGraphAsymmErrors*)fileData->Get(histBaseName);
TGraphAsymmErrors * effMC = (TGraphAsymmErrors*)fileMC->Get(histBaseName);
effData->SetLineColor(2);
effData->SetMarkerColor(2);
effData->SetMarkerSize(1.2);
effData->SetMarkerStyle(20);
effMC->SetLineColor(4);
effMC->SetMarkerColor(4);
effMC->SetMarkerStyle(21);
effMC->GetXaxis()->SetTitleOffset(1.1);
effMC->GetXaxis()->SetTitleSize(0.05);
effMC->GetYaxis()->SetTitleOffset(1.1);
effMC->GetYaxis()->SetTitleSize(0.05);
effMC->GetYaxis()->SetRangeUser(0.0,1.001);
TString EtaRegion("Endcap");
if (histBaseName.Contains("Barrel"))
EtaRegion = "Barrel";
TCanvas * canv = new TCanvas("canv","",700,600);
effMC->Draw("APE");
effData->Draw("PESame");
TLegend * leg = new TLegend(0.69,0.17,0.94,0.40);
leg->SetFillColor(0);
leg->SetHeader(EtaRegion);
leg->SetTextSize(0.06);
leg->AddEntry(effData,"Data","lp");
leg->AddEntry(effMC,"MC","lp");
leg->Draw();
canv->SetGridx();
canv->SetGridy();
canv->Print(histBaseName+"_eff.png");
canv->Update();
}
示例13: Graph
Graph *GetJESGraph(double E) {
Graph *g = new Graph();
int Np=0;
for (int i=-45;i<45;++i) {
double eta=0.05+0.1*i;
double JES=GetJES(E,eta);
//JES+=GetJES(E,-eta); JES/=2;
double pT=E/cosh(eta);
if (pT/JES<10) continue;
if ( _jesFile.Contains("FatJet") && pT/JES<40 ) continue;
//if (E==30)
// printf("eta = %.2f, JES: %.2f, E = %.2f, Eem: %.2f\n",eta,JES,E,E/JES);
//abort();
g->SetPoint(Np++,eta,1.0/JES);
}
return g;
}
示例14: GetSize
/**
* Get the size of a given run
*
* @param in Input stream
* @param runNo Run number to search for
* @param mc True for simulations
* @param minSize Least size
*
* @return true on success
*/
Bool_t GetSize(std::istream& in, ULong_t runNo,
Bool_t mc, ULong_t minSize=100000)
{
TString line;
TString tgt2(mc ? "table_row_right" : "ESDs size");
Int_t cnt = 0;
do {
line.ReadLine(in);
if (!line.Contains(tgt2)) continue;
cnt++;
if (mc && cnt < 3) continue;
if (!mc) line.ReadLine(in);
if (fDebug) Info("", line);
TString ssiz;
if (mc) {
Int_t first = line.Index(">");
Int_t last = line.Index("<",first+1);
if (first == kNPOS || last == kNPOS) {
Error("GetDir", "Failed to get directory from %s", line.Data());
return false;
}
ssiz = line(first+1, last-first-1);
}
else {
for (Int_t i = 0; i < line.Length(); i++) {
if (line[i] == '<') break;
if (line[i] == ' ' || line[i] == '\t' || line[i] == ',') continue;
ssiz.Append(line[i]);
}
}
Long_t size = ssiz.Atoll();
if (fDebug) Info("", "Got run %lu %lu" , runNo, size);
if (size < 0) {
Error("GetSize", "Failed to extract size for run %lu", runNo);
return false;
}
if (ULong_t(size) < minSize) {
Warning("GetSize","Run %lu does not have enough events %lu",runNo,size);
return false;
}
break;
} while (!in.eof());
return true;
}
示例15: WriteAsciiFile
Int_t KVRTGIDManager::WriteAsciiFile ( const Char_t * filename, const TCollection *selection, Bool_t update )
{
// Write identification functions in file 'filename'.
// If selection=0 (default), write all grids.
// If update=true, call UpdateListFromIDGridManager() before writing
// If selection!=0, write only grids in list.
// Returns number of functions written in file.
if( update ) UpdateListFromIDGridManager();
if( !fIDGlobalList ){
Warning("KVRTGIDManager::WriteAsciiFile","No listed identification functions to write");
return 0;
}
ofstream tgidfile ( filename );
if( !tgidfile.is_open() ){
Error("KVRTGIDManager::WriteAsciiFile","No write permission for file %s", filename);
return 0;
}
const TCollection *list_tgid = ( selection ? selection : fIDGlobalList );
TIter next ( list_tgid );
KVTGID *tgid = NULL;
Int_t n_saved = 0;
while ( ( tgid = (KVTGID *)next() ) ) {
// Not write a KVTGID copy
TString tmp = tgid->GetTitle();
if(tmp.Contains("COPY")){
tmp.Remove(0, tmp.Index("0x"));
KVTGID *tmp_tgid = reinterpret_cast<KVTGID *>((Int_t)tmp.Atof());
Warning("KVRTGIDManager::WriteAsciiFile","The function %s (%s, %p) is not written because it is a copy of %s (%s, %p)"
, tgid->GetName(), tgid->ClassName(), tgid
, tmp_tgid->GetName(), tmp_tgid->ClassName(), tmp_tgid);
continue;
}
tgid->WriteToAsciiFile ( tgidfile );
Info( "KVRTGIDManager::WriteAsciiFile", "%s (%s, %p) saved", tgid->GetName(), tgid->ClassName(), tgid );
n_saved++;
}
tgidfile.close();
return n_saved;
}