Giter VIP home page Giter VIP logo

loopcode's Introduction

myplots is an example of making plots from ntupels.


SampleInfo.h is a class that stores all information you need for a sample. It has the path to the rootfile, but also the name of the sample, x-section .... This can generally be used and extended as desired.

SUSYLooperHists loops over a ntupel (TTree) to make plots and gets all the information it needs from SampleInfo for each sample. From any Ttree one can make automated code for looping using makeClass(). SUSYLooperHists is such a code with minor modification and some examples of plots. You can make your oen makeClass code and than apply the modification neede are described below. I.e. if you have a different TTree just add these modifications to the automated code.

myplots uses the above two classes to make loops over some samples (ntupels) and overlays the plots. 

When running the code make sure your root version understand eos and or you use only local samples. The example pathes to rootfiles (.root) need of course to be adopted.


_______________________________________________________________________________________________________
changes to makeClass code, e.g. XYZ.C 


// defaults  from makeClass() that need to be changed

class XYZ {

 public:
...
  void      Loop(); // return nothing
...

}

XYZ::XYZ(TTree *tree) : fChain(0) // need to give it a tree
{
// if parameter tree is not specified (or zero), connect the file
// used to generate this class and read the Tree.
   if (tree == 0) {
      TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject("XYZ.root"); 
      if (!f || !f->IsOpen()) {
         f = new TFile("data.root");
      }
      f->GetObject("XYZ",tree);

   }
   Init(tree);
}


Here the changes for SUSYLooperHists!!

//*** return a TFile pointer for the loop, allows to handle the  TFile withplots afterwards easily***
// add this +++++ to header
#include "SampleInfo.h" 
#include <TString.h>

class SUSYLooperHists {

// add this +++++ (members)
 private:
  TString outputFileName;
  float weight;
//  ++++++++

...
  TFile*      Loop();// returns Tfile with plots: replace void  Loop();
  susySoftLepton(SampleInfo mySample);// constructor that takes sample info as input: replace default contructor susySoftLepton(TTree *tree=0);
...

}

// *** get all the information like x-section weigt, rootfile path from class SampleInfo ***
SUSYLooperHists::SUSYLooperHists(SampleInfo mySample)// need to give it a SampleInfo
{

  TFile *f = TFile::Open(mySample.FilePath);
  TTree* tree = (TTree*) f->Get(YOURTREENAME); 
  outputFileName = mySample.OutputFileNameTag+".root";
  weight = mySample.weight();
  Init(tree);
  cout << "looping over: \""<< mySample.FilePath<< "\" to put plots into: \""<< outputFileName<<"\""<<endl;;

}

loopcode's People

Watchers

James Cloos avatar Markus Stoye avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.