Main Page | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members | Related Pages

SFSetOfH2F.C

Go to the documentation of this file.
00001 
00021 #include "jbltools/sfh/SFSetOfH2F.h"
00022 #include "jbltools/sfh/RegH2F.h"
00023 #include "jbltools/sfh/BinningFun.h"
00024 #include "jbltools/sfh/BaseCutBase.h"
00025 #include "jbltools/sfh/FloatFunBase.h"
00026 #include "jbltools/sfh/BinningFun.h"
00027 #include "jbltools/sfh/FillIterator.h"
00028 
00029 #include <TFile.h>
00030 #include <TF1.h>
00031 #include <TAxis.h>
00032 
00033 #include <iostream>
00034 #include <cmath>
00035 #include <cassert>
00036 
00037 static const char *ident="@(#)$Id: SFSetOfH2F.C,v 1.4 2005/08/23 12:05:44 blist Exp $";
00038 
00039 SFSetOfH2F::SFSetOfH2F (const char* name_,               
00040                         const char* title_,           
00041                         Int_t nbinsx,                
00042                         Axis_t xlow,                 
00043                         Axis_t xup,                  
00044                         Int_t nbinsy,                
00045                         Axis_t ylow,                 
00046                         Axis_t yup,    
00047                         const ROListPoR& hhl,          
00048                         const FloatFunPoR& xfun_,      
00049                         const FloatFunPoR& yfun_,        
00050                         const BaseCutPoR& cut_,        
00051                         const FloatFunPoR& wfun_,      
00052                         const BinningFunPoR& binning_, 
00053                         const FillIteratorPoR& iter_)
00054 : SetOfH2F (name_, title_, nbinsx, xlow, xup, nbinsy, ylow, yup, hhl, binning_),
00055   xfun (xfun_.pff), yfun (yfun_.pff), cut(cut_.pbc), wfun (wfun_.pff), iter(iter_.pfi)
00056 {
00057   checkIterators(name_);
00058 }  
00059 
00060 SFSetOfH2F::SFSetOfH2F (const char* name_,               
00061                         const char* title_,             
00062                         Int_t nbinsx,                   
00063                         const Double_t* xbins,          
00064                         Int_t nbinsy,                   
00065                         Axis_t ylow,                    
00066                         Axis_t yup,                     
00067                         const ROListPoR& hhl,          
00068                         const FloatFunPoR& xfun_,      
00069                         const FloatFunPoR& yfun_,        
00070                         const BaseCutPoR& cut_,        
00071                         const FloatFunPoR& wfun_,      
00072                         const BinningFunPoR& binning_, 
00073                         const FillIteratorPoR& iter_)
00074 : SetOfH2F (name_, title_, nbinsx, xbins, nbinsy, ylow, yup, hhl, binning_),
00075   xfun (xfun_.pff), yfun (yfun_.pff), cut(cut_.pbc), wfun (wfun_.pff), iter(iter_.pfi)
00076 {
00077   checkIterators(name_);
00078 }  
00079 
00080 SFSetOfH2F::SFSetOfH2F (const char* name_,               
00081                         const char* title_,          
00082                         Int_t nbinsx,                
00083                         Axis_t xlow,                 
00084                         Axis_t xup,                  
00085                         Int_t nbinsy,                
00086                         const Double_t* ybins,       
00087                         const ROListPoR& hhl,        
00088                         const FloatFunPoR& xfun_,      
00089                         const FloatFunPoR& yfun_,        
00090                         const BaseCutPoR& cut_,        
00091                         const FloatFunPoR& wfun_,      
00092                         const BinningFunPoR& binning_, 
00093                         const FillIteratorPoR& iter_)
00094 : SetOfH2F (name_, title_, nbinsx, xlow, xup, nbinsy, ybins, hhl, binning_),
00095   xfun (xfun_.pff), yfun (yfun_.pff), cut(cut_.pbc), wfun (wfun_.pff), iter(iter_.pfi)
00096 {
00097   checkIterators(name_);
00098 }  
00099 
00100 SFSetOfH2F::SFSetOfH2F (const char* name_,               
00101                         const char* title_,             
00102                         Int_t nbinsx,                   
00103                         const Double_t* xbins,          
00104                         Int_t nbinsy,                   
00105                         const Double_t* ybins,          
00106                         const ROListPoR& hhl,           
00107                         const FloatFunPoR& xfun_,      
00108                         const FloatFunPoR& yfun_,        
00109                         const BaseCutPoR& cut_,        
00110                         const FloatFunPoR& wfun_,      
00111                         const BinningFunPoR& binning_, 
00112                         const FillIteratorPoR& iter_)
00113 : SetOfH2F (name_, title_, nbinsx, xbins, nbinsy, ybins, hhl, binning_),
00114   xfun (xfun_.pff), yfun (yfun_.pff), cut(cut_.pbc), wfun (wfun_.pff), iter(iter_.pfi)
00115 {
00116   checkIterators(name_);
00117 }  
00118 
00119 SFSetOfH2F::SFSetOfH2F (const char* name_,               
00120                         const char* title_,             
00121                         Int_t nbinsx,                  
00122                         const Float_t* xbins,          
00123                         Int_t nbinsy,                  
00124                         const Float_t* ybins,          
00125                         const ROListPoR& hhl,          
00126                         const FloatFunPoR& xfun_,      
00127                         const FloatFunPoR& yfun_,        
00128                         const BaseCutPoR& cut_,        
00129                         const FloatFunPoR& wfun_,      
00130                         const BinningFunPoR& binning_, 
00131                         const FillIteratorPoR& iter_)
00132 : SetOfH2F (name_, title_, nbinsx, xbins, nbinsy, ybins, hhl, binning_),
00133   xfun (xfun_.pff), yfun (yfun_.pff), cut(cut_.pbc), wfun (wfun_.pff), iter(iter_.pfi)
00134 {
00135   checkIterators(name_);
00136 }  
00137 
00138 SFSetOfH2F::SFSetOfH2F (const char* name_,               
00139                         const char* title_,             
00140                         const Binning& xbinning,       
00141                         const Binning& ybinning,       
00142                         const ROListPoR& hhl,          
00143                         const FloatFunPoR& xfun_,      
00144                         const FloatFunPoR& yfun_,        
00145                         const BaseCutPoR& cut_,        
00146                         const FloatFunPoR& wfun_,      
00147                         const BinningFunPoR& binning_, 
00148                         const FillIteratorPoR& iter_)
00149 : SetOfH2F (name_, title_, xbinning, ybinning, hhl, binning_),
00150   xfun (xfun_.pff), yfun (yfun_.pff), cut(cut_.pbc), wfun (wfun_.pff), iter(iter_.pfi)
00151 {
00152   checkIterators(name_);
00153 }  
00154 
00155 
00156 SFSetOfH2F::~SFSetOfH2F () {
00157 }                    
00158 
00159 void SFSetOfH2F::Fill () {
00160   const BinningFun *binning = getBinning();
00161   assert (binning);
00162   if (!xfun) return;
00163   if (binning->isExclusive()) {
00164     if (!iter || iter->reset()) {
00165       do {
00166         if (!cut || (*cut)()) {
00167           Float_FF w = wfun ? (*wfun)() : 1.;
00168           int ibin = (*binning)();
00169           if (ibin >= 0) {
00170             if (TH2F *th2f=dynamic_cast<TH2F *>(getEntry(ibin))) th2f->Fill ((*xfun)(),(*yfun)(), w);
00171           } 
00172         } 
00173       } while (iter && iter->next());  
00174     }
00175   }
00176   else {
00177     if (!iter || iter->reset()) {
00178       do {
00179         if (!cut || (*cut)()) {
00180           Float_FF w = wfun ? (*wfun)() : 1.;
00181           Float_FF x = (*xfun)();
00182           Float_FF y = (*yfun)();
00183           int ibinup = binning->getNBins(); 
00184           for (int ibin = 0; ibin < ibinup; ++ibin) {
00185             if ((*binning)(ibin)) {
00186               if (TH2F *th2f=dynamic_cast<TH2F *>(getEntry(ibin))) th2f->Fill (x, y, w);
00187             } 
00188           } 
00189         } 
00190       } while (iter && iter->next());  
00191     }
00192   }
00193 }
00194 
00195 template<class Fun1, class Fun2>
00196 void SFSetOfH2F::checkTwoIterators(const char *name, 
00197                                           const char *fun1name, Fun1 *fun1, 
00198                                           const char *fun2name, Fun2 *fun2) {
00199   if (fun1 && fun1->getIterator() && 
00200       fun2  && fun2->getIterator() &&
00201       fun1->getIterator() != fun2->getIterator()) {
00202     std::cerr << "SFSetOfH2F: Iterators of " << fun1name
00203               << " and " << fun2name
00204               << " are different for histogram "
00205               << name << "!" << std::endl;
00206   }
00207   assert (!fun1 || !fun1->getIterator() || !fun2  || !fun2->getIterator()  || fun1->getIterator() == fun2->getIterator());
00208 }                       
00209 template<class Fun>
00210 void SFSetOfH2F::checkOneIterator (const char *name, 
00211                                           const char *funname, 
00212                                                 Fun  *fun) {
00213   if (fun && fun->getIterator()) {
00214     if (iter) {
00215       if (fun->getIterator() != iter) {
00216         std::cerr << "SFSetOfH2F: Iterator '" 
00217                   << fun->getIterator()->getName() 
00218                   << "' of " << funname 
00219                   << " '" << fun->getName() << "'"
00220                   << " and iter '" << iter->getName() 
00221                   << "'are different for histogram "
00222                   << name << "!\n";
00223       }
00224     }
00225     else {
00226 #if(DEBUG>=2)      
00227       std::cerr << "SFSetOfH2F: Iterator '" 
00228                 << fun->getIterator()->getName() << "' of " 
00229                 << funname
00230                 << " '" << fun->getName() << "'"
00231                 << " used as iterator for histogram "
00232                 << name << ".\n";
00233 #endif
00234       iter = const_cast<FillIterator *>(fun->getIterator());
00235     }
00236   }
00237   assert (!fun || !fun->getIterator() || fun->getIterator() == iter);
00238 }                       
00239 
00240 void SFSetOfH2F::checkIterators(const char *name) {
00241   const BinningFun *binning = getBinning();
00242   assert (binning);
00243   checkTwoIterators (name, "xfun", xfun, "yfun",    yfun);
00244   checkTwoIterators (name, "xfun", xfun, "cut",     cut);
00245   checkTwoIterators (name, "xfun", xfun, "wfun",    wfun);
00246   checkTwoIterators (name, "xfun", xfun, "binning", binning);
00247   checkTwoIterators (name, "yfun", yfun, "cut",     cut);
00248   checkTwoIterators (name, "yfun", yfun, "wfun",    wfun);
00249   checkTwoIterators (name, "yfun", yfun, "binning", binning);
00250   checkTwoIterators (name, "wfun", wfun, "cut",     cut);
00251   checkTwoIterators (name, "wfun", wfun, "binning", binning);
00252   checkTwoIterators (name, "cut",  cut,  "binning", binning);
00253 
00254   checkOneIterator (name, "xfun",    xfun);
00255   checkOneIterator (name, "yfun",    yfun);
00256   checkOneIterator (name, "wfun",    wfun);
00257   checkOneIterator (name, "cut",     cut);
00258   checkOneIterator (name, "binning", binning);
00259 }
00260 

Generated on Thu Oct 26 12:52:59 2006 for SFH by doxygen 1.3.2