File indexing completed on 2025-08-05 08:21:37
0001 #include "AnalyzeSimpleTree.h"
0002 #include "MySimpleTree.h"
0003 #include "MyTClonesArray.h"
0004
0005 #include <fun4all/Fun4AllServer.h>
0006 #include <fun4all/Fun4AllHistoManager.h>
0007 #include <fun4all/Fun4AllReturnCodes.h>
0008
0009 #include <phool/getClass.h>
0010 #include <phool/PHCompositeNode.h>
0011
0012 #include <TH1.h>
0013 #include <TH2.h>
0014
0015 AnalyzeSimpleTree::AnalyzeSimpleTree(const std::string &name): SubsysReco(name)
0016 {
0017 return ;
0018 }
0019
0020 int
0021 AnalyzeSimpleTree::Init(PHCompositeNode * )
0022 {
0023 Fun4AllServer *se = Fun4AllServer::instance();
0024
0025
0026
0027
0028
0029
0030 hm = new Fun4AllHistoManager("MYHISTOS");
0031 se->registerHistoManager(hm);
0032 myfloats = new TH1F("myfloats", "these are stupid floats", 201, -0.5, 200);
0033 my2dfloats = new TH2F("my2dfloats", "these floats are stupid in 2d", 201, -0.5, 199.5, 201, -0.5, 199.5);
0034
0035
0036 hm->registerHisto(myfloats);
0037 hm->registerHisto(my2dfloats);
0038 return 0;
0039 }
0040
0041 int
0042 AnalyzeSimpleTree::process_event(PHCompositeNode *topNode)
0043 {
0044
0045 MySimpleTree *mytree = findNode::getClass<MySimpleTree>(topNode, "MYSIMPLETREE");
0046 myfloats->Fill(mytree->MyFloat());
0047
0048
0049 MyTClonesArray *mycontainer = findNode::getClass<MyTClonesArray>(topNode, "MYTCARRAY");
0050 for (int j = 0; j < mycontainer->Entries();j++)
0051 {
0052 MySimpleTree *item = mycontainer->GetItem(j);
0053 my2dfloats->Fill(mytree->MyFloat(), item->MyFloat());
0054 }
0055 return Fun4AllReturnCodes::EVENT_OK;
0056 }
0057
0058 int AnalyzeSimpleTree::End(PHCompositeNode * )
0059 {
0060 hm->dumpHistos("myhistos.root");
0061 return Fun4AllReturnCodes::EVENT_OK;
0062 }