> For the complete documentation index, see [llms.txt](https://friederikebock.gitbook.io/pcgtutorial/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://friederikebock.gitbook.io/pcgtutorial/neutral-meson-and-direct-photon-analysis-afterburners/functions.md).

# Useful functions

In this chapter a brief overview of the most useful functions in the framework is presented. These functions are used very often by the convenors of this tutorial and are always recommended to be used.

## Plotting

1. The **basic plotting style** can be set in your macro via the following two lines. They take care of canvas colors, font styles, etc... and should generally always be used when plotting is intended in the macro.

   ```
    StyleSettingsThesis();
    SetPlotStyle();
   ```
2. Basic string functions:

   ```
    TString dateForOutput   = ReturnDateStringForOutput(); //date in format: YYYY_MM_DD
    TString collisionSystem = ReturnFullCollisionsSystem(energy); //i.e. "pp, #sqrt{s} = 7 TeV"
   ```
3. Basic **marker, color and size** settings for **different reconstruction methods** with `nameDet` being a string containing either one of: `"PCM", "PHOS", "EMCal", "PCM-PHOS", "PCM-EMCal", "PCM-Dalitz", "PHOS-Dalitz", "EMCal-Dalitz", "EMCal high pT", "EMCal merged", "PCMOtherDataset"`. **These colors should ALWAYS be used if the focus of a plot is to show multiple reconstruction methods!** These styles have been used in all recent publications where our group was involved.

   ```
    Color_t  colorDet = GetDefaultColorDiffDetectors(nameDet.Data(), kFALSE, kFALSE, kTRUE);
    Style_t  markerStyleDet = GetDefaultMarkerStyleDiffDetectors(nameDet.Data(), kFALSE);
    Size_t   markerSizeDet = GetDefaultMarkerSizeDiffDetectors(nameDet.Data(), kFALSE);
   ```
4. Basic **marker, color and size** settings for **different center of mass energies** with a string containing the energy setting, i.e. "900GeV" or "8TeV". **These colors should ALWAYS be used if the focus of a plot is to show multiple center of mass energy measurements of the same method together!** These styles have been used in all recent publications where our group was involved.

   ```
    Color_t colorEnergy       = GetColorDefaultColor("8TeV", "", "");
    Style_t markerStyleEnergy = GetDefaultMarkerStyle("8TeV", "", "");
    Size_t markerSizeEnergy   = GetDefaultMarkerSize("8TeV", "", "");
   ```
5. Set plotting styles for graphs, histograms, TF1:

   ```
    DrawGammaSetMarkerTGraphAsym(dummgyTGrAsym , 2, styleLineJETPHOX, colorJETPHOX, colorJETPHOX, widthLinesBoxes, kTRUE, colorJETPHOX,kTRUE);
   ```
6. Canvas setup:

   ```
    TCanvas* canvas = new TCanvas("canvas","",200,10,1350,900);  // gives the page size
    DrawGammaCanvasSettings( canvas, 0.08, 0.01, 0.01, 0.09); // sets margins (left, right, top, bottom)
   ```

   usually one directly sets the textsize in pixels for other plotting functions by using the canvas vertical pixel count (here 900) with:

   ```
    Int_t textSizeLabelsPixel = 900*0.04;
   ```
7. Make and format legends quickly:

   ```
    TLegend* legendExample   = GetAndSetLegend2(0.12, 0.14, 0.45, 0.14+(0.04*expectedLinesInLegend), textSizeLabelsPixel, 2, "", 43, 0);
    legendExample->AddEntry(dummgyTGrAsym,"legend text","p"); // last argument: p (point), l (line), f (fill), e (error), combinations possible, ie "pf", "lep", ...
    legendExample->Draw();
   ```

## Calculation

## Useful code

1. Cutting TGraphs to a certain x-range with while loop:

   ```
   // remove points below 1.5 GeV/c
   while(exampleGraph->GetX()[0] < 1.5)
      exampleGraph->RemovePoint(0);

   // remove points above 20 GeV/c
   while(exampleGraph->GetX()[exampleGraph->GetN()-1] > 20)
      exampleGraph->RemovePoint(exampleGraph->GetN()-1);
   ```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://friederikebock.gitbook.io/pcgtutorial/neutral-meson-and-direct-photon-analysis-afterburners/functions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
