Best practice for a class with many member variables

short question: If you should have many (even more than 200) member variables (each of them will be the plot of some physical interest in our analysis). What is the best place to declare these variables?

long explanation: The structure that I use for my analysis creates a class for iterating over events, it can be narrowed down to

constructor()
initialize()
execute()
finalize()

In the header you should indicate pointers like this (this is apparently a requirement of the package ROOTwe should use):

std::vector<double> *m_jet_pt;

and a pointer to the histogram class:

TH1F *h_jet_pt;

then constructoryou need to initialize pointers to some specific memory address (as far as I understand, this is for subsequent reading data from a file)

constructor()
{
  // this is data, will be associated to a TTree later
  m_jet_pt = 0;

  // this is a histogram
  h_jet_pt = new TH1F("name", "title", nbins, min_bin, max_bin); 
}

initialize , , , , ( , , ):

TFile *file = new TFile("filename.root");

// The tree is where the data is (for some reason ROOT uses C style casts)
TTree *tree = (TTree*)file->Get("MyTree");

// this is how to set the address of the member class pointer
// to point to the data in the tree:
tree->SetBranchAddress("m_jet_pt", &jet_pt);

execute , , ,

execute()
{
  // I omit here where the `i` index comes from as not relevant
  if(m_jet_pt->at(i) > 30)

    h_jet_pt->Fill();
}

, , finalize , , ,

finalize()
{
  h_jet_pt->Write();
}

immagine 20 jets, 30 electrons, 30 muons .., , - ! , , , ? , !

+4
1

ROOT / / TTree. , , , "" "". , . 200 -POD- . , ROOT , , , stl- .

, TTree :

tree->Branch(branchname, className, &p_object, bufsize, splitlevel)

. B: https://root.cern.ch/doc/master/classTTree.html

, ROOT , . TTree, Fill() GetEntry(), , , .

0

All Articles