OscFit::Template Class Reference

#include <Template.h>

List of all members.

Public Member Functions

 Template ()
 ~Template ()
void Add (Template *temp, Double_t w=1.0)
void ConditionalAdd (Template *temp, Double_t w1=1.0, Double_t w2=1.0)
void SpecialAdd (Template *tempCentre, Template *tempShifted, Double_t w=1.0)
void LoopFill (Run_t run, Containment_t containment, Flavour_t flavour, Charge_t charge, Resolution_t resolution, Topology_t topology, ProtonTag_t proton, ElectronTag_t electron, Histogram *h, Double_t w=1.0)
void Fill (Run_t run, Containment_t containment, Flavour_t flavour, Charge_t charge, Resolution_t resolution, Topology_t topology, ProtonTag_t proton, ElectronTag_t electron, Double_t a, Double_t b=1.0, Double_t c=1.0)
void Fill (Run_t run, Containment_t containment, Flavour_t flavour, Charge_t charge, Resolution_t resolution, Topology_t topology, ProtonTag_t proton, ElectronTag_t electron, Histogram *h, Double_t w=1.0)
Double_t GetTotalContent ()
Double_t GetBinContent (Run_t run, Containment_t containment, Flavour_t flavour, Charge_t charge)
Double_t GetBinContent (Run_t run, Containment_t containment, Flavour_t flavour, Charge_t charge, Resolution_t resolution, Topology_t topology, ProtonTag_t proton, ElectronTag_t electron)
HistogramGetHistogram (Run_t run, Containment_t containment, Flavour_t flavour, Charge_t charge, Resolution_t resolution, Topology_t topology, ProtonTag_t proton, ElectronTag_t electron)
HistogramMakeHistogram (Run_t run, Containment_t containment, Flavour_t flavour, Charge_t charge, Resolution_t resolution, Topology_t topology, ProtonTag_t proton, ElectronTag_t electron)
Bool_t TouchHistogram (Run_t run, Containment_t containment, Flavour_t flavour, Charge_t charge, Resolution_t resolution, Topology_t topology, ProtonTag_t proton, ElectronTag_t electron)
UInt_t GetNumHistograms ()
Int_t GetIndex (UInt_t n)
Int_t GetOrderedIndex (UInt_t n)
HistogramGetHistogram (UInt_t n)
HistogramGetHistogramAtIndex (Int_t n)
void PrintHistograms ()
void Scale (Double_t scale)
void SetDebug (Bool_t yesno=1)
void DeleteHistograms ()
void DeleteContents ()
void Reset ()
 Template ()
virtual ~Template ()
void Fill (Bin_t binType, Double_t x, Double_t w=1.0)
Int_t GetNumHistograms ()
HistogramGetHistogram (Int_t ibin)
HistogramGetHistogramByType (Bin_t binType)
TH1D * MakeTH1D (Bin_t binType, const char *name)
Double_t GetTotalContent ()
void BuildHistograms ()
void DeleteHistograms ()
void ReadHistograms (const char *filename)
void WriteHistograms (const char *filename)
void PrintHistograms ()
void Add (Template *temp, Double_t w=1.0)
void Reset ()

Static Public Member Functions

static Int_t GetID (Run_t run, Containment_t containment, Flavour_t flavour, Charge_t charge, Resolution_t resolution, Topology_t topology, ProtonTag_t proton, ElectronTag_t electron)
static void InvertID (Int_t id, Run_t &run, Containment_t &containment, Flavour_t &flavour, Charge_t &charge, Resolution_t &resolution, Topology_t &topology, ProtonTag_t &proton, ElectronTag_t &electron)

Private Member Functions

HistogramGet (Int_t id)
void Load (Int_t id, Histogram *hist)
void BuildHistogram (Run_t run, Containment_t containment, Flavour_t flavour, Charge_t charge, Resolution_t resolution, Topology_t topology, ProtonTag_t proton, ElectronTag_t electron)

Private Attributes

std::map< Int_t, Histogram * > fHistogramMap
std::vector< Histogram * > fHistogramList
std::vector< Int_t > fIndexList
HistogramfHistogram
Int_t fIndex
Bool_t fDebug
HistogramfHist
std::vector< Histogram * > fHistArray

Detailed Description

Definition at line 13 of file Template.h.


Constructor & Destructor Documentation

Template::Template (  ) 

Definition at line 11 of file Template.cxx.

00012 {
00013   fDebug = 0;
00014 }

Template::~Template (  ) 

Definition at line 16 of file Template.cxx.

References DeleteContents().

00017 {
00018   DeleteContents();
00019 }

OscFit::Template::Template (  ) 
virtual OscFit::Template::~Template (  )  [virtual]

Member Function Documentation

void OscFit::Template::Add ( Template temp,
Double_t  w = 1.0 
)
void Template::Add ( Template temp,
Double_t  w = 1.0 
)

Definition at line 21 of file Template.cxx.

References OscFit::Histogram::Add(), GetHistogram(), GetIndex(), GetNumHistograms(), InvertID(), OscFit::kNothing, OscFit::kNull, OscFit::kUnknownCharge, OscFit::kUnknownElectronTag, OscFit::kUnknownFlavour, OscFit::kUnknownProtonTag, OscFit::kUnknownRes, OscFit::kUnknownRun, MakeHistogram(), n, and run().

Referenced by OscFit::TemplateWriter::AddToFile(), OscFit::TemplateCalculator::BuildExpt(), OscFit::TemplateCalculator::CombineResBins(), OscFit::TemplateCalculator::GetCosmicBackground(), OscFit::TemplateCalculator::GetData(), OscFit::TemplateCalculator::GetDeltaExpectation(), OscFit::TemplateCalculator::GetExpectation(), OscFit::TemplateCalculator::GetExpectationForAtmosData(), OscFit::TemplateCalculator::GetExpectationForBeamData(), OscFit::TemplateCalculator::GetMC(), OscFit::TemplateCalculator::GetNCBackground(), and SpecialAdd().

00022 {
00023   if( temp==0 || w==0 ) return;
00024 
00025   for( UInt_t n=0; n<temp->GetNumHistograms(); n++ ){
00026     Int_t id = temp->GetIndex(n);
00027 
00028     Run_t         run         = kUnknownRun;
00029     Containment_t containment = kNull;
00030     Flavour_t     flavour     = kUnknownFlavour;
00031     Charge_t      charge      = kUnknownCharge;
00032     Resolution_t  resolution  = kUnknownRes;
00033     Topology_t    topology    = kNothing;
00034     ProtonTag_t   proton      = kUnknownProtonTag;
00035     ElectronTag_t electron    = kUnknownElectronTag;
00036 
00037     InvertID( id,
00038               run, containment, flavour, charge, 
00039               resolution, topology, proton, electron );
00040 
00041     Histogram* histExternal = temp->GetHistogram( run, containment, 
00042                                                   flavour, charge, 
00043                                                   resolution, topology, 
00044                                                   proton, electron );
00045 
00046     Histogram* histInternal = this->MakeHistogram( run, containment, 
00047                                                    flavour, charge, 
00048                                                    resolution, topology, 
00049                                                    proton, electron );
00050     histInternal->Add( histExternal, w );
00051   }
00052 
00053   return;
00054 }

void Template::BuildHistogram ( Run_t  run,
Containment_t  containment,
Flavour_t  flavour,
Charge_t  charge,
Resolution_t  resolution,
Topology_t  topology,
ProtonTag_t  proton,
ElectronTag_t  electron 
) [private]

Definition at line 296 of file Template.cxx.

References fHistogram, Get(), OscFit::BinningScheme::GetBinning(), GetID(), OscFit::BinningScheme::Instance(), and Load().

Referenced by MakeHistogram().

00297 {
00298   Int_t id = GetID( run, containment, flavour, charge, resolution, topology, proton, electron );
00299 
00300   if( id>=0 ){ 
00301     fHistogram = Get( id );  
00302     
00303     if( fHistogram==0 ){
00304       Binning* binning = BinningScheme::Instance()->GetBinning( run, containment, flavour, resolution );
00305       fHistogram = new Histogram( binning );
00306 
00307       Load( id, fHistogram );
00308     }
00309   }
00310 
00311   return;
00312 }

void Template::BuildHistograms (  ) 
void Template::ConditionalAdd ( Template temp,
Double_t  w1 = 1.0,
Double_t  w2 = 1.0 
)

Definition at line 56 of file Template.cxx.

References OscFit::Histogram::Add(), GetHistogram(), GetIndex(), GetNumHistograms(), InvertID(), OscFit::IsMINOSPlus(), OscFit::kNothing, OscFit::kNull, OscFit::kUnknownCharge, OscFit::kUnknownElectronTag, OscFit::kUnknownFlavour, OscFit::kUnknownProtonTag, OscFit::kUnknownRes, OscFit::kUnknownRun, MakeHistogram(), n, and run().

00057 {
00058   if( temp==0 || w1==0 ) return;
00059 
00060   for( UInt_t n=0; n<temp->GetNumHistograms(); n++ ){
00061     Int_t id = temp->GetIndex(n);
00062 
00063     Run_t         run         = kUnknownRun;
00064     Containment_t containment = kNull;
00065     Flavour_t     flavour     = kUnknownFlavour;
00066     Charge_t      charge      = kUnknownCharge;
00067     Resolution_t  resolution  = kUnknownRes;
00068     Topology_t    topology    = kNothing;
00069     ProtonTag_t   proton      = kUnknownProtonTag;
00070     ElectronTag_t electron    = kUnknownElectronTag;
00071 
00072     InvertID( id,
00073               run, containment, flavour, charge, 
00074               resolution, topology, proton, electron );
00075 
00076     Histogram* histExternal = temp->GetHistogram( run, containment, 
00077                                                   flavour, charge, 
00078                                                   resolution, topology, 
00079                                                   proton, electron );
00080 
00081     Histogram* histInternal = this->MakeHistogram( run, containment, 
00082                                                    flavour, charge, 
00083                                                    resolution, topology, 
00084                                                    proton, electron );
00085 
00086     // --- insert condition here ---
00087     // Switch off normalisation systematic for MINOS Plus
00088     //  w1 = 1 + alpha  (from TemplateCalculator)
00089     //  w2 = 1          (by default)
00090     if( OscFit::IsMINOSPlus(run) == false ) histInternal->Add( histExternal, w1 );
00091     else                                    histInternal->Add( histExternal, w2 );
00092   }
00093 
00094   return;
00095 }

void Template::DeleteContents (  ) 

Definition at line 354 of file Template.cxx.

References fHistogramList, fHistogramMap, and fIndexList.

Referenced by DeleteHistograms(), and ~Template().

00355 {
00356   std::map<Int_t,Histogram*>::iterator myIter = fHistogramMap.begin();
00357 
00358   for( ; myIter!=fHistogramMap.end(); myIter++ ){
00359     Histogram* hist = myIter->second;
00360     if( hist ) delete hist;
00361   }
00362 
00363   fHistogramMap.clear();
00364 
00365   fHistogramList.clear();
00366   fIndexList.clear();
00367   
00368   return;
00369 }

void OscFit::Template::DeleteHistograms (  ) 
void Template::DeleteHistograms (  )  [inline]

Definition at line 82 of file Template.h.

References DeleteContents().

Referenced by ReadHistograms().

00082 { DeleteContents(); }

void Template::Fill ( Bin_t  binType,
Double_t  x,
Double_t  w = 1.0 
)

Definition at line 24 of file twoflavours/Template.cxx.

References OscFit::Histogram::Fill(), and GetHistogramByType().

00025 {
00026   Histogram* myHist = (Histogram*)( GetHistogramByType(binType) );
00027 
00028   if( myHist ) myHist->Fill(x,w);
00029 
00030   return;
00031 }

void Template::Fill ( Run_t  run,
Containment_t  containment,
Flavour_t  flavour,
Charge_t  charge,
Resolution_t  resolution,
Topology_t  topology,
ProtonTag_t  proton,
ElectronTag_t  electron,
Histogram h,
Double_t  w = 1.0 
)

Definition at line 210 of file Template.cxx.

References OscFit::Histogram::Add(), and MakeHistogram().

00211 {
00212   if( h==0 ) return;
00213 
00214   Histogram* hist = MakeHistogram( run, containment, flavour, charge, 
00215                                    resolution, topology, proton, electron );
00216   if( hist ) hist->Add( h, w );
00217 }

void Template::Fill ( Run_t  run,
Containment_t  containment,
Flavour_t  flavour,
Charge_t  charge,
Resolution_t  resolution,
Topology_t  topology,
ProtonTag_t  proton,
ElectronTag_t  electron,
Double_t  a,
Double_t  b = 1.0,
Double_t  c = 1.0 
)

Definition at line 203 of file Template.cxx.

References OscFit::Histogram::Fill(), and MakeHistogram().

Referenced by OscFit::TemplateMaker::BuildTemplate(), OscFit::TemplateCalculator::CombineBins(), OscFit::TemplateCalculator::CombineRuns(), OscFit::Interface::Fill(), and OscFit::TemplateCalculator::FillCombinedBins().

00204 {
00205   Histogram* hist = MakeHistogram( run, containment, flavour, charge, 
00206                                    resolution, topology, proton, electron );
00207   if( hist ) hist->Fill( a, b, c );
00208 }

Histogram * Template::Get ( Int_t  id  )  [private]

Definition at line 314 of file Template.cxx.

References fHistogramMap.

Referenced by BuildHistogram(), GetHistogram(), and GetHistogramAtIndex().

00315 {
00316   Histogram* hist = 0;
00317 
00318   std::map<Int_t,Histogram*>::iterator myEntry = fHistogramMap.find(id);
00319 
00320   if( myEntry != fHistogramMap.end() ){
00321     hist = myEntry->second;
00322   }
00323 
00324   return hist;
00325 }

Double_t Template::GetBinContent ( Run_t  run,
Containment_t  containment,
Flavour_t  flavour,
Charge_t  charge,
Resolution_t  resolution,
Topology_t  topology,
ProtonTag_t  proton,
ElectronTag_t  electron 
)

Definition at line 196 of file Template.cxx.

References GetHistogram(), and OscFit::Histogram::GetTotalContent().

00197 {
00198   Histogram* hist = GetHistogram( run, containment, flavour, charge, 
00199                                   resolution, topology, proton, electron );
00200   if( hist ) return hist->GetTotalContent();  else return 0.0;
00201 }

Double_t Template::GetBinContent ( Run_t  run,
Containment_t  containment,
Flavour_t  flavour,
Charge_t  charge 
)

Definition at line 173 of file Template.cxx.

References OscFit::GetElectronTag(), OscFit::GetNumElectronTags(), OscFit::GetNumProtonTags(), OscFit::GetNumResBins(), OscFit::GetNumTopologies(), OscFit::GetProtonTag(), OscFit::GetResBin(), OscFit::GetTopology(), and total().

Referenced by OscFit::TwoFlavourFitter::PrintExpt(), and OscFit::ThreeFlavourFitter::PrintExpt().

00174 {
00175   Double_t total = 0.0;
00176 
00177   for( Int_t ires=0; ires<OscFit::GetNumResBins(); ires++ ){
00178     for( Int_t itop=0; itop<OscFit::GetNumTopologies(); itop++ ){
00179       for( Int_t iproton=0; iproton<OscFit::GetNumProtonTags(); iproton++ ){
00180         for( Int_t ielectron=0; ielectron<OscFit::GetNumElectronTags(); ielectron++ ){
00181           Resolution_t  resolution = OscFit::GetResBin(ires);
00182           Topology_t    topology   = OscFit::GetTopology(itop);
00183           ProtonTag_t   proton     = OscFit::GetProtonTag(iproton);
00184           ElectronTag_t electron   = OscFit::GetElectronTag(ielectron);
00185        
00186           total += GetBinContent( run, containment, flavour, charge,
00187                                   resolution, topology, proton, electron );
00188         }
00189       }
00190     }
00191   }
00192 
00193   return total;
00194 }

Histogram * Template::GetHistogram ( Int_t  ibin  ) 

Definition at line 43 of file twoflavours/Template.cxx.

References fHistArray.

00044 {  
00045   if( ibin<0 ) return 0;
00046 
00047   Histogram* myHist = 0;
00048 
00049   if( ibin>=0 && ibin<(Int_t)fHistArray.size() ){
00050     myHist = (Histogram*)(fHistArray.at((UInt_t)ibin));
00051   }
00052 
00053   return myHist;
00054 }

Histogram * Template::GetHistogram ( UInt_t  n  ) 

Definition at line 256 of file Template.cxx.

References fHistogramList.

00257 {
00258   if( n<fHistogramList.size() ){
00259     return fHistogramList.at(n);
00260   }
00261   else{
00262     return 0;
00263   }
00264 }

Histogram * Template::GetHistogram ( Run_t  run,
Containment_t  containment,
Flavour_t  flavour,
Charge_t  charge,
Resolution_t  resolution,
Topology_t  topology,
ProtonTag_t  proton,
ElectronTag_t  electron 
)

Definition at line 271 of file Template.cxx.

References Get(), and GetID().

Referenced by Add(), OscFit::TemplateCalculator::BuildExpt(), OscFit::TemplateCalculator::CombineResBins(), ConditionalAdd(), GetBinContent(), GetHistogramByType(), MakeHistogram(), PrintHistograms(), Scale(), SpecialAdd(), and TouchHistogram().

00272 {
00273   Histogram* hist = 0;
00274 
00275   Int_t id = GetID( run, containment, flavour, charge, resolution, topology, proton, electron );
00276 
00277   if( id>=0 ) hist = Get( id );
00278     
00279   return hist;
00280 }

Histogram * Template::GetHistogramAtIndex ( Int_t  n  ) 
Histogram * Template::GetHistogramByType ( Bin_t  binType  ) 
Int_t Template::GetID ( Run_t  run,
Containment_t  containment,
Flavour_t  flavour,
Charge_t  charge,
Resolution_t  resolution,
Topology_t  topology,
ProtonTag_t  proton,
ElectronTag_t  electron 
) [static]

Definition at line 408 of file Template.cxx.

References OscFit::GetNumCharges(), OscFit::GetNumContainments(), OscFit::GetNumElectronTags(), OscFit::GetNumFlavours(), OscFit::GetNumProtonTags(), OscFit::GetNumResBins(), OscFit::GetNumRuns(), OscFit::GetNumTopologies(), OscFit::kAmbig, OscFit::kContainedVertex, OscFit::kElectron, OscFit::kFullyContained, and OscFit::kNumu.

Referenced by BuildHistogram(), and GetHistogram().

00409 {
00410   Int_t id = -1;
00411 
00412   if( flavour!=kNumu && 
00413    !( containment==kContainedVertex
00414    || containment==kFullyContained ) ){
00415     return -1;
00416   }
00417      
00418   if( flavour!=kNumu && charge!=kAmbig ){
00419     return -1;
00420   }
00421 
00422   if( flavour!=kNumu && electron==kElectron ){
00423     return -1;
00424   }
00425 
00426   Int_t irun         = static_cast<Int_t>(run);
00427   Int_t icontainment = static_cast<Int_t>(containment); 
00428   Int_t iflavour     = static_cast<Int_t>(flavour);
00429   Int_t icharge      = static_cast<Int_t>(charge); 
00430   Int_t iresolution  = static_cast<Int_t>(resolution); 
00431   Int_t itopology    = static_cast<Int_t>(topology);
00432   Int_t iproton      = static_cast<Int_t>(proton);
00433   Int_t ielectron    = static_cast<Int_t>(electron);
00434 
00435   if( irun>=0         && irun<GetNumRuns()
00436    && icontainment>=0 && icontainment<GetNumContainments()
00437    && iflavour>=0     && iflavour<GetNumFlavours()
00438    && icharge>=0      && icharge<GetNumCharges()
00439    && iresolution>=0  && iresolution<GetNumResBins()
00440    && itopology>=0    && itopology<GetNumTopologies()
00441    && iproton>=0      && iproton<GetNumProtonTags()
00442    && ielectron>=0    && ielectron<GetNumElectronTags() ){
00443 
00444     id = (1+irun)         *20000000
00445        + (1+icontainment) *1000000
00446        + (1+iflavour)     *100000
00447        + (1+icharge)      *20000
00448        + (1+iresolution)  *1000
00449        + (1+itopology)    *100
00450        + (1+iproton)      *10    
00451        + (1+ielectron);
00452   }
00453 
00454   return id;
00455 } 

Int_t Template::GetIndex ( UInt_t  n  ) 

Definition at line 246 of file Template.cxx.

References fIndexList.

Referenced by Add(), OscFit::TemplateCalculator::CombineBins(), OscFit::TemplateCalculator::CombineRuns(), ConditionalAdd(), OscFit::TemplateCalculator::FillCombinedBins(), and SpecialAdd().

00247 {
00248   if( n<fIndexList.size() ){
00249     return fIndexList.at(n);
00250   }
00251   else{
00252     return -1;
00253   }
00254 }

Int_t OscFit::Template::GetNumHistograms (  ) 
Int_t Template::GetNumHistograms (  ) 
Int_t Template::GetOrderedIndex ( UInt_t  n  ) 

Definition at line 237 of file Template.cxx.

References fHistogramMap.

Referenced by OscFit::TemplateIO::WriteToFile().

00238 {
00239   std::map<Int_t,Histogram*>::iterator myEntry = fHistogramMap.begin();
00240 
00241   std::advance( myEntry, n );
00242 
00243   return myEntry->first;
00244 }

Double_t OscFit::Template::GetTotalContent (  ) 
Double_t Template::GetTotalContent (  ) 

Definition at line 159 of file Template.cxx.

References fHistogramMap, OscFit::Histogram::GetTotalContent(), and total().

Referenced by OscFit::TwoFlavourFitter::PrintExpt(), OscFit::ThreeFlavourFitter::PrintExpt(), OscFit::TemplateArray::PrintTemplates(), OscFit::TemplateMap::PrintTemplates(), OscFit::ThreeFlavourFitter::TouchExpt(), OscFit::TwoFlavourFitter::TouchExpt(), and OscFit::TemplateArray::TouchTemplates().

00160 {
00161   Double_t total = 0.0;
00162 
00163   std::map<Int_t,Histogram*>::iterator myIter = fHistogramMap.begin();
00164 
00165   for( ; myIter!=fHistogramMap.end(); myIter++ ){
00166     Histogram* hist = myIter->second;
00167     if( hist ) total += hist->GetTotalContent();
00168   }
00169 
00170   return total;
00171 }

void Template::InvertID ( Int_t  id,
Run_t run,
Containment_t containment,
Flavour_t flavour,
Charge_t charge,
Resolution_t resolution,
Topology_t topology,
ProtonTag_t proton,
ElectronTag_t electron 
) [static]

Definition at line 457 of file Template.cxx.

References OscFit::GetNumCharges(), OscFit::GetNumContainments(), OscFit::GetNumElectronTags(), OscFit::GetNumFlavours(), OscFit::GetNumProtonTags(), OscFit::GetNumResBins(), OscFit::GetNumRuns(), OscFit::GetNumTopologies(), OscFit::kNothing, OscFit::kNull, OscFit::kUnknownCharge, OscFit::kUnknownElectronTag, OscFit::kUnknownFlavour, OscFit::kUnknownProtonTag, OscFit::kUnknownRes, OscFit::kUnknownRun, and total().

Referenced by Add(), OscFit::TemplateCalculator::CombineBins(), OscFit::TemplateCalculator::CombineRuns(), ConditionalAdd(), OscFit::TemplateCalculator::FillCombinedBins(), PrintHistograms(), SpecialAdd(), and OscFit::TemplateIO::WriteToFile().

00458 {
00459   run         = kUnknownRun;
00460   containment = kNull;
00461   flavour     = kUnknownFlavour;
00462   charge      = kUnknownCharge;
00463   resolution  = kUnknownRes;
00464   topology    = kNothing;
00465   proton      = kUnknownProtonTag;
00466   electron    = kUnknownElectronTag;
00467 
00468   if( id<0 ) return;
00469 
00470   Double_t total = id;
00471 
00472   Int_t irun = (Int_t)(total/20000000.0) - 1;
00473   total -= (1+irun)*20000000.0;
00474 
00475   Int_t icontainment = (Int_t)(total/1000000.0) - 1;
00476   total -= (1+icontainment)*1000000.0;
00477 
00478   Int_t iflavour = (Int_t)(total/100000.0) - 1;
00479   total -= (1+iflavour)*100000.0;
00480 
00481   Int_t icharge = (Int_t)(total/20000.0) - 1;
00482   total -= (1+icharge)*20000.0;
00483 
00484   Int_t iresolution  = (Int_t)(total/1000.0) - 1;
00485   total -= (1+iresolution)*1000.0;
00486 
00487   Int_t itopology = (Int_t)(total/100.0) - 1;
00488   total -= (1+itopology)*100.0;
00489 
00490   Int_t iproton = (Int_t)(total/10.0) - 1;
00491   total -= (1+iproton)*10.0;
00492 
00493   Int_t ielectron = (Int_t)(total) - 1;
00494 
00495   if( irun>=0         && irun<GetNumRuns()
00496    && icontainment>=0 && icontainment<GetNumContainments()
00497    && iflavour>=0     && iflavour<GetNumFlavours()
00498    && icharge>=0      && icharge<GetNumCharges()
00499    && iresolution>=0  && iresolution<GetNumResBins()
00500    && itopology>=0    && itopology<GetNumTopologies()
00501    && iproton>=0      && iproton<GetNumProtonTags()
00502    && ielectron>=0    && ielectron<GetNumElectronTags() ){
00503     run         = static_cast<Run_t>(irun);
00504     containment = static_cast<Containment_t>(icontainment); 
00505     flavour     = static_cast<Flavour_t>(iflavour);
00506     charge      = static_cast<Charge_t>(icharge); 
00507     resolution  = static_cast<Resolution_t>(iresolution); 
00508     topology    = static_cast<Topology_t>(itopology);
00509     proton      = static_cast<ProtonTag_t>(iproton);
00510     electron    = static_cast<ElectronTag_t>(ielectron);
00511   }
00512 
00513   return;
00514 }

void Template::Load ( Int_t  id,
Histogram hist 
) [private]

Definition at line 327 of file Template.cxx.

References fHistogram, fHistogramList, fHistogramMap, fIndex, and fIndexList.

Referenced by BuildHistogram().

00328 {
00329   if( hist==0 ) return;
00330 
00331   std::map<Int_t,Histogram*>::iterator myEntry = fHistogramMap.find(id);
00332   
00333   if( myEntry==fHistogramMap.end() ){
00334     fHistogramMap.insert( std::pair<Int_t,Histogram*>(id,hist) );
00335     fHistogram = hist; fHistogramList.push_back(fHistogram);
00336     fIndex = id; fIndexList.push_back(fIndex);
00337   }
00338 
00339   return;
00340 }

void Template::LoopFill ( Run_t  run,
Containment_t  containment,
Flavour_t  flavour,
Charge_t  charge,
Resolution_t  resolution,
Topology_t  topology,
ProtonTag_t  proton,
ElectronTag_t  electron,
Histogram h,
Double_t  w = 1.0 
)

Definition at line 219 of file Template.cxx.

References OscFit::Histogram::Fill(), OscFit::Histogram::GetBinCenter(), OscFit::Histogram::GetBinContent(), OscFit::Histogram::GetNbins(), and MakeHistogram().

Referenced by OscFit::TemplateCalculator::FillCombinedBins().

00220 {
00221   if( h==0 ) return;
00222 
00223   Histogram* hist = MakeHistogram( run, containment, flavour, charge, 
00224                                    resolution, topology, proton, electron );
00225 
00226   for( Int_t ibin=0; ibin<hist->GetNbins(); ibin++ ){
00227     Double_t x = h->GetBinCenter(ibin);
00228     hist->Fill(x, h->GetBinContent(ibin) * w);
00229   }
00230 }

Histogram * Template::MakeHistogram ( Run_t  run,
Containment_t  containment,
Flavour_t  flavour,
Charge_t  charge,
Resolution_t  resolution,
Topology_t  topology,
ProtonTag_t  proton,
ElectronTag_t  electron 
)

Definition at line 282 of file Template.cxx.

References BuildHistogram(), GetHistogram(), and TouchHistogram().

Referenced by Add(), ConditionalAdd(), Fill(), LoopFill(), and SpecialAdd().

00283 {
00284   if( TouchHistogram( run, containment, flavour, charge, resolution, topology, proton, electron )==0 ){
00285     BuildHistogram( run, containment, flavour, charge, resolution, topology, proton, electron );
00286   }
00287 
00288   return GetHistogram( run, containment, flavour, charge, resolution, topology, proton, electron );
00289 }

TH1D * Template::MakeTH1D ( Bin_t  binType,
const char *  name 
)

Definition at line 79 of file twoflavours/Template.cxx.

References GetHistogramByType(), and OscFit::Histogram::MakeTH1D().

00080 {
00081   Histogram* hist = this->GetHistogramByType(binType);
00082 
00083   if( hist ) return hist->MakeTH1D(name);
00084   else return 0;
00085 }

void OscFit::Template::PrintHistograms (  ) 
void Template::PrintHistograms (  ) 

Definition at line 371 of file Template.cxx.

References OscFit::AsString(), fHistogramMap, GetHistogram(), OscFit::Histogram::GetTotalContent(), InvertID(), OscFit::kNothing, OscFit::kNull, OscFit::kUnknownCharge, OscFit::kUnknownElectronTag, OscFit::kUnknownFlavour, OscFit::kUnknownProtonTag, OscFit::kUnknownRes, OscFit::kUnknownRun, and run().

Referenced by OscFit::TwoFlavourFitter::PrintExpt(), and OscFit::ThreeFlavourFitter::PrintExpt().

00372 {
00373   std::map<Int_t,Histogram*>::iterator myIter = fHistogramMap.begin();
00374 
00375   Int_t ctr = 0;
00376 
00377   for( ; myIter!=fHistogramMap.end(); myIter++ ){
00378     Int_t id = myIter->first;
00379 
00380     Run_t         run         = kUnknownRun;
00381     Containment_t containment = kNull;
00382     Flavour_t     flavour     = kUnknownFlavour;
00383     Charge_t      charge      = kUnknownCharge;
00384     Resolution_t  resolution  = kUnknownRes;
00385     Topology_t    topology    = kNothing;
00386     ProtonTag_t   proton      = kUnknownProtonTag;
00387     ElectronTag_t electron    = kUnknownElectronTag;
00388 
00389     InvertID( id,
00390               run, containment, flavour, charge, 
00391               resolution, topology, proton, electron );
00392 
00393     Histogram* hist = this->GetHistogram( run, containment, 
00394                                           flavour, charge, 
00395                                           resolution, topology, 
00396                                           proton, electron );
00397 
00398     std::cout << "\t  (" << ctr << ") " 
00399               << "[" << OscFit::AsString(run) << "][" << OscFit::AsString(containment) << "]" 
00400               << "[" << OscFit::AsString(flavour) << "][" << OscFit::AsString(charge) << "]" 
00401               << "[" << OscFit::AsString(resolution) << "]" << "[" << OscFit::AsString(topology) << "]" 
00402               << "[" << OscFit::AsString(proton) << "][" << OscFit::AsString(electron) << "]" 
00403               << " Total=" << hist->GetTotalContent() << std::endl;
00404     ctr++;
00405   }
00406 }

void Template::ReadHistograms ( const char *  filename  ) 

Definition at line 98 of file twoflavours/Template.cxx.

References OscFit::AsString(), DeleteHistograms(), fHist, fHistArray, OscFit::GetBin(), and OscFit::GetNumBins().

Referenced by OscFit::TemplateMap::ReadTemplate().

00099 {
00100   DeleteHistograms();
00101 
00102   TDirectory* tmpd = gDirectory;
00103   TFile* file = new TFile(filename,"read");
00104 
00105   TString baseName = "h_";
00106   TString histName = "";
00107 
00108   for( Int_t ihist=0; ihist<OscFit::GetNumBins(); ihist++ ){  
00109     Bin_t binType = OscFit::GetBin(ihist);
00110 
00111     histName = baseName;
00112     histName.Append( AsString(binType) );
00113 
00114     fHist = 0;
00115 
00116     TH1D* myHist = (TH1D*)(file->Get( histName.Data() ));
00117 
00118     if( myHist ){
00119       fHist = new Histogram(myHist,binType);
00120     }
00121 
00122     fHistArray.push_back(fHist);
00123   }
00124 
00125   file->Close();
00126   tmpd->cd();
00127 
00128   return;
00129 }

void OscFit::Template::Reset (  ) 
void Template::Reset (  ) 
void Template::Scale ( Double_t  scale  ) 

Definition at line 151 of file Template.cxx.

References GetHistogram(), GetNumHistograms(), n, and OscFit::Histogram::Scale().

00152 {
00153   for( UInt_t n=0; n<GetNumHistograms(); n++ ){
00154     Histogram* hist = GetHistogram( n );
00155     if( hist ) hist->Scale( scale );
00156   }
00157 }

void OscFit::Template::SetDebug ( Bool_t  yesno = 1  )  [inline]

Definition at line 80 of file Template.h.

References fDebug.

00080 { fDebug = yesno; }

void Template::SpecialAdd ( Template tempCentre,
Template tempShifted,
Double_t  w = 1.0 
)

Definition at line 97 of file Template.cxx.

References OscFit::Histogram::Add(), Add(), GetHistogram(), GetIndex(), GetNumHistograms(), OscFit::Histogram::GetTotalContent(), InvertID(), OscFit::kNothing, OscFit::kNull, OscFit::kUnknownCharge, OscFit::kUnknownElectronTag, OscFit::kUnknownFlavour, OscFit::kUnknownProtonTag, OscFit::kUnknownRes, OscFit::kUnknownRun, MakeHistogram(), n, and run().

Referenced by OscFit::TemplateCalculator::GetDeltaExpectation(), and OscFit::TemplateCalculator::GetExpectation().

00098 {
00099   if( tempCentre==0 || w==0 ) return;
00100 
00101   if( tempShifted==0 ) return Add( tempCentre, w );
00102 
00103   for( UInt_t n=0; n<tempCentre->GetNumHistograms(); n++ ){
00104     Int_t id = tempCentre->GetIndex(n);
00105 
00106     Run_t         run         = kUnknownRun;
00107     Containment_t containment = kNull;
00108     Flavour_t     flavour     = kUnknownFlavour;
00109     Charge_t      charge      = kUnknownCharge;
00110     Resolution_t  resolution  = kUnknownRes;
00111     Topology_t    topology    = kNothing;
00112     ProtonTag_t   proton      = kUnknownProtonTag;
00113     ElectronTag_t electron    = kUnknownElectronTag;
00114 
00115     InvertID( id,
00116               run, containment, flavour, charge, 
00117               resolution, topology, proton, electron );
00118 
00119     Histogram* histCentre = tempCentre->GetHistogram( run, containment, 
00120                                                       flavour, charge, 
00121                                                       resolution, topology, 
00122                                                       proton, electron );
00123 
00124     Histogram* histShifted = tempShifted->GetHistogram( run, containment, 
00125                                                         flavour, charge, 
00126                                                         resolution, topology, 
00127                                                         proton, electron );
00128 
00129     Histogram* histInternal = this->MakeHistogram( run, containment, 
00130                                                    flavour, charge, 
00131                                                    resolution, topology, 
00132                                                    proton, electron );
00133 
00134     if( histShifted 
00135      && histShifted->GetTotalContent()>0.0 ) {
00136       histInternal->Add( histShifted, w );
00137     }
00138 
00139     else 
00140 
00141     if( histCentre
00142      && histCentre->GetTotalContent()>0.0 ) {
00143       histInternal->Add( histCentre, w );
00144     }
00145           
00146   }
00147 
00148   return;
00149 }

Bool_t Template::TouchHistogram ( Run_t  run,
Containment_t  containment,
Flavour_t  flavour,
Charge_t  charge,
Resolution_t  resolution,
Topology_t  topology,
ProtonTag_t  proton,
ElectronTag_t  electron 
)

Definition at line 291 of file Template.cxx.

References GetHistogram().

Referenced by MakeHistogram().

00292 {
00293   if( GetHistogram( run, containment, flavour, charge, resolution, topology, proton, electron ) ) return 1; else return 0;
00294 }

void Template::WriteHistograms ( const char *  filename  ) 

Definition at line 131 of file twoflavours/Template.cxx.

References OscFit::AsString(), fHist, fHistArray, OscFit::GetBin(), OscFit::GetNumBins(), and OscFit::Histogram::MakeTH1D().

Referenced by OscFit::TemplateMap::WriteTemplate().

00132 {
00133   TDirectory* tmpd = gDirectory;
00134   TFile* file = new TFile(filename,"recreate");
00135 
00136   TString baseName = "h_";
00137   TString histName = "";
00138 
00139   for( Int_t ihist=0; ihist<OscFit::GetNumBins(); ihist++ ){
00140     Bin_t binType = OscFit::GetBin(ihist);
00141     
00142     histName = baseName;
00143     histName.Append( AsString(binType) );
00144 
00145     fHist = (Histogram*)(fHistArray.at(ihist));
00146 
00147     TH1D* myHist = fHist->MakeTH1D( histName.Data() );    
00148     myHist->Write();
00149   }
00150 
00151   file->Close();
00152   tmpd->cd();
00153 
00154   return;
00155 }


Member Data Documentation

Bool_t OscFit::Template::fDebug [private]

Definition at line 116 of file Template.h.

Referenced by SetDebug().

Definition at line 42 of file twoflavours/Template.h.

Referenced by BuildHistograms(), ReadHistograms(), and WriteHistograms().

std::vector<Histogram*> OscFit::Template::fHistArray [private]

Definition at line 113 of file Template.h.

Referenced by BuildHistogram(), and Load().

Definition at line 110 of file Template.h.

Referenced by DeleteContents(), GetHistogram(), and Load().

std::map<Int_t,Histogram*> OscFit::Template::fHistogramMap [private]
Int_t OscFit::Template::fIndex [private]

Definition at line 114 of file Template.h.

Referenced by Load().

std::vector<Int_t> OscFit::Template::fIndexList [private]

Definition at line 111 of file Template.h.

Referenced by DeleteContents(), GetIndex(), GetNumHistograms(), and Load().


The documentation for this class was generated from the following files:

Generated on 15 Nov 2018 for loon by  doxygen 1.6.1