本文整理汇总了C++中std::string::compare方法的典型用法代码示例。如果您正苦于以下问题:C++ string::compare方法的具体用法?C++ string::compare怎么用?C++ string::compare使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::string
的用法示例。
在下文中一共展示了string::compare方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: insert
bool HighScoresList::insert(std::string name, int score)
{
if (name.compare("") == 0)
{
return false;
}
if (head_ == NULL) //This is the first item
{
head_ = new Item;
head_->name_ = name;
head_->score_ = score;
head_->next_ = NULL;
size_ = 1;
return true;
}
Item* temp = new Item;
temp->name_ = name;
temp->score_ = score;
temp->next_ = NULL;
Item* last = head_;
Item* previous;
if (last->score_ <= temp->score_)
{
temp->next_ = head_;
head_ = temp;
return true;
}
last = last->next_;
previous = head_;
bool found = false;
while (last != NULL)
{
if (last->score_ <= temp->score_)
{
previous->next_ = temp;
temp->next_ = last;
found = true;
break;
}
previous = previous->next_;
last = last->next_;
}//End while
bool lastItem = false;
if (!found) {
previous->next_ = temp;
lastItem = true;
}
size_++;
if (size_ > 10)
{
removeLastItem();
if (lastItem)
return false;
}
return true;
/*
std::cout << "Moving through list" << std::endl;
Item* conductor = head_;
Item* previous = head_;
while(conductor != NULL)
{
if(conductor->score_ >= score)
{
std::cout << "Score: " << conductor->score_ << std::endl;
if (conductor != head_)
previous = previous->next_;
conductor = conductor->next_;
} else {
Item* newNode = new Item;
newNode->name_ = name;
newNode->score_ = score;
newNode->next_ = conductor;
previous->next_ = newNode;
if (size_ == 10)
removeLastItem();
else
size_++;
return true;
}
}
std::cout << "Adding at end of list" << std::endl;
if (size_ < 10)
{
Item* newNode = new Item;
newNode->name_ = name;
newNode->score_ = score;
newNode->next_ = NULL;
previous->next_ = newNode;
size_++;
std::cout << "Inserted " << previous->score_ << std::endl;
return true;
//.........这里部分代码省略.........
示例2: is_me
// to identify
bool is_me(const char* filepath) const {
return (mv_filepath.compare(filepath) == 0);
}
示例3: ns__Inverse
int ns__Inverse( struct soap *soap,
std::string InputMatFilename,
std::string InvMethod_D=DEFAULTVAL,
std::string &OutputMatFilename=ERROR_FILENAME)
{
bool timeChecking, memoryChecking;
getConfig(timeChecking, memoryChecking);
if(timeChecking){
start = omp_get_wtime();
}
/* read from bin */
Mat src;
Mat dst;
if(!readMat(InputMatFilename, src))
{
Log(logERROR) << "Inv:: can not read bin file for src" << std::endl;
return soap_receiver_fault(soap, "Inv :: can not read bin file for src", NULL);
}
int method;
if(InvMethod_D == DEFAULTVAL) InvMethod_D = "DECOMP_LU";
if(InvMethod_D.compare("DECOMP_LU")==0) method = DECOMP_LU;
else if(InvMethod_D.compare("DECOMP_CHOLESKY")==0) method = DECOMP_CHOLESKY;
else if(InvMethod_D.compare("DECOMP_SVD")==0) method = DECOMP_SVD;
try{
dst = src.inv(method);
} catch( cv::Exception& e ) {
Log(logERROR) << e.what() << std::endl;
return soap_receiver_fault(soap, e.what(), NULL);
}
std::string toAppend = "_Inv";
getOutputFilename(OutputMatFilename, toAppend);
if(!saveMat(OutputMatFilename, dst))
{
Log(logERROR) << "Inv :: can not save mat to binary file" << std::endl;
return soap_receiver_fault(soap, "Inv :: can not save mat to binary file", NULL);
}
src.release();
dst.release();
if(timeChecking)
{
end = omp_get_wtime();
Log(logINFO) << "Inv :: " << "time elapsed " << end-start << std::endl;
}
if(memoryChecking)
{
double vm, rss;
getMemoryUsage(vm, rss);
Log(logINFO)<< "Inv :: VM usage :" << vm << std::endl
<< "Resident set size :" << rss << std::endl;
}
return SOAP_OK;
}
示例4: if
DX11RenderBuffer::DX11RenderBuffer(const std::string& bufferName, RenderBufferType type, Geometry* data, std::string const& sematic, BufferUsage bufferUsage, ShaderObject* vertexShader)
{
_bufferUsage = bufferUsage;
_elementSize = 0;
_bufferSize = 0;
_type = type;
void *pData = NULL;
std::vector<float> vData;
if( type == RBT_Vertex )
{
_bindFlags = D3D11_BIND_VERTEX_BUFFER;
DX11ShaderObject* shader = (DX11ShaderObject*)vertexShader;
for(unsigned int i=0; i< shader->ShaderReflect->InputSignatureParameters.size();++i)
{
if(shader->ShaderReflect->InputSignatureParameters[i].SemanticName.compare(sematic) == 0 )
{
_elementSize = shader->ShaderReflect->InputSignatureParameters[i].GetElementSize();
break;
}
}
if( _elementSize == 0 )
{
BOOST_ASSERT(0);
}
if(sematic.compare(DX11RenderLayout::POSITION) == 0 )
{
_bufferSize = _elementSize*data->Positions.size();
for(unsigned int index=0;index<data->Positions.size();++index)
{
glm::vec3& vec = data->ControllPositions[data->Positions[index]];
vData.push_back(vec.x);
vData.push_back(vec.y);
vData.push_back(vec.z);
}
}
else if(sematic.compare(DX11RenderLayout::COLOR) == 0 )
{
_bufferSize = _elementSize*data->Colors.size();
for(unsigned int index=0;index<data->Colors.size();++index)
{
glm::vec4& vec = data->Colors[index];
vData.push_back(vec.x);
vData.push_back(vec.y);
vData.push_back(vec.z);
vData.push_back(vec.w);
}
}
else if(sematic.compare(DX11RenderLayout::NORMAL) == 0 )
{
_bufferSize = _elementSize*data->Normals.size();
for(unsigned int index=0;index<data->Normals.size();++index)
{
glm::vec3& vec = data->Normals[index];
vData.push_back(vec.x);
vData.push_back(vec.y);
vData.push_back(vec.z);
}
}
else if(sematic.compare(DX11RenderLayout::TEXCOORD) == 0 )
{
_bufferSize = _elementSize*data->Texcoords.size();
for(unsigned int index=0;index<data->Texcoords.size();++index)
{
glm::vec2& vec = data->Texcoords[index];
vData.push_back(vec.x);
vData.push_back(vec.y);
}
}
else
{
BOOST_ASSERT(0);
}
pData = vData.data();
}
else if( _type == RBT_Index )
{
_bindFlags = D3D11_BIND_INDEX_BUFFER;
if( data->Indices.size() > 0 )
{
_elementSize = sizeof(unsigned int);
_bufferSize = sizeof(unsigned int) * data->Indices.size();
pData = data->Indices.data();
}
}
BOOST_ASSERT(_bufferSize > 0 );
DoCreateBuffer(pData);
D3DInterface->SetPrivateData(WKPDID_D3DDebugObjectName, bufferName.size(), bufferName.c_str());
}
示例5: runtime_error
bool xorg::testing::XServer::WaitForDevice(::Display *display, const std::string &name,
time_t timeout)
{
int opcode;
int event_start;
int error_start;
bool device_found = false;
if (!XQueryExtension(display, "XInputExtension", &opcode, &event_start,
&error_start))
throw std::runtime_error("Failed to query XInput extension");
XIEventMask *masks;
int nmasks;
bool mask_set, mask_created;
masks = set_hierarchy_mask(display, &nmasks, &mask_set, &mask_created);
XIDeviceInfo *info;
int ndevices;
info = XIQueryDevice(display, XIAllDevices, &ndevices);
for (int i = 0; !device_found && i < ndevices; i++) {
device_found = (name.compare(info[i].name) == 0);
}
XIFreeDeviceInfo(info);
while (!device_found &&
WaitForEventOfType(display, GenericEvent, opcode,
XI_HierarchyChanged, timeout)) {
XEvent event;
if (XNextEvent(display, &event) != Success)
throw std::runtime_error("Failed to get X event");
XGenericEventCookie *xcookie =
reinterpret_cast<XGenericEventCookie*>(&event.xcookie);
if (!XGetEventData(display, xcookie))
throw std::runtime_error("Failed to get X event data");
XIHierarchyEvent *hierarchy_event =
reinterpret_cast<XIHierarchyEvent*>(xcookie->data);
if (!(hierarchy_event->flags & XIDeviceEnabled)) {
XFreeEventData(display, xcookie);
continue;
}
device_found = false;
for (int i = 0; i < hierarchy_event->num_info; i++) {
if (!(hierarchy_event->info[i].flags & XIDeviceEnabled))
continue;
int num_devices;
XIDeviceInfo *device_info =
XIQueryDevice(display, hierarchy_event->info[i].deviceid,
&num_devices);
if (num_devices != 1 || !device_info)
throw std::runtime_error("Failed to query device");
if (name.compare(device_info[0].name) == 0) {
device_found = true;
break;
}
}
XFreeEventData(display, xcookie);
if (device_found)
break;
}
unset_hierarchy_mask(display, masks, nmasks, mask_set, mask_created);
return device_found;
}
示例6: startWith
static inline bool startWith(const std::string &str, const std::string &prefix) {
return str.compare(0, prefix.length(), prefix) == 0;
}
示例7: X_extended
double EWSMApproximateFormulae::X_extended(const std::string observable) const
{
double LH = log(mycache.getSM().getMHl() / 125.7);
double DH = mycache.getSM().getMHl() / 125.7 - 1.0;
double Dt = pow(mycache.getSM().getMtpole() / 173.2, 2.0) - 1.0;
double Das = mycache.getSM().getAlsMz() / 0.1184 - 1.0;
double Dal = mycache.getSM().DeltaAlphaL5q() / 0.059 - 1.0;
double DZ = mycache.getSM().getMz() / 91.1876 - 1.0;
double X0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15;
double ThError = 0.0; // Theoretical uncertainty
if (observable.compare("Gamma_nu") == 0) {
X0 = 167.157;
a1 = -0.1567;
a2 = -0.1194;
a3 = 0.1031;
a4 = -0.00269;
a5 = 1.258;
a6 = -0.13;
a7 = -0.020;
a8 = 0.0133;
a9 = -0.19;
a10 = -0.018;
a11 = -0.021;
a12 = 0.34;
a13 = -0.084;
a14 = 0.064;
a15 = 503.0;
} else if (observable.compare("Gamma_e_mu") == 0) {
X0 = 83.966;
a1 = -0.1017;
a2 = -0.06352;
a3 = 0.05500;
a4 = -0.00145;
a5 = 0.8051;
a6 = -0.027;
a7 = -0.017;
a8 = 0.0066;
a9 = -0.095;
a10 = -0.010;
a11 = -0.015;
a12 = 0.23;
a13 = -1.1;
a14 = 0.064;
a15 = 285.0;
} else if (observable.compare("Gamma_tau") == 0) {
X0 = 83.776;
a1 = -0.1016;
a2 = -0.06339;
a3 = 0.05488;
a4 = -0.00145;
a5 = 0.8036;
a6 = -0.026;
a7 = -0.017;
a8 = 0.0066;
a9 = -0.095;
a10 = -0.010;
a11 = -0.015;
a12 = 0.23;
a13 = -1.1;
a14 = 0.064;
a15 = 285.0;
} else if (observable.compare("Gamma_u") == 0) {
X0 = 299.936;
a1 = -0.5681;
a2 = -0.2636;
a3 = 0.2334;
a4 = -0.00592;
a5 = 4.057;
a6 = -0.50;
a7 = -0.058;
a8 = 0.0352;
a9 = 14.26;
a10 = 1.6;
a11 = -0.081;
a12 = 1.7;
a13 = -11.1;
a14 = 0.19;
a15 = 1251.0;
} else if (observable.compare("Gamma_c") == 0) {
X0 = 299.859;
a1 = -0.5680;
a2 = -0.2635;
a3 = 0.2334;
a4 = -0.00592;
a5 = 4.056;
a6 = -0.50;
a7 = -0.058;
a8 = 0.0352;
a9 = 14.26;
a10 = 1.6;
a11 = -0.081;
a12 = 1.7;
a13 = -11.1;
a14 = 0.19;
a15 = 1251.0;
} else if (observable.compare("Gamma_d_s") == 0) {
X0 = 382.770;
a1 = -0.6199;
a2 = -0.3182;
//.........这里部分代码省略.........
示例8: convertProcessType
ProcessType convertProcessType(const std::string& pcs_type_string)
{
if (pcs_type_string.compare("LIQUID_FLOW") == 0) return LIQUID_FLOW;
if (pcs_type_string.compare("TWO_PHASE_FLOW") == 0) return TWO_PHASE_FLOW;
if (pcs_type_string.compare("RICHARDS_FLOW") == 0) return RICHARDS_FLOW;
if (pcs_type_string.compare("GROUNDWATER_FLOW") == 0)
return GROUNDWATER_FLOW;
if (pcs_type_string.compare("HEAT_TRANSPORT") == 0) return HEAT_TRANSPORT;
if (pcs_type_string.compare("DEFORMATION") == 0) return DEFORMATION;
if (pcs_type_string.compare("DEFORMATION_FLOW") == 0)
return DEFORMATION_FLOW;
if (pcs_type_string.compare("MASS_TRANSPORT") == 0) return MASS_TRANSPORT;
if (pcs_type_string.compare("MULTI_PHASE_FLOW") == 0)
return MULTI_PHASE_FLOW;
if (pcs_type_string.compare("DEFORMATION_H2") == 0) return DEFORMATION_H2;
if (pcs_type_string.compare("AIR_FLOW") == 0) return AIR_FLOW;
if (pcs_type_string.compare("FLUID_MOMENTUM") == 0) return FLUID_MOMENTUM;
if (pcs_type_string.compare("RANDOM_WALK") == 0) return RANDOM_WALK;
if (pcs_type_string.compare("FLUX") == 0) return FLUX;
if (pcs_type_string.compare("PS_GLOBAL") == 0) return PS_GLOBAL;
if (pcs_type_string.compare("TH_MONOLITHIC") == 0) return TH_MONOLITHIC;
if (pcs_type_string.compare("NO_PCS") == 0) return NO_PCS;
// else
// std::cout << "WARNING in convertProcessType: process type #" <<
// pcs_type_string <<
//"# unknown" << "\n";
return INVALID_PROCESS;
}
示例9: convertDisType
DistributionType convertDisType(const std::string& dis_type_string)
{
if (dis_type_string.compare("CONSTANT") == 0) return CONSTANT;
if (dis_type_string.compare("ANALYTICAL") == 0) return ANALYTICAL;
if (dis_type_string.compare("AVERAGE") == 0) return AVERAGE;
if (dis_type_string.compare("CONSTANT_GEO") == 0) return CONSTANT_GEO;
if (dis_type_string.compare("GRADIENT") == 0) return GRADIENT;
if (dis_type_string.compare("RESTART") == 0) return RESTART;
if (dis_type_string.compare("LINEAR") == 0) return LINEAR;
if (dis_type_string.compare("POINT") == 0) return POINT;
if (dis_type_string.compare("CONSTANT_NEUMANN") == 0)
return CONSTANT_NEUMANN;
if (dis_type_string.compare("LINEAR_NEUMANN") == 0) return LINEAR_NEUMANN;
if (dis_type_string.compare("NORMALDEPTH") == 0) return NORMALDEPTH;
if (dis_type_string.compare("CRITICALDEPTH") == 0) return CRITICALDEPTH;
if (dis_type_string.compare("GREEN_AMPT") == 0) return GREEN_AMPT;
if (dis_type_string.compare("SYSTEM_DEPENDENT") == 0)
return SYSTEM_DEPENDENT;
if (dis_type_string.compare("PRECIPITATION") == 0) return PRECIPITATION;
if (dis_type_string.compare("DIRECT") == 0) return DIRECT;
if (dis_type_string.compare("FUNCTION") == 0)
return FUNCTION; // 24.08.2011. WW
if (dis_type_string.compare("ELEMENT") == 0) return ELEMENT;
if (dis_type_string.compare("INITIAL") == 0)
return INITIAL;
else
{
std::cout << "convertDisType #" << dis_type_string << "# not found"
<< "\n";
exit(1);
}
return INVALID_DIS_TYPE;
}
示例10: processWithLock
TyErrorId processWithLock(CAS &tcas, ResultSpecification const &res_spec)
{
outInfo("process start");
rs::StopWatch clock;
// init service client
char *argv[] = { const_cast<char *>("gt_annotation_client"), NULL };
int argc = sizeof(argv) / sizeof(char *) - 1;
//char** fake_argv = const_cast<char**> (&argv[0]);
ros::init(argc, argv, "gt_annotation_client");
ros::NodeHandle n;
ros::ServiceClient client = n.serviceClient<rs_log_learning::ImageGTAnnotation>("image_gt_annotation");
rs_log_learning::ImageGTAnnotation srv;
// grab cluster images
rs::SceneCas cas(tcas);
rs::Scene scene = cas.getScene();
cv::Mat color;
cas.get(VIEW_COLOR_IMAGE_HD, color);
std::vector<rs::Cluster> clusters;
scene.identifiables.filter(clusters);
// call the service of the UI with each cluster ROI image to annotate
for(int i = 0; i < clusters.size(); ++i)
{
rs::Cluster cluster = clusters.at(i);
rs::ImageROI image_rois = cluster.rois.get();
std::vector<rs_log_learning::Learning> learning;
clusters[i].annotations.filter(learning);
cv::Mat rgb, mask;
cv::Rect roi;
rs::conversion::from(image_rois.roi_hires(), roi);
rs::conversion::from(image_rois.mask_hires(), mask);
color(roi).copyTo(rgb, mask);
// prepare the image for the service call
cv_bridge::CvImagePtr cv_ptr;
cv_bridge::CvImage srv_msg;
if(rgb.type() == CV_8UC1)
{
outInfo(
"image from cluster " << i << " is of type CV_8UC1 with size: " << rgb.size);
outError("no encoding header for this frame");
}
else if(rgb.type() == CV_8UC3)
{
outInfo(
"image from cluster " << i << " is of type CV_8UC3 with size: " << rgb.size);
srv_msg.encoding = sensor_msgs::image_encodings::BGR8;
}
//srv_msg.header.frame_id = sensor_msgs::
srv_msg.image = rgb;
srv_msg.toImageMsg(srv.request.image);
outInfo("converted image from cluster " << i << " is " << (int)srv.request.image.width << "x" << (int)srv.request.image.height);
if(!learning.empty())
{
srv.request.lrn_name = learning.at(0).name.get();
srv.request.lrn_shape = learning.at(0).shape.get();
srv.request.lrn_confidence = learning.at(0).confidence.get();
}
else
{
srv.request.lrn_name = "<none>";
srv.request.lrn_shape = "<none>";
srv.request.lrn_confidence = 0;
}
// all data set, call the service
if(client.call(srv))
{
outInfo("got annotation back from ui service");
outInfo("entered - name: " << srv.response.gt_name
<< " shape: " << srv.response.gt_shape);
}
else
{
outError("Failed to call annotation service. start mpGTui");
}
// set strings returned from service
rs_log_learning::GroundTruthAnnotation gt = rs::create<rs_log_learning::GroundTruthAnnotation>(tcas);
gt.global_gt.set(srv.response.gt_name);
gt.shape.set(srv.response.gt_shape);
clusters[i].annotations.append(gt);
if(mode.compare("evaluate") == 0)
{
writeToCsv(srv.response.gt_name, srv.response.gt_shape,
srv.request.lrn_name, srv.request.lrn_shape,
srv.request.lrn_confidence);
}
}
//.........这里部分代码省略.........
示例11: convertPrimaryVariable
PrimaryVariable convertPrimaryVariable(const std::string& pcs_pv_string)
{
if (pcs_pv_string.compare("PRESSURE1") == 0) return PRESSURE;
if (pcs_pv_string.compare("PRESSURE2") == 0) return PRESSURE2;
if (pcs_pv_string.compare("PRESSURE_RATE1") == 0) return PRESSURE_RATE1;
if (pcs_pv_string.compare("SATURATION1") == 0) return SATURATION;
if (pcs_pv_string.compare("SATURATION2") == 0) return SATURATION2;
if (pcs_pv_string.compare("TEMPERATURE1") == 0) return TEMPERATURE;
if (pcs_pv_string.compare("DISPLACEMENT_X1") == 0) return DISPLACEMENT_X;
if (pcs_pv_string.compare("DISPLACEMENT_Y1") == 0) return DISPLACEMENT_Y;
if (pcs_pv_string.compare("DISPLACEMENT_Z1") == 0) return DISPLACEMENT_Z;
if (pcs_pv_string.compare("CONCENTRATION1") == 0) return CONCENTRATION;
if (pcs_pv_string.compare("HEAD") == 0) return HEAD;
if (pcs_pv_string.compare("VELOCITY_DM_X") == 0) return VELOCITY_DM_X;
if (pcs_pv_string.compare("VELOCITY_DM_Y") == 0) return VELOCITY_DM_Y;
if (pcs_pv_string.compare("VELOCITY_DM_Z") == 0) return VELOCITY_DM_Z;
if (pcs_pv_string.compare("VELOCITY1_X") == 0) return VELOCITY1_X;
if (pcs_pv_string.compare("VELOCITY1_Y") == 0) return VELOCITY1_Y;
if (pcs_pv_string.compare("VELOCITY1_Z") == 0) return VELOCITY1_Z;
if (pcs_pv_string.compare("STRESS_XX") == 0) return STRESS_XX;
if (pcs_pv_string.compare("STRESS_XY") == 0) return STRESS_XY;
if (pcs_pv_string.compare("STRESS_XZ") == 0) return STRESS_XZ;
if (pcs_pv_string.compare("STRESS_YY") == 0) return STRESS_YY;
if (pcs_pv_string.compare("STRESS_YZ") == 0) return STRESS_YZ;
if (pcs_pv_string.compare("STRESS_ZZ") == 0) return STRESS_ZZ;
if (pcs_pv_string.compare("STRAIN_XX") == 0) return STRAIN_XX;
if (pcs_pv_string.compare("STRAIN_XY") == 0) return STRAIN_XY;
if (pcs_pv_string.compare("STRAIN_XZ") == 0) return STRAIN_XZ;
if (pcs_pv_string.compare("STRAIN_YY") == 0) return STRAIN_YY;
if (pcs_pv_string.compare("STRAIN_YZ") == 0) return STRAIN_YZ;
if (pcs_pv_string.compare("STRAIN_ZZ") == 0) return STRAIN_ZZ;
if (pcs_pv_string.compare("STRAIN_PLS") == 0) return STRAIN_PLS;
// else
//{
// std::cout << "convertPrimaryVariable #" << pcs_pv_string << "# not found"
// << "\n";
// exit (1);
//}
return INVALID_PV;
}
示例12: do_
bool do_(std::string actual_output) {
return expected_output.compare(actual_output) == 0;
}
示例13: ffgammajet
void ztree::ffgammajet(std::string outfname, int centmin, int centmax, float phoetmin, float phoetmax, std::string gen)
{
string tag = outfname;
string s_alpha = gen;
if (fChain == 0) return;
Long64_t nentries = fChain->GetEntriesFast();
TFile * fout = new TFile(Form("%s_%s_%s_%d_%d.root",outfname.data(),tag.data(),s_alpha.data(),abs(centmin),abs(centmax)),"recreate");
TH2D * hsubept = new TH2D(Form("hsubept_%s_%s_%d_%d",tag.data(),s_alpha.data(),abs(centmin),abs(centmax)),Form(";#xi=ln(1/z);"),100,-0.5,99.5,100,0,100);
TH2D * hsubept_refcone = new TH2D(Form("hsubept_refcone_%s_%s_%d_%d",tag.data(),s_alpha.data(),abs(centmin),abs(centmax)),Form(";#xi=ln(1/z);"),100,-0.5,99.5,100,0,100);
TH1D * hjetpt = new TH1D(Form("hjetpt_%s_%s_%d_%d",tag.data(),s_alpha.data(),abs(centmin),abs(centmax)),Form(";jet p_{T};"),20,0,500);
TH1D * hjetgendphi = new TH1D(Form("hjetgendphi_%s_%s_%d_%d",tag.data(),s_alpha.data(),abs(centmin),abs(centmax)),Form(";#DeltaR_{gen,reco};"),20,0,0.1);
TH1D * hgammaff = new TH1D(Form("hgammaff_%s_%s_%d_%d",tag.data(),s_alpha.data(),abs(centmin),abs(centmax)),Form(";z;"),20,0,1);
TH1D * hgammaffxi = new TH1D(Form("hgammaffxi_%s_%s_%d_%d",tag.data(),s_alpha.data(),abs(centmin),abs(centmax)),Form(";#xi=ln(1/z);"),10,0,5);
TH1D * hgammaffxi_refcone = new TH1D(Form("hgammaffxi_refcone_%s_%s_%d_%d",tag.data(),s_alpha.data(),abs(centmin),abs(centmax)),Form(";#xi=ln(1/z);"),10,0,5);
TH1D * hgammaphoffxi = new TH1D(Form("hgammaphoffxi_%s_%s_%d_%d",tag.data(),s_alpha.data(),abs(centmin),abs(centmax)),Form(";#xi=ln(1/z);"),10,0,5);
TH1D * hgammaphoffxi_refcone = new TH1D(Form("hgammaphoffxi_refcone_%s_%s_%d_%d",tag.data(),s_alpha.data(),abs(centmin),abs(centmax)),Form(";#xi=ln(1/z);"),10,0,5);
Long64_t nbytes = 0, nb = 0;
cout<<phoetmin<<" "<<phoetmax<<endl;
for (Long64_t jentry=0; jentry<nentries;jentry++) {
if(jentry%10000==0) { cout<<jentry<<"/"<<nentries<<endl; }
Long64_t ientry = LoadTree(jentry);
if (ientry < 0) break;
// cout<<njet<<endl;
// if(jentry > 10000) break;
nb = fChain->GetEntry(jentry); nbytes += nb;
if(hiBin < centmin || hiBin >= centmax) continue; //centrality cut
if(nPho!=1) continue;
if(phoEt[0]<phoetmin || phoEt[0]>phoetmax) continue;
if(weight==0) weight=1;
// cout<<njet<<endl;
if(gen.compare("gen")==0)
{
for (int ijet = 0; ijet < njet; ijet++) {
if( nPho==2 ) continue;
if( jetpt[ijet]<40 ) continue; //jet pt Cut
if( fabs(jeteta[ijet]) > 1.6) continue; //jeteta Cut
if( fabs(jeteta[ijet]) < 0.3) continue; //jeteta Cut for reflected cone
if( jetID[ijet]==0 ) continue; //redundant in this skim (all true)
if( acos(cos(jetphi[ijet] - phoPhi[0])) < 7 * pi / 8 ) continue;
hjetpt->Fill(jetpt[ijet]);
float denrecodphi = acos(cos(jetphi[ijet] - gjetphi[ijet]));
hjetgendphi->Fill(denrecodphi);
for(int igen = 0 ; igen < mult ; ++igen)
{
if(!(abs(pdg[igen])==11 || abs(pdg[igen])==13 || abs(pdg[igen])==211 || abs(pdg[igen])==2212 || abs(pdg[igen])==321)) continue;
if(sube[igen] != 0) continue;
float dr = genjettrk_dr(igen,ijet);
float dr_refcone = genrefconetrk_dr(igen,ijet);
if(dr<0.3)
{
float z = pt[igen]/gjetpt[ijet];
float zpho = pt[igen]/phoEt[0];
float xi = log(1.0/z);
float xipho = log(1.0/zpho);
hgammaff->Fill(z);
hgammaffxi->Fill(xi);
hgammaphoffxi->Fill(xipho);
hsubept->Fill(sube[igen],pt[igen]);
// cout<<jetpt[ijet]<<endl;
}
if(dr_refcone<0.3)
{
float z = pt[igen]/gjetpt[ijet];
float zpho = pt[igen]/phoEt[0];
float xi = log(1.0/z);
float xipho = log(1.0/zpho);
hgammaffxi_refcone->Fill(xi);
hgammaphoffxi_refcone->Fill(xipho);
hsubept_refcone->Fill(sube[igen],pt[igen]);
}
}
}
}
else
{
for (int ijet = 0; ijet < njet; ijet++) {
if( nPho==2 ) continue;
if( jetpt[ijet]<40 ) continue; //jet pt Cut
if( fabs(jeteta[ijet]) > 1.6) continue; //jeteta Cut
if( fabs(jeteta[ijet]) < 0.3) continue; //jeteta Cut for reflected cone
if( jetID[ijet]==0 ) continue; //redundant in this skim (all true)
if( acos(cos(jetphi[ijet] - phoPhi[0])) < 7 * pi / 8 ) continue;
hjetpt->Fill(jetpt[ijet]);
float denrecodphi = acos(cos(jetphi[ijet] - gjetphi[ijet]));
hjetgendphi->Fill(denrecodphi);
for(int igen = 0 ; igen < mult ; ++igen)
{
if(!(abs(pdg[igen])==11 || abs(pdg[igen])==13 || abs(pdg[igen])==211 || abs(pdg[igen])==2212 || abs(pdg[igen])==321)) continue;
if(sube[igen] != 0) continue;
float dr = recojetgentrk_dr(igen,ijet);
float dr_refcone = recorefconegentrk_dr(igen,ijet);
if(dr<0.3)
{
float z = pt[igen]/gjetpt[ijet];
float zpho = pt[igen]/phoEt[0];
//.........这里部分代码省略.........
示例14: writeEdgeNode
//-----------------------------------------
void LegacyWriter::writeEdgeNode(xmlTextWriterPtr writer, const std::string& edge_id, const std::string& new_id, const std::string& source_id, const std::string& target_id, const std::string& cardinal, const std::string& type) {
//-----------------------------------------
/* Write an element named "edge" as child of edges. */
int rc = xmlTextWriterStartElement(writer, BAD_CAST "edge");
if (rc < 0) {
throw FileWriterException("Error at xmlTextWriterWriteElement");
}
/* Add an attribute with name "id" */
rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "id", BAD_CAST new_id.c_str());
if (rc < 0) {
throw FileWriterException( "Error at xmlTextWriterWriteAttribute");
}
/* Add an attribute with name "source" */
rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "source", BAD_CAST source_id.c_str());
if (rc < 0) {
throw FileWriterException( "Error at xmlTextWriterWriteAttribute");
}
/* Add an attribute with name "target" */
rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "target", BAD_CAST target_id.c_str());
if (rc < 0) {
throw FileWriterException( "Error at xmlTextWriterWriteAttribute");
}
/* Add an attribute with name "cardinal" */
if(cardinal.compare("1") > 0) {
/* 1 is a defaultValue and can be omitted */
rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "cardinal", BAD_CAST cardinal.c_str());
if (rc < 0) {
throw FileWriterException( "Error at xmlTextWriterWriteAttribute");
}
}
/* Add an attribute with name "type" */
if( type.compare("undef") != 0 ) {
t_graph t = _gexf->getGraphType();
if( (t != GRAPH_DIRECTED && type != "undirected") || /* undirected is the default value and can be omitted */
(t != GRAPH_UNDIRECTED && type != "directed") ) { /* directed can be omitted if it is the default value */
const string new_type = ( type == "undirected" ) ? "sim" : ( ( type == "directed" ) ? "dir" : "dou" );
rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "type", BAD_CAST new_type.c_str());
if (rc < 0) {
throw FileWriterException( "Error at xmlTextWriterWriteAttribute");
}
}
}
AttValueIter* row = _gexf->getData().getEdgeAttributeRow(Conv::strToId(edge_id));
if( row != NULL && row->hasNext() ) {
this->writeAttvaluesNode(writer, EDGE, edge_id);
}
/* Close the element named edge. */
rc = xmlTextWriterEndElement(writer);
if (rc < 0) {
throw FileWriterException("Error at xmlTextWriterEndElement");
}
}
示例15: starts_with
bool Command_line_options::starts_with(const std::string& str,
const std::string& prefix)
{
return !str.compare(0, prefix.size(), prefix);
}