std::string Context::shortContextInfo() const { std::string lineInfo; if (getFirstLine() == getLastLine()) { lineInfo = (boost::format("%1%.%2%-%3%") % getFirstLine() % getFirstColon() % getLastColon()).str(); } else { lineInfo = (boost::format("%1%.%2%-%3%.%4%") % getFirstLine() % getFirstColon() % getLastLine() % getLastColon()).str(); } return (boost::format("%1%(%2%)") % getSource() % lineInfo).str(); }
std::string Context::fullContextInfo() const { std::string lineInfo; if (getFirstLine() == getLastLine()) { lineInfo = (boost::format("%1%.%2%-%3%") % getFirstLine() % getFirstColon() % getLastColon()).str(); } else { lineInfo = (boost::format("%1%.%2%-%3%.%4%") % getFirstLine() % getFirstColon() % getLastLine() % getLastColon()).str(); } return (boost::format("[%1%: %2% `%3%']") % getSource() % lineInfo % getText()).str(); }
/** *Função que recebe e organiza a requisição do cliente */ Request readRequest(Host client) { ssize_t n; Request client_request; char line[MAXBUF]; char *metodo = malloc(5); char *recurso = malloc(1000); char *protocolo = malloc(20); char *post = malloc(800); /*Lendo requisição do cliente*/ n=read(client.socket, line, MAXBUF); /* Colocar os dados do socket(requisicao completa) na variável "line" */ strcpy(client_request.line, line); /* Manipulando a variavel line para extrair dados como o método, recurso, protocolo e post*/ metodo = strtok(line, " "); recurso = strtok(NULL, " "); protocolo = strtok(NULL, "\r"); strcpy(client_request.metodo, metodo); strcpy(client_request.recurso,recurso); strcpy(client_request.protocolo, protocolo); if (strcmp(client_request.metodo,"POST")==0) { strcpy(client_request.post, getLastLine(client_request.line)); } return client_request; }
/*------------------------------------------------------------------------*/ BOOL HistoryManager::appendLine(char *cline) { BOOL bOK = FALSE; if (cline) { if (!saveconsecutiveduplicatelines) { char *previousline = getLastLine(); if ((previousline) && (strcmp(previousline, cline) == 0)) { bOK = FALSE; } else { CommandLine Line(cline); CommandsList.push_back(Line); numberoflinesbeforehistoryissaved++; bOK = TRUE; CommandHistoryAppendLine(cline); } if (previousline) { FREE(previousline); previousline = NULL; } } else { CommandLine Line(cline); CommandsList.push_back(Line); numberoflinesbeforehistoryissaved++; bOK = TRUE; CommandHistoryAppendLine(cline); } } if (afterhowmanylineshistoryissaved != 0) { if (afterhowmanylineshistoryissaved == numberoflinesbeforehistoryissaved) { my_file.setHistory(CommandsList); my_file.writeToFile(); numberoflinesbeforehistoryissaved = 0; } } else { numberoflinesbeforehistoryissaved = 0; } return bOK; }
std::string Context::mediumContextInfo() const { std::string lineInfo; std::string text = getText(); const size_t MaxInfoLength = 16; if (text.length() > MaxInfoLength) { text = text.substr(0, MaxInfoLength) + "..."; } if (getFirstLine() == getLastLine()) { lineInfo = (boost::format("%1%.%2%-%3%") % getFirstLine() % getFirstColon() % getLastColon()).str(); } else { lineInfo = (boost::format("%1%.%2%-%3%.%4%") % getFirstLine() % getFirstColon() % getLastLine() % getLastColon()).str(); } return (boost::format("[%1%: %2%] `%3%'") % getSource() % lineInfo % text).str(); }
/*------------------------------------------------------------------------*/ BOOL HistoryManager::appendLine(char* _pstLine) { BOOL bOK = FALSE; if (_pstLine) { int i = 0; int len = 0; char* pstCleanedLine = NULL; /* remove space & carriage return at the end of line */ len = (int)strlen(_pstLine); pstCleanedLine = (char*) MALLOC(len + 1); memcpy(pstCleanedLine, _pstLine, len + 1); /* remove carriage return at the end of line */ for (i = len ; i > 0 ; i--) { if (pstCleanedLine[i] == '\n') { pstCleanedLine[i] = '\0'; len = i - 1; break; } } /* remove spaces at the end of line */ i = len; while (i >= 0) { if (pstCleanedLine[i] == ' ') { pstCleanedLine[i] = '\0'; } else { break; } i--; } if (strlen(pstCleanedLine) == 0) { FREE(pstCleanedLine); return TRUE; } // append if (m_bAllowConsecutiveCommand) { m_Commands.push_back(pstCleanedLine); m_iSavedLines++; bOK = TRUE; CommandHistoryAppendLine(pstCleanedLine); } else { char* pstPreviousLine = getLastLine(); if (pstPreviousLine && strcmp(pstPreviousLine, pstCleanedLine) == 0) { bOK = TRUE; } else { m_Commands.push_back(pstCleanedLine); m_iSavedLines++; bOK = TRUE; CommandHistoryAppendLine(pstCleanedLine); } if (pstPreviousLine) { FREE(pstPreviousLine); pstPreviousLine = NULL; } } if (m_iSaveLimit != 0) { if (m_iSavedLines >= m_iSaveLimit) { m_HF.setHistory(m_Commands); m_HF.writeToFile(); m_iSavedLines = 0; } } else { m_iSavedLines = 0; } if (pstCleanedLine) { FREE(pstCleanedLine); pstCleanedLine = NULL; } } return bOK; }
void combine_closure() { std::vector<TString> channels; channels.push_back("ee"); channels.push_back("emu"); channels.push_back("mumu"); channels.push_back("combined"); std::vector<TString> masses; //masses.push_back("166"); masses.push_back("169"); //masses.push_back("171"); masses.push_back("172"); //masses.push_back("173"); masses.push_back("175"); //masses.push_back("178"); for(std::vector<TString>::iterator ch = channels.begin(); ch != channels.end(); ++ch) { setHHStyle(*gStyle); TGraphAsymmErrors * graph = new TGraphAsymmErrors(); TGraphAsymmErrors * graphtotal = new TGraphAsymmErrors(); setStyle(graph); setStyle(graphtotal); for(std::vector<TString>::iterator m = masses.begin(); m != masses.end(); ++m) { TString filename = *m + "/MassFitDiffXSecSystematics_" + *ch + ".txt"; std::ifstream infile(filename); if (infile) { std::stringstream stream; std::string dummy; std::string line = getLastLine(infile); std::cout << line << '\n'; stream.clear(); stream << line; for(size_t i = 0; i < 4; ++i ) { stream >> dummy; } double outmass, statp, statn, systp, systn; stream >> outmass >> statp >> statn >> dummy >> systp >> systn; //stat = atof(dummy.erase(0,2).c_str()); double inmass = (atof(*m)+0.5); double tot_pos = sqrt(statp*statp + systp*systp); double tot_neg = sqrt(statn*statn + systn*systn); std::cout << outmass << "@" << inmass << " | " << statp << " " << statn << " | " << systp << " " << systn << " | " << tot_pos << " " << tot_neg << std::endl; // Add point: graph->SetPoint(m-masses.begin(),inmass,outmass); graphtotal->SetPoint(m-masses.begin(),inmass,outmass); graphtotal->SetPointError(m-masses.begin(),0,0,tot_neg,tot_pos); graph->SetPointError(m-masses.begin(),0,0,TMath::Abs(statn),TMath::Abs(statp)); } else std::cout << "Unable to open file " << filename << ".\n"; infile.close(); } graphtotal->GetXaxis()->SetTitle("input m_{t} #left[GeV#right]"); graphtotal->GetYaxis()->SetTitle("output m_{t} #left[GeV#right]"); Double_t m_min = 164, m_max = 182, m_nominal = 172.5; graphtotal->GetXaxis()->SetLimits(m_min,m_max); graphtotal->GetYaxis()->SetRangeUser(m_min,m_max); graph->SetLineColor(kGray+1); graph->SetMarkerStyle(20); graphtotal->SetLineColor(kOrange-4); TLine *l = new TLine(m_min,m_min,m_max,m_max); l->SetLineColor(kGray+1); l->SetLineStyle(7); l->SetLineWidth(2); TLine *l2 = new TLine(m_min,m_nominal,m_max,m_nominal); l2->SetLineColor(kGray+1); l2->SetLineStyle(7); l2->SetLineWidth(2); TCanvas * c = new TCanvas("diffxs_closure_" + *ch,"diffxs_closure_" + *ch); c->cd(); graphtotal->Draw("a p e1"); graph->Draw("same e1"); l->Draw(); l2->Draw(); DrawCMSLabels(); c->Print("diffxs_closure_" + *ch + ".pdf"); }