//////////////////////////////////////////////////////////////////////////
// //
// ATLFast //
// //
// Main class to control the ATLFast program. //
// //
// This class is a complete redesign of the Fortran program ATLfast. //
// This class is a general framework for programs that needs to: //
// - Initialise some parameters //
// - Loop on events //
// - Print results and save histograms, etc //
// //
// The event processor ATLFast::Make loops on a list of Makers //
// where each maker performs some task on the event data and generates //
// results. //
// New Makers can be inserted by a user without modifying this class. //
// Note that the order in which the Makers are called is the order //
// of insertion in the list of Makers. //
// Each Maker is responsible for creating its branch of the Tree. //
// The following table shows the list of makers currently implemented //
// The default option to Save the Maker info in the Tree is mentioned. //
// //
// Maker name Save in Tree //
// ========== ============ //
// MCMaker NO //
// ClusterMaker YES //
// ElectronMaker YES //
// MuonMaker YES //
// PhotonMaker YES //
// JetMaker YES //
// TrackMaker NO //
// TriggerMaker YES //
// MiscMaker YES //
// //
// Makers must derive from the base class ATLFMaker. //
// ATLFMaker provides a common interface to all Makers. //
// Each Maker is responsible for defining its own parameters and //
// histograms. //
// Each Maker has its own list of histograms. //
// Each Maker has an associated companion class corresponding to the //
// type of physics object reconstructed by the Maker. //
// For example, ATLFClusterMaker creates ATLFCluster objects. //
// ATLFTriggerMaker creates one single ATLFTrigger object. //
// The pointer supporting the created object(s) is defined in ATLFMaker //
// m_Fruits may point to a single object (eg. ATLFTrigger) or to a //
// TClonesArray of objects (eg. ATLFCluster). //
// //
// The function ATLFast::Maketree must be called after the creation //
// of the ATLFast object to create a Root Tree. //
// //
// An example of main program/macro to use ATLFast is given below: //
//========================================================================
//void umain(Int_t nevents=100)
//{
// gROOT->Reset();
// gSystem->Load("libatlfast.so"); // dynamically link the compiled shared library
//
// // Open the root output file
// TFile file("atlfast.root","recreate","ATLFast root file",2);
//
// ATLFast atlfast("atlfast"); // create main object to run atlfast
//
// User user; // create an object of the User class defined in user.C
//
// atlfast.Init(); // Initialise event (maker histograms,etc)
// atlfast.MakeTree(); // Create the Root tree
//
// gROOT->LoadMacro("user.C"); // compile/interpret user file
//
// for (Int_t i=0; i<nevents; i++) {
// if (i%100 == 0) printf("In loop:%dn",i);
// atlfast.Make(i); // Generate and reconstruct event
// user.FillHistograms(); // User has possibility to decide if store event here!
// atlfast.FillTree();
// atlfast.Clear(); // Clear all event lists
// }
// atlfast.Finish();
//
// // save objects in Root file
// atlfast.Write(); //save main atlfast object (and run parameters)
//}
//========================================================================
// //
// This example illustrates how to: //
// - Load a shared library //
// - Open a Root file //
// - Initialise ATLFast //
// - Load some user code (interpreted) //
// This user code may redefine some Maker parameters //
// - Make a loop on events //
// - Save histograms and the main ATLFast object and its Makers //
// //
//========================================================================
// An example of a User class is given below: //
//========================================================================
//
//#ifndef user_H
//#define user_H
//
//////////////////////////////////////////////////////////////////////////
// //
// User //
// //
// Example of a user class to perform user specific tasks when running //
// the ATLfast program. //
// //
// This class illustrates: //
// - How to set run parameters //
// - How to create and fill histograms //
// //
//////////////////////////////////////////////////////////////////////////
//
//class TH1F;
//class ATLFast;
//class ATLFClusterMaker;
//class ATLFPhotonMaker;
//
//class User {
//
//private:
// TH1F *m_hist1; //pointer to histogram
// TH1F *m_hist2; //pointer to histogram
// TH1F *m_hist3; //pointer to histogram
//public:
// User();
// void FillHistograms();
// void SetRunParameters();
//
//#endif
//};
//
//_________________________________________________________________________
//User::User()
//{
// SetRunParameters(); //change default parameters
//
// Create a few histograms
// m_hist1 = new TH1F("hist1","Number of tracks per event",100,0,100);
// m_hist2 = new TH1F("hist2","Number of clusters",100,0,100);
// m_hist3 = new TH1F("hist3","Number of isolated muons",20,0,20);
//}
//
//_________________________________________________________________________
//void User::FillHistograms()
//{
//// m_hist1.Fill(event->GetNtracks());
//// m_hist2.Fill(event->GetNclusters));
//// m_hist3.Fill(event->GetNIsoMuons());
//}
//
//_________________________________________________________________________
//void User::SetRunParameters()
//{
// // change ATLfast default parameters
//
// gATLFast->SetSmearMuonOpt(0);
// gATLFast->ClusterMaker()->SetGranBarrelEta(0.12);
// gATLFast->PhotonMaker()->SetMinPT(6.);
// gATLFast->TriggerMaker()->SetMuoEtaCoverage(2.8);
//
//}
//======================end of User class=================================
//
//////////////////////////////////////////////////////////////////////////
#include <TROOT.h>
#include <TChain.h>
#include <TTree.h>
#include <TBrowser.h>
#include <TClonesArray.h>
#include "ATLFast.h"
#include "ATLFMCMaker.h"
#include "ATLFClusterMaker.h"
#include "ATLFElectronMaker.h"
#include "ATLFMuonMaker.h"
#include "ATLFPhotonMaker.h"
#include "ATLFJetMaker.h"
#include "ATLFTrackMaker.h"
#include "ATLFTriggerMaker.h"
#include "ATLFMiscMaker.h"
#include "ATLFHistBrowser.h"
#include "ATLFBigBang.h"
#include "ATLFVirtualDisplay.h"
ATLFast *gATLFast;
ClassImp(ATLFast)
//_____________________________________________________________________________
ATLFast::ATLFast() : TNamed("atlfast","The ATLAS fast simulation")
{
m_Tree = 0;
m_Makers = 0;
m_Mode = 0;
m_MCMaker = 0;
m_ClusterMaker = 0;
m_ElectronMaker = 0;
m_MuonMaker = 0;
m_PhotonMaker = 0;
m_JetMaker = 0;
m_TrackMaker = 0;
m_TriggerMaker = 0;
m_MiscMaker = 0;
m_Display = 0;
}
//_____________________________________________________________________________
ATLFast::ATLFast(const char *name, const char *title)
: TNamed(name,title)
{
gATLFast = this;
m_Version = 100; //ATLFAST version number and release date
m_VersionDate = 300897;
m_Tree = 0;
m_Mode = 0;
m_Display = 0;
SetDefaultParameters();
gROOT->GetListOfBrowsables()->Add(this,"ATLFast");
// create the support list for the various lists of ATLFast objects
m_Makers = new TList();
// create "standard" makers and add them to the list of makers (in ATLFMaker constructor
// Note that the order in which makers are added to the list of makers is important
// makers will be processed in this order !!
m_MCMaker = new ATLFMCMaker("MCMaker","Make MC events");
m_ClusterMaker = new ATLFClusterMaker("ClusterMaker","Make ATLFast clusters");
m_MuonMaker = new ATLFMuonMaker("MuonMaker","Make ATLFast muons");
m_ElectronMaker = new ATLFElectronMaker("ElectronMaker","Make ATLFast electrons");
m_PhotonMaker = new ATLFPhotonMaker("PhotonMaker","Make ATLFast photons");
m_JetMaker = new ATLFJetMaker("JetMaker","Make ATLFast jets");
m_MiscMaker = new ATLFMiscMaker("MiscMaker","Make ATLFast miscelaneous");
m_TriggerMaker = new ATLFTriggerMaker("TriggerMaker","Make ATLFast trigger");
m_TrackMaker = new ATLFTrackMaker("TrackMaker","Make ATLFast tracks");
}
//_____________________________________________________________________________
ATLFast::~ATLFast()
{
// m_Makers->Delete();
// delete m_Makers;
}
//______________________________________________________________________________
void ATLFast::Browse(TBrowser *b)
{
if( b == 0) return;
if (m_Tree) b->Add(m_Tree,m_Tree->GetName());
b->Add(&m_HistBrowser, "Histograms");
b->Add(&m_BigBang, "BigBang");
TIter next(m_Makers);
ATLFMaker *maker;
while ((maker = (ATLFMaker*)next())) {
b->Add(maker,maker->GetName());
}
}
//_____________________________________________________________________________
void ATLFast::Clear(Option_t *option)
{
// Reset lists of event objects
TIter next(m_Makers);
ATLFMaker *maker;
while ((maker = (ATLFMaker*)next())) {
maker->Clear(option);
}
if (m_Display) m_Display->Clear();
}
//_____________________________________________________________________________
void ATLFast::Draw(Option_t *option)
{
// Insert current event in graphics pad list
// Check if the Event Display object has been created
if (!m_Display) {
Error("Draw","You must create an ATLFDisplay object first");
return;
}
m_Display->Draw(option);
}
//_____________________________________________________________________________
void ATLFast::GetEvent(Int_t event)
{
// Read event from Tree
if (m_Tree) m_Tree->GetEvent(event);
m_Event = event;
}
//_____________________________________________________________________________
void ATLFast::Init()
{
// Initialise makers
TIter next(m_Makers);
ATLFMaker *maker;
TObject *objfirst, *objlast;
while ((maker = (ATLFMaker*)next())) {
// save last created histogram in current Root directory
objlast = gDirectory->GetList()->Last();
// Initialise maker
maker->Init();
// Add Maker histograms in Maker list of histograms
if (objlast) objfirst = gDirectory->GetList()->After(objlast);
else objfirst = gDirectory->GetList()->First();
while (objfirst) {
maker->Histograms()->Add(objfirst);
objfirst = gDirectory->GetList()->After(objfirst);
}
}
}
//_____________________________________________________________________________
void ATLFast::Paint(Option_t *option)
{
// Paint ATLFast objects
m_Display->Paint(option);
}
//_____________________________________________________________________________
void ATLFast::PrintInfo()
{
// Gives information about versions etc.
printf("n\n");
printf("**************************************************************n");
printf("* ATLFast version:%3d released at %6d *n",m_Version, m_VersionDate);
printf("**************************************************************n");
printf("* *n");
printf("* Analyses event on particle level *n");
printf("* Simulation package by: *n");
printf("* E. Richter-Was, D. Froidevaux, L. Poggioli *n");
printf("* *n");
printf("* Contributed code: *n");
printf("* - L. Chevalier, M. Virchaux, C. Guyot --> *n");
printf("* muon pT resolution (in ATLFAST) *n");
printf("* *n");
printf("* - E. Arik and S. Cetin --> *n");
printf("* muon trigger efficiency (in ATLFAST and ATLFAST-B) *n");
printf("* *n");
printf("* - E. Reinchold, R. Dunkers, E.J.Buis --> *n");
printf("* helix parameter resolution (in ATLFAST) *n");
printf("* *n");
printf("* - G. F. Tartarelli --> *n");
printf("* helix parameter reconstruction (in ATLFAST) *n");
printf("* *n");
printf("* - D. Cavalli and S. Resconi --> *n");
printf("* tau-tagging effciency (in ATLFAST-B) *n");
printf("* *n");
printf("* - E. Ross --> *n");
printf("* b-tagging effciency (in ATLFAST-B) *n");
printf("* *n");
printf("* - S. Klyukhin, J. Soderqvist --> *n");
printf("* interface to HERWIG and ISAJET (in ATLFAST) *n");
printf("* *n");
printf("* - J. Soderqvist --> *n");
printf("* trust,oblateness,circularity calc.(in ATLFAST) *n");
printf("* *n");
printf("* - M. Stravrianakou --> *n");
printf("* ntuples format (in ATLFAST) *n");
printf("**************************************************************n");
printf("n\n");
// Print info for all defined Makers
TIter next(m_Makers);
ATLFMaker *maker;
while ((maker = (ATLFMaker*)next())) {
maker->PrintInfo();
}
}
//_____________________________________________________________________________
void ATLFast::FillTree()
{
// Fill the ROOT tree, looping on all active branches
// Clean generated particles (depending on option Save)
MCMaker()->CleanParticles();
// Now ready to fill the Root Tree
if(m_Tree) m_Tree->Fill();
}
//_____________________________________________________________________________
void ATLFast::InitChain(TChain *chain)
{
// Initialize branch addresses for all makers in a TChain
if (chain == 0) return;
m_Tree = chain;
TIter next(m_Makers);
ATLFMaker *maker;
while ((maker = (ATLFMaker*)next())) {
maker->SetChainAddress(chain);
}
}
//_____________________________________________________________________________
void ATLFast::MakeTree(const char* name, const char*title)
{
// Create a ROOT tree
// Loop on all makers to create the Root branch (if any)
if (m_Tree) return;
m_Tree = new TTree(name,title);
TIter next(m_Makers);
ATLFMaker *maker;
while ((maker = (ATLFMaker*)next())) {
maker->MakeBranch();
}
}
//_____________________________________________________________________________
void ATLFast::SetDefaultParameters()
{
// Setters for flags and switches
SetLuminosity();
SetBfield();
SetSmearing();
SetSmearMuonOpt();
SetSmearMuonFun();
SetSUSYcodeLSP();
SetTrackFinding();
}
//_____________________________________________________________________________
Int_t ATLFast::Make(Int_t i)
{
m_Event = i;
// Loop on all makers
Int_t ret;
TIter next(m_Makers);
ATLFMaker *maker;
while ((maker = (ATLFMaker*)next())) {
ret = maker->Make();
if (ret < 0) return ret;
}
return 0;
}
//_____________________________________________________________________________
void ATLFast::FillClone()
{
// Fill Makers fruits clones
TIter next(m_Makers);
ATLFMaker *maker;
while ((maker = (ATLFMaker*)next())) {
maker->FillClone();
}
}
//_____________________________________________________________________________
void ATLFast::Finish()
{
// Terminate a run
// place to make operations on histograms, normalization,etc.
TIter next(m_Makers);
ATLFMaker *maker;
while ((maker = (ATLFMaker*)next())) {
maker->Finish();
}
}
//_____________________________________________________________________________
void ATLFast::SortDown(Int_t n1, Float_t *a, Int_t *index, Bool_t down)
{
// sort the n1 elements of array a.
// In output the array index contains the indices of the sorted array.
// if down is false sort in increasing order (default is decreasing order)
// This is a translation of the CERNLIB routine sortzv (M101)
// based on the quicksort algorithm
Int_t i,i1,n,i2,i3,i33,i222,iswap,n2;
Int_t i22 = 0;
Float_t ai;
n = n1;
if (n <= 0) return;
if (n == 1) {index[0] = 0; return;}
for (i=0;i<n;i++) index[i] = i+1;
for (i1=2;i1<=n;i1++) {
i3 = i1;
i33 = index[i3-1];
ai = a[i33-1];
while(1) {
i2 = i3/2;
if (i2 <= 0) break;
i22 = index[i2-1];
if (ai <= a[i22-1]) break;
index[i3-1] = i22;
i3 = i2;
}
index[i3-1] = i33;
}
while(1) {
i3 = index[n-1];
index[n-1] = index[0];
ai = a[i3-1];
n--;
if(n-1 < 0) {index[0] = i3; break;}
i1 = 1;
while(2) {
i2 = i1+i1;
if (i2 <= n) i22 = index[i2-1];
if (i2-n > 0) {index[i1-1] = i3; break;}
if (i2-n < 0) {
i222 = index[i2];
if (a[i22-1] - a[i222-1] < 0) {
i2++;
i22 = i222;
}
}
if (ai - a[i22-1] > 0) {index[i1-1] = i3; break;}
index[i1-1] = i22;
i1 = i2;
}
}
if (!down) return;
n2 = n1/2;
for (i=0;i<n1;i++) index[i]--;
for (i=0;i<n2;i++) {
iswap = index[i];
index[i] = index[n1-i-1];
index[n1-i-1] = iswap;
}
}
//______________________________________________________________________________
void ATLFast::Streamer(TBuffer &R__b)
{
// Stream an object of class ATLFast.
if (R__b.IsReading()) {
R__b.ReadVersion(); // Version_t R__v = R__b.ReadVersion();
TNamed::Streamer(R__b);
if (!gATLFast) gATLFast = this;
gROOT->GetListOfBrowsables()->Add(this,"ATLFast");
R__b >> m_Version;
R__b >> m_VersionDate;
R__b >> m_Run;
R__b >> m_Event;
R__b >> m_Mode;
m_Tree = (TTree*)gDirectory->Get("T");
R__b >> m_Makers;
R__b >> m_MCMaker;
R__b >> m_ClusterMaker;
R__b >> m_ElectronMaker;
R__b >> m_MuonMaker;
R__b >> m_PhotonMaker;
R__b >> m_JetMaker;
R__b >> m_TrackMaker;
R__b >> m_TriggerMaker;
R__b >> m_MiscMaker;
R__b >> m_Luminosity;
R__b >> m_Bfield;
R__b >> m_Smearing;
R__b >> m_SmearMuonFun;
R__b >> m_SmearMuonOpt;
R__b >> m_SUSYcodeLSP;
R__b >> m_TrackFinding;
m_HistBrowser.Streamer(R__b);
} else {
R__b.WriteVersion(ATLFast::IsA());
TNamed::Streamer(R__b);
R__b << m_Version;
R__b << m_VersionDate;
R__b << m_Run;
R__b << m_Event;
R__b << m_Mode;
m_Tree->Write();
R__b << m_Makers;
R__b << m_MCMaker;
R__b << m_ClusterMaker;
R__b << m_ElectronMaker;
R__b << m_MuonMaker;
R__b << m_PhotonMaker;
R__b << m_JetMaker;
R__b << m_TrackMaker;
R__b << m_TriggerMaker;
R__b << m_MiscMaker;
R__b << m_Luminosity;
R__b << m_Bfield;
R__b << m_Smearing;
R__b << m_SmearMuonFun;
R__b << m_SmearMuonOpt;
R__b << m_SUSYcodeLSP;
R__b << m_TrackFinding;
m_HistBrowser.Streamer(R__b);
}
}
ROOT page - Class index - Top of the page
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.