Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-11-16 09:02:47

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 Q2 bins
0008 void postprocess_xsecQ(
0009     TString infile="out/xsecQ.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->diagonalPtXZ = true;
0017 
0018   // setup postprocessor ========================================
0019   PostProcessor *P = new PostProcessor(infile);
0020 
0021   // start output file  ========================================
0022   TString tableFile = P->GetPngDir() + "/table_counts_qbins.txt";
0023   P->StartTextFile(tableFile,"Counts and averages in bins of Q2");
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 bpt : P->GetBinNums("pt")) {
0029   for(int bx  : P->GetBinNums("x")) {
0030   for(int bz  : P->GetBinNums("z")) {
0031     if(A->CheckDiagonal(bpt,bx,bz,-1)) continue; // diagonalize
0032 
0033     // header for this (pt,x,z) bin
0034     P->AppendToTextFile(tableFile,Form("\nKinematic Bin: %d =========================",bpt));
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 Q2 bins; these are the rows of the table
0041       for(int bq : P->GetBinNums("q2")) {
0042 
0043     // skip full bin
0044     if(P->GetBinCut("q2",bq)->GetCutType()=="Full") continue;
0045 
0046         // ALGORITHM: dump tables of average values, in bins of Q2
0047         P->DumpAve(
0048             tableFile,
0049             A->GetHistosName(bpt,bx,bz,bq,by,bfs),
0050             "q2");
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 };