Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-06-26 07:06:05

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2023 Christopher Dilks
0003 
0004 R__LOAD_LIBRARY(EpicAnalysis)
0005 #include "PostProcessor.h"
0006 
0007 // dump counts and average kinematics in pT bins
0008 void postprocess_xsecPT(
0009     TString infile="out/xsecPT.crossCheck.root"
0010 ) {
0011 
0012   // instantiate empty analysis object ================================
0013   // - needed for some general information about binning
0014   // - specify settings such as diagonalized binnings
0015   AnalysisDelphes *A = new AnalysisDelphes();
0016   A->diagonalXZQ = true;
0017 
0018   // setup postprocessor ========================================
0019   PostProcessor *P = new PostProcessor(infile);
0020 
0021   // start output file  ========================================
0022   TString tableFile = P->GetPngDir() + "/table_counts_ptbins.txt";
0023   P->StartTextFile(tableFile,"Counts and averages in bins of pT");
0024 
0025   // loop over (pt,x,z) bins, diagonalized
0026   // TODO: when AnalysisDelphes::histSet is generalized, loops like this will
0027   // be significantly simpler
0028   for(int bx  : P->GetBinNums("x")) {
0029   for(int bz  : P->GetBinNums("z")) {
0030   for(int bq  : P->GetBinNums("q2")) {
0031     if(A->CheckDiagonal(-1,bx,bz,bq)) continue; // diagonalize
0032 
0033     // header for this (x,z,q2) bin
0034     P->AppendToTextFile(tableFile,Form("\nKinematic Bin: %d =========================",bx));
0035 
0036     // loop over y minima and final states; we will have one table per iteration
0037     for(int by  : P->GetBinNums("y")) {
0038     for(int bfs : P->GetBinNums("finalState")) {
0039 
0040       // loop over pT bins; these are the rows of the table
0041       for(int bpt : P->GetBinNums("pt")) {
0042 
0043         // skip full bin
0044         if(P->GetBinCut("pt",bpt)->GetCutType()=="Full") continue;
0045 
0046         // ALGORITHM: dump tables of average values, in bins of pT
0047         P->DumpAve(
0048             tableFile,
0049             A->GetHistosName(bpt,bx,bz,bq,by,bfs),
0050             "pt");
0051       };
0052 
0053       // finish ALGORITHM - called after the loop over table rows, so that
0054       // PostProcessor knows to start a new table for the next y minimum
0055       P->FinishDumpAve(tableFile);
0056     }};
0057   }}};
0058 
0059   // dump final table to stdout
0060   P->PrintTextFile(tableFile);
0061   cout << tableFile << " written" << endl;
0062 
0063   // finish
0064   P->Finish();
0065 };