Пример #1
0
void makeHistograms() {

  gROOT->Reset();
  gROOT->LoadMacro("CreateHistograms_C.so");

  TString input_ele = "/eos/uscms/store/user/bfrancis/inputs_zgamma/SingleElectron.root";
  TString input_muon = "/eos/uscms/store/user/bfrancis/inputs_zgamma/SingleMu.root";

  TString metType = "pfMET_t01";
  bool useNormalTopReweighting = true;

  bool useWhizard = false; // false = use madgraph

  double metCut = -1.;

  int controlRegion = PHOTON_REGION;
  int photonMode = PHOTON_MODE;

  if(controlRegion == kSigmaPlot) metCut = 50.;

  bool blinded = false;

  const int nChannels = 4;
  TString channels[nChannels] = {"ele_bjj", "muon_bjj",
				 "ele_jjj", "muon_jjj"};

  for(int i = 0; i < nChannels; i++) {
    if(channels[i].Contains("ele")) CreateHistograms(input_ele, i, metCut, blinded, controlRegion, photonMode, metType, useNormalTopReweighting, useWhizard);
    else CreateHistograms(input_muon, i, metCut, blinded, controlRegion, photonMode, metType, useNormalTopReweighting, useWhizard);
  }  

}
Пример #2
0
void plotSpectrum() {
  CreateHistograms();
  char* append = "";

  // ****** get the weight value for each pthat bin ******* //
  for(int i=0; i<nGenPtBins; i++) {
    // for(int i=5; i<6; i++) {
    if(i!=0) append = "+";
    DrawTreeForAllHistos( i, append );
  }


  ///////////////////////////////////////

  nJetsCalo->SetBinContent( 1, Zmass->Integral() ); 
  nJetsCalo->SetBinError( 1, sqrt(Zmass->Integral()) );
  nJetsPF->SetBinContent( 1, Zmass->Integral());
  nJetsPF->SetBinError( 1, sqrt(Zmass->Integral()) );
  nJetsGen->SetBinContent( 1, Zmass->Integral());
  nJetsGen->SetBinError( 1, sqrt(Zmass->Integral()) );

  nJetsCalo->SetBinContent( 2, CaloJetPt->Integral() ); 
  nJetsCalo->SetBinError( 2, sqrt(CaloJetPt->Integral()) );
  nJetsPF->SetBinContent( 2, PFJetPt->Integral());
  nJetsPF->SetBinError( 2, sqrt(PFJetPt->Integral()) );
  nJetsGen->SetBinContent( 2, GenJetPt->Integral());
  nJetsGen->SetBinError( 2, sqrt(GenJetPt->Integral()) );

  nJetsCalo->SetBinContent( 3, CaloJetPt2->Integral()); 
  nJetsCalo->SetBinError( 3, sqrt(CaloJetPt2->Integral()) );
  nJetsPF->SetBinContent( 3, PFJetPt2->Integral());
  nJetsPF->SetBinError( 3, sqrt(PFJetPt2->Integral()) );
  nJetsGen->SetBinContent( 3, GenJetPt2->Integral());
  nJetsGen->SetBinError( 3, sqrt(GenJetPt2->Integral()) );

  nJetsCalo->SetBinContent( 4, CaloJetPt3->Integral()); 
  nJetsCalo->SetBinError( 4, sqrt(CaloJetPt3->Integral()) );
  nJetsPF->SetBinContent( 4, PFJetPt3->Integral());
  nJetsPF->SetBinError( 4, sqrt(PFJetPt3->Integral()) );
  nJetsGen->SetBinContent( 4, GenJetPt3->Integral());
  nJetsGen->SetBinError( 4, sqrt(GenJetPt3->Integral()) );


  /////////////////////////////////////
  ZPt_Gen->Sumw2();
  ZPt_Reco->Sumw2();
  GenJetPt->Sumw2();
  CaloJetPt->Sumw2();
  PFJetPt->Sumw2();

  emPt_Gen->Sumw2();
  emPt_Reco->Sumw2();
  epPt_Gen->Sumw2();
  epPt_Reco->Sumw2();
  Zmass->Sumw2();
  ZEta_Gen->Sumw2();
  ZEta_Reco->Sumw2();
  GenJetEta->Sumw2();
  CaloJetEta->Sumw2();
  PFJetEta->Sumw2();

  GenJetPt2->Sumw2();
  CaloJetPt2->Sumw2();
  PFJetPt2->Sumw2();

  GenJetPt3->Sumw2();
  CaloJetPt3->Sumw2();
  PFJetPt3->Sumw2();


  // set proper style for plots
  gROOT->ProcessLine(".L mystyle.C");
  setTDRStyle();
  tdrStyle->SetErrorX(0.5);
  tdrStyle->SetPadLeftMargin(0.18);
  tdrStyle->SetPadRightMargin(0.10);
  tdrStyle->SetPadBottomMargin(0.16);
  tdrStyle->SetLegendBorderSize(0);
  tdrStyle->SetTitleYOffset(1.5);

  makeplotTwo(*ZPt_Reco, *ZPt_Gen, "ZPt_spectrum", 1);
  // makeplotTwo( *emPt_Reco, *emPt_Gen, "emPt_spectrum", 0);
  // makeplotTwo( *epPt_Reco, *epPt_Gen, "epPt_spectrum", 0);
  // makeplotTwo(*ZEta_Reco, *ZEta_Gen, "Z_eta_spectrum", 2);

  makeplotThree(*CaloJetPt, *GenJetPt, *PFJetPt, "Jet_spectrum", 1);
  makeplotThree(*CaloJetPt2, *GenJetPt2, *PFJetPt2, "Jet_spectrum2", 1);
  makeplotThree(*CaloJetPt3, *GenJetPt3, *PFJetPt3, "Jet_spectrum3", 1);

  makeplotThree(*CaloJetEta, *GenJetEta, *PFJetEta, "Jet_eta_spectrum", 2);
  //makeplot( *Zmass, "Zmass", "e", 0);



  //make ratio histograms
  CaloJetPtRatio2over1 = makeRatioHist( *CaloJetPt, *CaloJetPt2, "CaloJetPtRatio2over1",150);
  CaloJetPtRatio3over2 = makeRatioHist( *CaloJetPt2, *CaloJetPt3, "CaloJetPtRatio2over1",100);
  PFJetPtRatio2over1 = makeRatioHist( *PFJetPt, *PFJetPt2, "PFJetPtRatio2over1",150);
  PFJetPtRatio3over2 = makeRatioHist( *PFJetPt2, *PFJetPt3, "PFJetPtRatio3over2",100);
  GenJetPtRatio2over1 = makeRatioHist( *GenJetPt, *GenJetPt2, "GenJetPtRatio2over1",150);
  GenJetPtRatio3over2 = makeRatioHist( *GenJetPt2, *GenJetPt3, "GenJetPtRatio3over2",100);
  CaloJetPtRatio2over1->GetYaxis()->SetTitle("n^{Jet}_{#geq 2} / n^{Jet}_{#geq 1}");
  CaloJetPtRatio3over2->GetYaxis()->SetTitle("n^{Jet}_{#geq 3} / n^{Jet}_{#geq 2}");

  makeplotThree(*CaloJetPtRatio2over1, *GenJetPtRatio2over1, *PFJetPtRatio2over1, "JetPtRatio2over1", 0);
  makeplotThree(*CaloJetPtRatio3over2, *GenJetPtRatio3over2, *PFJetPtRatio3over2, "JetPtRatio3over2", 0);
  makeplotThree( *nJetsCalo, *nJetsGen, *nJetsPF, "JetMultiplicity", 1);

  //////////////////////////////////////
  //tdrStyle->SetPadLeftMargin(0.22);
  TFile outfile( (std::string("histograms_")+cmEnergy+".root").c_str(), "RECREATE"  );
  outfile.cd();
  ZPt_Gen->Write();
  ZPt_Reco->Write();
  GenJetPt->Write();
  CaloJetPt->Write();
  PFJetPt->Write();
  emPt_Gen->Write();
  emPt_Reco->Write();
  epPt_Gen->Write();
  epPt_Reco->Write();
  Zmass->Write();

  ZEta_Gen->Write();
  ZEta_Reco->Write();
  GenJetEta->Write();
  CaloJetEta->Write();
  PFJetEta->Write();

  GenJetPt2->Write();
  CaloJetPt2->Write();
  PFJetPt2->Write();

  GenJetPt3->Write();
  CaloJetPt3->Write();
  PFJetPt3->Write();

  nJetsCalo->Write();
  nJetsPF->Write();
  nJetsGen->Write();

  CaloJetPtRatio2over1->Write();
  CaloJetPtRatio3over2->Write();
  PFJetPtRatio2over1->Write();
  PFJetPtRatio3over2->Write();
  GenJetPtRatio2over1->Write();
  GenJetPtRatio3over2->Write();

  outfile.Close();
}
Пример #3
0
bool PdfTransfer::NDPdfTransfer(float *input, float *palette, float **rotations) {
	clock_t start, end;
	FILE *fp = fopen("time.txt", "w");
	unsigned long int var_time = 0;

	float *finalPic = new float[_projections * _inputSize];

	for (unsigned int i = 0; i < _iterations; ++i) {
		start = clock();
		float * ptrRotation = rotations[i];
		assert(ptrRotation);

		float *inputRotation = new float[_projections * _inputSize];
		float *paletteRotation = new float[_projections * _paletteSize];

		_matrixModule->matrix_multiply(ptrRotation, _projections, NUM_CHANNELS,
			input, NUM_CHANNELS, _inputSize, inputRotation, _projections, _inputSize);
#ifdef DEBUG
		if (!i) {
			printMatrix(ptrRotation, _projections, NUM_CHANNELS, "ptrRotation", _height, _width);
			printMatrix(input, NUM_CHANNELS, _inputSize, "input", _height, _width);
			printMatrix(inputRotation, _projections, _inputSize, "inputRotation", _height, _width);
		}
#endif
		_matrixModule->matrix_multiply(ptrRotation, _projections, NUM_CHANNELS,
			palette, NUM_CHANNELS, _paletteSize, paletteRotation, _projections, _paletteSize);

#ifdef DEBUG
		if (!i) {
			printMatrix(palette, NUM_CHANNELS, _paletteSize, "palette", _height, _width);
			printMatrix(paletteRotation, _projections, _paletteSize, "paletteRotation", _height, _width);
		}
#endif

		Histogram ** histogramsInput = new Histogram*[_projections];
		Histogram ** histogramsPalette = new Histogram*[_projections];

		//Step1: Creation of Histograms
		CreateHistograms(inputRotation, _inputSize,
			paletteRotation, _paletteSize, _projections, histogramsInput, histogramsPalette);


#ifdef DEBUG
		printHistogr(histogramsInput, i);
#endif

		std::vector<float> *inter = new std::vector<float>[_projections];
		for (unsigned int j = 0; j < _projections; ++j) {
			std::vector<float> ptr = SinglePdfTransfer(histogramsInput[j], histogramsPalette[j]);

			std::vector<float> newPtr(ptr.begin() + 1, ptr.end() - 1);
			float scale = bin_count / (histogramsInput[j]->GetOverallMax() -
				histogramsInput[j]->GetOverallMin());

			//populate X points before interpolation
			std::vector<float> X(newPtr.size());
			for (unsigned int k = 0; k < X.size(); ++k) {
				X[k] = (float) k;
			}
			std::vector<float> Xq(_inputSize);
			unsigned int itr = 0;
			for (unsigned k = j * _inputSize; k < (j + 1) * _inputSize; ++k, ++itr) {
				Xq[itr] = inputRotation[k];
				Xq[itr] = (Xq[itr] - histogramsInput[j]->GetOverallMin()) * scale;
			}


			inter[j] = linearInterpolation(X, newPtr, Xq);

			for (unsigned int k = 0; k < inter[j].size(); ++k) {
				inter[j][k] = inter[j][k] / scale + histogramsInput[j]->GetOverallMin();
				inter[j][k] -= matrix_access(inputRotation, _projections, _inputSize, j, k);
				matrix_access(finalPic, _projections, _inputSize, j, k) = inter[j][k];

			}
		}

#ifdef DEBUG
		char filename2[10];
		sprintf(filename2, "finalPic%d", i);
		printMatrix(finalPic, _projections, _inputSize, filename2, _height, _width);

#endif
		//resolve linear system of ptrRotation*x = inter
		_matrixModule->matrix_inverse(ptrRotation, _projections, NUM_CHANNELS);
		float *aux = new float[ _projections * _inputSize ];
		_matrixModule->matrix_multiply(ptrRotation, _projections, NUM_CHANNELS,
			finalPic, _projections, _inputSize,
			aux, _projections, _inputSize);
		_matrixModule->matrix_add(input, aux, input, _projections, _inputSize);


#ifdef DEBUG
		//if(!i)
		//{
		char filename[10];
		sprintf(filename, "iter%d", i);
		printMatrix(input, _projections, _inputSize, filename, _height, _width);
		//}
#endif

		end = clock();
		var_time = (end - start) / (CLOCKS_PER_SEC);
		fprintf(fp, "It took %lu seconds to complete %d iteration\n", var_time, i);

		//freeing memory
		delete [] inputRotation;
		delete [] paletteRotation;

	}

	//freeing heap
	delete [] finalPic;

	//used for logging time
	fclose(fp);
	return true;
}