Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 #include "CaloEmulatorTreeMaker.h"
0002 //for emc clusters
0003 #include <g4main/PHG4TruthInfoContainer.h>
0004 #include <g4main/PHG4Particle.h>
0005 #include <TMath.h>
0006 #include <calotrigger/TriggerRunInfov1.h>
0007 
0008 #include <calobase/RawTowerGeom.h>
0009 #include <jetbackground/TowerBackground.h>
0010 #include <calobase/RawCluster.h>
0011 #include <calobase/RawClusterContainer.h>
0012 #include <calobase/RawClusterUtility.h>
0013 #include <calobase/RawTowerGeomContainer.h>
0014 #include <calobase/RawTower.h>
0015 #include <calobase/RawTowerContainer.h>
0016 #include <HepMC/SimpleVector.h> 
0017 //for vetex information
0018 #include <globalvertex/GlobalVertex.h>
0019 #include <globalvertex/GlobalVertexMap.h>
0020 #include <vector>
0021 
0022 #include <fun4all/Fun4AllReturnCodes.h>
0023 #include <phool/PHCompositeNode.h>
0024 #include <phool/PHIODataNode.h>
0025 #include <phool/PHNode.h>
0026 #include <phool/PHNodeIterator.h>
0027 #include <phool/PHObject.h>
0028 #include <phool/getClass.h>
0029 // G4Cells includes
0030 
0031 #include <iostream>
0032 
0033 #include <map>
0034 
0035 //____________________________________________________________________________..
0036 CaloEmulatorTreeMaker::CaloEmulatorTreeMaker(const std::string &name, const std::string &outfilename):
0037   SubsysReco(name)
0038   
0039 {
0040   isSim = false;
0041   _foutname = outfilename;  
0042   m_calo_nodename = "TOWERINFO_CALIB";
0043 }
0044 
0045 //____________________________________________________________________________..
0046 CaloEmulatorTreeMaker::~CaloEmulatorTreeMaker()
0047 {
0048 
0049 }
0050 
0051 //____________________________________________________________________________..
0052 int CaloEmulatorTreeMaker::Init(PHCompositeNode *topNode)
0053 {
0054 
0055 
0056   if (isSim)
0057     {
0058       pt_cut = 1.;
0059     }
0060   triggeranalyzer = new TriggerAnalyzer();
0061   if (Verbosity()) std::cout << __FUNCTION__ << __LINE__<<std::endl;
0062   _f = new TFile( _foutname.c_str(), "RECREATE");
0063 
0064   std::cout << " making a file = " <<  _foutname.c_str() << " , _f = " << _f << std::endl;
0065   
0066   _tree = new TTree("ttree","a persevering date tree");
0067 
0068   if (isSim)
0069     {
0070       // _tree->Branch("_truth_particle_n", &b_truth_particle_n);
0071       // _tree->Branch("_truth_particle_pid",&b_truth_particle_pid);
0072       // _tree->Branch("_truth_particle_pt",&b_truth_particle_pt);
0073       // _tree->Branch("_truth_particle_eta",&b_truth_particle_eta);
0074       // _tree->Branch("_truth_particle_phi",&b_truth_particle_phi);
0075 
0076       _tree->Branch("truth_jet_pt_2",&b_truth_jet_pt_2);
0077       _tree->Branch("truth_jet_eta_2",&b_truth_jet_eta_2);
0078       _tree->Branch("truth_jet_phi_2",&b_truth_jet_phi_2);
0079       _tree->Branch("truth_jet_pt_4",&b_truth_jet_pt_4);
0080       _tree->Branch("truth_jet_eta_4",&b_truth_jet_eta_4);
0081       _tree->Branch("truth_jet_phi_4",&b_truth_jet_phi_4);
0082       _tree->Branch("truth_jet_pt_6",&b_truth_jet_pt_6);
0083       _tree->Branch("truth_jet_eta_6",&b_truth_jet_eta_6);
0084       _tree->Branch("truth_jet_phi_6",&b_truth_jet_phi_6);
0085 
0086     }
0087 
0088   if (useLL1)
0089     {
0090 
0091     }
0092   _i_event = 0;
0093   _tree->Branch("emcal_good",&b_emcal_good);
0094   _tree->Branch("emcal_energy",&b_emcal_energy);
0095   _tree->Branch("emcal_time",&b_emcal_time);
0096   _tree->Branch("emcal_phibin",&b_emcal_phibin);
0097   _tree->Branch("emcal_etabin",&b_emcal_etabin);
0098   _tree->Branch("hcalin_good",&b_hcalin_good);
0099   _tree->Branch("hcalin_energy",&b_hcalin_energy);
0100   _tree->Branch("hcalin_time",&b_hcalin_time);
0101   _tree->Branch("hcalin_phibin",&b_hcalin_phibin);
0102   _tree->Branch("hcalin_etabin",&b_hcalin_etabin);
0103   _tree->Branch("hcalout_good",&b_hcalout_good);
0104   _tree->Branch("hcalout_energy",&b_hcalout_energy);
0105   _tree->Branch("hcalout_time",&b_hcalout_time);
0106   _tree->Branch("hcalout_phibin",&b_hcalout_phibin);
0107   _tree->Branch("hcalout_etabin",&b_hcalout_etabin);
0108 
0109   _tree->Branch("mbd_vertex_z", &b_vertex_z, "mbd_vertex_z/F");
0110 
0111   _tree->Branch("njet_2", &b_njet_2, "njet_2/I");
0112   _tree->Branch("jet_pt_2", &b_jet_pt_2);
0113   _tree->Branch("jet_et_2", &b_jet_et_2);
0114   _tree->Branch("jet_eta_2", &b_jet_eta_2);
0115   _tree->Branch("jet_phi_2", &b_jet_phi_2);
0116   _tree->Branch("jet_emcal_2", &b_jet_emcal_2);
0117   _tree->Branch("jet_hcalout_2", &b_jet_hcalout_2);
0118   _tree->Branch("jet_hcalin_2", &b_jet_hcalin_2);
0119 
0120   _tree->Branch("njet_4", &b_njet_4, "njet_4/I");
0121   _tree->Branch("jet_pt_4", &b_jet_pt_4);
0122   _tree->Branch("jet_et_4", &b_jet_et_4);
0123   _tree->Branch("jet_eta_4", &b_jet_eta_4);
0124   _tree->Branch("jet_phi_4", &b_jet_phi_4);
0125   _tree->Branch("jet_emcal_4", &b_jet_emcal_4);
0126   _tree->Branch("jet_hcalout_4", &b_jet_hcalout_4);
0127   _tree->Branch("jet_hcalin_4", &b_jet_hcalin_4);
0128 
0129   _tree->Branch("njet_6", &b_njet_6, "njet_6/I");
0130   _tree->Branch("jet_pt_6", &b_jet_pt_6);
0131   _tree->Branch("jet_et_6", &b_jet_et_6);
0132   _tree->Branch("jet_eta_6", &b_jet_eta_6);
0133   _tree->Branch("jet_phi_6", &b_jet_phi_6);
0134   _tree->Branch("jet_emcal_6", &b_jet_emcal_6);
0135   _tree->Branch("jet_hcalout_6", &b_jet_hcalout_6);
0136   _tree->Branch("jet_hcalin_6", &b_jet_hcalin_6);
0137 
0138   std::cout << "Done initing the treemaker"<<std::endl;  
0139   return Fun4AllReturnCodes::EVENT_OK;
0140 }
0141 
0142 //____________________________________________________________________________..
0143 int CaloEmulatorTreeMaker::InitRun(PHCompositeNode *topNode)
0144 {
0145   if (Verbosity()) std::cout << __FUNCTION__ << __LINE__<<std::endl;
0146   return Fun4AllReturnCodes::EVENT_OK;
0147 }
0148 
0149 //____________________________________________________________________________..
0150 
0151 void CaloEmulatorTreeMaker::SetVerbosity(int verbo){
0152   _verbosity = verbo;
0153   return;
0154 }
0155 
0156 void CaloEmulatorTreeMaker::reset_tree_vars()
0157 {
0158   if (Verbosity()) std::cout << __FUNCTION__ << __LINE__<<std::endl;
0159 
0160   b_njet_2 = 0;
0161   b_jet_pt_2.clear();
0162   b_jet_et_2.clear();
0163   b_jet_eta_2.clear();
0164   b_jet_phi_2.clear();
0165   b_jet_emcal_2.clear();
0166   b_jet_hcalin_2.clear();
0167   b_jet_hcalout_2.clear();
0168   b_njet_4 = 0;
0169   b_jet_pt_4.clear();
0170   b_jet_et_4.clear();
0171   b_jet_eta_4.clear();
0172   b_jet_phi_4.clear();
0173   b_jet_emcal_4.clear();
0174   b_jet_hcalin_4.clear();
0175   b_jet_hcalout_4.clear();
0176 
0177   b_njet_6 = 0;
0178   b_jet_pt_6.clear();
0179   b_jet_et_6.clear();
0180   b_jet_eta_6.clear();
0181   b_jet_phi_6.clear();
0182   b_jet_emcal_6.clear();
0183   b_jet_hcalin_6.clear();
0184   b_jet_hcalout_6.clear();
0185 
0186   b_emcal_good.clear();
0187   b_emcal_energy.clear();
0188   b_emcal_time.clear();
0189   b_emcal_phibin.clear();
0190   b_emcal_etabin.clear();
0191 
0192   b_hcalin_good.clear();
0193   b_hcalin_energy.clear();
0194   b_hcalin_time.clear();
0195   b_hcalin_phibin.clear();
0196   b_hcalin_etabin.clear();
0197 
0198   b_hcalout_good.clear();  
0199   b_hcalout_energy.clear();
0200   b_hcalout_time.clear();
0201   b_hcalout_phibin.clear();
0202   b_hcalout_etabin.clear();
0203 
0204   if (isSim)
0205     {
0206       b_ntruth_jet_2 = 0;
0207       b_truth_jet_pt_2.clear();
0208       b_truth_jet_eta_2.clear();
0209       b_truth_jet_phi_2.clear();
0210       b_ntruth_jet_4 = 0;
0211       b_truth_jet_pt_4.clear();
0212       b_truth_jet_eta_4.clear();
0213       b_truth_jet_phi_4.clear();
0214       b_ntruth_jet_6 = 0;
0215       b_truth_jet_pt_6.clear();
0216       b_truth_jet_eta_6.clear();
0217       b_truth_jet_phi_6.clear();
0218     }
0219 
0220   return;
0221 }
0222 
0223 int CaloEmulatorTreeMaker::process_event(PHCompositeNode *topNode)
0224 {
0225 
0226   if (Verbosity()) std::cout << __FILE__ << " "<< __LINE__<<" "<<std::endl;
0227 
0228   _i_event++;
0229 
0230   reset_tree_vars();
0231 
0232 
0233 
0234   RawTowerGeomContainer *tower_geomIH = findNode::getClass<RawTowerGeomContainer>(topNode, "TOWERGEOM_HCALIN");
0235   RawTowerGeomContainer *tower_geomEM = findNode::getClass<RawTowerGeomContainer>(topNode, "TOWERGEOM_CEMC");
0236   RawTowerGeomContainer *tower_geomOH = findNode::getClass<RawTowerGeomContainer>(topNode, "TOWERGEOM_HCALOUT");
0237 
0238   if (isSim)
0239     {
0240 
0241       std::string truthJetName = "AntiKt_Truth_r02";
0242       JetContainer *jetstruth_2 = findNode::getClass<JetContainer>(topNode, truthJetName);
0243       if (jetstruth_2)
0244     {
0245       // zero out counters
0246       
0247       for (auto jet : *jetstruth_2)
0248         {
0249           if (jet->get_pt() < pt_cut_truth) continue;
0250 
0251           b_ntruth_jet_2++;
0252           b_truth_jet_pt_2.push_back(jet->get_pt());
0253           b_truth_jet_eta_2.push_back(jet->get_eta());
0254           b_truth_jet_phi_2.push_back(jet->get_phi());
0255         }
0256     }
0257       truthJetName = "AntiKt_Truth_r04";
0258       JetContainer *jetstruth_4 = findNode::getClass<JetContainer>(topNode, truthJetName);
0259       if (jetstruth_4)
0260     {
0261       // zero out counters
0262 
0263       for (auto jet : *jetstruth_4)
0264         {
0265           if (jet->get_pt() < pt_cut_truth) continue;
0266 
0267           b_ntruth_jet_4++;
0268           b_truth_jet_pt_4.push_back(jet->get_pt());
0269           b_truth_jet_eta_4.push_back(jet->get_eta());
0270           b_truth_jet_phi_4.push_back(jet->get_phi());
0271         }
0272     }
0273       truthJetName = "AntiKt_Truth_r06";
0274       JetContainer *jetstruth_6 = findNode::getClass<JetContainer>(topNode, truthJetName);
0275       if (jetstruth_6)
0276     {
0277       // zero out counters
0278 
0279       for (auto jet : *jetstruth_6)
0280         {
0281           if (jet->get_pt() < pt_cut_truth) continue;
0282 
0283           b_ntruth_jet_6++;
0284           b_truth_jet_pt_6.push_back(jet->get_pt());
0285           b_truth_jet_eta_6.push_back(jet->get_eta());
0286           b_truth_jet_phi_6.push_back(jet->get_phi());
0287         }
0288     }
0289     }
0290 
0291   GlobalVertexMap* vertexmap = findNode::getClass<GlobalVertexMap>(topNode, "RealVertexMap");
0292   if (!vertexmap)
0293     {
0294       vertexmap = findNode::getClass<GlobalVertexMap>(topNode, "GlobalVertexMap");
0295     }
0296 
0297   float vtx_z = 0;
0298   b_vertex_z = -999;
0299   if (vertexmap && !vertexmap->empty())
0300     {
0301       GlobalVertex* vtx = vertexmap->begin()->second;
0302       if (vtx)
0303     {
0304       vtx_z = vtx->get_z();
0305       b_vertex_z = vtx_z;
0306     }
0307     }
0308 
0309 
0310   TowerInfoContainer *hcalin_towers = findNode::getClass<TowerInfoContainer>(topNode, m_calo_nodename + "_HCALIN");
0311   if (!hcalin_towers)
0312     {
0313       std::cout << "no hcalin towers "<<std::endl;
0314       return Fun4AllReturnCodes::ABORTRUN;
0315     }
0316   int size;
0317   if (hcalin_towers)
0318     {
0319 
0320       size = hcalin_towers->size(); //online towers should be the same!
0321       for (int channel = 0; channel < size;channel++)
0322     {
0323       _tower = hcalin_towers->get_tower_at_channel(channel);
0324       float energy = _tower->get_energy();
0325       float time = _tower->get_time();    
0326       short good = (_tower->get_isGood() ? 1:0);
0327       unsigned int towerkey = hcalin_towers->encode_key(channel);
0328       int ieta = hcalin_towers->getTowerEtaBin(towerkey);
0329       int iphi = hcalin_towers->getTowerPhiBin(towerkey);
0330 
0331       b_hcalin_good.push_back(good);
0332       b_hcalin_energy.push_back(energy);
0333       b_hcalin_time.push_back(time);
0334       b_hcalin_etabin.push_back(ieta);
0335       b_hcalin_phibin.push_back(iphi);
0336     }
0337     }
0338   TowerInfoContainer *hcalout_towers = findNode::getClass<TowerInfoContainer>(topNode, m_calo_nodename + "_HCALOUT");
0339   if (!hcalout_towers)
0340     {
0341       std::cout << "no hcalout towers "<<std::endl;
0342       return Fun4AllReturnCodes::ABORTRUN;
0343     }
0344   if (hcalout_towers)
0345     {
0346 
0347       size = hcalout_towers->size(); //online towers should be the same!
0348       for (int channel = 0; channel < size;channel++)
0349     {
0350       _tower = hcalout_towers->get_tower_at_channel(channel);
0351       float energy = _tower->get_energy();
0352       float time = _tower->get_time();    
0353       unsigned int towerkey = hcalout_towers->encode_key(channel);
0354       int ieta = hcalout_towers->getTowerEtaBin(towerkey);
0355       int iphi = hcalout_towers->getTowerPhiBin(towerkey);
0356       short good = (_tower->get_isGood() ? 1:0);
0357       b_hcalout_good.push_back(good);
0358       b_hcalout_energy.push_back(energy);
0359       b_hcalout_time.push_back(time);
0360       b_hcalout_etabin.push_back(ieta);
0361       b_hcalout_phibin.push_back(iphi);
0362     }
0363     }
0364   TowerInfoContainer *emcalre_towers = findNode::getClass<TowerInfoContainer>(topNode, m_calo_nodename + "_CEMC_RETOWER");
0365   TowerInfoContainer *emcal_towers = findNode::getClass<TowerInfoContainer>(topNode, m_calo_nodename + "_CEMC");
0366   if (emcal_towers)
0367     {
0368       size = emcal_towers->size(); //online towers should be the same!
0369       for (int channel = 0; channel < size;channel++)
0370     {
0371       _tower = emcal_towers->get_tower_at_channel(channel);
0372       float energy = _tower->get_energy();
0373       float time = _tower->get_time();
0374       unsigned int towerkey = emcal_towers->encode_key(channel);
0375       int ieta = emcal_towers->getTowerEtaBin(towerkey);
0376       int iphi = emcal_towers->getTowerPhiBin(towerkey);
0377       short good = (_tower->get_isGood() ? 1:0);
0378       b_emcal_good.push_back(good);
0379       b_emcal_energy.push_back(energy);
0380       b_emcal_time.push_back(time);
0381       b_emcal_etabin.push_back(ieta);
0382       b_emcal_phibin.push_back(iphi);
0383     }
0384     }
0385 
0386    float background_v2 = 0;
0387    float background_Psi2 = 0;
0388    bool has_tower_background = false;
0389    TowerBackground *towBack = findNode::getClass<TowerBackground>(topNode, "TowerInfoBackground_Sub2");
0390    if (towBack)
0391      {
0392        has_tower_background = true;
0393        background_v2 = towBack->get_v2();
0394        background_Psi2 = towBack->get_Psi2();
0395      }
0396 
0397    std::string recoJetName = "AntiKt_Tower_r02_Sub1";
0398    JetContainer *jets_2 = findNode::getClass<JetContainer>(topNode, recoJetName);
0399    if (jets_2)
0400      {
0401        // zero out counters
0402 
0403        for (auto jet : *jets_2)
0404      {
0405        if (jet->get_pt() < pt_cut) continue;
0406 
0407        int n_comp_total = 0;
0408        int n_comp_ihcal = 0;
0409        int n_comp_ohcal = 0;
0410        int n_comp_emcal = 0;
0411 
0412        float jet_total_eT = 0;
0413        float eFrac_ihcal = 0;
0414        float eFrac_ohcal = 0;
0415        float eFrac_emcal = 0;
0416        float eFrac_emcal_ind = 0;
0417 
0418        float emcal_tower_max = 0;
0419        b_njet_2++;
0420        b_jet_pt_2.push_back(jet->get_pt());
0421        b_jet_eta_2.push_back(jet->get_eta());
0422        b_jet_phi_2.push_back(jet->get_phi());
0423         
0424        for (int iem = 0; iem < (int) emcal_towers->size(); iem++)
0425          {
0426 
0427            unsigned int calokey = emcal_towers->encode_key(iem);
0428            TowerInfo *tower = emcal_towers->get_tower_at_channel(iem);
0429            if (!tower->get_isGood())
0430          {
0431            continue;
0432          }
0433            int ieta = emcal_towers->getTowerEtaBin(calokey);
0434            int iphi = emcal_towers->getTowerPhiBin(calokey);
0435            const RawTowerDefs::keytype key = RawTowerDefs::encode_towerid(RawTowerDefs::CalorimeterId::CEMC, ieta, iphi);
0436            double tower_phi = tower_geomEM->get_tower_geometry(key)->get_phi();
0437            double tower_eta = tower_geomEM->get_tower_geometry(key)->get_eta();
0438 
0439            double dR = sqrt(TMath::Power(getDPHI(tower_phi, jet->get_phi()), 2) + TMath::Power(tower_eta - jet->get_eta(), 2));
0440            if (dR > 0.2) continue;
0441 
0442            float tower_eT = tower->get_energy() / std::cosh(tower_eta);
0443 
0444            eFrac_emcal_ind += tower_eT;
0445          }     
0446        for (auto comp : jet->get_comp_vec())
0447          {
0448 
0449            unsigned int channel = comp.second;
0450            TowerInfo *tower;
0451            float tower_eT = 0;
0452            if (comp.first == 26 || comp.first == 30)
0453          {  // IHcal
0454            tower = hcalin_towers->get_tower_at_channel(channel);
0455            if (!tower || !tower_geomIH)
0456              {
0457                continue;
0458              }
0459            if(!tower->get_isGood()) continue;
0460 
0461            unsigned int calokey = hcalin_towers->encode_key(channel);
0462 
0463            int ieta = hcalin_towers->getTowerEtaBin(calokey);
0464            int iphi = hcalin_towers->getTowerPhiBin(calokey);
0465            const RawTowerDefs::keytype key = RawTowerDefs::encode_towerid(RawTowerDefs::CalorimeterId::HCALIN, ieta, iphi);
0466            float tower_phi = tower_geomIH->get_tower_geometry(key)->get_phi();
0467            float tower_eta = tower_geomIH->get_tower_geometry(key)->get_eta();
0468            tower_eT = tower->get_energy() / std::cosh(tower_eta);
0469 
0470            if (comp.first == 30)
0471              {  // is sub1
0472                if (has_tower_background)
0473              {
0474                float UE = towBack->get_UE(1).at(ieta);
0475                float tower_UE = UE * (1 + 2 * background_v2 * std::cos(2 * (tower_phi - background_Psi2)));
0476                tower_eT = (tower->get_energy() - tower_UE) / std::cosh(tower_eta);
0477              }
0478              }
0479 
0480            eFrac_ihcal += tower_eT;
0481            jet_total_eT += tower_eT;
0482            n_comp_ihcal++;
0483            n_comp_total++;
0484          }
0485            else if (comp.first == 27 || comp.first == 31)
0486          {  // IHcal
0487            tower = hcalout_towers->get_tower_at_channel(channel);
0488 
0489            if (!tower || !tower_geomOH)
0490              {
0491                continue;
0492              }
0493 
0494            unsigned int calokey = hcalout_towers->encode_key(channel);
0495            int ieta = hcalout_towers->getTowerEtaBin(calokey);
0496            int iphi = hcalout_towers->getTowerPhiBin(calokey);
0497            const RawTowerDefs::keytype key = RawTowerDefs::encode_towerid(RawTowerDefs::CalorimeterId::HCALOUT, ieta, iphi);
0498            float tower_phi = tower_geomOH->get_tower_geometry(key)->get_phi();
0499            float tower_eta = tower_geomOH->get_tower_geometry(key)->get_eta();
0500            tower_eT = tower->get_energy() / std::cosh(tower_eta);
0501 
0502            if (comp.first == 31)
0503              {  // is sub1
0504                if (has_tower_background)
0505              {
0506                float UE = towBack->get_UE(2).at(ieta);
0507                float tower_UE = UE * (1 + 2 * background_v2 * std::cos(2 * (tower_phi - background_Psi2)));
0508                tower_eT = (tower->get_energy() - tower_UE) / std::cosh(tower_eta);
0509              }
0510              }
0511            eFrac_ohcal += tower_eT;
0512            jet_total_eT += tower_eT;
0513            n_comp_ohcal++;
0514            n_comp_total++;
0515          }
0516            else if (comp.first == 28 || comp.first == 29)
0517          {  // IHcal
0518            tower = emcalre_towers->get_tower_at_channel(channel);
0519 
0520            if (!tower || !tower_geomIH)
0521              {
0522                continue;
0523              }
0524 
0525            unsigned int calokey = emcalre_towers->encode_key(channel);
0526            int ieta = emcalre_towers->getTowerEtaBin(calokey);
0527            int iphi = emcalre_towers->getTowerPhiBin(calokey);
0528            const RawTowerDefs::keytype key = RawTowerDefs::encode_towerid(RawTowerDefs::CalorimeterId::HCALIN, ieta, iphi);
0529            float tower_phi = tower_geomIH->get_tower_geometry(key)->get_phi();
0530            float tower_eta = tower_geomIH->get_tower_geometry(key)->get_eta();
0531            tower_eT = tower->get_energy() / std::cosh(tower_eta);
0532 
0533            if (comp.first == 29)
0534              {  // is sub1
0535                if (has_tower_background)
0536              {
0537                float UE = towBack->get_UE(0).at(ieta);
0538                float tower_UE = UE * (1 + 2 * background_v2 * std::cos(2 * (tower_phi - background_Psi2)));
0539                tower_eT = (tower->get_energy() - tower_UE) / std::cosh(tower_eta);
0540              }
0541              }
0542 
0543            if (tower_eT > emcal_tower_max)
0544              {
0545                emcal_tower_max = tower_eT;
0546              }
0547            eFrac_emcal += tower_eT;
0548            jet_total_eT += tower_eT;
0549            n_comp_emcal++;
0550            n_comp_total++;
0551          }         
0552          }
0553        //      std::cout << n_comp_total << " = " << n_comp_emcal << " " << n_comp_hcalout << " from " << 
0554        eFrac_emcal /= jet_total_eT;
0555        eFrac_ihcal /= jet_total_eT;
0556        eFrac_ohcal /= jet_total_eT;
0557 
0558        b_jet_et_2.push_back(jet_total_eT);
0559        b_jet_emcal_2.push_back(eFrac_emcal);
0560        b_jet_hcalin_2.push_back(eFrac_ihcal);
0561        b_jet_hcalout_2.push_back(eFrac_ohcal);
0562      }
0563      }
0564 
0565    recoJetName = "AntiKt_Tower_r04_Sub1";
0566    JetContainer *jets_4 = findNode::getClass<JetContainer>(topNode, recoJetName);
0567    if (jets_4)
0568      {
0569        // zero out counters
0570 
0571        for (auto jet : *jets_4)
0572      {
0573        if (jet->get_pt() < pt_cut) continue;
0574 
0575        int n_comp_total = 0;
0576        int n_comp_ihcal = 0;
0577        int n_comp_ohcal = 0;
0578        int n_comp_emcal = 0;
0579 
0580        float jet_total_eT = 0;
0581        float eFrac_ihcal = 0;
0582        float eFrac_ohcal = 0;
0583        float eFrac_emcal = 0;
0584        float eFrac_emcal_ind = 0;
0585 
0586        float emcal_tower_max = 0;
0587        b_njet_4++;
0588        b_jet_pt_4.push_back(jet->get_pt());
0589        b_jet_eta_4.push_back(jet->get_eta());
0590        b_jet_phi_4.push_back(jet->get_phi());
0591 
0592        for (int iem = 0; iem < (int) emcal_towers->size(); iem++)
0593          {
0594 
0595            unsigned int calokey = emcal_towers->encode_key(iem);
0596            TowerInfo *tower = emcal_towers->get_tower_at_channel(iem);
0597            if (!tower->get_isGood())
0598          {
0599            continue;
0600          }
0601            int ieta = emcal_towers->getTowerEtaBin(calokey);
0602            int iphi = emcal_towers->getTowerPhiBin(calokey);
0603            const RawTowerDefs::keytype key = RawTowerDefs::encode_towerid(RawTowerDefs::CalorimeterId::CEMC, ieta, iphi);
0604            double tower_phi = tower_geomEM->get_tower_geometry(key)->get_phi();
0605            double tower_eta = tower_geomEM->get_tower_geometry(key)->get_eta();
0606 
0607            double dR = sqrt(TMath::Power(getDPHI(tower_phi, jet->get_phi()), 2) + TMath::Power(tower_eta - jet->get_eta(), 2));
0608            if (dR > 0.4) continue;
0609 
0610            float tower_eT = tower->get_energy() / std::cosh(tower_eta);
0611 
0612            eFrac_emcal_ind += tower_eT;
0613          }     
0614        for (auto comp : jet->get_comp_vec())
0615          {
0616 
0617            unsigned int channel = comp.second;
0618            TowerInfo *tower;
0619            float tower_eT = 0;
0620            if (comp.first == 26 || comp.first == 30)
0621          {  // IHcal
0622            tower = hcalin_towers->get_tower_at_channel(channel);
0623            if (!tower || !tower_geomIH)
0624              {
0625                continue;
0626              }
0627            if(!tower->get_isGood()) continue;
0628 
0629            unsigned int calokey = hcalin_towers->encode_key(channel);
0630 
0631            int ieta = hcalin_towers->getTowerEtaBin(calokey);
0632            int iphi = hcalin_towers->getTowerPhiBin(calokey);
0633            const RawTowerDefs::keytype key = RawTowerDefs::encode_towerid(RawTowerDefs::CalorimeterId::HCALIN, ieta, iphi);
0634            float tower_phi = tower_geomIH->get_tower_geometry(key)->get_phi();
0635            float tower_eta = tower_geomIH->get_tower_geometry(key)->get_eta();
0636            tower_eT = tower->get_energy() / std::cosh(tower_eta);
0637 
0638            if (comp.first == 30)
0639              {  // is sub1
0640                if (has_tower_background)
0641              {
0642                float UE = towBack->get_UE(1).at(ieta);
0643                float tower_UE = UE * (1 + 2 * background_v2 * std::cos(2 * (tower_phi - background_Psi2)));
0644                tower_eT = (tower->get_energy() - tower_UE) / std::cosh(tower_eta);
0645              }
0646              }
0647 
0648            eFrac_ihcal += tower_eT;
0649            jet_total_eT += tower_eT;
0650            n_comp_ihcal++;
0651            n_comp_total++;
0652          }
0653            else if (comp.first == 27 || comp.first == 31)
0654          {  // IHcal
0655            tower = hcalout_towers->get_tower_at_channel(channel);
0656 
0657            if (!tower || !tower_geomOH)
0658              {
0659                continue;
0660              }
0661 
0662            unsigned int calokey = hcalout_towers->encode_key(channel);
0663            int ieta = hcalout_towers->getTowerEtaBin(calokey);
0664            int iphi = hcalout_towers->getTowerPhiBin(calokey);
0665            const RawTowerDefs::keytype key = RawTowerDefs::encode_towerid(RawTowerDefs::CalorimeterId::HCALOUT, ieta, iphi);
0666            float tower_phi = tower_geomOH->get_tower_geometry(key)->get_phi();
0667            float tower_eta = tower_geomOH->get_tower_geometry(key)->get_eta();
0668            tower_eT = tower->get_energy() / std::cosh(tower_eta);
0669 
0670            if (comp.first == 31)
0671              {  // is sub1
0672                if (has_tower_background)
0673              {
0674                float UE = towBack->get_UE(2).at(ieta);
0675                float tower_UE = UE * (1 + 2 * background_v2 * std::cos(2 * (tower_phi - background_Psi2)));
0676                tower_eT = (tower->get_energy() - tower_UE) / std::cosh(tower_eta);
0677              }
0678              }
0679 
0680            eFrac_ohcal += tower_eT;
0681            jet_total_eT += tower_eT;
0682            n_comp_ohcal++;
0683            n_comp_total++;
0684          }
0685            else if (comp.first == 28 || comp.first == 29)
0686          {  // IHcal
0687            tower = emcalre_towers->get_tower_at_channel(channel);
0688 
0689            if (!tower || !tower_geomIH)
0690              {
0691                continue;
0692              }
0693 
0694            unsigned int calokey = emcalre_towers->encode_key(channel);
0695            int ieta = emcalre_towers->getTowerEtaBin(calokey);
0696            int iphi = emcalre_towers->getTowerPhiBin(calokey);
0697            const RawTowerDefs::keytype key = RawTowerDefs::encode_towerid(RawTowerDefs::CalorimeterId::HCALIN, ieta, iphi);
0698            float tower_phi = tower_geomIH->get_tower_geometry(key)->get_phi();
0699            float tower_eta = tower_geomIH->get_tower_geometry(key)->get_eta();
0700            tower_eT = tower->get_energy() / std::cosh(tower_eta);
0701 
0702            if (comp.first == 29)
0703              {  // is sub1
0704                if (has_tower_background)
0705              {
0706                float UE = towBack->get_UE(0).at(ieta);
0707                float tower_UE = UE * (1 + 2 * background_v2 * std::cos(2 * (tower_phi - background_Psi2)));
0708                tower_eT = (tower->get_energy() - tower_UE) / std::cosh(tower_eta);
0709              }
0710              }
0711 
0712            if (tower_eT > emcal_tower_max)
0713              {
0714                emcal_tower_max = tower_eT;
0715              }
0716            eFrac_emcal += tower_eT;
0717            jet_total_eT += tower_eT;
0718            n_comp_emcal++;
0719            n_comp_total++;
0720          }         
0721          }
0722        //      std::cout << n_comp_total << " = " << n_comp_emcal << " " << n_comp_hcalout << " from " << 
0723        emcal_tower_max /= eFrac_emcal;
0724 
0725        b_jet_et_4.push_back(jet_total_eT);
0726        b_jet_emcal_4.push_back(eFrac_emcal);
0727        b_jet_hcalin_4.push_back(eFrac_ihcal);
0728        b_jet_hcalout_4.push_back(eFrac_ohcal);
0729 
0730      }
0731      }
0732 
0733 
0734    recoJetName = "AntiKt_Tower_r06_Sub1";
0735    JetContainer *jets_6 = findNode::getClass<JetContainer>(topNode, recoJetName);
0736    if (jets_6)
0737      {
0738        // zero out counters
0739 
0740        for (auto jet : *jets_6)
0741      {
0742        if (jet->get_pt() < pt_cut) continue;
0743 
0744        int n_comp_total = 0;
0745        int n_comp_ihcal = 0;
0746        int n_comp_ohcal = 0;
0747        int n_comp_emcal = 0;
0748 
0749        float jet_total_eT = 0;
0750        float eFrac_ihcal = 0;
0751        float eFrac_ohcal = 0;
0752        float eFrac_emcal = 0;
0753        float eFrac_emcal_ind = 0;
0754 
0755        float emcal_tower_max = 0;
0756        b_njet_6++;
0757        b_jet_pt_6.push_back(jet->get_pt());
0758        b_jet_eta_6.push_back(jet->get_eta());
0759        b_jet_phi_6.push_back(jet->get_phi());
0760 
0761        for (int iem = 0; iem < (int) emcal_towers->size(); iem++)
0762          {
0763 
0764            unsigned int calokey = emcal_towers->encode_key(iem);
0765            TowerInfo *tower = emcal_towers->get_tower_at_channel(iem);
0766            if (!tower->get_isGood())
0767          {
0768            continue;
0769          }
0770            int ieta = emcal_towers->getTowerEtaBin(calokey);
0771            int iphi = emcal_towers->getTowerPhiBin(calokey);
0772            const RawTowerDefs::keytype key = RawTowerDefs::encode_towerid(RawTowerDefs::CalorimeterId::CEMC, ieta, iphi);
0773            double tower_phi = tower_geomEM->get_tower_geometry(key)->get_phi();
0774            double tower_eta = tower_geomEM->get_tower_geometry(key)->get_eta();
0775 
0776            double dR = sqrt(TMath::Power(getDPHI(tower_phi, jet->get_phi()), 2) + TMath::Power(tower_eta - jet->get_eta(), 2));
0777            if (dR > 0.6) continue;
0778 
0779            float tower_eT = tower->get_energy() / std::cosh(tower_eta);
0780 
0781            eFrac_emcal_ind += tower_eT;
0782          }     
0783        for (auto comp : jet->get_comp_vec())
0784          {
0785 
0786            unsigned int channel = comp.second;
0787            TowerInfo *tower;
0788            float tower_eT = 0;
0789            if (comp.first == 26 || comp.first == 30)
0790          {  // IHcal
0791            tower = hcalin_towers->get_tower_at_channel(channel);
0792            if (!tower || !tower_geomIH)
0793              {
0794                continue;
0795              }
0796            if(!tower->get_isGood()) continue;
0797 
0798            unsigned int calokey = hcalin_towers->encode_key(channel);
0799 
0800            int ieta = hcalin_towers->getTowerEtaBin(calokey);
0801            int iphi = hcalin_towers->getTowerPhiBin(calokey);
0802            const RawTowerDefs::keytype key = RawTowerDefs::encode_towerid(RawTowerDefs::CalorimeterId::HCALIN, ieta, iphi);
0803            float tower_phi = tower_geomIH->get_tower_geometry(key)->get_phi();
0804            float tower_eta = tower_geomIH->get_tower_geometry(key)->get_eta();
0805            tower_eT = tower->get_energy() / std::cosh(tower_eta);
0806 
0807            if (comp.first == 30)
0808              {  // is sub1
0809                if (has_tower_background)
0810              {
0811                float UE = towBack->get_UE(1).at(ieta);
0812                float tower_UE = UE * (1 + 2 * background_v2 * std::cos(2 * (tower_phi - background_Psi2)));
0813                tower_eT = (tower->get_energy() - tower_UE) / std::cosh(tower_eta);
0814              }
0815              }
0816 
0817            eFrac_ihcal += tower_eT;
0818            jet_total_eT += tower_eT;
0819            n_comp_ihcal++;
0820            n_comp_total++;
0821          }
0822            else if (comp.first == 27 || comp.first == 31)
0823          {  // IHcal
0824            tower = hcalout_towers->get_tower_at_channel(channel);
0825 
0826            if (!tower || !tower_geomOH)
0827              {
0828                continue;
0829              }
0830 
0831            unsigned int calokey = hcalout_towers->encode_key(channel);
0832            int ieta = hcalout_towers->getTowerEtaBin(calokey);
0833            int iphi = hcalout_towers->getTowerPhiBin(calokey);
0834            const RawTowerDefs::keytype key = RawTowerDefs::encode_towerid(RawTowerDefs::CalorimeterId::HCALOUT, ieta, iphi);
0835            float tower_phi = tower_geomOH->get_tower_geometry(key)->get_phi();
0836            float tower_eta = tower_geomOH->get_tower_geometry(key)->get_eta();
0837            tower_eT = tower->get_energy() / std::cosh(tower_eta);
0838 
0839            if (comp.first == 31)
0840              {  // is sub1
0841                if (has_tower_background)
0842              {
0843                float UE = towBack->get_UE(2).at(ieta);
0844                float tower_UE = UE * (1 + 2 * background_v2 * std::cos(2 * (tower_phi - background_Psi2)));
0845                tower_eT = (tower->get_energy() - tower_UE) / std::cosh(tower_eta);
0846              }
0847              }
0848 
0849            eFrac_ohcal += tower_eT;
0850            jet_total_eT += tower_eT;
0851            n_comp_ohcal++;
0852            n_comp_total++;
0853          }
0854            else if (comp.first == 28 || comp.first == 29)
0855          {  // IHcal
0856            tower = emcalre_towers->get_tower_at_channel(channel);
0857 
0858            if (!tower || !tower_geomIH)
0859              {
0860                continue;
0861              }
0862 
0863            unsigned int calokey = emcalre_towers->encode_key(channel);
0864            int ieta = emcalre_towers->getTowerEtaBin(calokey);
0865            int iphi = emcalre_towers->getTowerPhiBin(calokey);
0866            const RawTowerDefs::keytype key = RawTowerDefs::encode_towerid(RawTowerDefs::CalorimeterId::HCALIN, ieta, iphi);
0867            float tower_phi = tower_geomIH->get_tower_geometry(key)->get_phi();
0868            float tower_eta = tower_geomIH->get_tower_geometry(key)->get_eta();
0869            tower_eT = tower->get_energy() / std::cosh(tower_eta);
0870 
0871            if (comp.first == 29)
0872              {  // is sub1
0873                if (has_tower_background)
0874              {
0875                float UE = towBack->get_UE(0).at(ieta);
0876                float tower_UE = UE * (1 + 2 * background_v2 * std::cos(2 * (tower_phi - background_Psi2)));
0877                tower_eT = (tower->get_energy() - tower_UE) / std::cosh(tower_eta);
0878              }
0879              }
0880 
0881            if (tower_eT > emcal_tower_max)
0882              {
0883                emcal_tower_max = tower_eT;
0884              }
0885            eFrac_emcal += tower_eT;
0886            jet_total_eT += tower_eT;
0887            n_comp_emcal++;
0888            n_comp_total++;
0889          }         
0890          }
0891        //      std::cout << n_comp_total << " = " << n_comp_emcal << " " << n_comp_hcalout << " from " << 
0892        b_jet_et_6.push_back(jet_total_eT);
0893        b_jet_emcal_6.push_back(eFrac_emcal);
0894        b_jet_hcalin_6.push_back(eFrac_ihcal);
0895        b_jet_hcalout_6.push_back(eFrac_ohcal);
0896 
0897      }
0898      }
0899 
0900 
0901    // recoJetName = "AntiKt_Tower_r06_Sub1";
0902    // JetContainer *jets_6 = findNode::getClass<JetContainer>(topNode, recoJetName);
0903    // if (jets_6)
0904    //   {
0905    //     // zero out counters
0906 
0907        
0908    //     for (auto jet : *jets_6)
0909    //    {
0910    //      //      if (jet->get_pt() < pt_cut) continue;
0911    //      int n_comp_total = 0;
0912    //      int n_comp_ihcal = 0;
0913    //      int n_comp_ohcal = 0;
0914    //      int n_comp_emcal = 0;
0915 
0916    //      float jet_total_eT = 0;
0917    //      float eFrac_ihcal = 0;
0918    //      float eFrac_ohcal = 0;
0919    //      float eFrac_emcal = 0;
0920 
0921    //      float emcal_tower_max = 0;
0922    //      b_njet_6++;
0923    //      b_jet_pt_6.push_back(jet->get_pt());
0924    //      b_jet_eta_6.push_back(jet->get_eta());
0925    //      b_jet_phi_6.push_back(jet->get_phi());
0926    //      b_jet_mass_6.push_back(jet->get_mass());
0927    //      for (auto comp : jet->get_comp_vec())
0928    //        {
0929    //          unsigned int channel = comp.second;
0930    //          TowerInfo *tower;
0931 
0932    //          float tower_eT = 0;
0933    //          if (comp.first == 26 || comp.first == 30)
0934    //        {  // IHcal
0935    //          tower = hcalin_towers->get_tower_at_channel(channel);
0936    //          if (!tower || !tower_geomIH)
0937    //            {
0938    //              continue;
0939    //            }
0940    //          if(!tower->get_isGood()) continue;
0941 
0942    //          unsigned int calokey = hcalin_towers->encode_key(channel);
0943    //          int ieta = hcalin_towers->getTowerEtaBin(calokey);
0944    //          int iphi = hcalin_towers->getTowerPhiBin(calokey);
0945    //          const RawTowerDefs::keytype key = RawTowerDefs::encode_towerid(RawTowerDefs::CalorimeterId::HCALIN, ieta, iphi);
0946    //          float tower_phi = tower_geomIH->get_tower_geometry(key)->get_phi();
0947    //          float tower_eta = tower_geomIH->get_tower_geometry(key)->get_eta();
0948    //          tower_eT = tower->get_energy() / std::cosh(tower_eta);
0949 
0950    //          if (comp.first == 30)
0951    //            {  // is sub1
0952    //              if (has_tower_background)
0953    //            {
0954    //              float UE = towBack->get_UE(1).at(ieta);
0955    //              float tower_UE = UE * (1 + 2 * background_v2 * std::cos(2 * (tower_phi - background_Psi2)));
0956    //              tower_eT = (tower->get_energy() - tower_UE) / std::cosh(tower_eta);
0957    //            }
0958    //            }
0959 
0960    //          eFrac_ihcal += tower_eT;
0961    //          jet_total_eT += tower_eT;
0962    //          n_comp_ihcal++;
0963    //          n_comp_total++;
0964    //        }
0965    //          else if (comp.first == 27 || comp.first == 31)
0966    //        {  // IHcal
0967    //          tower = hcalout_towers->get_tower_at_channel(channel);
0968 
0969    //          if (!tower || !tower_geomOH)
0970    //            {
0971    //              continue;
0972    //            }
0973 
0974    //          unsigned int calokey = hcalout_towers->encode_key(channel);
0975    //          int ieta = hcalout_towers->getTowerEtaBin(calokey);
0976    //          int iphi = hcalout_towers->getTowerPhiBin(calokey);
0977    //          const RawTowerDefs::keytype key = RawTowerDefs::encode_towerid(RawTowerDefs::CalorimeterId::HCALOUT, ieta, iphi);
0978    //          float tower_phi = tower_geomOH->get_tower_geometry(key)->get_phi();
0979    //          float tower_eta = tower_geomOH->get_tower_geometry(key)->get_eta();
0980    //          tower_eT = tower->get_energy() / std::cosh(tower_eta);
0981 
0982    //          if (comp.first == 31)
0983    //            {  // is sub1
0984    //              if (has_tower_background)
0985    //            {
0986    //              float UE = towBack->get_UE(2).at(ieta);
0987    //              float tower_UE = UE * (1 + 2 * background_v2 * std::cos(2 * (tower_phi - background_Psi2)));
0988    //              tower_eT = (tower->get_energy() - tower_UE) / std::cosh(tower_eta);
0989    //            }
0990    //            }
0991 
0992    //          eFrac_ohcal += tower_eT;
0993    //          jet_total_eT += tower_eT;
0994    //          n_comp_ohcal++;
0995    //          n_comp_total++;
0996    //        }
0997    //          else if (comp.first == 28 || comp.first == 29)
0998    //        {  // IHcal
0999    //          tower = emcalre_towers->get_tower_at_channel(channel);
1000 
1001    //          if (!tower || !tower_geomIH)
1002    //            {
1003    //              continue;
1004    //            }
1005 
1006    //          unsigned int calokey = emcalre_towers->encode_key(channel);
1007    //          int ieta = emcalre_towers->getTowerEtaBin(calokey);
1008    //          int iphi = emcalre_towers->getTowerPhiBin(calokey);
1009    //          const RawTowerDefs::keytype key = RawTowerDefs::encode_towerid(RawTowerDefs::CalorimeterId::HCALIN, ieta, iphi);
1010    //          float tower_phi = tower_geomIH->get_tower_geometry(key)->get_phi();
1011    //          float tower_eta = tower_geomIH->get_tower_geometry(key)->get_eta();
1012    //          tower_eT = tower->get_energy() / std::cosh(tower_eta);
1013 
1014    //          if (comp.first == 29)
1015    //            {  // is sub1
1016    //              if (has_tower_background)
1017    //            {
1018    //              float UE = towBack->get_UE(0).at(ieta);
1019    //              float tower_UE = UE * (1 + 2 * background_v2 * std::cos(2 * (tower_phi - background_Psi2)));
1020    //              tower_eT = (tower->get_energy() - tower_UE) / std::cosh(tower_eta);
1021    //            }
1022    //            }
1023 
1024    //          if (tower_eT > emcal_tower_max)
1025    //            {
1026    //              emcal_tower_max = tower_eT;
1027    //            }
1028    //          eFrac_emcal += tower_eT;
1029    //          jet_total_eT += tower_eT;
1030    //          n_comp_emcal++;
1031    //          n_comp_total++;
1032    //        }         
1033    //        }
1034    //      emcal_tower_max /= eFrac_emcal;
1035    //      eFrac_ihcal /= jet_total_eT;
1036    //      eFrac_ohcal /= jet_total_eT;
1037    //      eFrac_emcal /= jet_total_eT;
1038 
1039    //      b_jet_et_6.push_back(jet_total_eT);
1040    //      b_jet_emcal_tower_frac_6.push_back(emcal_tower_max);
1041    //      b_jet_emcal_frac_6.push_back(eFrac_emcal);
1042    //      b_jet_hcalin_frac_6.push_back(eFrac_ihcal);
1043    //      b_jet_hcalout_frac_6.push_back(eFrac_ohcal);
1044 
1045    //    }
1046    //   }
1047    if (Verbosity()) std::cout << __FILE__ << " "<< __LINE__<<" "<<std::endl;
1048    
1049    _tree->Fill();
1050    
1051    return Fun4AllReturnCodes::EVENT_OK;
1052 }
1053 
1054 
1055 
1056 void CaloEmulatorTreeMaker::GetNodes(PHCompositeNode* topNode)
1057 {
1058 
1059 
1060 }
1061 
1062 int CaloEmulatorTreeMaker::ResetEvent(PHCompositeNode *topNode)
1063 {
1064   if (Verbosity() > 0)
1065     {
1066       std::cout << "CaloEmulatorTreeMaker::ResetEvent(PHCompositeNode *topNode) Resetting internal structures, prepare for next event" << std::endl;
1067     }
1068 
1069 
1070   return Fun4AllReturnCodes::EVENT_OK;
1071 }
1072 
1073 //____________________________________________________________________________..
1074 int CaloEmulatorTreeMaker::EndRun(const int runnumber)
1075 {
1076   if (Verbosity() > 0)
1077     {
1078       std::cout << "CaloEmulatorTreeMaker::EndRun(const int runnumber) Ending Run for Run " << runnumber << std::endl;
1079     }
1080   return Fun4AllReturnCodes::EVENT_OK;
1081 }
1082 
1083 //____________________________________________________________________________..
1084 int CaloEmulatorTreeMaker::End(PHCompositeNode *topNode)
1085 {
1086   if (Verbosity() > 0)
1087     {
1088       std::cout << "CaloEmulatorTreeMaker::End(PHCompositeNode *topNode) This is the End..." << std::endl;
1089     }
1090   std::cout<<"Total events: "<<_i_event<<std::endl;
1091   _f->Write();
1092   _f->Close();
1093 
1094   return Fun4AllReturnCodes::EVENT_OK;
1095 }
1096 
1097 //____________________________________________________________________________..
1098 int CaloEmulatorTreeMaker::Reset(PHCompositeNode *topNode)
1099 {
1100   if (Verbosity() > 0)
1101     {
1102       std::cout << "CaloEmulatorTreeMaker::Reset(PHCompositeNode *topNode) being Reset" << std::endl;
1103     }
1104   return Fun4AllReturnCodes::EVENT_OK;
1105 }
1106 
1107 Double_t CaloEmulatorTreeMaker::getDPHI(Double_t phi1, Double_t phi2) {
1108   Double_t dphi = phi1 - phi2;
1109 
1110   //3.141592653589
1111   if ( dphi > TMath::Pi() )
1112     dphi = dphi - 2. * TMath::Pi();
1113   if ( dphi <= -TMath::Pi() )
1114     dphi = dphi + 2. * TMath::Pi();
1115 
1116   if ( TMath::Abs(dphi) > TMath::Pi() ) {
1117     std::cout << " commonUtility::getDPHI error!!! dphi is bigger than TMath::Pi() " << std::endl;
1118     std::cout << " " << phi1 << ", " << phi2 << ", " << dphi << std::endl;
1119   }
1120 
1121   return dphi;
1122 }