Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-06-01 07:07:15

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2023 Christopher Dilks
0003 
0004 R__LOAD_LIBRARY(EpicAnalysis)
0005 
0006 /* run in a grid of (x,Q2) 2D bins
0007  * - various ways to make a grid are demonstrated
0008  * - observe how the resulting histograms differ in each (x,Q2) bin
0009  */
0010 void analysis_xqbins(
0011     TString configFile="tutorial/delphes.config", // input config file
0012     TString outfilePrefix="tutorial.xqbins"       // output filename prefix
0013 ) {
0014 
0015   // setup analysis ========================================
0016   AnalysisDelphes *A = new AnalysisDelphes(configFile, outfilePrefix);
0017 
0018   //A->maxEvents = 30000; // use this to limit the number of events
0019   A->SetReconMethod("Ele"); // set reconstruction method
0020   A->AddFinalState("pipTrack"); // pion final state
0021   //A->AddFinalState("KpTrack"); // kaon final state
0022 
0023 
0024   // define cuts ====================================
0025   /* - cuts are defined the same way as bins are defined (see below for syntax details and examples);
0026    *   the `CutDef` class handles bin definitions
0027    *
0028    * For example, if you want to apply the y<0.95 cut, do:
0029    *   A->AddBinScheme("y");
0030    *   A->BinScheme("y")->BuildBin("Max",0.95);
0031    * This makes a single y bin, defined by a maximum of 0.95.
0032    * 
0033    * If instead you want to make a cut of 0.01<y<0.95, you must do
0034    *   A->AddBinScheme("y");
0035    *   A->BinScheme("y")->BuildBin("Range",0.01,0.95);
0036    * to define a single y bin. If instead you try to do something like
0037    *   A->AddBinScheme("y");
0038    *   A->BinScheme("y")->BuildBin("Min",0.01);
0039    *   A->BinScheme("y")->BuildBin("Max",0.95);
0040    * you would actually be defining two y bins, one with the minimum and a
0041    * second with the maximum, which may not be what you want.
0042    * 
0043    * You must also be mindful of what other bins you are defining. Suppose you
0044    * want to apply a Q2>10 GeV2 cut, and then do an analysis in bins of Q2. If
0045    * you do
0046    *   A->AddBinScheme("q2");
0047    *   A->BinScheme("q2")->BuildBin("Min",10); // Q2>10 GeV2 cut
0048    *   A->BinScheme("q2")->BuildBins( 5, 10,    100,  true ); // 5 bins in range 10-100 GeV, equal width log scale
0049    * you are actually defining 6 Q2 bins: the 5 you specify with `BuildBins`
0050    * plus the one you specified with `BuildBin("Min",10)`. In this case, only
0051    * the third line is needed to apply the Q2>10 GeV2 cut, since your binning
0052    * range starts at 10 GeV2.
0053    */ 
0054   // here are some common cuts we typically use for SIDIS:
0055   A->AddBinScheme("w");  A->BinScheme("w")->BuildBin("Min",3.0); // W > 3 GeV
0056   A->AddBinScheme("y");  A->BinScheme("y")->BuildBin("Range",0.01,0.95); // 0.01 < y < 0.95
0057   A->AddBinScheme("z");  A->BinScheme("z")->BuildBin("Range",0.2,0.9); // 0.2 < z < 0.9
0058   A->AddBinScheme("xF"); A->BinScheme("xF")->BuildBin("Min",0.0); // xF > 0
0059   A->AddBinScheme("ptLab");  A->BinScheme("ptLab")->BuildBin("Min",0.1); // pT_lab > 0.1 GeV (tracking limit)
0060 
0061 
0062 
0063   // set binning scheme ====================================
0064 
0065   // first add what bin schemes you want; you don't have to define
0066   // bins for all of them, but you need to add at least the ones
0067   // you plan to use below
0068   A->AddBinScheme("q2");
0069   A->AddBinScheme("x");
0070   A->AddBinScheme("pt");
0071 
0072   // then add the bins that you want
0073   // - tutorial switch statement: change tutorial number to try out
0074   //   the different binning implementations
0075   int tutorialNum = 1;
0076   switch(tutorialNum) {
0077 
0078     case 0:
0079       // 1D binning in Q2, equal width in linear scale
0080       // - arguments of BuildBins are: (numBins, min, max, log-scale bool)
0081       // - alternatively: BuildBins(TAxis*, log-scale bool)
0082       // - log-scale is false by default
0083       A->BinScheme("q2")->BuildBins(  3, 1, 100);
0084       break;
0085 
0086     case 1:
0087       // 3x3 grid of (x,Q2) bins, equal width in logarithmic scale
0088       A->BinScheme("q2")->BuildBins( 3, 1,    100,  true );
0089       A->BinScheme("x")->BuildBins(  3, 0.01, 1,    true );
0090       break;
0091 
0092     case 2:
0093       // alternatively: equal width in linear scale
0094       A->BinScheme("q2")->BuildBins( 3, 1,    100 );
0095       A->BinScheme("x")->BuildBins(  3, 0.01, 1   );
0096       break;
0097 
0098     case 3:
0099       // custom 2x2 grid (see `CutDef` class for more cut definitions)
0100       // - arguments of BuildBin are (cutType, a, b), where cutType is
0101       //   one of the types given in `../src/CutDef.cxx`, and a and b
0102       //   depend on which cutType
0103       // - various cutTypes are exemplified here:
0104       A->BinScheme("q2")->BuildBin("Max",10); // Q2 < 10 GeV2
0105       A->BinScheme("q2")->BuildBin("Min",10); // Q2 > 10 GeV2
0106       A->BinScheme("x")->BuildBin("Range", 0.05, 0.2 ); // 0.05 < x < 0.2
0107       A->BinScheme("x")->BuildBin("CenterDelta", 0.5, 0.1 ); // |x-0.5|<0.1
0108       break;
0109 
0110     case 4:
0111       // overlapping Q2 bins, by specifying various Q2 minima
0112       // - bins are arbitrary and allowed to be overlapping
0113       A->BinScheme("q2")->BuildBin("Min",1);
0114       A->BinScheme("q2")->BuildBin("Min",10);
0115       A->BinScheme("q2")->BuildBin("Min",50);
0116       break;
0117 
0118     case 5:
0119       // 3D binning: 2x2 grid of (x,Q2) bins, for two pT bins
0120       // - you can add more dimensions, but be careful of the curse
0121       //   of dimensionality
0122       A->BinScheme("q2")->BuildBins( 2, 1,    100,  true );
0123       A->BinScheme("x")->BuildBins(  2, 0.01, 1,    true );
0124       A->BinScheme("pt")->BuildBin("Range", 0.2, 0.5 );
0125       A->BinScheme("pt")->BuildBin("Range", 0.5, 0.8 );
0126       break;
0127   };
0128 
0129 
0130 
0131   // perform the analysis ==================================
0132   A->Execute();
0133 
0134   // for reference, here is a print out of HistosDAG
0135   // - it lists each node, together with its inputs and outputs, which
0136   //   indicate the connections between the nodes
0137   //A->GetHistosDAG()->PrintBreadth("HistosDAG Nodes");
0138 };