Example #1
0
__stdcall  function2(const char *graphName, const char *lineNum)
{ 
	static string outbuf;

    try
    {
		// ====== Find object or create a new one ===========
		GraphMap::iterator graphIter = graphs.find(graphName);

		if (graphIter != graphs.end())
		{
			int line = atoi(lineNum);
			if ((line > 0) && (line <= 4))
				graphIter->second.BarGraph(line, outbuf); // get line one of the graph
			else
				outbuf = "[bad line number]";
		}
		else
		{
			outbuf = "[No such graph]";
		}
        
	} catch (char *e) {
		outbuf = e;
	} catch (string s) {
		outbuf = s;
	} catch(...) {
        outbuf = "Exception";
    }

	return const_cast<char *>(outbuf.c_str());
}
Example #2
0
void SingleAnalysis::ComputeSystematics(int pointID, const GraphMap &nominalMap, const GraphMap &systGraphMap,
		GraphName graphName, GraphSystErrorMap &upperBoundErrorMap, GraphSystErrorMap &lowerBoundErrorMap)
{
	double systVar = 0.d;
	double nominalVar = 0.d;
	double systVarDiff = 0.d;

	nominalVar = nominalMap.find(graphName)->second->GetY()[pointID];
	systVar = systGraphMap.find(graphName)->second->GetY()[pointID];
	systVarDiff = systVar - nominalVar;

	std::cout << "Graph name : " << graphName << std::endl;
	std::cout << "syst error on point id " << pointID << " is " << systVarDiff << std::endl;

	if( systVarDiff > 0.d )
		upperBoundErrorMap[graphName] += systVarDiff*systVarDiff;
	else
		lowerBoundErrorMap[graphName] += systVarDiff*systVarDiff;
}
void OverlayAnalysis::FillGraphs()
{
    std::cout << "Filling graphs" << std::endl;

    for(DataTypeVector::const_iterator dataIter = m_dataTypeVector.begin(), dataEndIter = m_dataTypeVector.end() ;
            dataEndIter != dataIter ; ++dataIter)
    {
        DataType dataType = *dataIter;
        DrawAttributeMapping drawAttributeMapping(dataType);

        GraphMap graphMap;
        graphMap[N_PFOS] = drawAttributeMapping.ConfigureGraph(new TGraphErrors());
        graphMap[NEUTRAL_PURITY] = drawAttributeMapping.ConfigureGraph(new TGraphErrors());
        graphMap[NEUTRAL_EFFICIENCY] = drawAttributeMapping.ConfigureGraph(new TGraphErrors());
        graphMap[NEUTRAL_RECOVER_PROBA] = drawAttributeMapping.ConfigureGraph(new TGraphErrors());
        graphMap[NEUTRAL_ENERGY_DIFFERENCE_EFFICIENT] = drawAttributeMapping.ConfigureGraph(new TGraphErrors());

        for(IntVector::iterator nIter = m_neutralEnergies.begin(), nEndIter = m_neutralEnergies.end() ;
                nEndIter != nIter ; ++nIter)
        {
            int neutralEnergy = *nIter;

            for(IntVector::iterator cIter = m_chargedEnergies.begin(), cEndIter = m_chargedEnergies.end() ;
                    cEndIter != cIter ; ++cIter)
            {
                int chargedEnergy = *cIter;
                int pointID = 0;

                for(unsigned int distance = m_startDistance ; distance <= m_endDistance ; distance += m_distanceStep)
                {
                    std::string completeFileName =
                        m_rootFileDirectory
                        + this->GetDataName(dataType)
                        + "/"
                        + this->GetFileName(neutralEnergy, chargedEnergy, distance, dataType);

                    TFile *pFile = TFile::Open(completeFileName.c_str());

                    if(!pFile)
                        throw std::runtime_error("Wrong file name !");

                    TTree *pTree = (TTree *) pFile->Get(m_treeName.c_str());

                    if(!pTree)
                        throw std::runtime_error("Wrong tree name !");

                    TreeAnalyzer treeAnalyzer(pTree);
                    treeAnalyzer.Loop(pointID, static_cast<double>(distance), graphMap);

                    pointID++;
                }
            }
        }

        // Add graphs in multi graph map
        for(GraphMap::const_iterator graphIter = graphMap.begin(), graphEndIter = graphMap.end() ;
                graphEndIter != graphIter ; ++graphIter)
            m_canvasMultiGraphMap[graphIter->first].second->Add(graphIter->second);

    }
}
Example #4
0
void SingleAnalysis::FillFromFile(DataType dataType)
{
	DrawAttributeMapping drawAttributeMapping(dataType);
	GraphMap graphMap;

	graphMap[E_REC] = drawAttributeMapping.ConfigureGraph(new TGraphErrors());
	graphMap[E_REC_DEVIATION] = drawAttributeMapping.ConfigureGraph(new TGraphErrors());
	graphMap[E_RESOL] = drawAttributeMapping.ConfigureGraph(new TGraphErrors());

	int pointID = 0;

	std::ifstream ifile;
	std::string completeFileName =
		m_rootFileDirectory
		+ this->GetDataName(dataType)
		+ "/"
		+ this->GetBasicFileName(dataType);

	std::cout << "File name is " << completeFileName << std::endl;

	ifile.open( completeFileName.c_str(), std::ios::in );

	if( ! ifile.is_open() || ! ifile.good() )
		throw std::runtime_error("Wrong file name !");

	unsigned int nEnergies = 0;
	ifile >> nEnergies;

	if( 0 == nEnergies )
		throw std::runtime_error("Invalid n energy points");

	for( unsigned int e=0 ; e<nEnergies ; e++ )
	{
		int energy = 0;
		ifile >> energy;

		std::cout << "Energy is " << energy << std::endl;

		float erec, erecError, eresol, eresolError, erecDev, erecDevError = 0.f;
		ifile >> erec >> erecError >> eresol >> eresolError;

		std::cout << "Erec " << erec << " , erecError " << erecError << " , eresol " << eresol << " , eresolError " << eresolError << std::endl;

		erecDev = (erec - energy) / energy;
		erecDevError = erecError / energy;

		graphMap[E_REC]->SetPoint(e, energy, erec);
		graphMap[E_REC]->SetPointError(e, 0, erecError);

		graphMap[E_REC_DEVIATION]->SetPoint(e, energy, erecDev);
		graphMap[E_REC_DEVIATION]->SetPointError(e, 0, erecDevError);

		graphMap[E_RESOL]->SetPoint(e, energy, eresol);
		graphMap[E_RESOL]->SetPointError(e, 0, eresolError);
	}

	// Add graphs in multi graph map
	for(GraphMap::const_iterator graphIter = graphMap.begin(), graphEndIter = graphMap.end() ;
			graphEndIter != graphIter ; ++graphIter)
		m_canvasMultiGraphMap[graphIter->first].second->Add(graphIter->second);
}
Example #5
0
Graph&
findOrCreateGraph(const char *param1, const char *param2)
{
	string graphName(param2);

	// check if we have seen this graph definition before
	GraphMap::iterator graphIter = graphs.find(graphName);

    if (graphIter != graphs.end())
	{
		assert(graphIter->first == graphName);
		if (graphIter->second.createParams == param1)
			return graphIter->second;

		// inital parameters have changed - delete the old object and create a new one.
		graphs.erase(graphIter);
	}
           
    // otherwise create the object  

	
        // ====== Parse parameters ===========
		// param1 is options and takes the form:
		//   HeightxWidth#Direction#BarStyle#SampleTime#min#max#CounterName
		// where:
		//   HeightxWidth is the size of the bar graph
		//   Direction is one of: d, u, l, r   [for down/up/left/right]
		//   SampleTime is how often the counter value is fetched, in 1/10 seconds.
		//   BarStyle selects the custom characters to use
		//   CounterName is a name of a performance counter (ie. '\Processor(0)\% Processor Time')
	    //   min - used for scaling graph.
	    //   max - used for scaling graph.
		// param2 is a name to use in function2 to get further lines.
	    
		// handle HeightxWidth
		unsigned int height = atoi(param1); 
		char *x = strchr(param1, 'x');
        if (x == NULL)
           throw "[HEIGHTxWIDTH required]";
		unsigned int width = atoi(x+1);
		if ((width < 1) || (width > 40))
			throw "[Width out of range]";
		if ((height < 1) || (height > 4))
			throw "[Height out of range]";

		// handle Direction
		Graph::Direction direction;
		char *hash = strchr(x, '#');
		if (hash != NULL)
		{
			hash ++;
			switch (*hash)
			{
			case 'l': direction = Graph::LEFT; break;
			case 'r': direction = Graph::RIGHT; break;
			case 'u': direction = Graph::UP; break;
			case 'd': direction = Graph::DOWN; break;
			default: throw "[Invalid direction]";
			}
		} 
		else
			direction = Graph::UP;

		// handle BarStyle
		unsigned int barStyle;
		if (hash != NULL)
			hash = strchr(hash, '#');
	
		if (hash != NULL)
		{
			hash ++;
			if (!JustDigits(hash))
				throw "[perf: bad bar style]";
			barStyle = atoi(hash);
		}
		else
			barStyle = 1;
		

		// handle SampleTime
		unsigned int sampleTime;
		if (hash != NULL)
			hash = strchr(hash, '#');

		if (hash != NULL)
		{
			hash ++;
			if (!JustDigits(hash))
				throw "[perf: bad sample time]";
			sampleTime = atoi(hash) * 100; // convert to mSec

			if (sampleTime < 1)
				throw "[Invalid Sample Time]";
		} 
		else
			sampleTime = 500; 
		


		// handle min
		unsigned int min;
		if (hash != NULL)
			hash = strchr(hash, '#');
	
		if (hash != NULL)
		{
			hash ++;
			if (!JustDigits(hash))
				throw "[perf: bad min]";
			min = atoi(hash);
		}
		else
			min = 0;

		// handle max
		unsigned int max;
		if (hash != NULL)
			hash = strchr(hash, '#');
	
		if (hash != NULL)
		{
			hash ++;
			if (!JustDigits(hash))
				throw "[perf: bad max]";
			max = atoi(hash);
		}
		else
			max = 100;
				
		// handle counterName
		char *counterName;
		if (hash != NULL)
			hash = strchr(hash, '#');

		if (hash != NULL)
		{
			hash ++;
			counterName = hash;
		}
		else
			counterName = "\\Processor(0)\\% Processor Time";

		
		// Convert our barStyle to that used by graph
		switch (barStyle)
		{
		case 0: break;
		case 1: break;
		case 2: barStyle |= SIXWIDE; break;
		case 3: barStyle |= SIXWIDE | SEVENHIGH; break;
		case 4: barStyle |= SEVENHIGH; break;
		case 5: break;
		case 9: barStyle = 6 | SEVENHIGH; break;
		case 13: barStyle = 7 | SEVENHIGH; break;
		case 99: barStyle = TINY; break;
		case 100: barStyle = TINY | SIXWIDE; break;
		case 101: barStyle = TINY | SIXWIDE | SEVENHIGH; break;
		case 102: barStyle = TINY | SEVENHIGH; break;
		default:
			throw "[perf: unknown bar style]";
		}


		if (barStyle & TINY) // special bar style for small (1x8 or less) graphs
		{
			if (height > 1)
				throw "[Graph too high for tiny graphs]";
			if (width > 8)
				throw "[Graph too wide for tiny graphs]";

			if (barStyle & SIXWIDE)
				width *= 6;
			else
				width *= 5; // there are 5 pixels in a custom chars.
		}

		
		graphs.insert(pair<string, GraphObj>(graphName, 
			GraphObj(param1, height, width, sampleTime, string(counterName), direction, barStyle, min, max)));
		GraphMap::iterator graphIter2 = graphs.find(graphName);
		assert(graphIter2 != graphs.end());
		return graphIter2->second;
}
Example #6
0
extern "C" PERF_API  void
__stdcall  SmartieFini()
{
	graphs.clear();
}
Example #7
0
Network::NetEdgeIterator::NetEdgeIterator(const GraphMap& m) {
  _begin = m.begin();
  _end = m.end();
  reset();
}