示例#1
0
TGraphErrors* ExtractCalCurve(vector<calData>& FitPositions, vector<Float_t>& Energies)
//void ExtractCalCurve(vector<Float_t>& FitPositions, vector<Float_t>& Energies)
{
    //TF1* calFit = new TF1("calFit","[0]*x + [1]",0,800E3);
    TGraphErrors* calCurve = new TGraphErrors(Energies.size());
    
    //Get highest energy peak and estimate [0]
    std::vector<calData>::iterator pit;
    std::vector<Float_t>::iterator eit;
    
    pit = max_element(FitPositions.begin(),FitPositions.end(),CompareByadc);
    eit = max_element(Energies.begin(),Energies.end());
    
    //Extrapolate coefficient and place first point
    int currPoint = 1;
    calCurve->SetPoint(currPoint,(*pit).fadc,*eit);
    calCurve->SetPointError(currPoint,(*pit).efadc,0.0);
    TFitResultPtr r = calCurve->Fit("pol1","SQ");   
    Float_t a = r->Parameter(1);

    Float_t CurrentPeak = 0.0;
    Float_t CurrentEnergy = 0.0;
    Float_t CurrentEnergyEst = 0.0;
    // Loop through found peaks and locate closest estimated energy
    // Assume fitted peaks are already ordered from lowest to highest
    for(std::vector<calData>::iterator i = --(FitPositions.end()); i!=FitPositions.begin(); --i)
    {
        currPoint++;
        CurrentPeak = (*i).fadc;
        CurrentEnergyEst = CurrentPeak*a;
        Float_t CurrentDelta = 800E3;
        for(std::vector<Float_t>::iterator j = Energies.begin(); j!=Energies.end(); j++)
	{
		if( abs(*j - CurrentEnergyEst) < CurrentDelta)
		{
			CurrentDelta = abs(*j - CurrentEnergyEst);
                        CurrentEnergy = *j;
		}
	} 
	
	calCurve->SetPoint(currPoint,CurrentPeak,CurrentEnergy);
        calCurve->SetPointError(currPoint,(*i).efadc,CurrentDelta);
        r = calCurve->Fit("pol1","SQ");
        a = r->Parameter(1);
    }
    r->Print("V");
    return calCurve; 
}
int RampCorrellation_single(std::string file_name, TGraphErrors &graph, TGraphErrors &graph2, vector<double> &vec_errors)
{

	TTree *t = new TTree();
	const std::string file_path = "/home/jlab/github/MagCloak_Analysis/calibration/data-calib/DATA_MegaVIEW/";
//	std::string file_name = "DataFile_2016-12-08_06-59-11.csv";
	std::string file = file_path+file_name;

	t->ReadFile(file.c_str());
//	t->Print();

	TCanvas *c = new TCanvas();
	t->Draw("TMath::Abs(B1/B2):time");
	TGraph *gh = (TGraph*)c->GetListOfPrimitives()->FindObject("Graph");
	double ratio_mean = gh->GetMean(2);
	double ratio_std = gh->GetRMS(2);

	t->Draw("Bnom:time");
	TGraph *gh1 = (TGraph*)c->GetListOfPrimitives()->FindObject("Graph");
	double nom_mean = gh1->GetMean(2);
	double nom_std = 0;

//	cout << "At " << nom_mean << " mT, B1/B2 is: " << ratio_mean << " +/- " << ratio_std << endl;
	
	c->Close();

	int n = graph.GetN();
	graph.SetPoint(n,nom_mean,ratio_mean);
	graph.SetPointError(n,nom_std,ratio_std);

//-------------------------------------------------------------------------------

	TCanvas *c2 = new TCanvas();
	t->Draw("B3:time");
	TGraph *gh2 = (TGraph*)c2->GetListOfPrimitives()->FindObject("Graph");
	double B3_mean = -1*(gh2->GetMean(2));
	double B3_std = gh2->GetRMS(2);
	
	int n2 = graph2.GetN();
	graph2.SetPoint(n2, nom_mean, B3_mean);
	graph2.SetPointError(n2, nom_std, B3_std);
	
	c2->Close();

	if(nom_mean < 500) vec_errors.push_back(B3_std);

	return 0;
}
示例#3
0
//______________________________________________________________________________
TGraphErrors *GraphRatio(TGraphErrors *g1,TGraphErrors *g2)
{
  Int_t n = g1->GetN();
  if (n != g2->GetN()) {
    Printf("!!!!!!!!!!!!!!!!");
    return 0;
  }

  TGraphErrors *g = new TGraphErrors(n);
  g->SetMarkerStyle(20);
  g->GetXaxis()->SetTitle("p_{t}, GeV/c");
  g->SetTitle(Form("#frac{%s}{%s}", g1->GetTitle(), g2->GetTitle()));
  Double_t x, y1, y2;
  Double_t c0, c1, c12, e0, e1;
  Double_t *ex = g1->GetEX();
  Double_t *ey = g1->GetEY();
  for (Int_t i = 0; i < n; i++) {
    g1->GetPoint(i, x, y1);
    g2->GetPoint(i, x, y2);
    if (TMath::Abs(y2) < 1.E-12) y2 = 1.0;
    c0 = y1;
    c1 = y2;
    c12 = c1*c1;
    e0  = g1->GetErrorY(i);
    e1  = g2->GetErrorY(i);
    g->SetPoint(i, x, y1/y2);
    g->SetPointError(i, ex[i], (e0*e0*c1*c1 + e1*e1*c0*c0)/(c12*c12));
  }

  return g;
}
示例#4
0
文件: drawAvsB.C 项目: miquork/jecsys
TGraphErrors* addGraph(TGraphErrors *g1, TGraphErrors *g2) {
  
  assert(g1->GetN()==g2->GetN());
  TGraphErrors *g = (TGraphErrors*)g1->Clone();//new TGraphErrors(g1->GetN());
  for (int i = 0; i != g1->GetN(); ++i) {

    double x1 = g1->GetX()[i];
    double x2 = g2->GetX()[i];
    assert(fabs(x1/x2-1)<0.1);

    double ex1 = g1->GetEX()[i];
    double ex2 = g2->GetEX()[i];

    double y1 = g1->GetY()[i];
    double y2 = g2->GetY()[i];

    double ey1 = g1->GetEY()[i];
    double ey2 = g2->GetEY()[i];

    double x = (ey2*ey2*x1 + ey1*ey1*x2) / (ey2*ey2+ey1*ey1);
    double y = (ey2*ey2*y1 + ey1*ey1*y2) / (ey2*ey2+ey1*ey1);
    double ex = (ey2*ey2*ex1 + ey1*ey1*ex2) / (ey2*ey2+ey1*ey1);
    double ey = (ey2*ey2*ey1 + ey1*ey1*ey2) / (ey2*ey2+ey1*ey1);

    g->SetPoint(i, x, y);
    g->SetPointError(i, ex, ey);
  }

  return g;
}
示例#5
0
void add_point( double coefover, double sigma, double dsigma ){//============================================================


      TGraphErrors *fisig;
      if ( gROOT->GetListOfSpecials()->FindObject("fisig")!=NULL ){
	fisig=(TGraphErrors*) gROOT->GetListOfSpecials()->FindObject("fisig");
	printf("fisig exists\n%s","");
      }else{

	printf("\n\n NO fisig exists NONONO \n\n\n%s","");

	fisig=new TGraphErrors();
	fisig->SetTitle("fisig");
	fisig->SetName("fisig");
	gROOT->GetListOfSpecials()->Add( fisig );// TRICK TO KEEP IT
	gDirectory->Add( fisig );
	fisig->SetMarkerStyle(7);
      }


      int n=fisig->GetN();
      fisig->SetPoint(n,coefover,sigma);
      fisig->SetPointError(n,0.0,dsigma);
      //      fisig->Print(); // too many data 

     char text[100];
      sprintf(text,"%.3f ... %d",coefover, fisig->GetN()  );

      //      TText *t=new TText(from,0,text ); 
      //      t->SetTextSize(0.08);t->Draw();
 

}//============================================================
示例#6
0
void ExpManager::GetExp1DGraphX(TString NameTitle, double zmin, double zmax, double ymin, double ymax, TString grid){   // do the same thing as for the polar interpolation

    TGraphErrors *fGraph = new TGraphErrors(); //= new TGraph2DErrors(np, x_array, y_array, bz_array, ex, ey, ez);
    fGraph->SetTitle("Experimental Data;X (mm);Magnetic Field (mT)");
    fGraph->SetMarkerSize(1.2);
    fGraph->SetMarkerStyle(20);
    fGraph->SetMarkerColor(kBlue);
    fGraph->SetLineColor(kBlue);
    fGraph->SetLineWidth(2);
       
    int graph_counter = 0 ; 
   for (unsigned i=0; i< fExpY.size(); i++)   {
    //cout <<  " X "  << fExpX.at(i) ;  
        if( (fExpY.at(i) >= ymin && fExpY.at(i) <= ymax) && (fExpZ.at(i) >= zmin && fExpZ.at(i) <= zmax)  && fGrid.at(i)== grid ){
            cout << "  < ----- " ; 
            fGraph->SetPoint(graph_counter,fExpX.at(i),fExpB.at(i));    // CHECK, add new the stuff for emag
            fGraph->SetPointError(graph_counter,fExpXErr.at(i),fExpBErr.at(i));   // CHECK, add new the stuff for emag
            graph_counter++;
        }
        cout << endl ; 
   }

    fGraph->SetTitle(NameTitle+Form(" Experimental Data : %.2f < Depth < %.2f mm  __  %.2f < Y < %.2f mm;X (mm);Magnetic Field (mT)",zmin,zmax,ymin,ymax));
    fGraph->SetName(NameTitle+Form("_Exp_Depth_%.2f_%.2fmm_Y_%.2f_%.2fmm",zmin,zmax,ymin,ymax));
    fGraph->Write();

}
示例#7
0
TGraphErrors bestFit(TTree *tree, TString alphaName, TString constTermName){
  Double_t alpha, constTerm;
  alphaName.ReplaceAll("-","_");
  constTermName.ReplaceAll("-","_");

  tree->SetBranchAddress(alphaName,&alpha);
  tree->SetBranchAddress(constTermName,&constTerm);

  //Long64_t nEntries=genTree->GetEntries();

  TGraphErrors graph;
  Int_t iPoint=0;

  tree->GetEntry(0);
  graph.SetPoint(0, constTerm, alpha);
  graph.SetPointError(0,0, 0);
  iPoint++;

  graph.Set(iPoint);
  tree->ResetBranchAddresses();
  graph.Draw("A P");
//   graph.SetFillColor(kBlue);
//   graph.SetLineColor(kYellow);
//   graph.GetXaxis()->SetTitle("Energy [GeV]");
//   graph.GetYaxis()->SetTitle("Additional smearing [%]");
  return graph;
}
示例#8
0
void ExpManager::GetSim1DGraphZ(TString NameTitle, double xmin, double xmax, double ymin, double ymax, TString grid ){   // do the same thing as for the polar interpolation

    TGraphErrors *fGraph = new TGraphErrors(); //= new TGraph2DErrors(np, x_array, y_array, bz_array, ex, ey, ez);
    fGraph->SetTitle("Simulated Data;Z (mm);Magnetic Field (mT)");
    fGraph->SetMarkerSize(1.2);
    fGraph->SetMarkerStyle(20);
    fGraph->SetMarkerColor(kBlue);
    fGraph->SetLineColor(kBlue);
    fGraph->SetLineWidth(2);
       
    int graph_counter = 0 ; 
   for (unsigned i=0; i< fExpY.size(); i++)   {
    //cout <<  " X "  << fExpX.at(i) ;  
        if( (fExpX.at(i) >= xmin && fExpX.at(i) <= xmax) && (fExpY.at(i) >= ymin && fExpY.at(i) <= ymax) &&  fGrid.at(i)==grid ){
            fGraph->SetPoint(graph_counter,fExpZ.at(i),fSimB.at(i));    
            fGraph->SetPointError(graph_counter,fExpZErr.at(i),0);   
            graph_counter++;
        } 
   }

    fGraph->SetTitle(NameTitle+Form(" Simulated Data : %.2f < X < %.2f mm  __  %.2f < Y < %.2f mm;Z (mm);Magnetic Field (mT)",xmin,xmax,ymin,ymax));
    fGraph->SetName(NameTitle+Form("_Sim_X_%.2f_%.2fmm_Y_%.2f_%.2fmm",xmin,xmax,ymin,ymax));
    fGraph->Write();

}
示例#9
0
void draw() {

  gStyle->SetOptStat(0000);

  TGraphErrors* gr = new TGraphErrors("papel_um.txt", "%lg %lg %lg %lg");
  gr->Draw("A");

  gr->GetXaxis()->SetTitle("Diametro (mm)");
  gr->GetYaxis()->SetTitle("Massa (u.m.)");
  gr->SetTitle("Dimensao Fractal - Papel");
  gr->SetMarkerStyle(20);
  gr->SetMarkerSize(gr->GetMarkerSize()/2.);

  TCanvas* c1 = new TCanvas();
  gr->Draw("AP");
  c1->Print("gr1.png");


  TGraphErrors* grlog = new TGraphErrors();
  for (int i=0; i<gr->GetN(); i++) {
    grlog->SetPoint(i, TMath::Log(gr->GetX()[i]), TMath::Log(gr->GetY()[i]));
    grlog->SetPointError(i, gr->GetEX()[i]/gr->GetX()[i], 0.0);
  }
  grlog->Draw("A");
  grlog->GetXaxis()->SetTitle("Logaritmo do diametro (diametro em mm)");
  grlog->GetYaxis()->SetTitle("Logaritmo da massa (massa em unidade arbitraria)");
  grlog->SetTitle("Dimensao Fractal - Papel");
  grlog->SetMarkerStyle(20);
  //  grlog->SetMarkerSize(gr->GetMarkerSize()/2.);
  grlog->Fit("pol1");
  TCanvas* c2 = new TCanvas();
  grlog->Draw("AP");
  c2->Print("gr2.png");

}
示例#10
0
TGraphErrors g(TTree *genTree, TString constTermName=""){
  Double_t alpha, constTerm;
  genTree->SetBranchAddress("alpha",&alpha);
  genTree->SetBranchAddress("constTerm",&constTerm);

  Long64_t nEntries=genTree->GetEntries();

  TH1F h("smearingHist","",10000,0,0.1);
  TGraphErrors graph;
  Int_t iPoint=0;
  for(Double_t energy=20; energy<150; energy+=10){
    h.Reset();
    for(Long64_t jentry=0; jentry<nEntries; jentry++){
      genTree->GetEntry(jentry);
      h.Fill(sqrt(alpha*alpha/energy+constTerm*constTerm));
    }
    graph.SetPoint(iPoint, energy, h.GetMean());
    graph.SetPointError(iPoint,0, h.GetRMS());
    iPoint++;
  }
  h.SetTitle(constTermName);
  h.SaveAs("tmp/h-"+constTermName+".root");
  graph.Set(iPoint);
  genTree->ResetBranchAddresses();
  graph.Draw("A L3");
  graph.SetFillColor(kBlue);
  graph.SetLineColor(kYellow);
  graph.GetXaxis()->SetTitle("Energy [GeV]");
  graph.GetYaxis()->SetTitle("Additional smearing [%]");
  return graph;
}
示例#11
0
TGraphErrors g(TTree *tree, TString alphaName, TString constTermName){
  Double_t alpha, constTerm;
  alphaName.ReplaceAll("-","_");
  constTermName.ReplaceAll("-","_");

  tree->SetBranchAddress(alphaName,&alpha);
  tree->SetBranchAddress(constTermName,&constTerm);

  //Long64_t nEntries=genTree->GetEntries();

  TGraphErrors graph;
  Int_t iPoint=0;

  tree->GetEntry(0);
  std::cout << alpha << "\t" << constTerm << std::endl;
  Double_t alpha2=alpha*alpha;
  Double_t const2=constTerm*constTerm;
  for(Double_t energy=20; energy<150; energy+=10){
    Double_t addSmearing = (sqrt(alpha2/energy+const2));
    
    graph.SetPoint(iPoint, energy, addSmearing);
    graph.SetPointError(iPoint,0, 0);
    iPoint++;
  }

  graph.Set(iPoint);
  tree->ResetBranchAddresses();
  graph.Draw("A L");
  graph.SetFillColor(kBlue);
  graph.SetLineColor(kYellow);
  graph.GetXaxis()->SetTitle("Energy [GeV]");
  graph.GetYaxis()->SetTitle("Additional smearing [%]");
  return graph;
}
示例#12
0
TGraphErrors* getMoliereGraph( std::vector<DataFile> dataFiles ) {

  TGraphErrors* graph = new TGraphErrors(0);

  for( unsigned i=0; i<dataFiles.size(); ++i ) {

    if( dataFiles[i].file==0 ) continue;

    Double_t x = (i==0) ? -1 : dataFiles[i].absThickness;

    Double_t y = ((TH1D*)(dataFiles[i].file->Get("Rmoliere")))->GetMean();
    Double_t yerr = ((TH1D*)(dataFiles[i].file->Get("Rmoliere")))->GetMeanError();

    graph->SetPoint(i, x, y);
    graph->SetPointError(i, 0, yerr);

    if( i==0 ) std::cout << "LYSO Moliere radius: " << y << std::endl;

  }

  graph->SetName( "mol" );
  graph->SetTitle( "Moliere Radius [mm]" );

  return graph;

}
TGraphErrors *TruePoint(TH1 *hT, TH1 *hp, int t, double y)
{
  double ymin = hp->GetMinimum();
  double ymax = hp->GetMaximum();
  double yDrawData = y>0? y : ymin + 0.2*(ymax-ymin);
  TGraphErrors *truePoint = new TGraphErrors();
  truePoint->SetPoint(0, hT->GetBinContent(t+1), yDrawData);
  SetGraphProps(truePoint, kRed+2, kGray, kRed+2, kOpenCircle, 1.5);
  return truePoint;
}
TGraphErrors *DataPoint(TH1 *hD, TH1 *hp, int t, double y)
{
  double ymin = hp->GetMinimum();
  double ymax = hp->GetMaximum();
  double yDrawData = y>0? y : ymin + 0.2*(ymax-ymin);
  TGraphErrors *dataPoint = new TGraphErrors();
  dataPoint->SetPoint(0, hD->GetBinContent(t+1), yDrawData);
  dataPoint->SetPointError(0, hD->GetBinError(t+1), 0.0);
  SetGraphProps(dataPoint, kBlack, kNone, kBlack, kFullCircle, 1.0);
  return dataPoint;
}
示例#15
0
int main(int narg,char **arg)
{
  int i;
  double x,y;
  ifstream file;
  TApplication myapp("App",NULL,NULL);
  TCanvas tela;
  TGraphErrors graf;
  TF1 fun("fun","[0]*exp(-x*x/(2*[1]*[1]))");

  if(narg<2)
    {
      cerr<<"usa: "<<arg[0]<<" file"<<endl;
      exit(0);
    }

  file.open(arg[1]);

  if(file.good()==0)
    {
      cout<<"File: "<<arg[1]<<" inesistente!"<<endl;
      exit(0);
    }

  i=0;
  double dum,N=1;
  while(file>>x>>dum>>y)
    {
      if(i==0) N=y;
      graf.SetPoint(i,x,y);
      graf.SetPointError(i,0,0.0001);
      i++;
    }
  
  fun.SetParameter(0,N);
  fun.SetParameter(1,1);

  fun.SetParName(0,"N");
  fun.SetParName(1,"S");

  graf.Draw("AP");

  graf.Fit("fun");

  //graf.GetXaxis()->SetLimits(0,x);

  tela.Modified();
  tela.Update();

  myapp.Run(true);

  return 0;
}
TGraphErrors *MD68Point(TH1 *hp, double y)
{
  double ymin = hp->GetMinimum();
  double ymax = hp->GetMaximum();
  double yDraw = y>0? y : ymin + 0.25*(ymax-ymin);
  TGraphErrors *g = new TGraphErrors();
  MaxDensityInterval mdi = GetMDI(hp, 0.68);
  g->SetPoint(0, mdi.u, yDraw);
  g->SetPointError(0, mdi.du, 0);
  SetGraphProps(g, kAzure, kAzure, kAzure, kOpenSquare, 1.5);
  return g;
}
///
/// Make an evolution graph for one parameter.
///
TGraphErrors* ParameterEvolutionPlotter::makeEvolutionGraphErrors(vector<RooSlimFitResult*> results, TString parName)
{
	TGraphErrors *g = new TGraphErrors(results.size());
	int iGraph = 0;
	for ( int i=0; i<results.size(); i++ ){
		if ( results[i] ){
			g->SetPoint(iGraph, results[i]->getParVal(scanVar1), results[i]->getParVal(parName));
			g->SetPointError(iGraph, 0, results[i]->getParErr(parName));
			iGraph++;
		}
	}
	return g;
}
示例#18
0
void OneBin(Int_t bin, 
	    TH1* h0900,
	    TH1* h2760, 
	    TH1* h7000, 
	    TH1* h8000, 
	    TMultiGraph* mg,
	    TNtuple* tuple,
	    Double_t sysErr=0.076)
{
  Info("OneBin", "Getting one bin %d,%p,%p,%p,%p,%p",
       bin, h0900,h2760,h7000,h8000,tuple);
  
  Double_t eta = h0900->GetXaxis()->GetBinCenter(bin);
  Double_t w   = h0900->GetXaxis()->GetBinWidth(bin);
  Info("", "Eta=%f +/- %f", eta, w);
  Double_t e[] = { 900.,  2760., 7000., 8000., 0 };
  TH1*     h[] = { h0900, h2760, h7000, h8000, 0 };
  Float_t  x[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
  x[0] = eta;
  x[1] = w;

  TGraphErrors* g = new TGraphErrors(0);
  g->SetName(Form("eta%03d", bin));
  g->SetTitle(Form("%f", eta));
  g->SetMarkerStyle(bin % 10 + 20);
  g->SetMarkerColor(bin % 6 + 2);
  
  Double_t* pe = e;
  TH1**     ph = h;
  Int_t     i  = 0;
  Int_t     j  = 1;
  while (*pe && *ph) { 
    Double_t c = (*ph)->GetBinContent(bin);
    Double_t v = sysErr*c;
    if (c > 1e-6){
      g->SetPoint(i, *pe, c);
      g->SetPointError(i, w, v);
      x[Int_t(2*j+0)] = c;
      x[Int_t(2*j+1)] = v;
      i++;
    }
    j++;
    pe++;
    ph++;
  }
  if (tuple) tuple->Fill(x);
  if (i > 0) mg->Add(g);
  else delete g;
}
///
/// Plot the discrepancy between the observable and the predicted
/// observable when making predictions about observables by scanning
/// them. This checks if the chi2 term of the observable is tight enough.
/// This only works for 1D scans for now.
///
void ParameterEvolutionPlotter::plotObsScanCheck()
{
	vector<RooSlimFitResult*> results = curveResults;

	cout << "ParameterEvolutionPlotter::plotObsScanCheck() : plotting ..." << endl;
	TCanvas *c2 = newNoWarnTCanvas("plotObsScanCheck"+getUniqueRootName(), title, 800,600);
	c2->SetLeftMargin(0.2);

	// get observable
	TGraphErrors *g = new TGraphErrors(results.size());
	int iGraph = 0;

	for ( int i=0; i<results.size(); i++ ){
		assert(results[i]);
		// get value of observable
		float obsValue = results[i]->getParVal(scanVar1);
		float obsError = w->var(scanVar1)->getError();

		// get value of theory prediction
		setParameters(w,parsName,results[i]);
		TString thName = scanVar1;
		thName.ReplaceAll("_obs","_th");
		if ( !w->function(thName) ){
			cout << "ParameterEvolutionPlotter::plotObsScanCheck() : ERROR : theory value not found: " << thName << endl;
			continue;
		}
		float thValue = w->function(thName)->getVal();
		g->SetPoint(iGraph, iGraph, obsValue-thValue);
		g->SetPointError(iGraph, 0., obsError);
		iGraph++;
	}

	g->SetTitle(scanVar1);
	g->GetXaxis()->SetTitle("scan step");
	g->GetYaxis()->SetTitleSize(0.06);
	g->GetYaxis()->SetLabelSize(0.04);
	g->GetYaxis()->SetTitleOffset(1.5);
	g->GetYaxis()->SetTitle(scanVar1);
	Int_t ci = 927;
	TColor *col = new TColor(ci, 0, 0, 1, " ", 0.5);
	g->SetFillColor(ci);
	g->SetFillStyle(1001);
	g->Draw("a3");
	g->Draw("lxsame");
	c2->Update();

	savePlot(c2, "parEvolutionObsSanCheck_"+name+"_"+scanVar1);
}
void CreateAndFillUserTGraph(const char* nameAndTitle, Int_t npoint, Double_t xvalue, Double_t yvalue, Double_t xErr, Double_t yErr)
{
  map<std::string , TGraphErrors*>::iterator nh_h = userTGraphs_.find(std::string(nameAndTitle));
  TGraphErrors * h;
  if( nh_h == userTGraphs_.end() )
    {
      h = new TGraphErrors(0);
      userTGraphs_[std::string(nameAndTitle)] = h;
      h->SetPoint(npoint, xvalue, yvalue);
      h->SetPointError(npoint, xErr, yErr);
    }
  else
    {
      nh_h->second->SetPoint(npoint, xvalue, yvalue);
      nh_h->second->SetPointError(npoint, xErr, yErr);
    }
}
示例#21
0
//____________________________________________________________
TGraphErrors* histo_to_tgraph( TH1* h, bool zero_sup )
{
 if( !h ) return 0;

 TGraphErrors *tg = new TGraphErrors( 0 );
 int point( 0 );
 for( int i=0; i<h->GetNbinsX(); i++ )
 {
 double x = h->GetXaxis()->GetBinCenter( i+1 );
 double y = double( h->GetBinContent( i+1 ) );
 double error = double( h->GetBinError( i+1 ) );
 if( zero_sup && !y ) continue;
 tg->SetPoint( point, x, y );
 tg->SetPointError( point, 0, error );
 point++;
 } 

 return tg;
}
示例#22
0
TGraphErrors* getTheoXSec(TString file) {
    TTree t;

    t.ReadFile(file);

    TGraphErrors *g = new TGraphErrors(t.GetEntries());

    float m,x,e;
    t.SetBranchAddress("mass",&m);
    t.SetBranchAddress("xsec",&x);
    t.SetBranchAddress("err",&e);


    int iEntry=-1;
    while(t.GetEntry(++iEntry)) {
        g->SetPoint(iEntry,m,x);
        g->SetPointError(iEntry,0,e);
    }
    return g;
}
示例#23
0
TGraphErrors* getVolumeGraph( std::vector<DataFile> dataFiles ) {

  TGraphErrors* graph = new TGraphErrors(0);

  for( unsigned i=0; i<dataFiles.size(); ++i ) {

    if( dataFiles[i].file==0 ) continue;

    Double_t x = (i==0) ? -1 : dataFiles[i].absThickness;

    float actThickness = (dataFiles[i].actType=="LYSO") ? 1.5 : cef3_thickness;
    Double_t y = actThickness*dataFiles[i].nLayers;

    graph->SetPoint(i,x,y);

  }

  graph->SetName( "vol" );
  graph->SetTitle( "Active Volume [au]");

  return graph;

}
示例#24
0
TGraphErrors g(Double_t alpha, Double_t constTerm){
  TGraphErrors graph;
  Int_t iPoint=0;

  //  std::cout << alpha << "\t" << constTerm << std::endl;
  Double_t alpha2=alpha*alpha;
  Double_t const2=constTerm*constTerm;
  for(Double_t energy=20; energy<150; energy+=10){
    Double_t addSmearing = (sqrt(alpha2/energy+const2));
    
    graph.SetPoint(iPoint, energy, addSmearing);
    graph.SetPointError(iPoint,0, 0);
    iPoint++;
  }

  graph.Set(iPoint);
  graph.Draw("A L");
  graph.SetFillColor(kBlue);
  graph.SetLineColor(kYellow);
  graph.GetXaxis()->SetTitle("Energy [GeV]");
  graph.GetYaxis()->SetTitle("Additional smearing [%]");
  return graph;
}
示例#25
0
void ExpManager::GetExp1DGraphPolar(TString NameTitle, double zmin, double zmax, double anglemin, double anglemax, TString grid) {

    TGraphErrors *fGraph = new TGraphErrors(); //= new TGraph2DErrors(np, x_array, y_array, bz_array, ex, ey, ez);
    fGraph->SetTitle("Experimental Data;Radius (mm);Magnetic Field (mT)");
    fGraph->SetMarkerSize(1.2);
    fGraph->SetMarkerStyle(20);
    fGraph->SetMarkerColor(kBlue);
    fGraph->SetLineColor(kBlue);
    fGraph->SetLineWidth(2);
       
    int graph_counter = 0 ; 
   for (unsigned i=0; i< fExpR.size(); i++)   {
        if( (fExpTheta.at(i) >= anglemin && fExpTheta.at(i) <= anglemax) && (fExpZ.at(i) >= zmin && fExpZ.at(i) <= zmax) && fGrid.at(i)== grid ){ 
            fGraph->SetPoint(graph_counter,fExpR.at(i),fExpB.at(i));    
            fGraph->SetPointError(graph_counter,fExpRErr.at(i),fExpBErr.at(i));   
            graph_counter++;
        }
   }

    fGraph->SetTitle(NameTitle+Form(" Experimental Data : %.2f < Depth < %.2f mm  __  %.2f#circ < Angle < %.2f#circ;Radius (mm);Magnetic Field (mT)",zmin,zmax,anglemin,anglemax));
    fGraph->SetName(NameTitle+Form("_Exp_Depth_%.2f_%.2fmm_Angle_%.2f_%.2fdeg",zmin,zmax,anglemin,anglemax));
    fGraph->Write();

}
示例#26
0
void ExpManager::DrawMap(TString NameTitle, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) {

    TMultiGraph *mg = new TMultiGraph();
    
    //Draw a cross
    TGraphErrors *frame = new TGraphErrors(); //= new TGraph2DErrors(np, x_array, y_array, bz_array, ex, ey, ez);
    frame->SetPoint(0,+0,+100);
    frame->SetPoint(1,+0,-100);
    frame->SetPoint(2,0,0); 
    frame->SetPoint(3,-100,0); 
    frame->SetPoint(4,+100,0);
    frame->SetPoint(5,+0,+0); 
    frame->SetPoint(6,+0,-100);
    frame->SetMarkerColor(kWhite);
    frame->SetDrawOption("ap");
    
    //Draw the map 
    TGraphErrors *fGraph = new TGraphErrors(); //= new TGraph2DErrors(np, x_array, y_array, bz_array, ex, ey, ez);
    fGraph->SetMarkerSize(1.2);
    fGraph->SetMarkerStyle(20);
    fGraph->SetMarkerColor(kBlue);
    fGraph->SetLineColor(kBlue);
    fGraph->SetLineWidth(1);
    //fGraph->SetDrawOption("ap");
    
    int graph_counter = 0 ; 
   for (unsigned i=0; i< fExpY.size(); i++)   {
        if( (fExpX.at(i) >= xmin && fExpX.at(i) <= xmax) && (fExpY.at(i) >= ymin && fExpY.at(i) <= ymax) && (fExpZ.at(i) >= zmin && fExpZ.at(i) <= zmax) ) {
            fGraph->SetPoint(graph_counter,fExpX.at(i),fExpY.at(i));    
            fGraph->SetPointError(graph_counter,fExpXErr.at(i),fExpYErr.at(i)); 
            graph_counter++;
        } 
   }

    //fGraph->Write();
    mg->SetTitle(NameTitle+Form(" Map : %.2f < X < %.2f mm    %.2f < Y < %.2f mm    %.2f < Z < %.2f mm;X (mm);Y (mm)",xmin,xmax,ymin,ymax,zmin,zmax));
    mg->SetName(NameTitle+Form("_Map__X_%.2f_%.2fmm__Y_%.2f_%.2fmm__Z_%.2f_%.2fmm",xmin,xmax,ymin,ymax,zmin,zmax));
    mg->Add(frame); 
    mg->Add(fGraph);
    mg->Write();
}
// Better to keep this in a seperate file
TGraphErrors* CMS_7TEV(Double_t scale) {

    //7 TeV measurement at CMS
    TGraphErrors *gre = new TGraphErrors(33);
    gre->SetName("Graph");
    gre->SetTitle("Graph");
    gre->SetFillColor(1);
    gre->SetMarkerStyle(21);
    gre->SetPoint(0,0.15,9.94559);
    gre->SetPointError(0,0,0.4460492);
    gre->SetPoint(1,0.25,6.4274);
    gre->SetPointError(1,0,0.2867568);
    gre->SetPoint(2,0.35,3.69525);
    gre->SetPointError(2,0,0.1654095);
    gre->SetPoint(3,0.45,2.2442);
    gre->SetPointError(3,0,0.1009501);
    gre->SetPoint(4,0.55,1.40735);
    gre->SetPointError(4,0,0.06369867);
    gre->SetPoint(5,0.65,0.920301);
    gre->SetPointError(5,0,0.04193949);
    gre->SetPoint(6,0.75,0.616821);
    gre->SetPointError(6,0,0.0283265);
    gre->SetPoint(7,0.85,0.426732);
    gre->SetPointError(7,0,0.01975661);
    gre->SetPoint(8,0.95,0.299085);
    gre->SetPointError(8,0,0.01397616);
    gre->SetPoint(9,1.1,0.183225);
    gre->SetPointError(9,0,0.00845129);
    gre->SetPoint(10,1.3,0.0995915);
    gre->SetPointError(10,0,0.004670335);
    gre->SetPoint(11,1.5,0.056565);
    gre->SetPointError(11,0,0.002704398);
    gre->SetPoint(12,1.7,0.0337805);
    gre->SetPointError(12,0,0.001650384);
    gre->SetPoint(13,1.9,0.0208494);
    gre->SetPointError(13,0,0.001043639);
    gre->SetPoint(14,2.1,0.01323271);
    gre->SetPointError(14,0,0.0006804352);
    gre->SetPoint(15,2.3,0.00852133);
    gre->SetPointError(15,0,0.0004520424);
    gre->SetPoint(16,2.5,0.00555772);
    gre->SetPointError(16,0,0.0003051332);
    gre->SetPoint(17,2.7,0.00369416);
    gre->SetPointError(17,0,0.0002105437);
    gre->SetPoint(18,2.9,0.00275361);
    gre->SetPointError(18,0,0.0001617788);
    gre->SetPoint(19,3.1,0.001784498);
    gre->SetPointError(19,0,0.0001103706);
    gre->SetPoint(20,3.3,0.001251193);
    gre->SetPointError(20,0,8.105581e-05);
    gre->SetPoint(21,3.5,0.000932109);
    gre->SetPoint(22,3.7,0.00072809);
    gre->SetPointError(22,0,5.106009e-05);
    gre->SetPoint(23,3.9,0.000483879);
    gre->SetPointError(23,0,3.643427e-05);
    gre->SetPoint(24,4.1,0.000397255);
    gre->SetPointError(24,0,3.101453e-05);
    gre->SetPoint(25,4.3,0.000281682);
    gre->SetPointError(25,0,2.426278e-05);
    gre->SetPoint(26,4.5,0.0001898557);
    gre->SetPointError(26,0,1.777722e-05);
    gre->SetPoint(27,4.7,0.0001404168);
    gre->SetPointError(27,0,1.377145e-05);
    gre->SetPoint(28,4.9,0.0001152827);
    gre->SetPointError(28,0,1.228788e-05);
    gre->SetPoint(29,5.1,8.94332e-05);
    gre->SetPointError(29,0,1.021356e-05);
    gre->SetPoint(30,5.3,6.56232e-05);
    gre->SetPointError(30,0,8.759586e-06);
    gre->SetPoint(31,5.5,5.48406e-05);
    gre->SetPointError(31,0,8.112416e-06);
    gre->SetPoint(32,5.7,4.50414e-05);
    gre->SetPointError(32,0,7.518979e-06);

    /*
    gre->SetPoint(33,5.9,3.60633e-05);
    gre->SetPointError(33,0,5.641449e-06);
    gre->SetPoint(34,6.25,2.018451e-05);
    gre->SetPointError(34,0,3.081411e-06);
    gre->SetPoint(35,6.75,1.966985e-05);
    gre->SetPointError(35,0,2.63818e-06);
    gre->SetPoint(36,7.25,1.572381e-05);
    gre->SetPointError(36,0,2.668063e-06);
    gre->SetPoint(37,7.75,8.84664e-06);
    gre->SetPointError(37,0,2.136684e-06);
    gre->SetPoint(38,8.25,1.264757e-05);
    gre->SetPointError(38,0,3.756436e-06);
    gre->SetPoint(39,8.75,6.31772e-06);
    gre->SetPointError(39,0,2.762383e-06);
    gre->SetPoint(40,9.25,5.99949e-06);
    gre->SetPointError(40,0,3.246975e-06);
    gre->SetPoint(41,9.25,5.99949e-06);
    gre->SetPointError(41,0,3.239439e-06);
    /*


    /*
    Double_t x[33], y[33];
    Double_t xerr[33], yerr[33];

    for(Int_t i=0; i<33;i++){
       gre->GetPoint(i,x[i],y[i]);
       gre->SetPoint(i,x[i],scale*y[i]);
       //gre->GetPointError(i,x[i],yerr[i]);
       xerr[i] = 0, yerr[i] = 0;
       gre->SetPointError(i,scale*xerr[i],scale*yerr[i]);
    }
    */
    return gre;
}
示例#28
0
void ratiofit_vbf()
{
  const Int_t nbins = 11;
  double Bins[12] = {130.,200.,300.,400.,500.,600.,700.,800.,900.,1000.,1250.,1500.};
  
  TString OutDir = "vbf_plots_pol1Func";
  //TString OutDir = "vbf_plots_OneoversqrtXFunc";
  //TString OutDir = "vbf_plots_OneoverXFunc";
  
  gSystem->mkdir(OutDir);
  
  TFile *fname;

  fname = new TFile("mWW_sf_reweighted/scaleFactors.root");

  char tmpName[50];
  char a0Name[50];
  char a1Name[50];
  char histName[50];
  char mWWrange[50];

  //Histograms
  TH1D* h1_powheg_phantom[5];

  TString pol1Func("pol1");
  //TString pol2Func("pol2");
  //TString ExpFunc("ExpFunc");
  //TString sqrtFunc("sqrtFunc");
  //TString OneoverXFunc("OneoverXFunc");
  //TString OneoversqrtXFunc("OneoversqrtXFunc");
  
  TFitResultPtr fitres;
  TF1 *fit_func = new TF1("fit_func",pol1Func,130,1620);
  //TFitResultPtr fitres;  TF1 *fit_func = new TF1("fit_func",pol2Func,0,1500);
  //TFitResultPtr fitres;  TF1 *fit_func = new TF1("fit_func",ExpFunc,130,1500,3);
  //TFitResultPtr fitres;  TF1 *fit_func = new TF1("fit_func",sqrtFunc,130,1500,3);
  //TF1 *fit_func = new TF1("fit_func",OneoverXFunc,130,1620,2);
  //TF1 *fit_func = new TF1("fit_func",OneoversqrtXFunc,130,1620,2);
  
  TGraphErrors *grRatio  = 0;
  
  Double_t xval[nbins];
  Double_t xerr[nbins];
  Double_t rMean[nbins];
  Double_t rMeanErr[nbins];
    
  TCanvas *c = MakeCanvas("c","c",900,900);
  TGraphErrors *errBand = new TGraphErrors(nbins+2);

  char fitparam[100];
  char chi2ndf[50];
    
  for(int i(0);i<5;i++)
  {
    sprintf(tmpName,"h1_powheg_phantom_%d",i);
    h1_powheg_phantom[i] = (TH1D*)fname->Get(tmpName)->Clone(tmpName);// h1_powheg_phantom[i]->Sumw2();

    for(Int_t ibin=0; ibin<nbins; ibin++) {
      xval[ibin] = 0.5*(Bins[ibin+1]+Bins[ibin]);
      xerr[ibin] = 0.5*(Bins[ibin+1]-Bins[ibin]);
      
      rMean[ibin]    = h1_powheg_phantom[i]->GetBinContent(ibin+1);
      rMeanErr[ibin] = h1_powheg_phantom[i]->GetBinError(ibin+1);
    
    }
    
    grRatio = new TGraphErrors(nbins,xval,rMean,xerr,rMeanErr);
    grRatio->SetName("grRatio");

    //njet=0 set fit function parameter limits
    //fit_func->SetParLimits(0,0.93,0.97);
    //fit_func->SetParLimits(1,-0.00015,-0.000095);

    //njet=1 set fit function parameter limits
    //fit_func->SetParLimits(0,0.,5.);
    //fit_func->SetParLimits(1,-5.0,0.0);
    
    //fit_func->SetRange(300.,1000.);
    //fit_func->SetParameters(0.9582,-0.0001); //njet=0 fix fit function parameters

    //fit_func->SetParameter(0,0.95);
    //fit_func->SetParameter(1,1.52);
    //fit_func->SetParameter(2,-0.0041);
    //fit_func->FixParameter(0,0);
    //fit_func->SetParameter(0,1);
    //fit_func->SetParameter(1,-30);
    //fit_func->SetParameter(2,-0.00001);
    //fit_func->FixParameter(2,-0.00425127);
    
    //fit_func->SetParLimits(1,0.0,0.0);
    //fit_func->FixParameter(1,0);
    if(i==1)
    {
      //fit_func->SetParameter(0,1.1);
      //fit_func->SetParameter(1,0.0);
    }
    if(i==2)
    {
      fit_func->SetParameter(0,0.9);
      fit_func->SetParameter(1,0.00001);
    }
    
    if(i==3)
    {
      //fit_func->SetParLimits(1,-0.00015,-0.000095);
      fit_func->SetParameter(0,0.4);
      fit_func->SetParameter(1,0.000001);
    }
    fitres = grRatio->Fit("fit_func","QMRN0FBSE");
    //fitres = grRatio->Fit("fit_func","QMRN0SE");
    sprintf(chi2ndf,"#chi^{2}/ndf = %.4f",(fit_func->GetChisquare())/(fit_func->GetNDF()));
    //errBand->SetPoint(0,0.002*(xval[nbins-1]),fit_func->Eval(0.002*(xval[nbins-1])));
    errBand->SetPoint(0,0,130);
    errBand->SetPointError(0,0,dpol1Func(fit_func,0.002*(xval[nbins-1]),fitres));
    //errBand->SetPointError(0,0,dpol2Func(fit_func,0.002*(xval[nbins-1]),fitres));
    //errBand->SetPointError(0,0,dExpFunc(fit_func,0.002*(xval[nbins-1]),fitres));
    //errBand->SetPointError(0,0,dsqrtFunc(fit_func,0.002*(xval[nbins-1]),fitres));
    //errBand->SetPointError(0,0,dOneoverXFunc(fit_func,0.002*(xval[nbins-1]),fitres));
    //errBand->SetPointError(0,0,dOneoversqrtXFunc(fit_func,0.002*(xval[nbins-1]),fitres));
    //cout <<"0\t" << 0.002*(xval[nbins-1])<<"\t"<<fit_func->Eval(0.002*(xval[nbins-1]))<<"\t"<<dOneoversqrtXFunc(fit_func,0.002*(xval[nbins-1]),fitres)<<endl; 
    errBand->SetPoint(1,130,fit_func->Eval(130));
    //errBand->SetPointError(1,0,dOneoverXFunc(fit_func,130,fitres));
    //errBand->SetPointError(1,0,dOneoversqrtXFunc(fit_func,130,fitres));
    errBand->SetPointError(1,0,dpol1Func(fit_func,130,fitres));
    for(Int_t j=2; j<=nbins; j++) {
      errBand->SetPoint(j,xval[j-1],fit_func->Eval(xval[j-1]));
      //errBand->SetPointError(j,0,dExpFunc(fit_func,xval[j-1],fitres));
      //errBand->SetPointError(j,0,dsqrtFunc(fit_func,xval[j-1],fitres));
      //errBand->SetPointError(j,0,dOneoverXFunc(fit_func,xval[j-1],fitres));
      //errBand->SetPointError(j,0,dOneoversqrtXFunc(fit_func,xval[j-1],fitres));
      errBand->SetPointError(j,0,dpol1Func(fit_func,xval[j-1],fitres));
      //cout <<j<<"\t"<<xval[j-1]<<"\t"<<fit_func->Eval(xval[j-1])<<"\t"<<dOneoversqrtXFunc(fit_func,xval[j-1],fitres)<<endl;
    }
    errBand->SetPoint(nbins+1,1.2*(xval[nbins-1]),fit_func->Eval(1.2*(xval[nbins-1])));
    errBand->SetPointError(nbins+1,0,dpol1Func(fit_func,1.2*(xval[nbins-1]),fitres));
    //errBand->SetPointError(nbins+1,0,dpol2Func(fit_func,1.2*(xval[nbins-1]),fitres));
    //errBand->SetPointError(nbins+1,0,dExpFunc(fit_func,1.2*(xval[nbins-1]),fitres));
    //errBand->SetPointError(nbins+1,0,dsqrtFunc(fit_func,1.2*(xval[nbins-1]),fitres));
    //errBand->SetPointError(nbins+1,0,dOneoverXFunc(fit_func,1.2*(xval[nbins-1]),fitres));
    //errBand->SetPointError(nbins+1,0,dOneoversqrtXFunc(fit_func,1.2*(xval[nbins-1]),fitres));

    sprintf(histName,"Fit_%d_jet",i);
    CPlot plotFunc(histName,"","mWW","POWHEG/Phantom");
    plotFunc.setOutDir(OutDir);
    if(i>6)
    {
      plotFunc.AddGraph(grRatio,"");
      plotFunc.AddGraph(errBand,"3",kAzure-9,kFullDotSmall);
    }
    plotFunc.AddGraph(grRatio,"",kBlack,kFullCircle);
    if(i>6)
      plotFunc.AddFcn(fit_func,kRed);
    
    sprintf(histName,"njet=%d",i);
    if(i==3)
      sprintf(histName,"njet#geq3");
    if(i==4)
      sprintf(histName,"Inclusive jet bins");
    
    plotFunc.AddTextBox(histName,0.68,0.9,0.88,0.86,0,kBlack,-1);
    if(i>6)
    {
      plotFunc.AddTextBox(chi2ndf,0.25,0.9,0.45,0.86,0,kBlack,-1);
      sprintf(fitparam,"a = %.4f #pm %.4f",fit_func->GetParameter(0),fit_func->GetParError(0));
      plotFunc.AddTextBox(fitparam,0.25,0.86,0.45,0.82,0,kBlack,-1);
      sprintf(fitparam,"b = %.6f #pm %.6f",fit_func->GetParameter(1),fit_func->GetParError(1));
      plotFunc.AddTextBox(fitparam,0.25,0.82,0.5,0.78,0,kBlack,-1);
    }
    //sprintf(fitparam,"c = %.8f #pm %.8f",fit_func->GetParameter(2),fit_func->GetParError(2));
    //plotFunc.AddTextBox(fitparam,0.25,0.78,0.45,0.74,0,kBlack,-1);
    if(i==0)
    {
    //  plotFunc.SetYRange(0.5,4.0);
      //plotFunc.AddLine(0,1.52049,1640,1.52049,kBlack,2);
    }
    if(i==1)
    {
      //plotFunc.SetYRange(0.8,1.5);
      //plotFunc.AddLine(0,0.97262,1640,0.97262,kBlack,2);
    }
    if(i==2)
    {
      //plotFunc.SetYRange(0.8,1.2);
      plotFunc.AddLine(0,0.993992,1640,0.993992,kBlack,2);
    }
    if(i==3)
    {
      //plotFunc.SetYRange(0.0,1.3);
      plotFunc.AddLine(0,0.720189,1640,0.720189,kBlack,2);
    }
    
    plotFunc.Draw(c,kTRUE,"png");
  }

}
示例#29
0
void countMuonsPerRunD3PD(){

  //gInterpreter->GenerateDictionary("map<int, double >","map.h;map");
  int cutValue = 11;
  float ptmin = 10.0;
  //float ptmin = 4.;
  //TString fileNameMuonIn = "/afs/cern.ch/user/t/tbalestr/public/16.6.2.5/WorkArea/run/HISingleMuon.root";

///7.3 ub^-1 2010 data
  //TString fileNameMuonIn = "/tmp/tbalestr/HISingleMuon_Aug4_v2.root";
  ///2011 PbPb data
  //TString fileNameMuonIn = "/tmp/tbalestr/HISingleMuon_DPD_HP_merged_26May.root";
  //TString fileNameMuonIn = "/tmp/tbalestr/HISingleMuon_DPD_HP_30May.root";

  TString baseString = "/mnt/Lustre/cgrp/atlas_hi/tbalestri/";
  TString fileNameMuonIn = baseString+"HardProbesFiles/HISingleMuonHardProbesData.04.17.2013.root";  
  TFile* fMuIn = new TFile(fileNameMuonIn, "READ");
  if ( !fMuIn->IsOpen() ) {
    std::cout << fMuIn << " not found!" << std::endl;
  }

  TFile* outFile = new TFile("muonsPerRun.root","recreate");
  
  ///lumi in ub^-1
  std::vector<double> vLumi;
  vLumi.push_back(0.0137422);
  vLumi.push_back(0.126333);
  vLumi.push_back(1.28605451);
  vLumi.push_back(0.08307752);
  vLumi.push_back(3.948807);
  vLumi.push_back(2.766361);
  vLumi.push_back(3.606919);
  vLumi.push_back(3.809249);
  vLumi.push_back(4.11709);
  vLumi.push_back(4.88581);
  vLumi.push_back(2.50513);
  vLumi.push_back(0.0619227);
  vLumi.push_back(0.9694949);
  vLumi.push_back(0.582203);
  vLumi.push_back(5.42834);
  vLumi.push_back(4.20247);
  vLumi.push_back(0.38549);
  vLumi.push_back(5.50425);
  vLumi.push_back(3.15969);
  vLumi.push_back(4.19951);
  vLumi.push_back(5.24396);
  vLumi.push_back(5.30817);
  vLumi.push_back(0.0433861);
  vLumi.push_back(5.29888);
  vLumi.push_back(5.30346);
  vLumi.push_back(0.757212);
  vLumi.push_back(5.985104);
  vLumi.push_back(5.1515);
  vLumi.push_back(6.57761);
  vLumi.push_back(1.75062);
  vLumi.push_back(5.43771);
  vLumi.push_back(3.13928);
  vLumi.push_back(5.14981);
  vLumi.push_back(4.90751);
  vLumi.push_back(2.521785);
  vLumi.push_back(6.45269);
  vLumi.push_back(3.59951);
  vLumi.push_back(5.33795);
  vLumi.push_back(6.16766);
  vLumi.push_back(1.77379);
  vLumi.push_back(0.923454);
  vLumi.push_back(2.07656);

  std::vector<int> vRun;
  vRun.push_back(193211);
  vRun.push_back(193270);
  vRun.push_back(193291);
  vRun.push_back(193295);
  vRun.push_back(193321);
  vRun.push_back(193403);
  vRun.push_back(193412);
  vRun.push_back(193447);
  vRun.push_back(193463);
  vRun.push_back(193481);
  vRun.push_back(193491);
  vRun.push_back(193492);
  vRun.push_back(193493);
  vRun.push_back(193494);
  vRun.push_back(193546);
  vRun.push_back(193558);
  vRun.push_back(193599);
  vRun.push_back(193604);
  vRun.push_back(193641);
  vRun.push_back(193655);
  vRun.push_back(193662);
  vRun.push_back(193679);
  vRun.push_back(193687);
  vRun.push_back(193718);
  vRun.push_back(193795);
  vRun.push_back(193823);
  vRun.push_back(193825);
  vRun.push_back(193826);
  vRun.push_back(193834);
  vRun.push_back(193890);
  vRun.push_back(194017);
  vRun.push_back(194060);
  vRun.push_back(194061);
  vRun.push_back(194121);
  vRun.push_back(194160);
  vRun.push_back(194163);
  vRun.push_back(194179);
  vRun.push_back(194192);
  vRun.push_back(194193);
  vRun.push_back(194370);
  vRun.push_back(194374);
  vRun.push_back(194382);
  const int nRuns = vRun.size(); 

  TGraphErrors* grLumi = new TGraphErrors(nRuns);
  TGraphErrors* grMuPerLumi = new TGraphErrors(nRuns);

  int valNt[30], EF_mu4_MSonly_L1TE50_Matched20[30],EF_mu4_L1VTE50_Matched20[30],runNt, mu_muid_nNt;
  int EF_mu10_MSonly_EFFS_L1ZDC_Matched20[30], EF_mu10_MSonly_EFFS_L1TE10_Matched20[30],EF_mu10_MSonly_EFFS_L1TE20_Matched20[30];
  int EF_mu10_MSonly_EFFS_L1ZDC, EF_mu10_MSonly_EFFS_L1TE10, EF_mu10_MSonly_EFFS_L1TE20, EF_mu4_MSonly_L1TE50, EF_mu4_L1VTE50;
  float ptNt[30], centralityNt,etaNt[30],eLossNt[30],scatNt[30];

  TChain* tree = new TChain("tree","tree");
  std::cout << "Filling the tree for " << fileNameMuonIn << std::endl;
  tree->Add(fileNameMuonIn);
  // --- Set branch adresses ---
  tree->SetBranchAddress("val", &valNt);
  tree->SetBranchAddress("pt", &ptNt);
  tree->SetBranchAddress("eta", &etaNt);
  tree->SetBranchAddress("eLoss",&eLossNt);
  tree->SetBranchAddress("scat",&scatNt);
  tree->SetBranchAddress("mu_muid_n", &mu_muid_nNt);
  tree->SetBranchAddress("run", &runNt);
  tree->SetBranchAddress("centrality", &centralityNt); 
  tree->SetBranchAddress("EF_mu4_MSonly_L1TE50", &EF_mu4_MSonly_L1TE50); 
  tree->SetBranchAddress("EF_mu4_L1VTE50", &EF_mu4_L1VTE50); 
  tree->SetBranchAddress("EF_mu4_MSonly_L1TE50_Matched20", &EF_mu4_MSonly_L1TE50_Matched20); 
  tree->SetBranchAddress("EF_mu4_L1VTE50_Matched20", &EF_mu4_L1VTE50_Matched20); 
  tree->SetBranchAddress("EF_mu10_MSonly_EFFS_L1ZDC", &EF_mu10_MSonly_EFFS_L1ZDC); 
  tree->SetBranchAddress("EF_mu10_MSonly_EFFS_L1TE10", &EF_mu10_MSonly_EFFS_L1TE10); 
  tree->SetBranchAddress("EF_mu10_MSonly_EFFS_L1TE20", &EF_mu10_MSonly_EFFS_L1TE20); 
  tree->SetBranchAddress("EF_mu10_MSonly_EFFS_L1ZDC_Matched20", &EF_mu10_MSonly_EFFS_L1ZDC_Matched20); 
  tree->SetBranchAddress("EF_mu10_MSonly_EFFS_L1TE10_Matched20", &EF_mu10_MSonly_EFFS_L1TE10_Matched20); 
  tree->SetBranchAddress("EF_mu10_MSonly_EFFS_L1TE20_Matched20", &EF_mu10_MSonly_EFFS_L1TE20_Matched20); 

  tree->SetBranchStatus("*",0);
  tree->SetBranchStatus("val", 1);
  tree->SetBranchStatus("pt", 1);
  tree->SetBranchStatus("eta", 1);
  tree->SetBranchStatus("eLoss",1);
  tree->SetBranchStatus("scat",1);
  tree->SetBranchStatus("mu_muid_n", 1);
  tree->SetBranchStatus("run", 1);
  tree->SetBranchStatus("centrality", 1); 
  tree->SetBranchStatus("EF_mu4_MSonly_L1TE50", 1); 
  tree->SetBranchStatus("EF_mu4_L1VTE50", 1); 
  tree->SetBranchStatus("EF_mu4_MSonly_L1TE50_Matched20", 1); 
  tree->SetBranchStatus("EF_mu4_L1VTE50_Matched20", 1); 
  tree->SetBranchStatus("EF_mu10_MSonly_EFFS_L1ZDC", 1); 
  tree->SetBranchStatus("EF_mu10_MSonly_EFFS_L1TE10", 1); 
  tree->SetBranchStatus("EF_mu10_MSonly_EFFS_L1TE20", 1); 
  tree->SetBranchStatus("EF_mu10_MSonly_EFFS_L1ZDC_Matched20", 1); 
  tree->SetBranchStatus("EF_mu10_MSonly_EFFS_L1TE10_Matched20", 1); 
  tree->SetBranchStatus("EF_mu10_MSonly_EFFS_L1TE20_Matched20", 1); 

 std::cout << "Number of entries: " << tree->GetEntries() << std::endl; 
 
 ///map runnumber to #mu
 ///need to used multimap since >1 muon 
 ///value for each run number key
 std::multimap < int, int> runMap;

  ///loop over all events
  for ( int i = 0; i < tree->GetEntries(); ++i ) {
 //   if(i>10000) break;
    tree->LoadTree(i);
    tree->GetEntry(i);

    if(i%10000==0) std::cout << "Event " << i << std::endl;

        for(int imu = 0; imu<mu_muid_nNt; imu++){
            if (
                (valNt[imu]>cutValue) 
                && abs(etaNt[imu])>0.1 
                && abs(etaNt[imu])<2.4 
                && ptNt[imu]>ptmin 
                && centralityNt>=0. 
                && centralityNt<=0.8
                && ( (EF_mu10_MSonly_EFFS_L1ZDC&&EF_mu10_MSonly_EFFS_L1ZDC_Matched20[imu]) ||
                    (EF_mu10_MSonly_EFFS_L1TE10&&EF_mu10_MSonly_EFFS_L1TE10_Matched20[imu])
                    ||(EF_mu10_MSonly_EFFS_L1TE20&&EF_mu10_MSonly_EFFS_L1TE20_Matched20[imu]) )	
		        ){
                ///count number of muons in this run that pass
                runMap.insert(make_pair (runNt,1) );
               }
         } //imu
   } //i
                
   std::cout << std::endl;
   std::cout << "-------------------------  " << std::endl;
   std::cout << " S U M M A R Y " << std::endl;
   std::cout << "-------------------------  " << std::endl;

   TString spreadSheetName = "muonCountingSpreadSheet.csv";
   std::ofstream spreadSheet;
   spreadSheet.open(spreadSheetName);

   double totLumi = 0.0, totalMu = 0;
   for(int iRun = 0; iRun<nRuns; ++iRun){

        int muonsPassed = runMap.count( vRun[iRun] );
        ///Muons per nb^-1
        double muPerLumi = (double)muonsPassed/vLumi[iRun]/1000.0;
        ///Number of muons passed in run iRun
        std::cout << "Index: " << iRun+1 << "\tRun: " << vRun[iRun] << 
            "\tLumi: " << vLumi[iRun]/1000.0 << "\tMuons: " << muonsPassed << "\tMuons/nb^-1: " 
            << muPerLumi << std::endl;

        totLumi += vLumi[iRun]/1000.0;
        totalMu += muonsPassed;

        grMuPerLumi->SetPoint(iRun,vRun[iRun],muPerLumi);
        grMuPerLumi->SetPointError(iRun,0.5, TMath::Sqrt(muonsPassed)/vLumi[iRun]/1000.0);

        grLumi->SetPoint(iRun,totLumi,totalMu);
        grLumi->SetPointError(iRun, 0.0, 0.0);

        writeToSpreadsheet(spreadSheet,iRun+1,vRun[iRun],vLumi[iRun]/1000.,muonsPassed);
   }

   grMuPerLumi->Draw("ape");
   grLumi->Draw("ape");

   outFile->cd();
   grLumi->Write("muonLumiDependence");
   grMuPerLumi->Write("muonPerLumi");

   std::cout << " Total Luminosity: " << totLumi << " nb^-1 " << std::endl;
   std::cout << " Total Muons passed: " << totalMu << std::endl;

   spreadSheet.close();
                
/*
            
  cout << "Number of runs: " << runMap.size() << endl;
  cout << "Run \t" << "Luminosity(ub^-1) \t" << " #muons \t" << "muons/lumi" << endl;
  ///map run lumi to #mu
  //std::map < int, double> lumiMap;
  for (unsigned int j = 0; j<runMap.size(); ++j){
    int runTemp = vRun.at(j);
    double lumiTemp = vLumi.at(j);
    map <int,int>::const_iterator iPairFound = runMap.find(runTemp);
    cout << iPairFound->first << " \t " << lumiTemp << " \t " << " \t " << iPairFound->second << " \t " << " \t " << (double)iPairFound->second/lumiTemp << endl; 
    sum += runMap[runTemp];
  }

  cout << "Total Luminosity = " << totLumi << endl;
  cout << "Total = " << sum << endl;
  */
}
示例#30
0
map<int,vector<double> > RPCChambersCluster::getReconstructedHits(vector<unsigned> vectorOfReferenceChambers, const int & timeWindow,const int & timeReference,bool & isVerticalTrack,map<int,double> & scintilatorsCoordinates,const bool & keepRecoTrack,TFile * fileForRecoTracks,const int & eventNum,const double & correlationFactor, const ESiteFileType & fileType){
  
  // 
  
  map<int,vector<double> > mapOfHits; //
  // the default value for Chi2goodness is 20 
  //double best_chi2goodnes_value = Chi2goodness+10 ; // this variable is used as reference so that it holds the best chi2 found for a track, so its used only a track with better chi2 to be accepted
  double currentBestCorrFact = -2;
  
  int lastFitPoint = 0;
  
  for (int i = 0 ; i < this->getNumberOfChambers() ; i++){
    this->getChamberNumber(i+1)->findAllClustersForTriggerTimeReferenceAndTimeWindow(timeReference,timeWindow,5);
    //cout  << "Chamber is " << i+1 << endl;
  }
  
  vector<vector<int> > vectorOfClusterNumberCombinations;  
  
  if (fileType == kIsCERNrawFile ){
    
    assert(vectorOfReferenceChambers.size() == 3 );
    
    lastFitPoint = 9;
    
    for ( int i = 0 ; i < this->getChamberNumber(vectorOfReferenceChambers[0])->getNumberOfClusters() ; i++ ){
      for( int j = 0 ; j < this->getChamberNumber(vectorOfReferenceChambers[1])->getNumberOfClusters() ; j++ ){
	for( int k = 0 ; k < this->getChamberNumber(vectorOfReferenceChambers[vectorOfReferenceChambers.size()-1])->getNumberOfClusters() ; k++ ){
	  
	  vector<int> singleCombination;
	  
	  singleCombination.push_back(i+1);
	  singleCombination.push_back(j+1);
	  singleCombination.push_back(k+1);
	  
	  for (int f = 0 ; f < singleCombination.size() ; f++){	  
	    if(this->getChamberNumber(vectorOfReferenceChambers[f])->getSizeOfCluster(singleCombination.at(f)) > 5 ) continue;	  
	    // don't insert combination if there is too big cluster. 
	  }
	  
	  vectorOfClusterNumberCombinations.push_back(singleCombination);
	  
	}
      }
    }
  }
  
  if (fileType == kIsBARCrawFile || fileType == kIsGENTrawFile ){
    // add implementation for BARC and Ghent stand . 
    lastFitPoint = 5;
    
    assert(vectorOfReferenceChambers.size() == 2);
    
    for ( int i = 0 ; i < this->getChamberNumber(vectorOfReferenceChambers[0])->getNumberOfClusters() ; i++ ){
      for( int j = 0 ; j < this->getChamberNumber(vectorOfReferenceChambers[1])->getNumberOfClusters() ; j++ ){
      
	vector<int> singleCombination;
	singleCombination.push_back(i+1);
	singleCombination.push_back(j+1);
	
	for (int f = 0 ; f < singleCombination.size() ; f++){
	  if(this->getChamberNumber(vectorOfReferenceChambers[f])->getSizeOfCluster(singleCombination.at(f)) > 5 ) continue;
	  // don't insert combination if there is too big cluster. 
	}
	
	vectorOfClusterNumberCombinations.push_back(singleCombination);
      
      }
    }
  }
  
  string topScintToString, botScintToString;
  
  for (int combinationsVectorElement = 0 ; combinationsVectorElement < vectorOfClusterNumberCombinations.size() ; combinationsVectorElement ++){
    
    // the partition logic start  here - track could pass more than one partition
    
    int direction = 0 ; // direction should describe how the partition changes from one reference chamber to another. It 
    vector<int> RefChamberClusterPartition;
    bool positive = false;
    bool negative = false;
    int partitionPenetrated = 1;
    
    // the Y coordinate is the partition number (1 2 or 3 - A B or C)
    
    vector<int> clusterNum = vectorOfClusterNumberCombinations.at(combinationsVectorElement);
    
    for (int ii = 0; ii < clusterNum.size() ; ii++){
      RefChamberClusterPartition.push_back(this->getChamberNumber(vectorOfReferenceChambers[ii])->getXYCoordinatesOfCluster(clusterNum.at(ii)).at(1));
    }
    
    isVerticalTrack = true;
    
    for ( int ii = 0; ii < RefChamberClusterPartition.size() - 1 ; ii++ ){
      direction = (RefChamberClusterPartition.at(ii) - RefChamberClusterPartition.at(ii+1));
      if (direction != 0) { 
	direction = direction/abs(direction); 
	partitionPenetrated++;
      } // get only the sign ( +1 or -1)
      if (direction && direction == -1)  { positive = true; isVerticalTrack = false; }
      if (direction && direction == 1 )  { negative = true; isVerticalTrack = false; }
    }
    
    if ( positive && negative ) continue;
    // cannot have a track that goes in both direction
    
    /*
    TH1F * histXZ = new TH1F("fitHistogram","XZ plane",110,0,11);
    histXZ->GetYaxis()->SetRangeUser(-20,52);
    histXZ->SetMarkerColor(kBlue);
    histXZ->SetMarkerStyle(kCircle);
    histXZ->GetXaxis()->SetTitle("Shelf number");
    histXZ->GetYaxis()->SetTitle("Channel number");
    */
    
    TF1 * fitfunc = new TF1("FitTrack","[0]+x*[1]",0,lastFitPoint+1);
    
    TGraphErrors * graphXZ = new TGraphErrors();
    graphXZ->GetXaxis()->SetTitle("Shelf number");
    graphXZ->GetYaxis()->SetTitle("Channel number");
    //graphXZ->SetLineColor(0);
    graphXZ->SetMarkerColor(kBlack);
    graphXZ->SetMarkerStyle(kFullCircle);
    graphXZ->SetName("fit graph");
    graphXZ->SetTitle("XZ plane");
    graphXZ->GetXaxis()->SetTitle("Muon station");
    graphXZ->GetYaxis()->SetTitle("Channel number");
    
    fitfunc->SetLineColor(kBlue);        
    
    vector<double> coordinates;
    double xCoordinate = 0;
    int yCoordinate = 0;
    int zCoorinate = 0;
    
    
    for (int ii=0 ; ii < vectorOfReferenceChambers.size() ; ii++){
      
      coordinates = this->getChamberNumber(vectorOfReferenceChambers[ii])->getXYCoordinatesOfCluster(clusterNum[ii]);
      xCoordinate = coordinates.at(0);
      yCoordinate = coordinates.at(1);
      zCoorinate = 10*vectorOfReferenceChambers[ii];
      Double_t errorValue = this->getChamberNumber(vectorOfReferenceChambers[ii])->getSizeOfCluster(clusterNum[ii]);
//       histXZ->SetBinContent(zCoorinate,xCoordinate);  
//       histXZ->SetBinError(zCoorinate,errorValue/2);
      //cout << xCoordinate << " " << yCoordinate << endl;
      graphXZ->SetPoint(ii,vectorOfReferenceChambers[ii],xCoordinate);
      graphXZ->SetPointError(ii,0,errorValue/2);
    }
    
    Double_t params[2];
    graphXZ->Fit(fitfunc,"RFQ");
    fitfunc->GetParameters(params);
    
    //cout << "par1 " << params[0] << " par2 " << params[1] << " chi2 " << fitfunc->GetChisquare() << endl;
    // The resudials - difference between estimated fit value and the middle of the nearest cluster
    
    int prevReference = 0 , nextReference = 0 , prevReferencePartition = 0 , nextReferencePartition = 0; 
    bool currentChamberIsReference = false;
    int startCounter = 0, endCounter = 0;
    
    if ( abs(graphXZ->GetCorrelationFactor()) >= correlationFactor && abs(graphXZ->GetCorrelationFactor()) > currentBestCorrFact ) {
      // in case of only one partition, get the partition number of the first reference point
      currentBestCorrFact = abs(graphXZ->GetCorrelationFactor());
      
      int referenceChambersIncrementor = 0;
      bool negativeChannelNumberIsFound = false;
      
      // ---------
            
      for ( int currentChNumber = 0 ; currentChNumber < this->getNumberOfChambers() ; currentChNumber++ ) {
	// check where the chamber is according to the reference chambers
	vector<double> vectorOfpartitionsAndHit;
	double channelNum = fitfunc->Eval(currentChNumber+1);

	/** four cases 1. the chamber is before the first reference 2. the chamber is after the last reference 3. the chamber is between two references 4. the chamber is a reference */
	
	for(int refCheck = 0 ; refCheck < vectorOfReferenceChambers.size(); refCheck++){
	  // find the surounding references
	  if (currentChNumber+1 == vectorOfReferenceChambers.at(refCheck)){
	    currentChamberIsReference = true;
	    break;
	  }
	  if ( vectorOfReferenceChambers.at(refCheck) > currentChNumber+1 && refCheck == 0 ){
	    // its before the first reference chamber
	    nextReference = vectorOfReferenceChambers.at(refCheck);
	    nextReferencePartition = this->getChamberNumber(nextReference)->getXYCoordinatesOfCluster(clusterNum[refCheck]).at(1);
	    break;
	    
	  }
	  
	  if ( vectorOfReferenceChambers.at(refCheck) < currentChNumber+1 && refCheck == vectorOfReferenceChambers.size() - 1 ){
	    // its after the last chamber
	    prevReference = vectorOfReferenceChambers.at(refCheck);
	    prevReferencePartition = this->getChamberNumber(prevReference)->getXYCoordinatesOfCluster(clusterNum[refCheck]).at(1);
	    break;    
	  }
	  if ( vectorOfReferenceChambers.at(refCheck) < currentChNumber+1 && vectorOfReferenceChambers.at(refCheck+1) > currentChNumber+1 ){
	    // its between two references
	    prevReference = vectorOfReferenceChambers.at(refCheck) ;
	    nextReference = vectorOfReferenceChambers.at(refCheck+1);
	    prevReferencePartition = this->getChamberNumber(prevReference)->getXYCoordinatesOfCluster(clusterNum[refCheck]).at(1);
	    nextReferencePartition = this->getChamberNumber(nextReference)->getXYCoordinatesOfCluster(clusterNum[refCheck+1]).at(1);
	    break;    
	  }
	}
	
	// end of partition possibilities
	
	if(!currentChamberIsReference){
	  
	  if (nextReference && prevReference == 0){
	    if (positive){
	      prevReferencePartition = 1;      
	    }
	    if(negative){
	      prevReferencePartition = this->getChamberNumber(1)->getClones();      
	    }    
	  }
	  
	  if (prevReferencePartition && nextReferencePartition == 0){
	    if (positive){
	      nextReferencePartition = this->getChamberNumber(1)->getClones();      
	    }
	    if(negative){
	      nextReferencePartition = 1;      
	    }    
	  }
	  
	  if (partitionPenetrated == 1 ){
	    prevReferencePartition = yCoordinate;
	    nextReferencePartition = yCoordinate;    
	    
	    int firstRef = vectorOfReferenceChambers.at(0);
	    int lastRef = vectorOfReferenceChambers.at(vectorOfReferenceChambers.size() - 1);
	    int ccham =  currentChNumber+1;
	    
	    if(! (lastRef > ccham && firstRef < ccham) ){
	      // all partitions are possible, chambers are out of the reference scope
	      prevReferencePartition = this->getChamberNumber(1)->getClones(); 
	      nextReferencePartition = 1; // 3 in case of ecap chamber      
	    }
	  }
	  
	  if (positive){ startCounter = prevReferencePartition; endCounter = nextReferencePartition; }
	  else { startCounter = nextReferencePartition ; endCounter = prevReferencePartition ; }
	  
	  for (int currentCounter = startCounter ; currentCounter <= endCounter; currentCounter ++ ){
	    assert(currentCounter > 0 && currentCounter < 4);
	    vectorOfpartitionsAndHit.push_back(currentCounter);    
	  }
	}
	
	else{
	  vectorOfpartitionsAndHit.push_back(this->getChamberNumber(currentChNumber+1)->getXYCoordinatesOfCluster(clusterNum[referenceChambersIncrementor]).at(1));
	  referenceChambersIncrementor ++;
	}
	
	prevReference = 0 ; nextReference = 0 ; prevReferencePartition = 0 ; nextReferencePartition = 0; currentChamberIsReference = false;
	//cout << "Chamber " << l+1 << " " <<  coordinates.at(1) << " " << fitfunc->Eval(l+1) << " " << endl;
	
	int channelNumberToStore = channelNum;
	if (channelNumberToStore < 96/this->getChamberNumber(1)->getClones()){
	  channelNumberToStore += 1;
	} // add one to represent the fired channel, or none if the channel is on the right border
	
	vectorOfpartitionsAndHit.push_back(channelNumberToStore); // the last element is the number of the channel
	
	// Debug lines
	/**
	cout << "Chamber is " << currentChNumber+1 << " partitions " ;
	for (int thesize = 0 ; thesize < vectorOfpartitionsAndHit.size() - 1; thesize++){
	  cout << vectorOfpartitionsAndHit.at(thesize) << " " ;
	}
	
	cout << "channel " << vectorOfpartitionsAndHit.at(vectorOfpartitionsAndHit.size()-1) << endl;
	*/
	
	mapOfHits[currentChNumber+1] = vectorOfpartitionsAndHit;
	
      }      
      
      // ---------- scintilators coordinates estimate
      
      for (int scintNum = 0 ; scintNum < 31 ; scintNum++){
	if(this->getTriggerObjectNumber(1)->getChannel(scintNum+1)->hasHit() && vectorOfClusterNumberCombinations.size() == 1 ) {
	  if (scintNum < 10) { scintilatorsCoordinates[scintNum+1] = graphXZ->Eval(0); topScintToString = boost::lexical_cast<string>(scintNum+1); }
	  else { scintilatorsCoordinates[scintNum+1] = graphXZ->Eval(lastFitPoint+1); botScintToString = boost::lexical_cast<string>(scintNum+1); }
	}
      }      
    }
    
    // get only vertical tracks from the A partition if there are only two scint hits
    if (keepRecoTrack && isVerticalTrack && !mapOfHits.empty() && scintilatorsCoordinates.size() == 2){
      
      graphXZ->SetName(boost::lexical_cast<string>(eventNum).c_str());
      string partition;
      if (mapOfHits.find(vectorOfReferenceChambers.at(0))->second.at(0) == 1) partition = "A";
      else if (mapOfHits.find(vectorOfReferenceChambers.at(0))->second.at(0) == 2) partition = "B";
      else partition = "C";
      
      graphXZ->SetTitle(("Correlation factor is "+boost::lexical_cast<string>(graphXZ->GetCorrelationFactor()) + " trigger channels top: " + topScintToString + " bottom: " + botScintToString ).c_str());
      if(abs(graphXZ->GetCorrelationFactor()) >= correlationFactor) {
	
	string scintCombination="_"+topScintToString+"_"+botScintToString+"_"+partition;
	TDirectory * dir = fileForRecoTracks->GetDirectory(scintCombination.c_str(),true);
	
	if(!dir) {  
	  //fileForRecoTracks->ls();
	  fileForRecoTracks->mkdir(scintCombination.c_str()) ;
	  fileForRecoTracks->cd("");
	} 
	
	fileForRecoTracks->cd(scintCombination.c_str());
	//cout << fileForRecoTracks->GetPath() << endl;
      }
      else{ fileForRecoTracks->cd("") ; fileForRecoTracks->cd("badTracks") ; }
      
      graphXZ->Write(graphXZ->GetName(),TObject::kOverwrite);
      fileForRecoTracks->cd("");
      //fileForRecoTracks->Write(graphXZ->GetName(),TObject::kOverwrite);
    }
    
    fitfunc->Delete();
    //histXZ->Delete();
    graphXZ->Delete();
    
  }  
  
  return mapOfHits;
}