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

SFHProf.C

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

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