Example #1
0
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;
    }
    std::cout << "Did not insert" << std::endl;
    return false; */
}
Example #2
0
 // to identify
 bool is_me(const char* filepath) const {
     return (mv_filepath.compare(filepath) == 0);
 }
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;
}
	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());
	}
Example #5
0
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;
}
Example #6
0
static inline bool startWith(const std::string &str, const std::string &prefix) {
    return str.compare(0, prefix.length(), prefix) == 0;
}
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;
        a3 = 0.2800;
        a4 = -0.00711;
        a5 = 3.810;
        a6 = -0.25;
        a7 = -0.060;
        a8 = 0.0420;
        a9 = 10.20;
        a10 = -2.4;
        a11 = -0.083;
        a12 = 0.65;
        a13 = -10.1;
        a14 = 0.19;
        a15 = 1468.0;
    } else if (observable.compare("Gamma_b") == 0) {
        X0 = 375.723;
        a1 = -0.5744;
        a2 = -0.3074;
        a3 = 0.2725;
        a4 = -0.00703;
        a5 = -2.292;
        a6 = -0.027;
        a7 = -0.013;
        a8 = 0.0428;
        a9 = 10.53;
        a10 = -2.4;
        a11 = -0.088;
        a12 = 1.2;
        a13 = -10.1;
        a14 = 0.19;
        a15 = 1456.0;
    } else if (observable.compare("GammaZ") == 0) {
        X0 = 2494.24;
        a1 = -3.725;
        a2 = -2.019;
        a3 = 1.773;
        a4 = -0.04554;
        a5 = 19.63;
        a6 = -2.0;
        a7 = -0.36;
        a8 = 0.257;
        a9 = 58.60;
        a10 = -4.1;
        a11 = -0.53;
        a12 = 7.6;
        a13 = -56.0;
        a14 = 1.3;
        a15 = 9256.0;
        ThError = mycache.getSM().getDelGammaZ();
    } else if (observable.compare("sigmaHadron") == 0) {
        X0 = 41488.4;
        a1 = 3.88;
        a2 = 0.829;
        a3 = -0.911;
        a4 = 0.0076;
        a5 = 61.10;
        a6 = 16.0;
        a7 = -2.0;
        a8 = -0.59;
        a9 = -579.4;
        a10 = 38.0;
        a11 = -0.26;
        a12 = 6.5;
        a13 = 84.0;
        a14 = 9.5;
        a15 = -86152.0;
    } else if (observable.compare("R0_lepton") == 0) {
        X0 = 20750.9;
        a1 = -10.00;
        a2 = -1.83;
        a3 = 1.878;
        a4 = -0.0343;
        a5 = -38.8;
        a6 = -11.0;
        a7 = 1.2;
        a8 = 0.72;
        a9 = 732.1;
        a10 = -44.0;
        a11 = -0.64;
        a12 = 5.6;
        a13 = -357.0;
        a14 = -4.7;
        a15 = 11771.0;
    } else if (observable.compare("R0_charm") == 0) {
        X0 = 172.23;
        a1 = -0.034;
        a2 = -0.0058;
        a3 = 0.0054;
        a4 = -0.00012;
        a5 = 1.00;
        a6 = -0.15;
        a7 = -0.0074;
        a8 = 0.00091;
        a9 = 2.3;
        a10 = 1.3;
        a11 = -0.0013;
        a12 = 0.35;
        a13 = -1.2;
        a14 = 0.014;
        a15 = 37.0;
    } else if (observable.compare("R0_bottom") == 0) {
        X0 = 215.80;
        a1 = 0.036;
        a2 = 0.0057;
        a3 = -0.0044;
        a4 = 0.000062;
        a5 = -2.98;
        a6 = 0.20;
        a7 = 0.020;
        a8 = -0.00036;
        a9 = -1.3;
        a10 = -0.84;
        a11 = -0.0019;
        a12 = 0.054;
        a13 = 0.73;
        a14 = -0.011;
        a15 = -18.0;
    } else
        throw std::runtime_error("ApproximateFormulae::X_extended(): " + observable + " is not defined");

    return ( 0.001
            * (X0 + a1 * LH + a2 * LH * LH + a3 * DH + a4 * DH * DH + a5 * Dt + a6 * Dt * Dt
            + a7 * Dt * LH + a8 * Dt * LH * LH + a9 * Das + a10 * Das * Das + a11 * Das * LH
            + a12 * Das * Dt + a13 * Dal + a14 * Dal * LH + a15 * DZ) + ThError);
}
Example #8
0
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;
}
Example #9
0
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;
}
  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);
      }
    }

    outInfo("took: " << clock.getTime() << " ms.");
    return UIMA_ERR_NONE;
  }
Example #11
0
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;
}
Example #12
0
 bool do_(std::string actual_output) {
     return expected_output.compare(actual_output) == 0;
 }
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];
            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]);

        for (int itrk = 0; itrk < nTrk; itrk++) {
          float dr = jettrk_dr(itrk,ijet);
          // float dr = genjetrecotrk_dr(itrk,ijet);
          float dr_refcone = refconetrk_dr(itrk,ijet);
          // float dr_refcone = genrefconerecotrk_dr(itrk,ijet);
          if(dr<0.3)
          {
            float z = trkPt[itrk]/jetpt[ijet];
            float zpho = trkPt[itrk]/phoEt[0];
            float xi = log(1.0/z);
            float xipho = log(1.0/zpho);

            hgammaff->Fill(z,trkWeight[itrk]);
            hgammaffxi->Fill(xi,trkWeight[itrk]);
            hgammaphoffxi->Fill(xipho,trkWeight[itrk]);
            // hgammaff->Fill(z);
            // hgammaffxi->Fill(xi);
            // hgammaphoffxi->Fill(xipho);
            // cout<<jetpt[ijet]<<endl;
          }
          if(dr_refcone<0.3)
          {
            float z = trkPt[itrk]/jetpt[ijet];
            float zpho = trkPt[itrk]/phoEt[0];
            float xi = log(1.0/z);
            float xipho = log(1.0/zpho);

            hgammaffxi_refcone->Fill(xi,trkWeight[itrk]);
            hgammaphoffxi_refcone->Fill(xipho,trkWeight[itrk]);
            // hgammaffxi_refcone->Fill(xi);
            // hgammaphoffxi_refcone->Fill(xipho);
          }
        }
        // photons: normal mode power mode
        // pho 40 trigger
        // photon spike cuts etc
        // phoet > 35
        // phoet > 40 after correction // haven't made it yet
        // phoeta < 1.44
        // sumiso < 1 GeV
        // h/em < 0.1
        // sigmaetaeta < 0.01

        // jets:
        // some pt
        // jeteta < 1.6
        // some id cuts // none yet but we'll add some
        // ak3pupf jets

        // delphi > 7 pi / 8


      }
    }
    */


  }

  fout->Write();
  fout->Close();
}
//-----------------------------------------
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");
    }
}
bool Command_line_options::starts_with(const std::string& str,
                                       const std::string& prefix)
{
   return !str.compare(0, prefix.size(), prefix);
}
Example #16
0
SourceTermType convertSTType(const std::string& str)
{
	if (str.compare("SOURCE") == 0) return SOURCE;
	if (str.compare("NEUMANN") == 0) return NEUMANN;
	return INVALID_ST_TYPE;
}
Example #17
0
u32 ISOFileSystem::OpenFile(std::string filename, FileAccess access, const char *devicename)
{
	// LBN unittest
	/*
	u32 a, b;
	if (parseLBN("/sce_lbn0x307aa_size0xefffe000", &a, &b)) {
		ERROR_LOG(FILESYS, "lbn: %08x %08x", a, b);
	} else {
		ERROR_LOG(FILESYS, "faillbn: %08x %08x", a, b);
	}*/


	OpenFileEntry entry;
	entry.isRawSector = false;
	entry.isBlockSectorMode = false;

	if (filename.compare(0,8,"/sce_lbn") == 0)
	{
		u32 sectorStart = 0xFFFFFFFF, readSize = 0xFFFFFFFF;
		parseLBN(filename, &sectorStart, &readSize);
		if (sectorStart >= blockDevice->GetNumBlocks())
		{
			WARN_LOG(FILESYS, "Unable to open raw sector: %s, sector %08x, max %08x", filename.c_str(), sectorStart, blockDevice->GetNumBlocks());
			return 0;
		}

		DEBUG_LOG(FILESYS, "Got a raw sector open: %s, sector %08x, size %08x", filename.c_str(), sectorStart, readSize);
		u32 newHandle = hAlloc->GetNewHandle();
		entry.seekPos = 0;
		entry.file = 0;
		entry.isRawSector = true;
		entry.sectorStart = sectorStart;
		entry.openSize = readSize;
		// when open as "umd1:/sce_lbn0x0_size0x6B49D200", that mean open umd1 as a block device.
		// the param in sceIoLseek and sceIoRead is lba mode. we must mark it.
		if(strncmp(devicename, "umd0:", 5)==0 || strncmp(devicename, "umd1:", 5)==0)
			entry.isBlockSectorMode = true;

		entries[newHandle] = entry;
		return newHandle;
	}

	if (access & FILEACCESS_WRITE)
	{
		ERROR_LOG(FILESYS, "Can't open file %s with write access on an ISO partition", filename.c_str());
		return 0;
	}

	// May return entireISO for "umd0:"
	entry.file = GetFromPath(filename);
	if (!entry.file){
		return 0;
	}

	if (entry.file==&entireISO)
		entry.isBlockSectorMode = true;

	entry.seekPos = 0;

	u32 newHandle = hAlloc->GetNewHandle();
	entries[newHandle] = entry;
	return newHandle;
}
Example #18
0
TimType convertTimType(const std::string& str)
{
	if (str.compare("STEADY") == 0) return TIM_STEADY;
	if (str.compare("TRANSIENT") == 0) return TIM_TRANSIENT;
	return INVALID_TIM_TYPE;
}
Example #19
0
double EWSMApproximateFormulae::X(const std::string observable) const
{
    double LH = log(mycache.getSM().getMHl() / 125.7);
    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, c1, c2, c3, c4, c5, c6, c7;
    if (observable.compare("Gamma_nu") == 0) {
        X0 = 167.157;
        c1 = -0.055;
        c2 = 1.26;
        c3 = -0.19;
        c4 = -0.02;
        c5 = 0.36;
        c6 = -0.1;
        c7 = 503.0;
    } else if (observable.compare("Gamma_e_mu") == 0) {
        X0 = 83.966;
        c1 = -0.047;
        c2 = 0.807;
        c3 = -0.095;
        c4 = -0.01;
        c5 = 0.25;
        c6 = -1.1;
        c7 = 285.0;
    } else if (observable.compare("Gamma_tau") == 0) {
        X0 = 83.776;
        c1 = -0.047;
        c2 = 0.806;
        c3 = -0.095;
        c4 = -0.01;
        c5 = 0.25;
        c6 = -1.1;
        c7 = 285.0;
    } else if (observable.compare("Gamma_u") == 0) {
        X0 = 299.936;
        c1 = -0.34;
        c2 = 4.07;
        c3 = 14.27;
        c4 = 1.6;
        c5 = 1.8;
        c6 = -11.1;
        c7 = 1253.0;
    } else if (observable.compare("Gamma_c") == 0) {
        X0 = 299.860;
        c1 = -0.34;
        c2 = 4.07;
        c3 = 14.27;
        c4 = 1.6;
        c5 = 1.8;
        c6 = -11.1;
        c7 = 1253.0;
    } else if (observable.compare("Gamma_d_s") == 0) {
        X0 = 382.770;
        c1 = -0.34;
        c2 = 3.83;
        c3 = 10.20;
        c4 = -2.4;
        c5 = 0.67;
        c6 = -10.1;
        c7 = 1469.0;
    } else if (observable.compare("Gamma_b") == 0) {
        X0 = 375.724;
        c1 = -0.30;
        c2 = -2.28;
        c3 = 10.53;
        c4 = -2.4;
        c5 = 1.2;
        c6 = -10.0;
        c7 = 1458.0;
    } else if (observable.compare("GammaZ") == 0) {
        X0 = 2494.24;
        c1 = -2.0;
        c2 = 19.7;
        c3 = 58.60;
        c4 = -4.0;
        c5 = 8.0;
        c6 = -55.9;
        c7 = 9267.0;
    } else if (observable.compare("sigmaHadron") == 0) {
        X0 = 41488.4;
        c1 = 3.0;
        c2 = 60.9;
        c3 = -579.4;
        c4 = 38.0;
        c5 = 7.3;
        c6 = 85.0;
        c7 = -86027.0;
    } else if (observable.compare("R0_lepton") == 0) {
        X0 = 20750.9;
        c1 = -8.1;
        c2 = -39.0;
        c3 = 732.1;
        c4 = -44.0;
        c5 = 5.5;
        c6 = -358.0;
        c7 = 11702.0;
    } else if (observable.compare("R0_charm") == 0) {
        X0 = 172.23;
        c1 = -0.029;
        c2 = 1.0;
        c3 = 2.3;
        c4 = 1.3;
        c5 = 0.38;
        c6 = -1.2;
        c7 = 37.0;
    } else if (observable.compare("R0_bottom") == 0) {
        X0 = 215.80;
        c1 = 0.031;
        c2 = -2.98;
        c3 = -1.32;
        c4 = -0.84;
        c5 = 0.035;
        c6 = 0.73;
        c7 = -18.0;
    } else
        throw std::runtime_error("ApproximateFormulae::X(): " + observable + " is not defined");

    return ( 0.001
            * (X0 + c1 * LH + c2 * Dt + c3 * Das + c4 * Das * Das + c5 * Das * Dt + c6 * Dal + c7 * DZ));
}
Example #20
0
 bool operator()(const std::string& input) const {
     const bool head = input.compare("head") == 0;
     const bool tail = input.compare("tail") == 0;
     return head || tail;
 }
Example #21
0
ActivityAttributeType Activity::QueryActivityAttribute(const std::string& attributeName) const
{
	ActivityAttributeType result;

	result.startTime = 0;
	result.endTime = 0;
	result.unitSystem = UnitMgr::GetUnitSystem();

	if (attributeName.compare(ACTIVITY_ATTRIBUTE_START_TIME) == 0)
	{
		result.value.intVal = m_startTimeSecs;
		result.valueType = TYPE_INTEGER;
		result.measureType = MEASURE_TIME;
		result.startTime = m_startTimeSecs;
		result.endTime = 0;
		result.valid = m_startTimeSecs > 0;
	}
	else if (attributeName.compare(ACTIVITY_ATTRIBUTE_END_TIME) == 0)
	{
		result.value.intVal = m_endTimeSecs;
		result.valueType = TYPE_INTEGER;
		result.measureType = MEASURE_TIME;
		result.startTime = m_startTimeSecs;
		result.endTime = m_endTimeSecs;
		result.valid = m_endTimeSecs > 0;
	}
	else if (attributeName.compare(ACTIVITY_ATTRIBUTE_HEART_RATE) == 0)
	{
		uint64_t timeSinceLastUpdate = 0;
		if (!HasStopped())
			timeSinceLastUpdate = CurrentTimeInMs() - m_lastHeartRateUpdateTime;

		SegmentType hr = CurrentHeartRate();
		result.value.doubleVal = hr.value.doubleVal;
		result.valueType = TYPE_DOUBLE;
		result.measureType = MEASURE_BPM;
		result.startTime = hr.startTime;
		result.endTime = hr.endTime;
		result.valid = (m_numHeartRateReadings > 0) && (timeSinceLastUpdate < 3000);
	}
	else if (attributeName.compare(ACTIVITY_ATTRIBUTE_AVG_HEART_RATE) == 0)
	{
		result.value.doubleVal = AverageHeartRate();
		result.valueType = TYPE_DOUBLE;
		result.measureType = MEASURE_BPM;
		result.valid = m_numHeartRateReadings > 0;
	}
	else if (attributeName.compare(ACTIVITY_ATTRIBUTE_MAX_HEART_RATE) == 0)
	{
		SegmentType hr = MaxHeartRate();
		result.value.doubleVal = hr.value.doubleVal;
		result.valueType = TYPE_DOUBLE;
		result.measureType = MEASURE_BPM;
		result.startTime = hr.startTime;
		result.endTime = hr.endTime;
		result.valid = m_numHeartRateReadings > 0;
	}
	else if (attributeName.compare(ACTIVITY_ATTRIBUTE_HEART_RATE_ZONE) == 0)
	{
		result.value.doubleVal = HeartRateZone();
		result.valueType = TYPE_DOUBLE;
		result.measureType = MEASURE_PERCENTAGE;
		result.valid = m_numHeartRateReadings > 0;
	}
	else if (attributeName.compare(ACTIVITY_ATTRIBUTE_ELAPSED_TIME) == 0)
	{
		result.value.timeVal = ElapsedTimeInSeconds();
		result.valueType = TYPE_TIME;
		result.measureType = MEASURE_TIME;
		result.valid = true;
	}
	else if (attributeName.compare(ACTIVITY_ATTRIBUTE_CALORIES_BURNED) == 0)
	{
		result.value.doubleVal = CaloriesBurned();
		result.valueType = TYPE_DOUBLE;
		result.measureType = MEASURE_CALORIES;
		result.valid = true;
	}
	else if (attributeName.compare(ACTIVITY_ATTRIBUTE_X) == 0)
	{
		try
		{
			if (m_lastAccelReading.reading.count(AXIS_NAME_X) > 0)
			{
				result.value.doubleVal = m_lastAccelReading.reading.at(AXIS_NAME_X);
				result.valueType = TYPE_DOUBLE;
				result.measureType = MEASURE_G;
				result.valid = true;
			}
			else
			{
				result.valid = false;
			}
		}
		catch (...)
		{
			result.valid = false;
		}
	}
	else if (attributeName.compare(ACTIVITY_ATTRIBUTE_Y) == 0)
	{
		try
		{
			if (m_lastAccelReading.reading.count(AXIS_NAME_Y) > 0)
			{
				result.value.doubleVal = m_lastAccelReading.reading.at(AXIS_NAME_Y);
				result.valueType = TYPE_DOUBLE;
				result.measureType = MEASURE_G;
				result.valid = true;
			}
			else
			{
				result.valid = false;
			}
		}
		catch (...)
		{
			result.valid = false;
		}
	}
	else if (attributeName.compare(ACTIVITY_ATTRIBUTE_Z) == 0)
	{
		try
		{
			if (m_lastAccelReading.reading.count(AXIS_NAME_Z) > 0)
			{
				result.value.doubleVal = m_lastAccelReading.reading.at(AXIS_NAME_Z);
				result.valueType = TYPE_DOUBLE;
				result.measureType = MEASURE_G;
				result.valid = true;
			}
			else
			{
				result.valid = false;
			}
		}
		catch (...)
		{
			result.valid = false;
		}
	}
	else if (attributeName.compare(ACTIVITY_ATTRIBUTE_ADDITIONAL_WEIGHT) == 0)
	{
		result.value.doubleVal = AdditionalWeightUsedKg();
		result.valueType = TYPE_DOUBLE;
		result.measureType = MEASURE_WEIGHT;
		result.valid = true;
	}
	else
	{
		result.valueType = TYPE_NOT_SET;
		result.valid = false;
	}
	return result;
}
Example #22
0
void parseOutRG(SamFileHeader& header, std::string& noRgPgString, SamFileHeader* newHeader, bool ignorePI)
{
    noRgPgString.clear();
    // strings for comparing if two RGs with same ID are the same.
    static std::string prevString = "";
    static std::string newString = "";

    SamHeaderRecord* rec = header.getNextHeaderRecord();
    while(rec != NULL)
    {
        if(rec->getType() == SamHeaderRecord::RG)
        {
            if(newHeader != NULL)
            {
                // This is an RG line.
                // First check if this RG is already included in the new header.
                SamHeaderRG* prevRG = newHeader->getRG(rec->getTagValue("ID"));
                
                if(prevRG != NULL)
                {
                    // This RG already exists, check that they are the same.
                    // If they are the same, there is nothing to do.
                    bool status = true;
                    prevString.clear();
                    newString.clear();
                    status &= prevRG->appendString(prevString);
                    status &= rec->appendString(newString);

                    if(prevString != newString)
                    {
                        if(!ignorePI)
                        {
                            Logger::gLogger->error("Failed to add readgroup to "
                                                   "header, duplicate, but "
                                                   "non-identical RG ID, %s\n"
                                                   "prev:\t(%s)\nnew:\t(%s)",
                                                   rec->getTagValue("ID"),
                                                   prevString.c_str(),
                                                   newString.c_str());
                        }
                        else
                        {
                            // Check for a PI string.
                            size_t prevPIStart = prevString.find("PI:");
                            size_t newPIStart = newString.find("PI:");

                            // If they are both npos, then PI was not found
                            // so fail.
                            if((prevPIStart == std::string::npos) &&
                               (newPIStart == std::string::npos))
                            {
                                // They are not identical, so report an error.
                                Logger::gLogger->error("Failed to add readgroup"
                                                       " to header, duplicate,"
                                                       " but non-identical RG"
                                                       " ID, %s\n"
                                                       "prev:\t(%s)\nnew:\t(%s)",
                                                       rec->getTagValue("ID"),
                                                       prevString.c_str(),
                                                       newString.c_str());
                            }
                            else
                            {
                                // PI found in one or both strings.
                                size_t prevPIEnd;
                                size_t newPIEnd;
                                if(prevPIStart == std::string::npos)
                                {
                                    // new string has PI, so compare to the start of that.
                                    prevPIStart = newPIStart;
                                    prevPIEnd = newPIStart;
                                }
                                else
                                {
                                    prevPIEnd = prevString.find('\t', prevPIStart) + 1;
                                }
                                if(newPIStart == std::string::npos)
                                {
                                    // new string has PI, so compare to the start of that.
                                    newPIStart = prevPIStart;
                                    newPIEnd = newPIStart;
                                }
                                else
                                {
                                    newPIEnd = newString.find('\t', newPIStart) + 1;
                                }
                                // Compare before PI.
                                if((newString.compare(0, newPIStart, prevString, 0, prevPIStart) != 0) ||
                                   (newString.compare(newPIEnd, std::string::npos, prevString,
                                                      prevPIEnd, std::string::npos) != 0))
                                {
                                    // They are not identical, so report an error.
                                    Logger::gLogger->error("Failed to add readgroup to header, "
                                                           "duplicate, but non-identical RG ID, %s, "
                                                           "even when ignoring PI\n"
                                                           "prev:\t(%s)\nnew:\t(%s)",
                                                           rec->getTagValue("ID"),
                                                           prevString.c_str(),
                                                           newString.c_str());
                                }
                                else
                                {
                                    Logger::gLogger->warning("Warning: ignoring non-identical PI field "
                                                             "for RG ID, %s",
                                                             rec->getTagValue("ID"));
                                }
                            }
                        }
                    }
                }
                else
                {
                    // This RG does not exist yet, so add it to the new header.
                    if(!newHeader->addRecordCopy((SamHeaderRG&)(*rec)))
                    {
                        // Failed to add the RG, exit.
                        Logger::gLogger->error("Failed to add readgroup to header, %s",
                                               newHeader->getErrorMessage());
                    }
                }
            }
        }
        else if(rec->getType() == SamHeaderRecord::PG)
        {
            if(newHeader != NULL)
            {
                // This is a PG line.
                // First check if this PG is already included in the new header.
                SamHeaderPG* prevPG = newHeader->getPG(rec->getTagValue("ID"));
                
                if(prevPG != NULL)
                {
                    // This PG already exists, check if they are the same.
                    // If they are the same, there is nothing to do.
                    bool status = true;
                    prevString.clear();
                    newString.clear();
                    status &= prevPG->appendString(prevString);
                    status &= rec->appendString(newString);
                    if(prevString != newString)
                    {
                        // They are not identical, ignore for now.
                        // TODO: change the ID, and add it.
                        Logger::gLogger->warning("Warning: dropping duplicate, "
                                                 "but non-identical PG ID, %s",
                                                 rec->getTagValue("ID"));
                    }
                }
                else
                {
                    // This PG does not exist yet, so add it to the new header.
                    if(!newHeader->addRecordCopy((SamHeaderPG&)(*rec)))
                    {
                        // Failed to add the PG, exit.
                        Logger::gLogger->error("Failed to add PG to header, %s",
                                               newHeader->getErrorMessage());
                    }
                }
            }
        }
        else
        {
            rec->appendString(noRgPgString);
        }
        rec = header.getNextHeaderRecord();
    }

    // Append the comments.
    header.appendCommentLines(noRgPgString);
}
Example #23
0
inline bool ends_with(const std::string& str, const std::string& suffix) {
    return str.size() > suffix.size() && str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0;
}
Example #24
0
bool SessionManager::rotateTo( std::string addr, bool audio )
{
    lockSessions();

    int numSessions = availableVideoSessions->numObjects();
    int lastRotatePos = rotatePos;
    if ( lastRotatePos != -1 )
        lastRotateSession =
            dynamic_cast<SessionEntry*>( (*availableVideoSessions)[ rotatePos ] );
    if ( numSessions == 0 )
    {
        unlockSessions();
        return false;
    }

    SessionEntry* current;

    // if arg is an empty string, just rotate to next. otherwise, figure out
    // rotate pos of string arg
    if ( addr.compare( "" ) == 0 )
    {
        if ( ++rotatePos >= numSessions )
        {
            rotatePos = 0;
        }
        current =
            dynamic_cast<SessionEntry*>( (*availableVideoSessions)[ rotatePos ] );
    }
    else
    {
        current = findSessionByAddress( addr, AVAILABLEVIDEOSESSION );

        if ( current != NULL )
        {
            rotatePos = indexOf( current );
        }
    }

    if ( current == NULL )
    {
        gravUtil::logWarning( "SessionManager::rotateTo: session %s"
                              " not found\n", addr.c_str() );
        unlockSessions();
        return false;
    }

    // only rotate if there is a valid old one & it isn't the same as
    // current
    if ( lastRotateSession != NULL && current != NULL &&
            lastRotateSession != current )
    {
        disableSession( lastRotateSession );
        initSession( current );
    }
    // case for first rotate
    else if ( lastRotatePos == -1 )
    {
        initSession( current );
    }

    unlockSessions();

    return true;
}
Example #25
0
	double typeToFraction(std::string text) {
		if (text.compare("1024th") == 0) {
			return 1.0/1024.0;
		} else if (text.compare("512th") == 0) {
			return 1.0/512.0;
		} else if (text.compare("256th") == 0) {
			return 1.0/256.0;
		} else if (text.compare("128th") == 0) {
			return 1.0/128.0;
		} else if (text.compare("64th") == 0) {
			return 1.0/64.0;
		} else if (text.compare("32nd") == 0) {
			return 1.0/32.0;
		} else if (text.compare("16th") == 0) {
			return 1.0/16.0;
		} else if (text.compare("eighth") == 0) {
			return 1.0/8.0;
		} else if (text.compare("quarter") == 0) {
			return 1.0/4.0;
		} else if (text.compare("half") == 0) {
			return 1.0/2.0;
		} else if (text.compare("whole") == 0) {
			return 1.0;
		} else {
			return -1;
		}
	}
Example #26
0
bool CVar::tryBinding(const std::string& binding)
{
    std::string bindingName = binding;
    Athena::utility::tolower(bindingName);
    if (binding.compare("mouse") != -1)
    {
        for (int i = 0; i < (int)MouseButton::COUNT; i++)
        {
            std::string name = enumToStdString((MouseButton)i);
            Athena::utility::tolower(name);
            if(!name.compare(bindingName))
            {
                m_binding.MouseButtonVal = (MouseButton)i;
                return true;
            }
        }
    }

    if (binding.compare("joy") > -1)
    {
        for (int i = 0; i < IJoystickManager::MaxJoysticks; i++)
        {
            // first axis
            for (int j = 0; j < orJoystickManagerRef.maxAxes(i); j++)
            {
                // First try axis
                std::string axisName = Athena::utility::sprintf("joy%i.%i", i, j);
                std::string negAxisName = Athena::utility::sprintf("-joy%i.%i", i, j);

                m_binding.Joysticks[i].Axis = j;
                m_binding.Joysticks[i].valid = true;
                if (!axisName.compare(bindingName))
                {
                    m_binding.Joysticks[i].NegativeAxis = false;
                    return true;
                }
                else if (!negAxisName.compare(bindingName))
                {
                    m_binding.Joysticks[i].NegativeAxis = true;
                    return true;
                }
            }

            // Now buttons
            for (int j = 0; j < orJoystickManagerRef.maxAxes(i); j++)
            {
                // First try axis
                std::string buttonName = Athena::utility::sprintf("joy%i.button%i", i, j);
                if (!buttonName.compare(bindingName))
                {
                    m_binding.Joysticks[i].Button = j;
                    m_binding.Joysticks[i].valid = true;
                    return true;
                }
            }
        }
    }

    // Now for keyboard
    for (int i = 0; i < (int)Key::KEYCOUNT; i++)
    {
        std::string keyName = enumToStdString((Key)i);
        Athena::utility::tolower(keyName);
        if (!bindingName.compare(keyName))
        {
            m_binding.KeyVal = (Key)i;
            return true;
        }
    }

    // Oops user specified an invalid key!
    return false;
}
Example #27
0
bool GameState::IsType(const std::string &type) {
	return type.compare("GameState") == 0;
};
Example #28
0
void createPseudoDataFunc(double luminosity, const std::string decayChannel, TString specifier){
  // specifier="NoDistort" for closure test; "topPtUp", "topPtDown", "ttbarMassUp", "ttbarMassDown" or "data" for shape distortions; "1000" for Zprime
  // "verbose": set detail level of output ( 0: no output, 1: std output 2: output for debugging )
  int verbose=0;
  // "smear": say if you want to do a poisson smearing for each bin or just a combination for the different samples 
  bool smear=false;
  // "dataFile": absolute path of data file, used to define plots of interest
  TString dataFile= "";
  if(decayChannel.compare("electron")==0) dataFile="/afs/naf.desy.de/group/cms/scratch/tophh/RecentAnalysisRun8TeV_doubleKinFit/elecDiffXSecData2012ABCDAll.root";
  else                                    dataFile="/afs/naf.desy.de/group/cms/scratch/tophh/RecentAnalysisRun8TeV_doubleKinFit/muonDiffXSecData2012ABCDAll.root";
  // "useReweightedTop": use parton level reweighted ttbar signal file in pseudo data?
  bool useReweightedTop = (specifier.Contains("NoDistort")) ? false : true;
  // "zprime": include additional Zprime in pseudo data?
  bool zprime=specifier.Contains("1000") ? true : false;
  // naming for outputfile, constructed within macro
  TString outNameExtension="";

  // check input parameter validity
  // type of closure test
  if(!(specifier.Contains("NoDistort")||specifier.Contains("1000")||specifier.Contains("data")||specifier.Contains("topPtUp")||specifier.Contains("topPtDown")||specifier.Contains("ttbarMassUp")||specifier.Contains("ttbarMassDown")||specifier.Contains("topMass161p5")||specifier.Contains("topMass163p5")||specifier.Contains("topMass166p5")||specifier.Contains("topMass169p5")||specifier.Contains("topMass175p5")||specifier.Contains("topMass178p5")||specifier.Contains("topMass181p5")||specifier.Contains("topMass184p5"))){
    std::cout << "ERROR: invalid input specifier=" << specifier << std::endl;
    std::cout << "supported are: specifier=NoDistort,1000,data,topPtUp,topPtDown,ttbarMassUp,ttbarMassDown,topMass161p5,topMass163p5,topMass166p5,topMass169p5,topMass175p5,topMass178p5,topMass181p5,topMass184p5" << std::endl;
    exit(0);
  }
  // decay channel
  if(!(decayChannel.compare("electron")==0||decayChannel.compare("muon")==0)){
    std::cout << "ERROR: invalid input decayChannel=" << decayChannel << std::endl;
    std::cout << "supported are: decayChannel=muon,electron" << std::endl;
    exit(0);
  }
  

  //  ---
  //     create container for histos and files
  //  ---
  std::map<unsigned int, TFile*> files_;
  std::map< TString, std::map <unsigned int, TH1F*> > histo_;
  std::map< TString, std::map <unsigned int, TH2F*> > histo2_;

  //  ---
  //     parton level reweighted top distribution
  //  ---
  // a) name and path of rootfile
  // path
  TString nameTtbarReweighted="/afs/naf.desy.de/group/cms/scratch/tophh/RecentAnalysisRun8TeV_doubleKinFit/";
  // subfolder for reweighting systematics
  if(specifier!="NoDistort"&&!specifier.Contains("p5")){
    nameTtbarReweighted+="ttbarReweight/";
    // SG reweighting test
    if(decayChannel.compare("electron")==0) nameTtbarReweighted+="elecDiffXSec";
    else                                    nameTtbarReweighted+="muonDiffXSec";
    nameTtbarReweighted+="SigSysDistort"+specifier+"Summer12PF.root";
  }
  else{
    // SG sample for corresponding top mass
    int sys=sysNo; // == "NoDistort"
    if(     specifier=="topMass161p5") sys=sysTopMassDown4;
    else if(specifier=="topMass163p5") sys=sysTopMassDown3;
    else if(specifier=="topMass166p5") sys=sysTopMassDown2;
    else if(specifier=="topMass169p5") sys=sysTopMassDown;
    else if(specifier=="topMass175p5") sys=sysTopMassUp;
    else if(specifier=="topMass178p5") sys=sysTopMassUp2;
    else if(specifier=="topMass181p5") sys=sysTopMassUp3;
    else if(specifier=="topMass184p5") sys=sysTopMassUp4;
    nameTtbarReweighted+=TopFilename(kSig, sys, decayChannel);
  }
  // BG
  TString nameTtbarBGReweighted=nameTtbarReweighted;
  nameTtbarBGReweighted.ReplaceAll("Sig","Bkg");
  if(useReweightedTop&&!specifier.Contains("p5")) outNameExtension+="Reweighted"+specifier;
  // b) get average weight for reweighted samples
  double avWeight=1;
  if(useReweightedTop && specifier!="NoDistort"&& !specifier.Contains("p5")){
    TFile* ttbarRewfile = new (TFile)(nameTtbarReweighted);
    TString weightPlot="eventWeightDileptonModelVariation/modelWeightSum";
    histo_["avWeight"][kSig] = (TH1F*)(ttbarRewfile->Get(weightPlot)->Clone());
    avWeight=histo_ ["avWeight"][kSig]->GetBinContent(2)/histo_ ["avWeight"][kSig]->GetBinContent(1);
    histo_["avWeight"].erase(kSig);
    TFile* sigfile = new (TFile)("/afs/naf.desy.de/group/cms/scratch/tophh/RecentAnalysisRun8TeV_doubleKinFit/"+TopFilename(kSig, sysNo, decayChannel));
    TString partonPlot="analyzeTopPartonLevelKinematics/ttbarMass";
    gROOT->cd();
    histo_["parton"   ][kSig] = (TH1F*)(sigfile     ->Get(partonPlot)->Clone());
    histo_["partonRew"][kSig] = (TH1F*)(ttbarRewfile->Get(partonPlot)->Clone());
    double avWeight2  = histo_["partonRew"][kSig]->Integral(0, histo_["partonRew"][kSig]->GetNbinsX()+1);
    avWeight2        /= histo_["parton"   ][kSig]->Integral(0, histo_["parton"   ][kSig]->GetNbinsX()+1);
    if(verbose>1){
      std::cout << "ratio unweighted/weighted" << std::endl;
      std::cout << avWeight  << " (from " << weightPlot << ")" << std::endl;
      std::cout << avWeight2 << TString(" (from entries in ")+partonPlot+" wrt /afs/naf.desy.de/group/cms/scratch/tophh/RecentAnalysisRun8TeV_doubleKinFit/"+TopFilename(kSig, sysNo, decayChannel)+"): " << std::endl;
    }
  }

  //  ---
  //     Z prime 
  //  ---
  // xSec scaling (default value chosen for M1000W100: 5pb)
  double xSecSF=1.0;
  // path & naming
  TString zprimeMass =specifier;
  TString zprimeWidth=specifier;
  zprimeWidth.ReplaceAll("1000", "100");
  TString nameZprime="/afs/naf.desy.de/group/cms/scratch/tophh/RecentAnalysisRun8TeV_doubleKinFit/zprime/";
  if(decayChannel.compare("electron")==0) nameZprime+="elec";
  else                                    nameZprime+="muon";
  nameZprime+="DiffXSecZprimeM"+zprimeMass+"W"+zprimeWidth+"Summer12PF.root";
  // event weight wrt luminosity
  double zPrimeLumiWeight=1.;
  if     (zprimeMass=="1000") zPrimeLumiWeight=(xSecSF*5*luminosity)/104043;
  // naming of oututfile 
  TString xSecSFstr="";
  if      (xSecSF==0.5 ) xSecSFstr="x0p5";
  else if (xSecSF==0.25) xSecSFstr="x0p25";
  else if (xSecSF==0.1 ) xSecSFstr="x0p1";
  else if (xSecSF==0.03) xSecSFstr="x0p03";
  else if (xSecSF>1.   ) xSecSFstr="x"+getTStringFromDouble(xSecSF,0);
  if(zprime) outNameExtension="andM"+zprimeMass+"W"+zprimeWidth+xSecSFstr+"Zprime";
  // sample iteration limit
  int kLast  =kSAToptW;
  int kZprime=kLast+1;
  if(zprime) kLast=kZprime;

  if(zprime&&zPrimeLumiWeight==1){
    std::cout << "ERROR: chosen zprime weight is exactly 1!" << std::endl;
    exit(0);
  }
  
  // -------------------------
  // !!! choose luminosity !!!
  // -------------------------
  TString lum = getTStringFromInt(roundToInt(luminosity));
  // -----------------------------------------
  // !!! add all contributing samples here !!!
  // -----------------------------------------
  TString inputFolder = "/afs/naf.desy.de/group/cms/scratch/tophh/RecentAnalysisRun8TeV_doubleKinFit/";
  // save all default top analysis samples in files_
  files_ = getStdTopAnalysisFiles(inputFolder, sysNo, dataFile, decayChannel);
  // remove combined file dor single Top & DiBoson
  if(files_.count(kSTop )>0)files_.erase(kSTop );
  if(files_.count(kDiBos)>0)files_.erase(kDiBos);
  // remove combined QCD file for electron channel
  if(decayChannel.compare("electron")==0&&files_.count(kQCD)>0) files_.erase(kQCD);
  // remove all QCD files to be consistent with later treatment
  if(files_.count(kQCD)>0) files_.erase(kQCD);
  if(decayChannel.compare("electron")==0){
    for(int sample = kQCDEM1; sample<=kQCDBCE3; sample++){
      if(files_.count(sample)>0) files_.erase(sample);
    }
  }
  // add zprime
  if(zprime) files_[kZprime]=new (TFile)(nameZprime);
  // exchange default ttbar files with the reweighted ones
  if(useReweightedTop){ 
    files_[kSig]=new (TFile)(nameTtbarReweighted  );
    files_[kBkg]=new (TFile)(nameTtbarBGReweighted);
  }

  //  -----------------------------------------
  //     get list of all plots to be considered
  //  -----------------------------------------
  std::vector<TString> plotList_;
  TString currentFolder ="";
  TString currentPlot   ="";
  if(verbose>0) std::cout << std::endl << "searching for all plots in file " << files_[kData]->GetName() << std::endl;
  // go to data file for getting plot names
  files_[kData]->cd();
  // loop objects in file
  TIter fileIterator(gDirectory->GetListOfKeys());
  if(verbose>2){
    std::cout << "looping objects in in ";
    gDirectory->pwd();
  }
  TKey *fileKey;
  int count=0;
  while( (fileKey = (TKey*)fileIterator()) ){
    ++count;
    if(verbose>2) std::cout << "folderObject #" << count;
    TObject *fileObject = fileKey->ReadObj(); 
    // check if object is a directory
    if(!(fileObject->InheritsFrom("TDirectory"))&&(verbose>2)) std::cout << " is no directory" << count << std::endl;
    if(fileObject->InheritsFrom("TDirectory")){
      currentFolder = (TString)fileObject->GetName();
      if(verbose>2) std::cout << " ("+currentFolder+")" << std::endl;
      // go to directory
      ((TDirectory*)fileObject)->cd();
      if(verbose>2){
	std::cout << "looping objects in in ";
	gDirectory->pwd();
      }
      TIter folderIterator(gDirectory->GetListOfKeys());
      TKey *folderKey;
      int count2=0;
      while( (folderKey = (TKey*)folderIterator()) ) {
	++count2;
	TObject *folderObject = folderKey->ReadObj(); 
	currentPlot = (TString)folderObject->GetName();
	if(verbose>2) std::cout << "plotObject #" << count2 << " ("+currentPlot+")" << std::endl;
	// check if object is a TH1 
	if(folderObject->InheritsFrom("TH1")){
	  if(verbose>2) std::cout << "inherits from TH1";
	  // check if TH2 and neglect because a simple 
	  // re-smearing is here not possible
	  if((folderObject->InheritsFrom("TH2"))&&(verbose>2)) std::cout << " and from TH2" << std::endl;
	  else{
	    if(verbose>2) std::cout << " and NOT from TH2" << std::endl;
	    // add to list of plots
	    if(verbose>2) std::cout << "will be added to list of output plots" << std::endl;
	    plotList_.push_back(currentFolder+"/"+currentPlot);
	  }
	}
      }
    }
  }
  // close data file after getting plot names
  files_[kData]->Close();
  // remove data file from list of considered files
  if(files_.count(kData )>0)files_.erase(kData );
  // print list of files considered
  if(verbose>0){
    std::cout << std::endl << "the following files will be considered: " << std::endl;
    // loop files
    for(int sample = kSig; sample<=kLast; sample++){
      // check existence of folder in all existing files
      if(files_.count(sample)>0){
	std::cout << files_[sample]->GetName() << std::endl;
      }
    }
  }
  // print out the name of all plots
  if(verbose>0){
    std::cout << std::endl << "list of all plots to be considered: " << std::endl;
    // loop list of plots
    for(unsigned int plot=0; plot<plotList_.size(); ++plot){
      std::cout << "\"" << plotList_[plot] << "\"" << std::endl;
    }
    std::cout << plotList_.size() << " plots in total" << std::endl;
  }
  // ---------------------------------------
  // !!! load all hists !!!
  // ---------------------------------------
  unsigned int N1Dplots=plotList_.size();
  int Nplots=0;
  if(verbose>0) std::cout << std::endl << "loading plots: " << std::endl;
  // a) for std analysis file (& reweighted ttbar)
  getAllPlots(files_, plotList_, histo_, histo2_, N1Dplots, Nplots, verbose-1);
  if(verbose>0){
    std::cout << Nplots << " plots loaded from " << plotList_.size();
    std::cout << " requested" << std::endl << "empty plots are not counted" << std::endl;
  }
  // b) for zprime
  if(zprime){ 
    for(unsigned int plot=0; plot<plotList_.size(); ++plot){
      histo_[plotList_[plot]][kZprime] = (TH1F*)(files_[kZprime]->Get(plotList_[plot]));
    }
  }

  // ---------------------------------------
  // !!! definition of output file(name) !!!
  // ---------------------------------------
  //TString outputfile="/afs/naf.desy.de/user/g/goerner/WGspace/RecentAnalysisRun8TeV_doubleKinFit/pseudodata/"+(TString)decayChannel+"PseudoData"+lum+"pb"+outNameExtension+"8TeV.root";
  TString outputfile="/afs/naf.desy.de/user/g/goerner/WGspace/RecentAnalysisRun8TeV_doubleKinFit/pseudodata/"+pseudoDataFileName(specifier, decayChannel);
  TFile* out = new TFile(outputfile, "recreate");
  if(verbose>0) std::cout << std::endl << "outputfile: " << outputfile << std::endl;
  poisson(histo_, plotList_, decayChannel, *out, luminosity, verbose, smear, useReweightedTop, avWeight, zprime, zPrimeLumiWeight);

  // free memory
  for(std::map< TString, std::map <unsigned int, TH1F*> >::iterator histo=histo_.begin(); histo!=histo_.end(); ++histo){
    for(std::map <unsigned int, TH1F*>::iterator histoSub=histo->second.begin(); histoSub!=histo->second.end(); ++histoSub){
      if(histoSub->second) delete histoSub->second;
    }
    histo->second.clear();
  }
  histo_ .clear();
  for(std::map< TString, std::map <unsigned int, TH2F*> >::iterator histo2=histo2_.begin(); histo2!=histo2_.end(); ++histo2){
    for(std::map <unsigned int, TH2F*>::iterator histo2Sub=histo2->second.begin(); histo2Sub!=histo2->second.end(); ++histo2Sub){
      if(histo2Sub->second) delete histo2Sub->second;      
    }
    histo2->second.clear();
  }
  histo2_ .clear();
  for(std::map<unsigned int, TFile*>::const_iterator file=files_.begin(); file!=files_.end(); ++file){
    if(file->second){
      file->second->Close();	  
      delete file->second;
    }
  }
  files_ .clear();
  out->Close();
  delete out;

}
		shared_ptr<IfcElectricApplianceTypeEnum> IfcElectricApplianceTypeEnum::readStepData( std::string& arg )
		{
			// read TYPE
			if( arg.compare( "$" ) == 0 ) { return shared_ptr<IfcElectricApplianceTypeEnum>(); }
			shared_ptr<IfcElectricApplianceTypeEnum> type_object( new IfcElectricApplianceTypeEnum() );
			if( _stricmp( arg.c_str(), ".COMPUTER." ) == 0 )
			{
				type_object->m_enum = IfcElectricApplianceTypeEnum::ENUM_COMPUTER;
			}
			else if( _stricmp( arg.c_str(), ".DIRECTWATERHEATER." ) == 0 )
			{
				type_object->m_enum = IfcElectricApplianceTypeEnum::ENUM_DIRECTWATERHEATER;
			}
			else if( _stricmp( arg.c_str(), ".DISHWASHER." ) == 0 )
			{
				type_object->m_enum = IfcElectricApplianceTypeEnum::ENUM_DISHWASHER;
			}
			else if( _stricmp( arg.c_str(), ".ELECTRICCOOKER." ) == 0 )
			{
				type_object->m_enum = IfcElectricApplianceTypeEnum::ENUM_ELECTRICCOOKER;
			}
			else if( _stricmp( arg.c_str(), ".ELECTRICHEATER." ) == 0 )
			{
				type_object->m_enum = IfcElectricApplianceTypeEnum::ENUM_ELECTRICHEATER;
			}
			else if( _stricmp( arg.c_str(), ".FACSIMILE." ) == 0 )
			{
				type_object->m_enum = IfcElectricApplianceTypeEnum::ENUM_FACSIMILE;
			}
			else if( _stricmp( arg.c_str(), ".FREESTANDINGFAN." ) == 0 )
			{
				type_object->m_enum = IfcElectricApplianceTypeEnum::ENUM_FREESTANDINGFAN;
			}
			else if( _stricmp( arg.c_str(), ".FREEZER." ) == 0 )
			{
				type_object->m_enum = IfcElectricApplianceTypeEnum::ENUM_FREEZER;
			}
			else if( _stricmp( arg.c_str(), ".FRIDGE_FREEZER." ) == 0 )
			{
				type_object->m_enum = IfcElectricApplianceTypeEnum::ENUM_FRIDGE_FREEZER;
			}
			else if( _stricmp( arg.c_str(), ".HANDDRYER." ) == 0 )
			{
				type_object->m_enum = IfcElectricApplianceTypeEnum::ENUM_HANDDRYER;
			}
			else if( _stricmp( arg.c_str(), ".INDIRECTWATERHEATER." ) == 0 )
			{
				type_object->m_enum = IfcElectricApplianceTypeEnum::ENUM_INDIRECTWATERHEATER;
			}
			else if( _stricmp( arg.c_str(), ".MICROWAVE." ) == 0 )
			{
				type_object->m_enum = IfcElectricApplianceTypeEnum::ENUM_MICROWAVE;
			}
			else if( _stricmp( arg.c_str(), ".PHOTOCOPIER." ) == 0 )
			{
				type_object->m_enum = IfcElectricApplianceTypeEnum::ENUM_PHOTOCOPIER;
			}
			else if( _stricmp( arg.c_str(), ".PRINTER." ) == 0 )
			{
				type_object->m_enum = IfcElectricApplianceTypeEnum::ENUM_PRINTER;
			}
			else if( _stricmp( arg.c_str(), ".REFRIGERATOR." ) == 0 )
			{
				type_object->m_enum = IfcElectricApplianceTypeEnum::ENUM_REFRIGERATOR;
			}
			else if( _stricmp( arg.c_str(), ".RADIANTHEATER." ) == 0 )
			{
				type_object->m_enum = IfcElectricApplianceTypeEnum::ENUM_RADIANTHEATER;
			}
			else if( _stricmp( arg.c_str(), ".SCANNER." ) == 0 )
			{
				type_object->m_enum = IfcElectricApplianceTypeEnum::ENUM_SCANNER;
			}
			else if( _stricmp( arg.c_str(), ".TELEPHONE." ) == 0 )
			{
				type_object->m_enum = IfcElectricApplianceTypeEnum::ENUM_TELEPHONE;
			}
			else if( _stricmp( arg.c_str(), ".TUMBLEDRYER." ) == 0 )
			{
				type_object->m_enum = IfcElectricApplianceTypeEnum::ENUM_TUMBLEDRYER;
			}
			else if( _stricmp( arg.c_str(), ".TV." ) == 0 )
			{
				type_object->m_enum = IfcElectricApplianceTypeEnum::ENUM_TV;
			}
			else if( _stricmp( arg.c_str(), ".VENDINGMACHINE." ) == 0 )
			{
				type_object->m_enum = IfcElectricApplianceTypeEnum::ENUM_VENDINGMACHINE;
			}
			else if( _stricmp( arg.c_str(), ".WASHINGMACHINE." ) == 0 )
			{
				type_object->m_enum = IfcElectricApplianceTypeEnum::ENUM_WASHINGMACHINE;
			}
			else if( _stricmp( arg.c_str(), ".WATERHEATER." ) == 0 )
			{
				type_object->m_enum = IfcElectricApplianceTypeEnum::ENUM_WATERHEATER;
			}
			else if( _stricmp( arg.c_str(), ".WATERCOOLER." ) == 0 )
			{
				type_object->m_enum = IfcElectricApplianceTypeEnum::ENUM_WATERCOOLER;
			}
			else if( _stricmp( arg.c_str(), ".USERDEFINED." ) == 0 )
			{
				type_object->m_enum = IfcElectricApplianceTypeEnum::ENUM_USERDEFINED;
			}
			else if( _stricmp( arg.c_str(), ".NOTDEFINED." ) == 0 )
			{
				type_object->m_enum = IfcElectricApplianceTypeEnum::ENUM_NOTDEFINED;
			}
			return type_object;
		}
Example #30
0
bool Path::isHeader(const std::string &path)
{
    const std::string extension = getFilenameExtensionInLowerCase(path);
    return (extension.compare(0, 2, ".h") == 0);
}