CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

BscAnalysisHistManager Class Reference

#include <BscTest.h>

Inheritance diagram for BscAnalysisHistManager:
TNamed

List of all members.

Public Member Functions

 BscAnalysisHistManager (TString managername)
TH1F * GetHisto (const TObjString histname)
TH1F * GetHisto (Int_t Number)
TH2F * GetHisto2 (Int_t Number)
TH2F * GetHisto2 (const TObjString histname)
void WriteToFile (TString fOutputFile, TString fRecreateFile)
 ~BscAnalysisHistManager ()

Private Member Functions

void BookHistos ()
void HistInit (const char *name, const char *title, Int_t nbinsx, Axis_t xlow, Axis_t xup, Int_t nbinsy, Axis_t ylow, Axis_t yup)
void HistInit (const char *name, const char *title, Int_t nbinsx, Axis_t xlow, Axis_t xup)
void StoreWeights ()

Private Attributes

TObjArray * fHistArray
TObjArray * fHistNamesArray
const char * fTypeTitle

Detailed Description

Definition at line 66 of file BscTest.h.


Constructor & Destructor Documentation

BscAnalysisHistManager::BscAnalysisHistManager ( TString  managername)

Definition at line 118 of file BscTest.cc.

References BookHistos(), fHistArray, fHistNamesArray, and fTypeTitle.

{
  // The Constructor

  fTypeTitle=managername;
  fHistArray = new TObjArray();      // Array to store histos
  fHistNamesArray = new TObjArray(); // Array to store histos's names

  BookHistos();

  fHistArray->Compress();            // Removes empty space
  fHistNamesArray->Compress();

  //      StoreWeights();                    // Store the weights

}
BscAnalysisHistManager::~BscAnalysisHistManager ( )

Definition at line 136 of file BscTest.cc.

References fHistArray, and fHistNamesArray.

{
  // The Destructor

  if(fHistArray){
    fHistArray->Delete();
    delete fHistArray;
  }

  if(fHistNamesArray){
    fHistNamesArray->Delete();
    delete fHistNamesArray;
  }
}

Member Function Documentation

void BscAnalysisHistManager::BookHistos ( ) [private]

Definition at line 152 of file BscTest.cc.

References HistInit().

Referenced by BscAnalysisHistManager().

{
  // at Start: (mm)
  HistInit("TrackPhi", "Primary Phi",   100,   0.,360. );
  HistInit("TrackTheta", "Primary Theta",   100,   0.,180. );
  HistInit("TrackP", "Track XY position Z+ ",  80, -80., 80.,  80, -80., 80. );
  HistInit("TrackM", "Track XY position Z-",   80, -80., 80.,  80, -80., 80. );
  HistInit("DetIDs", "Track DetId - vs +",   16, -0.5, 15.5,16, 15.5, 31.5 );
}
TH1F * BscAnalysisHistManager::GetHisto ( const TObjString  histname)

Definition at line 248 of file BscTest.cc.

References fHistNamesArray, GetHisto(), and getHLTprescales::index.

{
  // Get a histogram from the array with name = histname

  Int_t index = fHistNamesArray->IndexOf(&histname);
  return GetHisto(index);
}
TH1F * BscAnalysisHistManager::GetHisto ( Int_t  Number)

Definition at line 210 of file BscTest.cc.

References gather_cfg::cout, and fHistArray.

Referenced by GetHisto(), and BscTest::update().

{
  // Get a histogram from the array with index = Number

  if (Number <= fHistArray->GetLast()  && fHistArray->At(Number) != (TObject*)0){

    return (TH1F*)(fHistArray->At(Number));

  }else{

    std::cout << "!!!!!!!!!!!!!!!!!!GetHisto!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
    std::cout << " WARNING ERROR - HIST ID INCORRECT (TOO HIGH) - " << Number << std::endl;
    std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;

    return (TH1F*)(fHistArray->At(0));
  }
}
TH2F * BscAnalysisHistManager::GetHisto2 ( const TObjString  histname)

Definition at line 257 of file BscTest.cc.

References fHistNamesArray, GetHisto2(), and getHLTprescales::index.

{
  // Get a histogram from the array with name = histname

  Int_t index = fHistNamesArray->IndexOf(&histname);
  return GetHisto2(index);
}
TH2F * BscAnalysisHistManager::GetHisto2 ( Int_t  Number)

Definition at line 229 of file BscTest.cc.

References gather_cfg::cout, and fHistArray.

Referenced by GetHisto2().

{
  // Get a histogram from the array with index = Number

  if (Number <= fHistArray->GetLast()  && fHistArray->At(Number) != (TObject*)0){

    return (TH2F*)(fHistArray->At(Number));

  }else{

    std::cout << "!!!!!!!!!!!!!!!!GetHisto2!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
    std::cout << " WARNING ERROR - HIST ID INCORRECT (TOO HIGH) - " << Number << std::endl;
    std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;

    return (TH2F*)(fHistArray->At(0));
  }
}
void BscAnalysisHistManager::HistInit ( const char *  name,
const char *  title,
Int_t  nbinsx,
Axis_t  xlow,
Axis_t  xup,
Int_t  nbinsy,
Axis_t  ylow,
Axis_t  yup 
) [private]

Definition at line 195 of file BscTest.cc.

References fHistArray, fHistNamesArray, and fTypeTitle.

{
  // Add histograms and histograms names to the array

  char* newtitle = new char[strlen(title)+strlen(fTypeTitle)+5];
  strcpy(newtitle,title);
  strcat(newtitle," (");
  strcat(newtitle,fTypeTitle);
  strcat(newtitle,") ");
  fHistArray->AddLast((new TH2F(name, newtitle, nbinsx, xlow, xup, nbinsy, ylow, yup)));
  fHistNamesArray->AddLast(new TObjString(name));

}
void BscAnalysisHistManager::HistInit ( const char *  name,
const char *  title,
Int_t  nbinsx,
Axis_t  xlow,
Axis_t  xup 
) [private]

Definition at line 180 of file BscTest.cc.

References fHistArray, fHistNamesArray, and fTypeTitle.

Referenced by BookHistos().

{
  // Add histograms and histograms names to the array

  char* newtitle = new char[strlen(title)+strlen(fTypeTitle)+5];
  strcpy(newtitle,title);
  strcat(newtitle," (");
  strcat(newtitle,fTypeTitle);
  strcat(newtitle,") ");
  fHistArray->AddLast((new TH1F(name, newtitle, nbinsx, xlow, xup)));
  fHistNamesArray->AddLast(new TObjString(name));

}
void BscAnalysisHistManager::StoreWeights ( ) [private]

Definition at line 266 of file BscTest.cc.

References fHistArray, and i.

{
  // Add structure to each histogram to store the weights

  for(int i = 0; i < fHistArray->GetEntries(); i++){
    ((TH1F*)(fHistArray->At(i)))->Sumw2();
  }
}
void BscAnalysisHistManager::WriteToFile ( TString  fOutputFile,
TString  fRecreateFile 
)

Definition at line 164 of file BscTest.cc.

References gather_cfg::cout, fHistArray, and mergeVDriftHistosByStation::file.

Referenced by BscTest::~BscTest().

{

  //Write to file = fOutputFile

  std::cout <<"================================================================"<<std::endl;
  std::cout <<" Write this Analysis to File "<<fOutputFile<<std::endl;
  std::cout <<"================================================================"<<std::endl;

  TFile* file = new TFile(fOutputFile, fRecreateFile);

  fHistArray->Write();
  file->Close();
}

Member Data Documentation

TObjArray* BscAnalysisHistManager::fHistArray [private]
const char* BscAnalysisHistManager::fTypeTitle [private]

Definition at line 87 of file BscTest.h.

Referenced by BscAnalysisHistManager(), and HistInit().