Fork me on GitHub

Changeset 84 in svn


Ignore:
Timestamp:
Dec 4, 2008, 1:11:27 PM (16 years ago)
Author:
uid677
Message:

add output tree to example

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Examples/Analysis_Ex.cpp

    r81 r84  
    7272  //*********************Output root file of the analysis************************
    7373  //*****************************************************************************
    74   TString outputFile(argv[2]);
    75  
    7674  ExRootTreeReader *treeReaderGen = new ExRootTreeReader(&chainGen);
    7775  ExRootTreeReader *treeReaderRec = new ExRootTreeReader(&chainRec);
     
    8482  ofstream f_out(LogName.c_str(),ofstream::app);
    8583
     84  //create the output tree
     85  string outputfilename = argv[2];
     86  TFile *outputFile = TFile::Open(outputfilename.c_str(), "RECREATE"); // Creates the file, but should be closed just after
     87  outputFile->Close();
     88
     89  ExRootTreeWriter *treeWriter = new ExRootTreeWriter(outputfilename, "Analysis");
     90
    8691  //*****************************************************************************
    8792  //***************************Run the analysis**********************************
     
    8994
    9095  Analysis_Ex *DefaultOne = new  Analysis_Ex("Examples/Datacard_Analysis_Ex.dat",LogName);
    91   DefaultOne->Run(treeReaderGen,treeReaderRec,treeReaderTrig);
     96  DefaultOne->Run(treeReaderGen,treeReaderRec,treeReaderTrig,treeWriter);
    9297  DefaultOne->WriteOutput(LogName);
    9398  delete DefaultOne;
  • trunk/Examples/interface/Analysis_Ex.h

    r81 r84  
    3535  ~Analysis_Ex();
    3636 
    37   void Run(ExRootTreeReader *treeReaderGen, ExRootTreeReader *treeReaderRec, ExRootTreeReader *treeReaderTrig);//Analyze de l'event
     37  void Run(ExRootTreeReader *treeReaderGen, ExRootTreeReader *treeReaderRec, ExRootTreeReader *treeReaderTrig, ExRootTreeWriter *treeWriter);//Analyze de l'event
    3838  void WriteOutput(string LogName);
    3939
     
    5151};
    5252
     53//------------------------------------------------------------------------------
     54
     55class TRootInvm: public TObject
     56{
     57public:
     58
     59Float_t M;
     60
     61  ClassDef(TRootInvm, 1)
     62};
     63
     64
    5365#endif
  • trunk/Examples/src/Analysis_Ex.cc

    r81 r84  
    4444}
    4545
    46 void Analysis_Ex::Run(ExRootTreeReader *treeReaderGen, ExRootTreeReader *treeReaderRec, ExRootTreeReader *treeReaderTrig)
     46void Analysis_Ex::Run(ExRootTreeReader *treeReaderGen, ExRootTreeReader *treeReaderRec, ExRootTreeReader *treeReaderTrig, ExRootTreeWriter *treeWriter)
    4747{
    4848  total=0;//initialisation of total number of events
     
    7070  //to get the trigger information
    7171  const TClonesArray *TRIGGER  = treeReaderTrig->UseBranch("TrigResult");
    72  
     72
     73  //Define the branches that will be filled during the analysis
     74  ExRootTreeBranch *INVMASS = treeWriter->NewBranch("INVMass", TRootInvm::Class());
     75  TRootInvm *inv_mass;
    7376  //*******************************************
    7477 
     
    296299     for(Int_t k = numElec; k < (numElec+mu.GetEntries()); k++)Lept[k].SetPxPyPzE(mu[k-numElec]->Px,mu[k-numElec]->Py,mu[k-numElec]->Pz,mu[k-numElec]->E);
    297300   
     301     //Example how to white a branch in the output file
     302     inv_mass=(TRootInvm*) INVMASS->NewEntry();
     303     inv_mass->M=(Lept[0]+Lept[1]).M();
     304 
    298305     if((Lept[0]+Lept[1]).M() > INV_MASS_LL )continue;// the invariant mass should be < INV_MASS_LL
    299306     cut_2++;//event accepted
     307
     308     treeWriter->Fill();
    300309   }
     310 treeWriter->Write();
    301311
    302312}
     
    350360}
    351361
    352 
  • trunk/Makefile

    r83 r84  
    101101        src/TreeClassesLinkDef.h \
    102102        interface/TreeClasses.h
     103tmp/Examples/src/Analysis_ExDict.$(SrcSuf): \
     104        Examples/src/Analysis_ExLinkDef.h \
     105        Examples/interface/Analysis_Ex.h
    103106DICT =  \
    104107        tmp/Utilities/ExRootAnalysis/src/BlockClassesDict.$(SrcSuf) \
    105         tmp/src/TreeClassesDict.$(SrcSuf)
     108        tmp/src/TreeClassesDict.$(SrcSuf) \
     109        tmp/Examples/src/Analysis_ExDict.$(SrcSuf)
    106110
    107111DICT_OBJ =  \
    108112        tmp/Utilities/ExRootAnalysis/src/BlockClassesDict.$(ObjSuf) \
    109         tmp/src/TreeClassesDict.$(ObjSuf)
     113        tmp/src/TreeClassesDict.$(ObjSuf) \
     114        tmp/Examples/src/Analysis_ExDict.$(ObjSuf)
    110115
    111116tmp/src/BFieldProp.$(ObjSuf): \
     
    541546        @touch $@
    542547
     548Examples/interface/Analysis_Ex.h: \
     549        Utilities/ExRootAnalysis/interface/ExRootTreeReader.h \
     550        Utilities/ExRootAnalysis/interface/ExRootTreeWriter.h \
     551        Utilities/ExRootAnalysis/interface/ExRootTreeBranch.h \
     552        Utilities/ExRootAnalysis/interface/TSimpleArray.h \
     553        Utilities/ExRootAnalysis/interface/BlockClasses.h
     554        @touch $@
     555
    543556interface/SmearUtil.h: \
    544557        Utilities/ExRootAnalysis/interface/BlockClasses.h \
  • trunk/genMakefile.tcl

    r83 r84  
    126126  global prefix suffix objSuf exeSuf
    127127   
    128   set executable [glob -nocomplain {Delphes.cpp} {Resolutions.cpp} {Examples/Trigger_Only.cpp} ]
     128  set executable [glob -nocomplain {Delphes.cpp} {Resolutions.cpp} {Examples/Trigger_Only.cpp} {Exemples/Analysis_Ex.cpp}]
    129129                               
    130130  set exeFiles {}
     
    232232executableDeps {*.cpp} {Examples/*.cpp}
    233233
    234 dictDeps {DICT} {Utilities/ExRootAnalysis/src/*LinkDef.h} {src/*LinkDef.h}
     234dictDeps {DICT} {Utilities/ExRootAnalysis/src/*LinkDef.h} {src/*LinkDef.h} {Examples/src/*LinkDef.h}
    235235
    236236sourceDeps {SOURCE} {src/*.cc} {Utilities/ExRootAnalysis/src/*.cc} {Utilities/Hector/src/*.cc} {Utilities/CDFCones/src/*cc} {Utilities/Fastjet/src/*.cc} {Utilities/Fastjet/plugins/CDFCones/*.cc} {Utilities/Fastjet/plugins/CDFCones/src/*.cc} {Utilities/Fastjet/plugins/SISCone/*.cc} {Utilities/Fastjet/plugins/SISCone/src/*.cc} {Examples/src/*.cc}
Note: See TracChangeset for help on using the changeset viewer.