Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:14:01

0001 
0002 #include "WaveFormNtuple.h"
0003 
0004 #include <calobase/TowerInfo.h>
0005 #include <calobase/TowerInfoContainer.h>
0006 
0007 #include <fun4all/Fun4AllReturnCodes.h>
0008 
0009 #include <phool/PHCompositeNode.h>
0010 #include <phool/getClass.h>
0011 
0012 #include <TFile.h>
0013 #include <TNtuple.h>
0014 
0015 //____________________________________________________________________________..
0016 WaveFormNtuple::WaveFormNtuple(const std::string &name):
0017  SubsysReco(name)
0018 {
0019 }
0020 
0021 //____________________________________________________________________________..
0022 int WaveFormNtuple::InitRun(PHCompositeNode * /*topNode*/)
0023 {
0024   outfile = TFile::Open("ntuple.root","RECREATE");
0025   ntup = new TNtuple("ntup","waveform analysis","e:t:chi2:ped:status:s5:s6:s7");
0026   return Fun4AllReturnCodes::EVENT_OK;
0027 }
0028 
0029 //____________________________________________________________________________..
0030 int WaveFormNtuple::process_event(PHCompositeNode *topNode)
0031 {
0032   TowerInfoContainer *towerinfocontainer = findNode::getClass<TowerInfoContainer>(topNode,"TOWERS_HCALOUT");
0033   if (towerinfocontainer)
0034   {
0035     unsigned int nchannels = towerinfocontainer->size();
0036     for (unsigned int channel = 0; channel < nchannels; channel++)
0037     {
0038       TowerInfo *rawtwr = towerinfocontainer->get_tower_at_channel(channel);
0039       
0040       // std::cout << "energy: " << rawtwr->get_energy() << std::endl;
0041       // std::cout << "time: " << rawtwr->get_time_float() << std::endl;
0042       // for (int j = 0; j < 12; j++)
0043       // {
0044       //    std::cout << "waveform_value[" << j << "]: " << rawtwr->get_waveform_value(j) << std::endl;
0045       // }
0046       ntup->Fill(rawtwr->get_energy(), rawtwr->get_time_float(),rawtwr->get_chi2(), rawtwr->get_pedestal(),rawtwr->get_status(), rawtwr->get_waveform_value(5), rawtwr->get_waveform_value(6), rawtwr->get_waveform_value(7));
0047     }
0048   }
0049   return Fun4AllReturnCodes::EVENT_OK;
0050 }
0051 
0052 //____________________________________________________________________________..
0053 int WaveFormNtuple::End(PHCompositeNode * /*topNode*/)
0054 {
0055   std::cout << "WaveFormNtuple::End(PHCompositeNode *topNode) This is the End..." << std::endl;
0056 
0057   outfile->cd();
0058   ntup->Write();
0059   outfile->Close();
0060   return Fun4AllReturnCodes::EVENT_OK;
0061 }