Commit 653c09fb authored by vpalladi's avatar vpalladi

added class TH2Det. This class will provide 2d histos with the detector shape.

parent 6a80a1fa
#ifndef TH2det_HH
#define TH2det_HH
#include <iostream>
#include <string>
#include "TH2Poly.h"
#include "Geometry.hh"
#include "Event.hh"
class TH2Det{
public:
TH2Det(){
hOccupancy = new TH2Poly**[Geometry::kNumberOfEndcaps];
for(int e=0; e<Geometry::kNumberOfEndcaps; e++){
hOccupancy[e] = new TH2Poly*[Geometry::kNumberOfLayers];
for(int l=0; l<Geometry::kNumberOfLayers; l++){
string histoName= "E"+to_string(e)+"L"+to_string(l)+"_"+"Occupancy";
hOccupancy[e][l] = new TH2Poly();
hOccupancy[e][l]->SetName( histoName.c_str() );
hOccupancy[e][l]->SetTitle( histoName.c_str() );
vector<hgcWafer*> wafers = Geometry::getWafers(e, l);
for(unsigned i_wafer=0; i_wafer<wafers.size(); i_wafer++){
vector<hgcTriggerCell*> tcs = wafers.at(i_wafer)->getTriggerCells();
for(unsigned i_tc=0; i_tc<tcs.size(); i_tc++){
vector< pair<float,float> > corners = tcs.at(i_tc)->getCorners();
const int nCorners = corners.size();
Double_t X[nCorners];
Double_t Y[nCorners];
for(unsigned i_corner=0; i_corner<corners.size(); i_corner++ ){
X[i_corner] = corners.at(i_corner).first;
Y[i_corner] = corners.at(i_corner).second;
}
hOccupancy[e][l]->AddBin(nCorners, X, Y);
}
}
}
}
}
~TH2Det(){
for(unsigned e(0); e<Geometry::kNumberOfEndcaps; e++){
for(unsigned l(0); l<Geometry::kNumberOfLayers; l++){
delete hOccupancy[e][l];
}
delete hOccupancy[e];
}
}
void Reset(){
for(unsigned e(0); e<Geometry::kNumberOfEndcaps; e++)
for(unsigned l(0); l<Geometry::kNumberOfLayers; l++)
hOccupancy[e][l]->Reset("ICE");
}
void Fill(int endcap, int layer, double x, double y, double w=1.){
hOccupancy[endcap][layer]->Fill(x, y, w);
}
TH2Poly* GetHisto(int endcap, int layer){
return hOccupancy[endcap][layer];
}
TH2Poly*** GetHistos(){
return hOccupancy;
}
void Write(TFile* f){
f->cd();
for(unsigned e(0); e<Geometry::kNumberOfEndcaps; e++) {
for(unsigned l(0); l<Geometry::kNumberOfLayers; l++) {
std::string label("");
TDirectory* dir = f->mkdir( (label+"E"+to_string(e)+"L"+to_string(l)).c_str() );
dir->cd();
hOccupancy[e][l]->Write();
}
}
}
private:
TH2Poly*** hOccupancy;
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment