Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/RooAbsMCStudyModule.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*****************************************************************************
0002  * Project: RooFit                                                           *
0003  * Package: RooFitCore                                                       *
0004  *    File: $Id: RooAbsMCStudyModule.h,v 1.2 2007/05/11 09:11:30 verkerke Exp $
0005  * Authors:                                                                  *
0006  *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
0007  *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
0008  *                                                                           *
0009  * Copyright (c) 2000-2005, Regents of the University of California          *
0010  *                          and Stanford University. All rights reserved.    *
0011  *                                                                           *
0012  * Redistribution and use in source and binary forms,                        *
0013  * with or without modification, are permitted according to the terms        *
0014  * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
0015  *****************************************************************************/
0016 
0017 #ifndef ROO_ABS_MC_STUDY_MODULE
0018 #define ROO_ABS_MC_STUDY_MODULE
0019 
0020 #include "RooArgSet.h"
0021 #include "RooMCStudy.h"
0022 class RooAbsPdf;
0023 class RooDataSet ;
0024 class RooAbsData ;
0025 class RooAbsGenContext ;
0026 class RooFitResult ;
0027 class RooPlot ;
0028 class RooRealVar ;
0029 
0030 class RooAbsMCStudyModule : public TNamed {
0031 public:
0032 
0033   RooAbsMCStudyModule(const char* name, const char* title) ;
0034   RooAbsMCStudyModule(const RooAbsMCStudyModule& other) ;
0035 
0036   /// Initializer method called upon attachment to given RooMCStudy object
0037   bool doInitializeInstance(RooMCStudy& /*study*/) ;
0038 
0039   /// Initializer called immediately after attachment to RooMCStudy object and initialization of module base class
0040   virtual bool initializeInstance() {
0041     return true ;
0042   }
0043 
0044   /// Method called at the beginning of each RooMCStudy run
0045   virtual bool initializeRun(Int_t /*numSamples*/) {
0046     return true ;
0047   }
0048 
0049   /// Method called at the end of each RooMCStudy run. If a RooDataSet is returned, it must have a length equal to
0050   /// the number of toy experiments performed and will merged with the fitpar dataset of RooMCStudy.
0051   virtual RooDataSet* finalizeRun() {
0052     return nullptr ;
0053   }
0054 
0055   /// Method called after resetting of generator parameters to initial values and before call to generator context
0056   /// Any modifications to generator parameters will affect next generation operation (only)
0057   virtual bool processBeforeGen(Int_t /*sampleNum*/) {
0058     return true ;
0059   }
0060 
0061   /// Method called after generation of toy data sample and resetting of fit parameters to initial values and before
0062   /// actual fit is performed. Any modifications to fit parameters will apply to next fit operation. Note that setConstant
0063   /// flag of fit parameters are not explicitly reset by RooMCStudy, so any changes made to these flags here will persist
0064   virtual bool processBetweenGenAndFit(Int_t /*sampleNum*/) {
0065     return true ;
0066   }
0067 
0068   /// Method called after fit has been performed.
0069   virtual bool processAfterFit(Int_t /*sampleNum*/) {
0070     return true ;
0071   }
0072 
0073 protected:
0074 
0075    // Interface methods to RooMCStudy objects,
0076    // which are only functional after module has been attached to a RooMCStudy object
0077 
0078    /// Refit model using original or specified data sample
0079    RooFit::OwningPtr<RooFitResult> refit(RooAbsData* inGenSample=nullptr);
0080 
0081    /// Return generate sample
0082    RooAbsData* genSample() {
0083      return _mcs ? _mcs->_genSample : nullptr ;
0084    }
0085 
0086    /// Return generator pdf
0087    RooAbsPdf* genModel() {
0088      return _mcs ? _mcs->_genModel : nullptr ;
0089    }
0090 
0091    // Accessor for generator context, generator parameters, prototype data and projected dependents.
0092    RooAbsGenContext* genContext() {
0093      return _mcs ? _mcs->_genContext.get() : nullptr ;
0094    }
0095 
0096    /// Return initial value of generator model parameters
0097    RooArgSet* genInitParams() {
0098      return _mcs ? &_mcs->_genInitParams : nullptr ;
0099    }
0100 
0101    /// Return current value of generator model parameters
0102    RooArgSet* genParams() {
0103      return _mcs ? &_mcs->_genParams : nullptr ;
0104    }
0105 
0106    /// Return generator prototype data provided by user
0107    const RooDataSet* genProtoData() {
0108      return _mcs ? _mcs->_genProtoData : nullptr ;
0109    }
0110 
0111    /// Return projected observables
0112    RooArgSet* projDeps() {
0113      return _mcs ? &_mcs->_projDeps : nullptr ;
0114    }
0115 
0116    // Accessors for fit observables, fit model, current and initial fit parameters and NLL value
0117 
0118    /// Return fit model observables
0119    RooArgSet* dependents() {
0120      return _mcs ? &_mcs->_dependents : nullptr ;
0121    }
0122 
0123    /// Return all observables
0124    RooArgSet* allDependents() {
0125      return _mcs ? &_mcs->_allDependents : nullptr ;
0126    }
0127 
0128    /// Return fit model
0129    RooAbsPdf* fitModel() {
0130      return _mcs ? _mcs->_fitModel : nullptr ;
0131    }
0132 
0133    /// Return initial value of parameters of fit model
0134    RooArgSet* fitInitParams() {
0135      return _mcs ? &_mcs->_fitInitParams : nullptr ;
0136    }
0137 
0138    /// Return current value of parameters of fit model
0139    RooArgSet* fitParams() {
0140      return _mcs ? &_mcs-> _fitParams : nullptr ;
0141    }
0142 
0143    /// Return pointer to RooRealVar holding minimized -log(L) value
0144    RooRealVar* nllVar() {
0145      return _mcs ? _mcs->_nllVar.get() : nullptr ;
0146    }
0147 
0148    // Accessors for fit options, generator and MCstudy configuration flags
0149 
0150    /// Return list of fit options provided by user
0151    RooLinkedList* fitOptList() {
0152      return _mcs ? &_mcs->_fitOptList : nullptr ;
0153    }
0154 
0155    /// If true extended mode generation is requested
0156    bool extendedGen() {
0157      return _mcs ? _mcs->_extendedGen : false ;
0158    }
0159 
0160    /// If true binning of data between generating and fitting is requested
0161    bool binGenData() {
0162      return _mcs ? _mcs->_binGenData : false ;
0163    }
0164 
0165    /// Return expected number of events from generator model
0166    double numExpGen() {
0167      return _mcs ? _mcs->_nExpGen : 0 ;
0168    }
0169 
0170    /// If true randomization of prototype data order is requested
0171    bool randProto() {
0172      return _mcs ? _mcs->_randProto : false ;
0173    }
0174 
0175    /// If true verbose message in the generation step is requested
0176    bool verboseGen() {
0177      return _mcs ? _mcs->_verboseGen : false ;
0178    }
0179 
0180 private:
0181 
0182   RooMCStudy* _mcs ; ///< Pointer to RooMCStudy object module is attached to
0183 
0184   ClassDefOverride(RooAbsMCStudyModule,0) // Monte Carlo study manager add-on module
0185 } ;
0186 
0187 
0188 #endif
0189