本文整理汇总了C++中TString::Last方法的典型用法代码示例。如果您正苦于以下问题:C++ TString::Last方法的具体用法?C++ TString::Last怎么用?C++ TString::Last使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TString
的用法示例。
在下文中一共展示了TString::Last方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: imgconv
// used to create output file for canvas
void imgconv( TCanvas* c, const TString & fname )
{
// return;
if (NULL == c) {
cout << "*** Error in TMVAGlob::imgconv: canvas is NULL" << endl;
}
else {
// create directory if not existing
TString f = fname;
TString dir = f.Remove( f.Last( '/' ), f.Length() - f.Last( '/' ) );
gSystem->mkdir( dir );
TString pngName = fname + ".png";
TString gifName = fname + ".gif";
TString epsName = fname + ".eps";
c->cd();
// create eps (other option: c->Print( epsName ))
if (UsePaperStyle) {
c->Print(epsName);
}
else {
cout << "--- --------------------------------------------------------------------" << endl;
cout << "--- If you want to save the image as eps, gif or png, please comment out " << endl;
cout << "--- the corresponding lines (line no. 239-241) in tmvaglob.C" << endl;
cout << "--- --------------------------------------------------------------------" << endl;
c->Print(epsName);
c->Print(pngName);
// c->Print(gifName);
}
}
}
示例2: FindAny
void FindAny(bool found, const TString& fsname, TClass* cl, TString baseexpected, const char* ext, const char* tag) {
if (baseexpected == "") {
baseexpected = cl->GetName();
Ssiz_t posCol = baseexpected.First('<');
if (posCol != -1) {
baseexpected.Remove(posCol, baseexpected.Length());
}
posCol = baseexpected.Last(':');
if (posCol != -1) {
baseexpected.Remove(0, posCol + 1);
}
baseexpected += ext;
}
if (!found) {
if (baseexpected != "FAIL") {
printf("FAIL: %s file for class %s not found\n", tag, cl->GetName());
}
return;
} else {
if (baseexpected == "FAIL") {
printf("FAIL: expected to not find %s file for class %s but got %s\n",
tag, cl->GetName(), fsname.Data());
return;
}
}
if (!fsname.EndsWith(baseexpected)) {
printf("FAIL: class %s expected %s file %s, got %s\n",
cl->GetName(), tag, baseexpected.Data(), fsname.Data());
return;
}
}
示例3: GetFormatFromDataSet
TString GetFormatFromDataSet(TString dataset) {
// Info("runAAF.C","Detecting format from dataset (may take while, depends on network connection)...");
TString dsTreeName;
if (dataset.Contains("#")) {
Info("runAAF.C",Form("Detecting format from dataset name '%s' ...",dataset.Data()));
dsTreeName=dataset(dataset.Last('#'),dataset.Length());
} else {
Info("runAAF.C",Form("Detecting format from dataset '%s' (may take while, depends on network connection) ...",dataset.Data()));
TFileCollection *ds = gProof->GetDataSet(dataset.Data());
if (!ds) {
Error(Form("Dataset %s doesn't exist on proof cluster!!!!",dataset.Data()));
return "";
}
dsTreeName = ds->GetDefaultTreeName();
}
if (dsTreeName.Contains("esdTree")) {
Info("runAAF.C","ESD input format detected ...");
return "ESD";
} else if (dsTreeName.Contains("aodTree")) {
Info("runAAF.C","AOD input format detected ...");
return "AOD";
} else {
Error("runAAF.C",Form("Tree %s is not supported !!!",dsTreeName.Data()));
Error("runAAF.C",Form("Maybe set your DS to %s#esdTree or %s#aodTree",dataset.Data(),dataset.Data()));
}
return "";
}
示例4: RecoQA
void RecoQA(const char* inFile) {
gROOT->LoadMacro("bfcread_hist_prefixes_add_to_ps.C");
TString baseName = inFile;
if (baseName.EndsWith(".daq"))
baseName.ReplaceAll(".daq",".hist.root");
else if (baseName.EndsWith(".event.root"))
baseName.ReplaceAll(".event.root",".hist.root");
else if (baseName.EndsWith(".MuDst.root"))
baseName.ReplaceAll(".MuDst.root",".hist.root");
TString histFile = baseName;
baseName.Remove(0,baseName.Last('/')+1);
TString outputName = baseName;
outputName.ReplaceAll(".root",".CC");
TString histList = "StRoot/St_QA_Maker/QAhlist_Reco.h";
if (! gSystem->Which(".",histList.Data()))
histList.Prepend(gSystem->ExpandPathName("$STAR/"));
bfcread_hist_prefixes_add_to_ps(histFile.Data(),"EventQA",
"bfcTree",outputName.Data(),baseName.Data(),histList.Data());
}
示例5: makehlt_tree
void makehlt_tree(TString filename, TString outfolder="root/hlt/sep4/"){
TString cuts[] = {"onelpt>15", "onmupt>15"};
TString tags[] = {"el15", "mu15"}, folder, sCut;
TChain tree("tree"); TChain treeglobal("treeglobal");
tree.Add(filename); treeglobal.Add(filename);
vector<int> genlep_thresh, v_nori_genels, v_nori_genmus;
vector<int> *nori_genels = &v_nori_genels, *nori_genmus = &v_nori_genmus;
int noriginal, nori_genmu0, nori_genel0;
treeglobal.SetBranchAddress("noriginal",&noriginal);
treeglobal.GetEntry(0);
genlep_thresh.push_back(0); genlep_thresh.push_back(10);
genlep_thresh.push_back(15); genlep_thresh.push_back(17);
genlep_thresh.push_back(20); genlep_thresh.push_back(25);
for(unsigned ind(0); ind<genlep_thresh.size(); ind++){
sCut = "Max$(genels_pt)>"; sCut += genlep_thresh[ind];
v_nori_genels.push_back(tree.GetEntries(sCut));
sCut = "Max$(genmus_pt)>"; sCut += genlep_thresh[ind];
v_nori_genmus.push_back(tree.GetEntries(sCut));
}
nori_genel0 = v_nori_genels[0]; nori_genmu0 = v_nori_genmus[0];
filename.Remove(0,filename.Last('/')+1);
filename.ReplaceAll(".root","");
for(int cut(0); cut<2; cut++){
folder = outfolder+"/"+tags[cut]+"/";
gSystem->mkdir(folder, kTRUE);
TTree *ctree = tree.CopyTree(cuts[cut]);
folder += filename+"_"+tags[cut]+".root";
ctree->SaveAs(folder);
TFile file(folder,"UPDATE");
file.cd();
TTree ctreeglobal("treeglobal", "treeglobal");
ctreeglobal.Branch("noriginal",&noriginal);
ctreeglobal.Branch("nori_genels",&nori_genels);
ctreeglobal.Branch("nori_genmus",&nori_genmus);
ctreeglobal.Branch("nori_genel0",&nori_genel0);
ctreeglobal.Branch("nori_genmu0",&nori_genmu0);
ctreeglobal.Branch("genlep_thresh", &genlep_thresh);
ctreeglobal.Fill();
ctreeglobal.Write();
file.Close();
}
}
示例6: misalignmentDependence
void misalignmentDependence(Int_t nFiles,TString *files,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
TString function,Int_t nParameters,Int_t *parameters,TString *parameternames,TString functionname = "",
Bool_t resolution = false,
TString saveas = "")
{
for (int i = 0; i < nParameters; i++)
{
TString saveasi = saveas;
TString insert = nPart(1,parameternames[i]);
insert.Prepend(".");
saveasi.Insert(saveasi.Last('.'),insert); //insert the parameter name before the file extension
misalignmentDependence(nFiles,files,names,misalignment,values,phases,xvar,yvar,
function,parameters[i],parameternames[i],functionname,
resolution,
saveasi);
}
}
示例7: write_ist_pednoise
void write_ist_pednoise() {
gSystem->Setenv("DB_ACCESS_MODE", "write");
gROOT->Macro("LoadLogger.C");
gSystem->Load("St_base.so");
gSystem->Load("libStDb_Tables.so");
gSystem->Load("StDbLib.so");
std::ifstream fPDlist("/star/u/ypwang/disk01/offline_hft/DB/pedNoiseTable4DB/pedNoiseFiles_Corr/pedRunList_Corr.txt");
if(!fPDlist.is_open())
{
std::cout << " There is no corrected pedRunList file! " << endl;
exit(0);
}
while(!fPDlist.eof()) {
TString sPDfile;
fPDlist >> sPDfile;
int found = sPDfile.Last('_');
if(found >= 0)
sPDfile.Replace(0, found + 1, "");
found = sPDfile.Last('.');
if(found >= 0)
sPDfile.Replace(found, sPDfile.Length(), "");
int runnumb = sPDfile.Atoi();
if(runnumb)
pedRunNumVec.push_back(runnumb);
}
fPDlist.close();
const int nPedRuns = pedRunNumVec.size();
cout << nPedRuns << " good pedestal runs recorded! " << endl;
if(debug) {
for(int i=0; i<nPedRuns; i++)
cout << i << "th pedestal run: " << pedRunNumVec[i] << endl;
}
std::ifstream fCosmicRunList("/star/u/ypwang/disk01/offline_hft/DB/pedNoiseTable4DB/cmNoise_cosmic/cosmicRunlist.txt");
if(!fCosmicRunList.is_open())
{
std::cout << " There is no cosmicRunList file! " << endl;
exit(0);
}
while(!fCosmicRunList.eof()) {
TString sCMNfile;
fCosmicRunList >> sCMNfile;
int found = sCMNfile.First('.');
if(found >= 0)
sCMNfile.Replace(found, sCMNfile.Length(), "");
int runnumb = sCMNfile.Atoi();
if(runnumb)
cosmicRunNumVec.push_back(runnumb);
}
fCosmicRunList.close();
const int nCosmicRuns = cosmicRunNumVec.size();
cout << nCosmicRuns << " good cosmic runs recorded! " << endl;
if(debug) {
for(int i=0; i<nCosmicRuns; i++)
cout << i << "th cosmic run: " << cosmicRunNumVec[i] << endl;
}
Int_t isBadChannel[110592];
Int_t isBadChip[864];
//loop pedestal runs
for(int iRun=0; iRun<nPedRuns; iRun++)
{
int runNumber = pedRunNumVec[iRun];
//below only for testing
//if(runNumber<15065020) continue;
int TbinPD = PDTBin(runNumber);
cout << "Reading pedestal run " << runNumber << " with " << TbinPD << " time bins! " << endl;
//retrieve time stamp information
char cmd[256];
sprintf(cmd, "/usr/bin/mysql -h dbbak.starp.bnl.gov --port=3413 -e \"SELECT FROM_UNIXTIME(startRunTime) as beginTime_human FROM RunLog.runDescriptor WHERE runNumber = %d\" >timeStamp_tmp", runNumber);
system(cmd);
TString mTimeStamp;
FILE *inR = fopen("timeStamp_tmp","r");
while(!feof(inR)) {
char buff[64];
if(fgets(buff,sizeof(buff),inR) == 0) continue ;
switch(buff[0]) {
case 'b' : //beginTime_human
continue ;
}
mTimeStamp = Form(buff);
}
fclose(inR);
sprintf(cmd, "/bin/rm timeStamp_tmp");
system(cmd);
int found = 19;
//.........这里部分代码省略.........
示例8: studyBinZero
//___________________________________________________________________
Int_t studyBinZero(TString pathData, TString fileNameData, TString listName = "",
Double_t etaLow = -0.9, Double_t etaUp = 0.9,
Double_t lowerCentrality = -2, Double_t upperCentrality = -2)
{
PrintSettingsAxisRangeForMultiplicityAxisForMB();
TString pathNameData = Form("%s/%s", pathData.Data(), fileNameData.Data());
if (listName == "") {
listName = pathNameData;
listName.Replace(0, listName.Last('/') + 1, "");
listName.ReplaceAll(".root", "");
}
TObjArray* histList = 0x0;
TFile* f = TFile::Open(pathNameData.Data());
if (!f) {
std::cout << std::endl;
std::cout << "Failed to open file \"" << pathNameData.Data() << "\"!" << std::endl;
return -1;
}
histList = (TObjArray*)(f->Get(listName.Data()));
if (!histList) {
std::cout << std::endl;
std::cout << "Failed to load list \"" << listName.Data() << "\"!" << std::endl;
return -1;
}
// Extract the data histograms
TH1* hNumEventsTriggerSel = dynamic_cast<TH1*>(histList->FindObject("fhEventsTriggerSel"));
TH1* hNumEventsTriggerSelVtxCut = dynamic_cast<TH1*>(histList->FindObject("fhEventsTriggerSelVtxCut"));
TH1* hNumEventsTriggerSelVtxCutZ= dynamic_cast<TH1*>(histList->FindObject("fhEventsProcessedNoPileUpRejection"));
TH1* hNumEventsTriggerSelVtxCutZPileUpRej= dynamic_cast<TH1*>(histList->FindObject("fhEventsProcessed"));
THnSparse* hDataTriggerSel = dynamic_cast<THnSparse*>(histList->FindObject("fChargedGenPrimariesTriggerSel"));
THnSparse* hDataTriggerSelVtxCut = dynamic_cast<THnSparse*>(histList->FindObject("fChargedGenPrimariesTriggerSelVtxCut"));
THnSparse* hDataTriggerSelVtxCutZ = dynamic_cast<THnSparse*>(histList->FindObject("fChargedGenPrimariesTriggerSelVtxCutZ"));
THnSparse* hDataTriggerSelVtxCutZPileUpRej = dynamic_cast<THnSparse*>(histList->FindObject("fChargedGenPrimariesTriggerSelVtxCutZPileUpRej"));
setSparseErrors(hDataTriggerSel);
setSparseErrors(hDataTriggerSelVtxCut);
setSparseErrors(hDataTriggerSelVtxCutZ);
setSparseErrors(hDataTriggerSelVtxCutZPileUpRej);
// Set multiplicity range, if desired. Note that mult and pT axes are the same for all histos
Int_t lowerCentralityBinLimit = -1;
Int_t upperCentralityBinLimit = -2;
Bool_t restrictCentralityAxis = kFALSE;
Double_t actualLowerCentrality = -1.;
Double_t actualUpperCentrality = -1.;
if (lowerCentrality >= -1 && upperCentrality >= -1) {
// Add subtract a very small number to avoid problems with values right on the border between to bins
lowerCentralityBinLimit = hNumEventsTriggerSel->GetXaxis()->FindFixBin(lowerCentrality + 0.001);
upperCentralityBinLimit = hNumEventsTriggerSel->GetXaxis()->FindFixBin(upperCentrality - 0.001);
// Check if the values look reasonable
if (lowerCentralityBinLimit <= upperCentralityBinLimit && lowerCentralityBinLimit >= 1
&& upperCentralityBinLimit <= hNumEventsTriggerSel->GetXaxis()->GetNbins()) {
actualLowerCentrality = hNumEventsTriggerSel->GetXaxis()->GetBinLowEdge(lowerCentralityBinLimit);
actualUpperCentrality = hNumEventsTriggerSel->GetXaxis()->GetBinUpEdge(upperCentralityBinLimit);
restrictCentralityAxis = kTRUE;
}
else {
std::cout << std::endl;
std::cout << "Requested centrality range out of limits or upper and lower limit are switched!" << std::endl;
return -1;
}
}
if (!restrictCentralityAxis)
GetAxisRangeForMultiplicityAxisForMB(hNumEventsTriggerSel->GetXaxis(), lowerCentralityBinLimit, upperCentralityBinLimit);
hNumEventsTriggerSel->GetXaxis()->SetRange(lowerCentralityBinLimit, upperCentralityBinLimit);
actualLowerCentrality = hNumEventsTriggerSel->GetXaxis()->GetBinLowEdge(hNumEventsTriggerSel->GetXaxis()->GetFirst());
actualUpperCentrality = hNumEventsTriggerSel->GetXaxis()->GetBinUpEdge(hNumEventsTriggerSel->GetXaxis()->GetLast());
std::cout << "centrality: ";
if (restrictCentralityAxis) {
std::cout << actualLowerCentrality << " - " << actualUpperCentrality << std::endl;
std::cout << "WARNING: Does it really make sense to restrict the centrality? Usually, centrality estimators imply centrality >= 0!"
<< std::endl;
}
else
std::cout << "MB (" << actualLowerCentrality << " - " << actualUpperCentrality << ")" << std::endl;
if (restrictCentralityAxis) {
hDataTriggerSel->GetAxis(iMult)->SetRange(lowerCentralityBinLimit, upperCentralityBinLimit);
hDataTriggerSelVtxCut->GetAxis(iMult)->SetRange(lowerCentralityBinLimit, upperCentralityBinLimit);
hDataTriggerSelVtxCutZ->GetAxis(iMult)->SetRange(lowerCentralityBinLimit, upperCentralityBinLimit);
hDataTriggerSelVtxCutZPileUpRej->GetAxis(iMult)->SetRange(lowerCentralityBinLimit, upperCentralityBinLimit);
}
//.........这里部分代码省略.........
示例9: PlotSingle
void PlotSingle(TString hname){
TString sam = hname; sam.Remove(0,sam.First('_')+1);
sam.Remove(sam.First('_'),sam.Length());
TString smoo = hname;smoo.Remove(0,smoo.Last('_')+1);
smoo.Remove(smoo.First('.'),smoo.Length());
TString binString = hname; binString.Remove(binString.Last('_'),binString.Length());
binString.Remove(0,binString.Last('_')+1);
int nM2bin = binString.Atoi(); int nPlbin = nM2bin%1000;
nM2bin = nM2bin/1000;
TString basename(hname);
Int_t slashpos = basename.Last('D');
if (slashpos>=0) {
basename.Remove(0,slashpos+1); basename.Remove(basename.First('.'),basename.Length());
} else { cout<<hname<<" is incorrect"<<endl; return;}
TString Base = "_"; Base += sam; Base += "_";
Base += binString; Base += "_"; Base += smoo;
TFile hfile(hname);
TH2F *h2 = (TH2F *)gDirectory->Get("h2");
TString inputfile = "fitSamples/pdfSample"; inputfile += sam; inputfile += ".root";
cout << "File = " << inputfile << endl;
TChain c("ntp1");
c.Add(inputfile);
TCanvas mm("mm","KEYS fits to mmiss-pstarl",1200,800);
double m2min = -4, m2max = 12, plmin = 0, plmax = 2.4;
double xlow = m2min,xhigh = m2max, ylow = plmin,yhigh = plmax;
Int_t nbinx = 80,nbiny = 80, Sam = sam.Atoi();
if (Sam==0 || Sam==2 || Sam==10 || Sam==12 || Sam == 20 || Sam == 23 || Sam == 26 || Sam == 29) {
xlow = -2; xhigh = 4;
if (Sam > 12) {nbinx = 40; nbiny = 40;}
} else if (Sam==1 || Sam==11) { xlow = -2; xhigh = 6;}
if (Sam==6 || Sam==7 || Sam==16 || Sam==17) {nbinx = 40; nbiny = 40;}
if (Sam==8 || Sam==18) {xhigh = 4; nbinx = 40; nbiny = 40;}
if (Sam==9 || Sam==19) {nbinx = 40; nbiny = 40;}
if (Sam==21 || Sam==22 || Sam==24 || Sam==25 || Sam==27 || Sam==28 || Sam==30 || Sam==31) {
xhigh = 8; nbinx = 40; nbiny = 20;}
if (Sam > 31) {nbinx = 40; nbiny = 20;}
if(Sam==0){xlow=-1; xhigh=1;}
double entries = c.GetEntries();
Double_t hIntegral=h2->Integral();
TString M2titles[] = {"0 < p*_{l} < 1 GeV","1 < p*_{l} < 1.4 GeV","1.4 < p*_{l} < 1.8 GeV",
"1.8 < p*_{l} < 2.4 GeV","0 < p*_{l} < 2.4 GeV"};
TString Pltitles[] = {"-4 < m^{2}_{miss} < 1 GeV^{2}","1 < m^{2}_{miss} < 12 GeV^{2}",
"-4 < m^{2}_{miss} < 12 GeV^{2}"};
TCut M2cuts[] = {"candPstarLep<1","candPstarLep>1&&candPstarLep<1.4",
"candPstarLep>1.4&&candPstarLep<1.8","candPstarLep>1.8&&candPstarLep<2.4", ""};
TCut Plcuts[] = {"candM2<1","candM2>=1",""};
double PlLimits[] = {0, 1, 1.4, 1.8, 2.4};
double M2Limits[] = {0., 5., 16.};
int binlim[5]; int plbinlim[3];
for(int i=0;i<5;i++) {
PlLimits[i] = PlLimits[i]/2.4*(double)nPlbin;
binlim[i] = (int)PlLimits[i];
if(i<3){
M2Limits[i] = M2Limits[i]/16.*(double)nM2bin;
plbinlim[i] = (int)M2Limits[i];
}
}
TString psname = "AWG82/results/keys/eps/Stitch/epsKeys"; psname += Base; psname += ".ps";
mm.Print(psname+"[");
TH1F *hm2[5], *m2[5], *hpl[3], *pl[3];
TString M2names[5], Plnames[3];
for(int i=0;i<5;i++){
M2names[i] = "hm2_"; M2names[i] += i;
hm2[i] = new TH1F(M2names[i],M2titles[i],nM2bin,m2min,m2max);
if(i<3) {
Plnames[i] = "hpl_"; Plnames[i] += i;
hpl[i] = new TH1F(Plnames[i],Pltitles[i],nPlbin,plmin,plmax);
}
}
hIntegral = h2->Integral();
for(int i=0;i<5;i++){
TString hdname = "dm2"; hdname += i;
TString vari = "candM2>>"; vari+=hdname; vari+="("; vari+= nbinx; vari+=",";vari+= xlow;
vari+=",";vari+= xhigh; vari+=")";
//M2cuts[i] += "weight<100";M2cuts[i] *= "wFF";
c.Draw(vari,M2cuts[i]);
m2[i] = (TH1F*)gDirectory->Get(hdname);
m2[i]->SetXTitle("m^{2}_{miss} [GeV^{2}]");
formatHisto(m2[i]);
gStyle->SetOptStat(0);
if(i<4){
for(int j=1; j<nM2bin+1; j++){
double binVal = 0;
for(int binp = binlim[i]+1; binp < binlim[i+1]+1; binp++){
binVal+=h2->GetBinContent(j,binp)*entries*nM2bin*(xhigh-xlow)/nbinx/(m2max-m2min)/hIntegral;
}
hm2[i]->SetBinContent(j,binVal);
}
}
hm2[i]->SetLineColor(4);
hm2[i]->SetLineWidth(1);
if(i<4) hm2[4]->Add(hm2[i]);
}
for(int i=0;i<3;i++){
TString hdname = "pl"; hdname += i;
//.........这里部分代码省略.........
示例10: glxlut_avr
void glxlut_avr(TString baseFile = "../data/lut100000.root"){
gROOT->ProcessLine(".L ../src/GlxLutNode.cxx+");
gInterpreter->GenerateDictionary("vector<TVector3>","TVector3.h");
TString inFile =baseFile;
TString outFile = baseFile.Remove(baseFile.Last('.'))+"_avr.root";
TFile* f = new TFile(inFile);
TTree *t=(TTree *) f->Get("glxlut") ;
TClonesArray* fLut[48];
for(Int_t l=0; l<48; l++){
fLut[l] = new TClonesArray("GlxLutNode");
t->SetBranchAddress(Form("LUT_%d",l),&fLut[l]);
}
TFile *fFileNew = TFile::Open(outFile, "RECREATE");
TClonesArray *fLutNew[48];
TTree *fTreeNew = new TTree("glxlut","Look-up table for DIRC. Averaged");
Int_t Nnodes = 20000;
for(Int_t l=0; l<48; l++){
fLutNew[l] = new TClonesArray("GlxLutNode");
fTreeNew->Branch(Form("LUT_%d",l),&fLutNew[l],256000,2);
TClonesArray &fLutaNew = *fLutNew[l];
for (Long64_t n=0; n<Nnodes; n++) {
new((fLutaNew)[n]) GlxLutNode(-1);
}
}
// TCanvas* c = new TCanvas("c","c",0,0,800,1200); c->Divide(1,2);
// TH1F * histNode = new TH1F("LutNode","Node vs Multiplicity",30000,0,150000);
// TH1F * hTime = new TH1F("hTime","Time",5000,0,10);
// TH1F * hDir = new TH1F("hDir","X component",1000,-1,1);
std::vector<TVector3> vArray[100];
std::vector<Double_t> tArray[100];
std::vector<Double_t> pArray;
TVector3 dir, dir2, sum;
Double_t angle, minangle,pathid,time,sumt;
GlxLutNode *node;
for(Int_t l=0; l<48; l++){
t->GetEntry(l);
for (Int_t inode=0; inode<fLut[l]->GetEntriesFast(); inode++){
if(inode%1000==0) cout<<"Node # "<<inode << " L "<<l<<endl;
node= (GlxLutNode*) fLut[l]->At(inode);
//histNode->Fill(node->GetNodeId(),node->Entries());
Int_t size = node->Entries();
if(size<1) continue;
for(int i=0; i<size; i++){
dir = node->GetEntry(i);
time = node->GetTime(i);
pathid = node->GetPathId(i);
// hDir->Fill(dir.X());
// hTime->Fill(time);
bool newid = true;
for(int j=0; j<pArray.size(); j++){
if(pathid == pArray[j]){
vArray[j].push_back(dir);
tArray[j].push_back(time);
newid= false;
}
}
if(newid) {
vArray[pArray.size()].push_back(dir);
tArray[pArray.size()].push_back(time);
pArray.push_back(pathid);
}
}
for(int j=0; j<pArray.size(); j++){
sum = TVector3(0,0,0);
sumt=0;
for(int v=0; v<vArray[j].size(); v++) {
sum += vArray[j][v];
sumt += tArray[j][v];
// hDir->Fill(vArray[j][v].X());
// hTime->Fill(tArray[j][v]);
}
// c->cd(1);
// hTime->Draw();
// c->cd(2);
// hDir->Draw();
// c->Update();
// c->WaitPrimitive();
// hDir->Reset();
// hTime->Reset();
if(vArray[j].size()<1) continue;
Double_t weight = 1/(Double_t)vArray[j].size();
sum *= weight;
sumt *= weight;
//.........这里部分代码省略.........
示例11: bfcread_hist_extract
void bfcread_hist_extract(
const Char_t *MainFile=
"/afs/rhic.bnl.gov/star/data/samples/gstar.hist.root",
const Char_t *MakerHistDir="EventQA",
const Char_t *TopDirTree="bfcTree",
Char_t *OutFile=0,
const Char_t *PrintList="")
{
cout << "bfcread_hist_extract.C, input hist file = "
<< MainFile << endl;
cout << "bfcread_hist_extract.C, directory name for hist = "
<< MakerHistDir << endl;
cout << "bfcread_hist_extract.C, top level directory in hist file = "
<< TopDirTree << endl;
//
gSystem->Load("St_base");
gSystem->Load("StChain");
gSystem->Load("StIOMaker");
gSystem->Load("StarClassLibrary");
gSystem->Load("StUtilities");
gSystem->Load("StAnalysisUtilities");
gSystem->Load("libglobal_Tables");
// setup chain with IOMaker - can read in .dst.root, .dst.xdf files
StIOMaker *IOMk = new StIOMaker("IO","r",MainFile,TopDirTree);
IOMk->SetDebug();
IOMk->SetIOMode("r");
IOMk->SetBranch("*",0,"0"); //deactivate all branches
IOMk->SetBranch("histBranch",0,"r"); //activate dst Branch
// constructor for other maker (not used in chain)
StHistUtil *HU = new StHistUtil;
// now must set pointer to StMaker so HistUtil can find histograms
// with StHistUtil methods
// -- input any maker pointer but must cast as type StMaker
HU->SetPntrToMaker((StMaker *)IOMk);
// ONLY use StIOMaker in chain
// --- now execute chain member functions - 1 event (histograms) only
IOMk->Init();
IOMk->Clear();
IOMk->Make();
// method to print out list of histograms
// - can do this anytime after they're booked
// - default is to print out QA hist branch
Int_t NoHist=0;
//NoHist = HU->ListHists(MakerHistDir);
TList* dList = HU->FindHists(MakerHistDir);
if (PrintList) HU->SetDefaultPrintList(MakerHistDir,PrintList);
NoHist = HU->CopyHists(dList);
TH1** nh = HU->getNewHist();
TString name = MainFile;
if (!OutFile) {
name.Remove(0,name.Last('/')+1);
TString name2 = MakerHistDir;
name2.Remove(0,name2.Last('/')+1);
name.Insert(name.First('.'),"_");
name.Insert(name.First('.'),name2);
OutFile = name.Data();
}
cout << "Output hist file: " << OutFile << endl;
TFile* ofile = new TFile(OutFile,"RECREATE");
for (int i=0; i<NoHist; i++) {
printf("Extracting: %d. %s : %s\n",
i+1,nh[i]->GetName(),nh[i]->GetTitle());
nh[i]->Write();
}
ofile->Close();
}
示例12: minuitFit
//.........这里部分代码省略.........
grP->Draw("AP");
//grC->Draw("same P");
gr2->Draw("same P");
grF->Draw("same");
grFmax->Draw("same");
grFmin->Draw("same");
gr0->Draw("same P");
// grPr->Draw("same P");
//grPPr->Draw("same P");
TLegend* leg2 = new TLegend(0.15,0.68,0.48,0.85);
leg2->AddEntry(gr0,"STAR Run 12 - Low p_{T} Analysis","pe");
leg2->AddEntry(gr2,"STAR Run 12 - High p_{T} Analysis","pe");
//leg2->AddEntry(grC,"Combined Trigs","pe");
leg2->AddEntry(grP,"STAR Run 6 Analysis (Stat. Uncertainty)","pe");
// leg2->AddEntry(grPr,"Run 12 Data, Run 5/6 Templates)","pe");
//leg2->AddEntry(grPPr,"Run 5/6 Refit (prev Template)","pe");
leg2->AddEntry(grF,"FONLL Calculation","l");
leg2->Draw("same");
// Write to Root File if open
if(makeROOT){
file3->Close();
file4->Close();
file->cd();
grP->Write("PreviousData");
//grC->Write("same P");
gr2->Write("HT2");
grF->Write("FONLL");
grFmax->Write("FONLLmax");
grFmin->Write("FONLLmin");
gr0->Write("HT0");
// grPr->Write("PrevTempMyData");
//grPPr->Write("PrevTempPreData");
}
// Make PDF with output canvases
if(makePDF)
{
//Set front page
TCanvas* fp = new TCanvas("fp","Front Page",100,0,1000,900);
fp->cd();
TBox *bLabel = new TBox(0.01, 0.88, 0.99, 0.99);
bLabel->SetFillColor(38);
bLabel->Draw();
TLatex tl;
tl.SetNDC();
tl.SetTextColor(kWhite);
tl.SetTextSize(0.033);
char tlName[100];
char tlName2[100];
TString titlename = FileName;
int found = titlename.Last('/');
if(found >= 0){
titlename.Replace(0, found+1, "");
}
sprintf(tlName, "RUN 12 NPE-h #Delta#phi Correlations");
tl.SetTextSize(0.05);
tl.SetTextColor(kWhite);
tl.DrawLatex(0.05, 0.92,tlName);
TBox *bFoot = new TBox(0.01, 0.01, 0.99, 0.12);
bFoot->SetFillColor(38);
bFoot->Draw();
tl.SetTextColor(kWhite);
tl.SetTextSize(0.05);
tl.DrawLatex(0.05, 0.05, (new TDatime())->AsString());
tl.SetTextColor(kBlack);
tl.SetTextSize(0.03);
tl.DrawLatex(0.1, 0.14, titlename);
sprintf(tlName,"TEST");
tl.DrawLatex(0.1, 0.8,tlName);
// Place canvases in order
TCanvas* temp = new TCanvas();
sprintf(name, "FFOutput/%s.pdf[", FileName);
temp->Print(name);
sprintf(name, "FFOutput/%s.pdf", FileName);
temp = deltaPhi;
temp->Print(name);
temp = fitResult0;
temp->Print(name);
temp = fitResult2;
temp->Print(name);
// temp = fitResultC;
// temp->Print(name);
temp = c1;
temp->Print(name);
sprintf(name, "FFOutput/%s.pdf]", FileName);
temp->Print(name);
}
if(makeROOT)
{
file->Write();
file->Close();
}
}
示例13: makePlot
//.........这里部分代码省略.........
label->SetFillStyle(0);
label->SetBorderSize(0);
label->Draw();
}
TPad* bottomPad = new TPad("bottomPad", "bottomPad", 0.00, 0.00, 1.00, 0.35);
bottomPad->SetFillColor(10);
bottomPad->SetTopMargin(0.02);
bottomPad->SetLeftMargin(0.15);
bottomPad->SetBottomMargin(0.24);
bottomPad->SetRightMargin(0.05);
bottomPad->SetGridx();
bottomPad->SetGridy();
canvas->cd();
bottomPad->Draw();
bottomPad->cd();
TH1* dummyHistogram_bottom = new TH1D("dummyHistogram_bottom", "dummyHistogram_bottom", 10, 0., 100.);
dummyHistogram_bottom->SetMinimum(-1.0);
dummyHistogram_bottom->SetMaximum(+1.0);
TAxis* xAxis_bottom = dummyHistogram_bottom->GetXaxis();
xAxis_bottom->SetTitle("calo-E_{T}^{miss} / GeV");
xAxis_bottom->SetTitleOffset(1.20);
xAxis_bottom->SetLabelColor(1);
xAxis_bottom->SetTitleColor(1);
xAxis_bottom->SetTitleSize(0.08);
xAxis_bottom->SetLabelOffset(0.02);
xAxis_bottom->SetLabelSize(0.08);
xAxis_bottom->SetTickLength(0.055);
TAxis* yAxis_bottom = dummyHistogram_bottom->GetYaxis();
yAxis_bottom->SetTitle("#frac{Data-Simulation}{Simulation}");
yAxis_bottom->SetTitleOffset(0.85);
yAxis_bottom->SetNdivisions(505);
yAxis_bottom->CenterTitle();
yAxis_bottom->SetTitleSize(0.08);
yAxis_bottom->SetLabelSize(0.08);
yAxis_bottom->SetTickLength(0.04);
dummyHistogram_bottom->SetTitle("");
dummyHistogram_bottom->SetStats(false);
dummyHistogram_bottom->Draw("axis");
TGraphAsymmErrors* graph_Data_div_mc_passed = makeGraph_data_div_mc(graph_Data_passed, graph_mcSum_passed);
graph_Data_div_mc_passed->SetLineColor(graph_Data_passed->GetLineColor());
graph_Data_div_mc_passed->SetMarkerColor(graph_Data_passed->GetMarkerColor());
graph_Data_div_mc_passed->SetMarkerStyle(graph_Data_passed->GetMarkerStyle());
graph_Data_div_mc_passed->Draw("p");
TF1* fit_Data_div_mc_passed =
new TF1("fit_Data_div_mc_passed", &integralCrystalBall_f_div_f,
fit_mcSum_passed->GetMinimumX(), fit_mcSum_passed->GetMaximumX(), 2*fit_mcSum_passed->GetNpar());
for ( int iPar = 0; iPar < fit_mcSum_passed->GetNpar(); ++iPar ) {
fit_Data_div_mc_passed->SetParameter(iPar, fit_Data_passed->GetParameter(iPar));
fit_Data_div_mc_passed->SetParameter(iPar + fit_mcSum_passed->GetNpar(), fit_mcSum_passed->GetParameter(iPar));
}
fit_Data_div_mc_passed->SetLineColor(graph_Data_div_mc_passed->GetLineColor());
fit_Data_div_mc_passed->SetLineWidth(2);
fit_Data_div_mc_passed->Draw("same");
TGraphAsymmErrors* graph_Data_div_mc_failed = makeGraph_data_div_mc(graph_Data_failed, graph_mcSum_failed);
graph_Data_div_mc_failed->SetLineColor(graph_Data_failed->GetLineColor());
graph_Data_div_mc_failed->SetMarkerColor(graph_Data_failed->GetMarkerColor());
graph_Data_div_mc_failed->SetMarkerStyle(graph_Data_failed->GetMarkerStyle());
graph_Data_div_mc_failed->Draw("p");
TF1* fit_Data_div_mc_failed =
new TF1("fit_Data_div_mc_failed", &integralCrystalBall_f_div_f,
fit_mcSum_failed->GetMinimumX(), fit_mcSum_failed->GetMaximumX(), 2*fit_mcSum_failed->GetNpar());
for ( int iPar = 0; iPar < fit_mcSum_failed->GetNpar(); ++iPar ) {
fit_Data_div_mc_failed->SetParameter(iPar, fit_Data_failed->GetParameter(iPar));
fit_Data_div_mc_failed->SetParameter(iPar + fit_mcSum_failed->GetNpar(), fit_mcSum_failed->GetParameter(iPar));
}
fit_Data_div_mc_failed->SetLineColor(graph_Data_div_mc_failed->GetLineColor());
fit_Data_div_mc_failed->SetLineWidth(2);
fit_Data_div_mc_failed->Draw("same");
topPad->RedrawAxis();
bottomPad->RedrawAxis();
canvas->Update();
size_t idx = outputFileName.Last('.');
std::string outputFileName_plot = std::string(outputFileName.Data(), 0, idx);
if ( idx != std::string::npos ) canvas->Print(std::string(outputFileName_plot).append(std::string(outputFileName.Data(), idx)).data());
//canvas->Print(std::string(outputFileName_plot).append(".png").data());
//canvas->Print(std::string(outputFileName_plot).append(".pdf").data());
topPad->Print(std::string(outputFileName_plot).append(".png").data());
topPad->Print(std::string(outputFileName_plot).append(".pdf").data());
delete legend;
delete label;
delete dummyHistogram_top;
delete topPad;
delete dummyHistogram_bottom;
delete bottomPad;
delete canvas;
}
示例14: qaConfig
Int_t qaConfig(TTree* tree, TString* returnStrings)
{
Float_t entryFrac=0.8, nsigmaOutlier=6., nsigmaWarning=3., epsilon=1.0e-6;
//
// specify all variables for which the status aliases shall be defined.
// only for these variables the lines in the trending plots can be computed and plotted.
//
TString sTrendVars="meanTPCncl;meanTPCnclF;meanMIP;resolutionMIP;MIPattachSlopeA;MIPattachSlopeC;";
sTrendVars+=";meanMIPele;resolutionMIPele;electroMIPSeparation;meanVertX;meanVertY;meanVertZ;meanMultPos;meanMultNeg;";
sTrendVars+=";tpcItsMatchA;tpcItsMatchC;tpcItsMatchHighPtA;tpcItsMatchHighPtC;lambdaPull;ptPull;yPull;zPull;";
sTrendVars+=";tpcConstrainPhiA;tpcConstrainPhiC;deltaPt;";
sTrendVars+=";offsetdRA;offsetdZA;offsetdRC;offsetdZC;dcarAP0;dcarAP1;dcarCP0;dcarCP1;";
sTrendVars+=";dcar_posA_0;dcar_posA_1;dcar_posA_2;dcaz_posA_0;dcaz_posA_1;dcaz_posA_2;";
sTrendVars+=";dcar_posC_0;dcar_posC_1;dcar_posC_2;dcaz_posC_0;dcaz_posC_1;dcaz_posC_2;";
sTrendVars+=";dcar_negA_0;dcar_negA_1;dcar_negA_2;dcaz_negA_0;dcaz_negA_1;dcaz_negA_2;";
sTrendVars+=";dcar_negC_0;dcar_negC_1;dcar_negC_2;dcaz_negC_0;dcaz_negC_1;dcaz_negC_2;";
//
// combined variables
// name them '..._combN' with N being the number of combined variables!
//
tree->SetAlias("meanMult_comb2" , "((meanMultPos+meanMultNeg)/2.)");
tree->SetAlias("tpcItsMatch_comb4" , "((tpcItsMatchA+tpcItsMatchC+tpcItsMatchHighPtA+tpcItsMatchHighPtC)/4)"); // mean of all 4.
tree->SetAlias("itsTpcPulls_comb4" , "(TMath::Sqrt(lambdaPull**2+ptPull**2+yPull**2+zPull**2))");
tree->SetAlias("tpcConstrainPhi_comb2" , "(TMath::Sqrt(tpcConstrainPhiA**2+tpcConstrainPhiC**2))"); // sqrt of quadr. sum ok because it's a bias.
tree->SetAlias("offsetd_comb4" , "(TMath::Sqrt(offsetdRA**2+offsetdZA**2+offsetdRC**2+offsetdZC**2))");
tree->SetAlias("dcarFitpar_comb4" , "((dcarAP0+dcarAP1+dcarCP0+dcarCP1)/4)"); // mean of 4.
tree->SetAlias("dcar0_comb4" , "(TMath::Sqrt(dcar_posA_0**2+dcar_posC_0**2+dcar_negA_0**2+dcar_negC_0**2))");
tree->SetAlias("dcar1_comb4" , "(TMath::Sqrt(dcar_posA_1**2+dcar_posC_1**2+dcar_negA_1**2+dcar_negC_1**2))");
tree->SetAlias("dcar2_comb4" , "(TMath::Sqrt(dcar_posA_2**2+dcar_posC_2**2+dcar_negA_2**2+dcar_negC_2**2))");
tree->SetAlias("dcaz0_comb4" , "(TMath::Sqrt(dcaz_posA_0**2+dcaz_posC_0**2+dcaz_negA_0**2+dcaz_negC_0**2))");
tree->SetAlias("dcaz1_comb4" , "(TMath::Sqrt(dcaz_posA_1**2+dcaz_posC_1**2+dcaz_negA_1**2+dcaz_negC_1**2))");
tree->SetAlias("dcaz2_comb4" , "(TMath::Sqrt(dcaz_posA_2**2+dcaz_posC_2**2+dcaz_negA_2**2+dcaz_negC_2**2))");
tree->SetAlias("MIPattachSlope_comb2" , "((MIPattachSlopeA+MIPattachSlopeC*(-1))/2)");
tree->SetAlias("PIDSepPow_comb2" , "(meanMIPele-meanMIP)/(0.5*(resolutionMIP*meanMIP+resolutionMIPele*meanMIPele))");
//
// add all combined variables to sTrendVars!
// only then the statistics aliases will be computed for them as well.
//
sTrendVars+=";meanMult_comb2;tpcItsMatch_comb4;itsTpcPulls_comb4;tpcConstrainPhi_comb2;";
sTrendVars+=";offsetd_comb4;dcarFitpar_comb4;dcar0_comb4;dcar1_comb4;dcar2_comb4;dcaz0_comb4;dcaz1_comb4;dcaz2_comb4;";
sTrendVars+=";MIPattachSlope_comb2;PIDSepPow_comb2;";
//
// specify criterion to mark runs with enough statistics.
// these runs are the basis for the computation of the outlier criteria.
// -> robust mean and rms are computed from given entry fraction (EF) of these runs!
//
tree->SetAlias("statisticOK", "(meanTPCncl>0)");
//
// creation of aliases for Outliers, Warnings, PhysicsAcceptable ...
// upper and lower limits needed separately to retrieve the numerical values for the line positions.
// for that reason the aliases are expected to be computable expressions.
//
TObjArray* oaTrendVars = sTrendVars.Tokenize(",;");
for (Int_t vari=0; vari<oaTrendVars->GetEntriesFast(); vari++)
{
TString sVar( oaTrendVars->At(vari)->GetName() );
// outliers, warnings and robust mean are set for all variables identically.
TStatToolkit::SetStatusAlias(tree, sVar.Data(), "statisticOK", Form("varname_OutlierMin:(MeanEF-%f*RMSEF-%f):%f", nsigmaOutlier, epsilon, entryFrac));
TStatToolkit::SetStatusAlias(tree, sVar.Data(), "statisticOK", Form("varname_OutlierMax:(MeanEF+%f*RMSEF+%f):%f", nsigmaOutlier, epsilon, entryFrac));
TStatToolkit::SetStatusAlias(tree, sVar.Data(), "statisticOK", Form("varname_WarningMin:(MeanEF-%f*RMSEF-%f):%f", nsigmaWarning, epsilon, entryFrac));
TStatToolkit::SetStatusAlias(tree, sVar.Data(), "statisticOK", Form("varname_WarningMax:(MeanEF+%f*RMSEF+%f):%f", nsigmaWarning, epsilon, entryFrac));
TStatToolkit::SetStatusAlias(tree, sVar.Data(), "statisticOK", Form("varname_RobustMean:(MeanEF+0):%f", entryFrac));
// physics acceptable should be set for each type of variable individually.
// some sets of variables are already set here, the rest should be set appropriately after the loop!
Float_t combfac=1.;
if (sVar.Contains("_comb")) {
TString last = sVar(sVar.Last('b')+1, sVar.Length());
combfac = TMath::Sqrt( atoi(last.Data()) );
}
if (sVar.Contains("dca")) {
TStatToolkit::SetStatusAlias(tree, sVar.Data(), "statisticOK", Form("varname_PhysAccMin:(MeanEF-%f+0)", 0.2*combfac)); // 2 mm around mean
TStatToolkit::SetStatusAlias(tree, sVar.Data(), "statisticOK", Form("varname_PhysAccMax:(MeanEF+%f+0)", 0.2*combfac)); // 2 mm around mean
}
else if (sVar.Contains("Pull")) {
TStatToolkit::SetStatusAlias(tree, sVar.Data(), "statisticOK", Form("varname_PhysAccMin:(MeanEF-%f+0)", 1.0*combfac)); // check them!
TStatToolkit::SetStatusAlias(tree, sVar.Data(), "statisticOK", Form("varname_PhysAccMax:(MeanEF+%f+0)", 1.0*combfac));
}
else { // other variables set to +- 5% of the mean as default to avoid crashes:
TStatToolkit::SetStatusAlias(tree, sVar.Data(), "statisticOK", Form("varname_PhysAccMin:(MeanEF-%f*MeanEF):%f", 0.05*combfac, entryFrac));
TStatToolkit::SetStatusAlias(tree, sVar.Data(), "statisticOK", Form("varname_PhysAccMax:(MeanEF+%f*MeanEF):%f", 0.05*combfac, entryFrac));
}
}
//
// all aliases can just be overwritten here...
// PhysAcc should be set to relative or absolute values appropriately!
//
TStatToolkit::SetStatusAlias(tree, "meanTPCncl", "statisticOK", Form("varname_PhysAccMin:(MeanEF-%f*MeanEF):%f", 0.05, entryFrac));
TStatToolkit::SetStatusAlias(tree, "meanTPCncl", "statisticOK", Form("varname_PhysAccMax:(MeanEF+%f*MeanEF):%f", 0.05, entryFrac));
TStatToolkit::SetStatusAlias(tree, "meanMIP", "statisticOK", Form("varname_PhysAccMin:(MeanEF-%f*MeanEF):%f", 0.01, entryFrac));
TStatToolkit::SetStatusAlias(tree, "meanMIP", "statisticOK", Form("varname_PhysAccMax:(MeanEF+%f*MeanEF):%f", 0.01, entryFrac));
TStatToolkit::SetStatusAlias(tree, "resolutionMIP", "statisticOK", Form("varname_PhysAccMin:(MeanEF-%f*MeanEF):%f", 0.10, entryFrac));
//.........这里部分代码省略.........
示例15: SplitPathName
void SplitPathName(TString pathname,TString *path,TString *name) {
int slash = pathname.Last('/');
*path = pathname(0,slash);
*name = pathname(slash+1,pathname.Length()-slash-1);
}