{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", " \n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

Searching for the Higgs boson in the H→γγ channel

\n", "\n", "## C++ notebook example" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Introduction**\n", "Let's take a current ATLAS Open Data sample and create a histogram:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In order to activate the interactive visualisation of the histogram that is later created we can use the JSROOT magic:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%jsroot on" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We need to include some standard C++ and ROOT libraries" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "// Creates a TChain to be used by the Analysis.C class\n", "#include \n", "#include \n", "#include \n", "#include \n", "#include \n", "#include " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Because we would like to use more than one ROOT input file, the best option is to use a TChain object. This allows to \"chain\" several samples into a single structure that we can later loop over" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(TString &) \"https://atlas-opendata.web.cern.ch/atlas-opendata/samples/2020/GamGam/\"[70]\n" ] } ], "source": [ "TString path = \"https://atlas-opendata.web.cern.ch/atlas-opendata/samples/2020/GamGam/\"" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "TChain* fChain = new TChain(\"mini\");\n", "\n", "fChain->AddFile(path+\"Data/data_A.GamGam.root\");\n", "fChain->AddFile(path+\"Data/data_B.GamGam.root\");\n", "fChain->AddFile(path+\"Data/data_C.GamGam.root\");\n", "fChain->AddFile(path+\"Data/data_D.GamGam.root\");" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now we're going to extract the photons variables" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "UInt_t Photon_n = -1; //number of preselected photons\n", "\n", "vector *Photon_pt; //transverse momentum of the photon\n", "vector *Photon_eta = 0; //pseudorapidity of the photon\n", "vector *Photon_phi = 0; //azimuthal angle of the photon\n", "vector *Photon_E = 0; //energy of the photon\n", "vector *Photon_isTightID = 0;\n", "\n", "Bool_t TrigP = 0;\n", "vector *Photon_ptcone30 = 0;\n", "vector *Photon_etcone20 = 0;" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here we're filling the variables defined above with the content of those inside the input ntuples" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "fChain->SetBranchAddress(\"photon_pt\", &Photon_pt); \n", "fChain->SetBranchAddress(\"photon_n\", &Photon_n); \n", "\n", "fChain->SetBranchAddress(\"photon_eta\", &Photon_eta);\n", "fChain->SetBranchAddress(\"photon_phi\", &Photon_phi);\n", "fChain->SetBranchAddress(\"photon_E\", &Photon_E);\n", "fChain->SetBranchAddress(\"photon_isTightID\", &Photon_isTightID);\n", "\n", "fChain->SetBranchAddress(\"trigP\", &TrigP);\n", "fChain->SetBranchAddress(\"photon_ptcone30\", &Photon_ptcone30);\n", "fChain->SetBranchAddress(\"photon_etcone20\", &Photon_etcone20);" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We're creating a histogram for this example. The plan in to fill them with events." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "//Invariant mass histograms definition\n", "TH1F *h_M_Hyy = new TH1F(\"h_M_Hyy\",\"Diphoton invariant-mass ; M_{#gamma#gamma} [GeV] ; Events / bin\", 30, 105, 160);" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We are selecting below a simple look for them." ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "h_M_Hyy->SetMarkerSize(2.0);\n", "h_M_Hyy->SetLineColor(kBlue);\n", "h_M_Hyy->SetFillColor(kBlue-10);" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The Higgs boson analysis implemented here considers Higgs boson decays into a photon pair. The event selection criteria are:" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "* Total number of entries to analyse: 7798424\n", "* Analysed a total of: 7798424 in this sample.\n" ] } ], "source": [ "int nentries, nbytes, i;\n", "nentries = (Int_t)fChain->GetEntries();\n", "\n", "std::cout << \"* Total number of entries to analyse: \" << nentries << std::endl;\n", "\n", "// Preselection of good photons\n", "\n", "for (i=0; i < nentries; i++)\n", "{\n", " nbytes = fChain->GetEntry(i);\n", " \n", " //# Cut: Diphoton trigger is satisfied\n", " if(TrigP)\n", " {\n", " int goodphoton_index[5]; // give the vector a size good enough to avoid segmentation faults due to events with more than 2 photons.\n", " int goodphoton_n = 0; // the total number of good photon\n", " int photon_index = 0;\n", " \n", " for(unsigned int j=0; jat(j))\n", " {\n", " //# Cut: two photons with 25 GeV and excluding the transition region between the barrel and endcap calorimeters\n", " if(Photon_pt->at(j) >25000. && TMath::Abs(Photon_eta->at(j))<2.37 && \n", " (TMath::Abs(Photon_eta->at(j)) < 1.37 || TMath::Abs(Photon_eta->at(j)) > 1.52))\n", " {\n", " goodphoton_n = goodphoton_n + 1; // count\n", " goodphoton_index[photon_index] = j;\n", " photon_index++;\n", " }\n", " }\n", " }\n", "\n", " //# Cut: Exactly two photons \n", " if(goodphoton_n==2)\n", " {\n", " int goodphoton1_index = goodphoton_index[0];\n", " int goodphoton2_index = goodphoton_index[1];\n", " // isolated photons\n", " if(((Photon_ptcone30->at(goodphoton1_index)/Photon_pt->at(goodphoton1_index)) < 0.065) && ((Photon_etcone20->at(goodphoton1_index) / Photon_pt->at(goodphoton1_index)) < 0.065 ))\n", " {\n", " if(((Photon_ptcone30->at(goodphoton2_index)/Photon_pt->at(goodphoton2_index)) < 0.065) && ((Photon_etcone20->at(goodphoton2_index) / Photon_pt->at(goodphoton2_index)) < 0.065 ))\n", " {\n", " // TLorentzVector definitions\n", " TLorentzVector Photon_1 = TLorentzVector();\n", " TLorentzVector Photon_2 = TLorentzVector();\n", " \n", " Photon_1.SetPtEtaPhiE(Photon_pt->at(goodphoton1_index), Photon_eta->at(goodphoton1_index), Photon_phi->at(goodphoton1_index),Photon_E->at(goodphoton1_index));\n", " Photon_2.SetPtEtaPhiE(Photon_pt->at(goodphoton2_index), Photon_eta->at(goodphoton2_index), Photon_phi->at(goodphoton2_index),Photon_E->at(goodphoton2_index));\n", " \n", " float dPhi_yy = fabs(Photon_phi->at(goodphoton1_index) - Photon_phi->at(goodphoton2_index));\n", " dPhi_yy = dPhi_yy < TMath::Pi() ? dPhi_yy : 2*TMath::Pi() - dPhi_yy;\n", " float m_yy = sqrt( 2 * Photon_1.Pt() * Photon_2.Pt() * \n", " (cosh( Photon_1.Eta() - Photon_2.Eta()) - cos(dPhi_yy)));\n", " \n", " //Calculation of the Invariant Mass using TLorentz vectors\n", " TLorentzVector Photon_12 = Photon_1 + Photon_2;\n", " float mass_inv_GeV = Photon_12.M()/1000.;\n", " \n", " h_M_Hyy->Fill(mass_inv_GeV);\n", " }\n", " }\n", " }\n", " } // end TrigPhoton request\n", "}\n", "\n", "std::cout << \"* Analysed a total of: \" << nentries << \" in this sample.\" << std::endl;" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Final plot" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "
\n", "\n", "\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "TCanvas *cz = new TCanvas(\"cz\",\"cz\",10,10,900,600);\n", "TText tz; tz.SetTextFont(42); tz.SetTextAlign(21);\n", "h_M_Hyy->Draw();\n", "cz->Draw();" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Log Scale" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "
\n", "\n", "\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "h_M_Hyy->Draw(\"E3\");\n", "cz->SetLogy();\n", "cz->Draw();" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Done!**" ] } ], "metadata": { "kernelspec": { "display_name": "ROOT C++", "language": "c++", "name": "root" }, "language_info": { "codemirror_mode": "text/x-c++src", "file_extension": ".C", "mimetype": " text/x-c++src", "name": "c++" } }, "nbformat": 4, "nbformat_minor": 1 }