Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:11:15

0001 #include "CentralityValid.h"
0002 
0003 #include <centrality/CentralityInfo.h>
0004 #include <calotrigger/MinimumBiasInfo.h>
0005 #include <fun4all/Fun4AllHistoManager.h>
0006 #include <fun4all/Fun4AllReturnCodes.h>
0007 
0008 #include <phool/PHCompositeNode.h>
0009 #include <phool/PHIODataNode.h>
0010 #include <phool/PHNode.h>
0011 #include <phool/PHNodeIterator.h>
0012 #include <phool/PHObject.h>
0013 #include <phool/PHRandomSeed.h>
0014 #include <phool/getClass.h>
0015 
0016 #include <TF1.h>
0017 #include <TEfficiency.h>
0018 #include <TFile.h>
0019 #include <TH2.h>
0020 #include <TNtuple.h>
0021 #include <TSystem.h>
0022 
0023 #include <cassert>
0024 #include <filesystem>
0025 #include <fstream>
0026 #include <iostream>
0027 #include <sstream>
0028 #include <string>
0029 #include <vector>
0030 
0031 CentralityValid::CentralityValid(const std::string &name, const std::string &hist_name)
0032   : SubsysReco(name)
0033 {
0034   _hist_filename = hist_name;
0035 }
0036 
0037 CentralityValid::~CentralityValid()
0038 {
0039   delete hm;
0040 }
0041 int CentralityValid::Init(PHCompositeNode * /*unused*/)
0042 {
0043   // Histograms
0044 
0045   hm = new Fun4AllHistoManager("CENTRALITY_VALIDATION_HIST");
0046 
0047   _h_centrality_bin = new TH1D("h_centrality_bin", ";Centrality Bin; 1/N{_Events}",20,0, 1.0);
0048   _h_centrality_bin_mb = new TH1D("h_centrality_bin_mb", ";Centrality Bin; 1/N{_Events}",20,0, 1.0);
0049 
0050   _he_min_bias = new TEfficiency("he_min_bias",";Min Bias?; Fraction of Events", 1, 0, 1);
0051   hm->registerHisto(_h_centrality_bin);
0052   hm->registerHisto(_h_centrality_bin_mb);
0053   hm->registerHisto(_he_min_bias);
0054   return Fun4AllReturnCodes::EVENT_OK;
0055 }
0056 
0057 int CentralityValid::InitRun(PHCompositeNode * /*unused*/)
0058 {
0059   if (Verbosity())
0060   {
0061     std::cout << __FILE__ << " :: " << __FUNCTION__ << std::endl;
0062   }
0063 
0064   return Fun4AllReturnCodes::EVENT_OK;
0065 }
0066 
0067 
0068 int CentralityValid::process_event(PHCompositeNode *topNode)
0069 {
0070   if (Verbosity())
0071   {
0072     std::cout << __FILE__ << " :: " << __FUNCTION__ << " :: " << __LINE__ << std::endl;
0073   }
0074 
0075   _central = findNode::getClass<CentralityInfo>(topNode, "CentralityInfo");
0076   
0077   if (!_central)
0078   {
0079     std::cout << "no centrality node " << std::endl;
0080     return Fun4AllReturnCodes::ABORTRUN;
0081   }
0082 
0083   _minimumbiasinfo = findNode::getClass<MinimumBiasInfo>(topNode, "MinimumBiasInfo");
0084   
0085   if (!_minimumbiasinfo)
0086   {
0087     std::cout << "no minimumbias node " << std::endl;
0088     return Fun4AllReturnCodes::ABORTRUN;
0089   }
0090 
0091   float centile = (_central->has_centile(CentralityInfo::PROP::mbd_NS)?_central->get_centile(CentralityInfo::PROP::mbd_NS) : -999.99);
0092 
0093   _h_centrality_bin->Fill(centile);
0094 
0095   bool isMinBias = _minimumbiasinfo->isAuAuMinimumBias();
0096 
0097   if (isMinBias)
0098     {
0099       _h_centrality_bin_mb->Fill(centile);
0100     }
0101   _he_min_bias->Fill(isMinBias,0);
0102   
0103   return Fun4AllReturnCodes::EVENT_OK;
0104 }
0105 
0106 int CentralityValid::End(PHCompositeNode * /* topNode*/)
0107 {
0108   hm->dumpHistos(_hist_filename.c_str(), "RECREATE");
0109 
0110   return 0;
0111 }