#include <iostream.h>
#include "TFndTofMon.h"
#include "TDirectory.h"
#include "TFndHTof.h"
#include "TObjArray.h"
ClassImp(TFndTofMon);
TFndTofMon::TFndTofMon(const char *fmode,Int_t tof_tdc_bins,Double_t tof_tdc_min,Double_t tof_tdc_max) {
tof_mon_adc = 0;
tof_mon_tdc = 0;
tof_mon_adc_tdc = 0;
const char *fhist = "_tof.root";
const char *fonl = "onl";
shmflg = 0;
if(!strcmp(fmode,fonl)) shmflg = 1;
//cout << "Online flag is " << onlflg << endl;
Int_t ilen = strlen(fmode)+strlen(fhist);
Char_t *ftofnam = new Char_t[ilen];
strcpy(ftofnam,fmode);
ftofnam = strcat(ftofnam,fhist);
ftof = new TFile(ftofnam,"RECREATE","Tof Histogram File");
if(shmflg) {
const char *mfntof = "tof.map";
mtof = TMapFile::Create(mfntof,"RECREATE",2000000,"Tof memory mapped file with histograms");
mtof->Print();
}
tofmult = new TH1F("tofmult","Tof multiplicity",10,-0.5,9.5);
tof_upp_mult = new TH1F("tof_upp_mult","Upper Multiplicity",10,-0.5,9.5);
tof_low_mult = new TH1F("tof_low_mult","Lower Multiplicity",10,-0.5,9.5);
tofmap = new TH1F("tofmap","Tof Hit pattern",20,0.5,20.5);
tofmapadc0 = new TH1F("tofmapadc0","Tof ADC pattern (F || R != 0)",20,0.5,20.5);
tofmapadc00 = new TH1F("tofmapadc00","Tof ADC pattern (F && R != 0)",20,0.5,20.5);
tofmapadcf = new TH1F("tofmapadcf","Tof ADC pattern (Front)",20,0.5,20.5);
tofmapadcr = new TH1F("tofmapadcr","Tof ADC pattern (Rear)",20,0.5,20.5);
tofmaptdc0 = new TH1F("tofmaptdc0","Tof TDC pattern (F || R != 0)",20,0.5,20.5);
tofmaptdc00 = new TH1F("tofmaptdc00","Tof TDC pattern (F && R != 0)",20,0.5,20.5);
tofmaptdcf = new TH1F("tofmaptdcf","Tof TDC pattern (Front)",20,0.5,20.5);
tofmaptdcr = new TH1F("tofmaptdcr","Tof TDC pattern (Rear)",20,0.5,20.5);
// shdir_tof->ls();
char hname[40];
char htitle[80];
Int_t tof_adc_bins = 103;
Double_t tof_adc_min = 0.;
Double_t tof_adc_max = 4120.;
for (Int_t ji=0;ji<n_tof_hist;ji++) {
sprintf(hname,"tof_mapadctdc_%d",ji+1);
sprintf(htitle,"ADC F/R vs TDC F/R for slab: %d",ji+1);
tof_mapadctdc[ji] = new TH2F(hname,htitle,4,-0.5,3.5,4,-0.5,3.5);
sprintf(hname,"tof_adc_tdc_%d",ji+1);
sprintf(htitle,"ADC vs TDC for slab: %d",ji+1);
tof_adc_tdc[ji] = new TH2F(hname,htitle,tof_tdc_bins,tof_tdc_min,tof_tdc_max,tof_adc_bins,tof_adc_min,tof_adc_max);
}
// TOF ADC
if(shmflg) {
const char *mfntof_adc = "tof_adc.map";
//TMapFile::SetMapAddress(0x40b40000);
mtof_adc = TMapFile::Create(mfntof_adc,"RECREATE",2000000,"Tof memory mapped file with ADC histograms");
mtof_adc->Print();
}
for (Int_t l=0;l<n_tof_hist;l++) {
sprintf(hname,"tofadcf_%d",l+1);
sprintf(htitle,"ADC Front for Slab: %d",l+1);
tofadcf[l] = new TH1F(hname,htitle,tof_adc_bins,tof_adc_min,tof_adc_max);
tofadcf[l]->SetFillColor(6);
sprintf(hname,"tofadcr_%d",l+1);
sprintf(htitle,"ADC Rear for Slab: %d",l+1);
tofadcr[l] = new TH1F(hname,htitle,tof_adc_bins,tof_adc_min,tof_adc_max);
tofadcr[l]->SetFillColor(7);
sprintf(hname,"tofcrg_%d",l+1);
sprintf(htitle,"ADC Front + Rear for Slab: %d",l+1);
tofcrg[l] = new TH1F(hname,htitle,tof_adc_bins,2*tof_adc_min,2*tof_adc_max);
tofcrg[l]->SetFillColor(9);
sprintf(hname,"tofadc_%d",l+1);
sprintf(htitle,"ADC Front vs Rear for Slab: %d",l+1);
tofadc[l] = new TH2F(hname,htitle,tof_adc_bins,tof_adc_min,tof_adc_max,tof_adc_bins,tof_adc_min,tof_adc_max);
tofadc[l]->SetFillColor(8);
}
// shdir_tof_adc->ls();
// TOF TDC
if(shmflg) {
const char *mfntof_tdc = "tof_tdc.map";
//TMapFile::SetMapAddress(0x40d29000);
mtof_tdc = TMapFile::Create(mfntof_tdc,"RECREATE",2000000,"Tof memory mapped file with TDC histograms");
mtof_tdc->Print();
}
for (Int_t k=0;k<n_tof_hist;k++) {
sprintf(hname,"toftdcf_%d",k+1);
sprintf(htitle,"TDC Front for Slab: %d",k+1);
toftdcf[k] = new TH1F(hname,htitle,tof_tdc_bins,tof_tdc_min,tof_tdc_max);
toftdcf[k]->SetFillColor(6);
sprintf(hname,"toftdcr_%d",k+1);
sprintf(htitle,"TDC Rear for Slab: %d",k+1);
toftdcr[k] = new TH1F(hname,htitle,tof_tdc_bins,tof_tdc_min,tof_tdc_max);
toftdcr[k]->SetFillColor(7);
sprintf(hname,"toftdf_%d",k+1);
sprintf(htitle,"TDC Front - Rear for Slab: %d",k+1);
toftdf[k] = new TH1F(hname,htitle,100,-100,100);
toftdf[k]->SetFillColor(9);
sprintf(hname,"toftmn_%d",k+1);
sprintf(htitle,"TDC Mean Time for Slab: %d",k+1);
toftmn[k] = new TH1F(hname,htitle,tof_tdc_bins,tof_tdc_min,tof_tdc_max);
toftmn[k]->SetFillColor(9);
sprintf(hname,"toftdc_%d",k+1);
sprintf(htitle,"TDC Front vs Rear for Slab: %d",k+1);
toftdc[k] = new TH2F(hname,htitle,tof_tdc_bins,tof_tdc_min,tof_tdc_max,tof_tdc_bins,tof_tdc_min,tof_tdc_max);
toftdc[k]->SetFillColor(8);
}
// shdir_tof_tdc->ls();
tof1d = 0;
tof2d = 0;
}
TFndTofMon::TFndTofMon() {
ftof = 0;
mtof = TMapFile::Create("tof.map","UPDATE");
mtof->Print();
mtof_adc = TMapFile::Create("tof_adc.map","UPDATE");
mtof_adc->Print();
mtof_tdc = TMapFile::Create("tof_tdc.map","UPDATE");
mtof_tdc->Print();
tof_mon_adc = new TCanvas("tof_mon_adc","Tof ADCs",10,10,600,600);
tof_mon_tdc = new TCanvas("tof_mon_tdc","Tof TDCs",640,10,600,600);
tof_mon_adc_tdc = new TCanvas("tof_mon_adc_tdc","Tof ADC/TDC correlation",640,640,600,300);
tof1d = 0;
tof2d = 0;
}
TFndTofMon::~TFndTofMon() {
if(ftof) ftof->Close();
delete ftof;
mtof->Close();
delete mtof;
mtof_adc->Close();
delete mtof_adc;
mtof_tdc->Close();
delete mtof_tdc;
delete tof_mon_adc;
delete tof_mon_tdc;
delete tof_mon_adc_tdc;
delete tof1d;
delete tof2d;
/*
delete tofmult;
delete tofmap;
*/
}
void TFndTofMon::Fill(TFndHdt *fndhdt) {
TObjArray *fHTof = fndhdt->GetTof();
Int_t nhtof = fndhdt->GetNHTof();
tofmult->Fill((Float_t) nhtof);
Int_t upp_mult = 0;
Int_t low_mult = 0;
for (Int_t j=0; j<nhtof; j++) {
TFndHTof *htof = (TFndHTof*) fHTof->At(j);
Float_t slb = (Float_t) (htof->GetSlab() - 100);
Int_t sf=0;
Float_t al = (Float_t) htof->GetAdcF();
Float_t ar = (Float_t) htof->GetAdcR();
Float_t tl = (Float_t) htof->GetTdcF();
Float_t tr = (Float_t) htof->GetTdcR();
tofmap->Fill(slb);
if(slb<10) upp_mult++;
if(slb>9 && slb<=18) low_mult++;
if((al+ar)!= 0)
tofmapadc0->Fill(slb);
if((al*ar) != 0)
tofmapadc00->Fill(slb);
if(al != 0)
tofmapadcf->Fill(slb);
if(ar != 0)
tofmapadcr->Fill(slb);
if((tl+tr)!= 0)
tofmaptdc0->Fill(slb);
if((tl*tr) != 0)
tofmaptdc00->Fill(slb);
if(tl != 0)
tofmaptdcf->Fill(slb);
if(tr != 0)
tofmaptdcr->Fill(slb);
Float_t itdc = 0.;
if(tl*tr) itdc = 3.;
if(tl && !tr) itdc = 1.;
if(!tl && tr) itdc = 2.;
Float_t iadc = 0.;
if(al*ar) iadc = 3.;
if(al && !ar) iadc = 1.;
if(!al && ar) iadc = 2.;
sf = (Int_t) slb - 1;
tof_mapadctdc[sf]->Fill(itdc,iadc);
tof_adc_tdc[sf]->Fill(tl,al);
tof_adc_tdc[sf]->Fill(tr,ar);
tofadcf[sf]->Fill(al);
tofadcr[sf]->Fill(ar);
tofadc[sf]->Fill(ar,al);
tofcrg[sf]->Fill(al+ar);
toftdcf[sf]->Fill(tl);
toftdcr[sf]->Fill(tr);
toftdc[sf]->Fill(tr,tl);
if (tl != tr) {
toftdf[sf]->Fill(tl-tr);
toftmn[sf]->Fill((tl+tr)/2);
}
}
tof_upp_mult->Fill((Float_t) upp_mult);
tof_low_mult->Fill((Float_t) low_mult);
}
void TFndTofMon::Update() {
mtof->Update();
mtof_adc->Update();
mtof_tdc->Update();
}
void TFndTofMon::WriteToFile() {
ftof->cd();
tofmap->Write();
tofmapadc0->Write();
tofmapadc00->Write();
tofmapadcf->Write();
tofmapadcr->Write();
tofmaptdc0->Write();
tofmaptdc00->Write();
tofmaptdcf->Write();
tofmaptdcr->Write();
tof_upp_mult->Write();
tof_low_mult->Write();
for(Int_t sf=0; sf<n_tof_hist; sf++) {
tof_mapadctdc[sf]->Write();
tof_adc_tdc[sf]->Write();
tof_adc_tdc[sf]->Write();
tofadcf[sf]->Write();
tofadcr[sf]->Write();
tofadc[sf]->Write();
tofcrg[sf]->Write();
toftdcf[sf]->Write();
toftdcr[sf]->Write();
toftdc[sf]->Write();
toftdf[sf]->Write();
toftmn[sf]->Write();
}
}
void TFndTofMon::DisplaySlab(Int_t slab) {
if(slab < 1 || slab > 20) {
cout << "WRONG slab number " << slab << endl;
return;
}
// TH1F *tof1d;
// TH2F *tof2d;
Char_t cslab[3];
sprintf(cslab,"%d",slab);
// ADC
tof_mon_adc->Clear();
tof_mon_adc->Divide(2,2);
for(Int_t ja=0; ja<4; ja++) {
TString *hname = new TString("tof");
if(ja==0) hname->Append("adcf_");
if(ja==1) hname->Append("adcr_");
if(ja==2) hname->Append("adc_");
if(ja==3) hname->Append("crg_");
hname->Append(cslab);
if(ja != 2) {
tof1d = (TH1F *) mtof_adc->Get(hname->Data());
} else {
tof2d = (TH2F *) mtof_adc->Get(hname->Data());
}
tof_mon_adc->cd(ja+1);
if(ja != 2) tof1d->Draw();
if(ja == 2) tof2d->Draw();
delete hname;
}
tof_mon_adc->Update();
tof_mon_tdc->Clear();
tof_mon_tdc->Divide(2,3);
for(Int_t jb=0; jb<5; jb++) {
TString *hname = new TString("tof");
if(jb==0) hname->Append("tdcf_");
if(jb==1) hname->Append("tdcr_");
if(jb==2) hname->Append("tdc_");
if(jb==3) hname->Append("tdf_");
if(jb==4) hname->Append("tmn_");
hname->Append(cslab);
if(jb != 2) {
tof1d = (TH1F *) mtof_tdc->Get(hname->Data());
} else {
tof2d = (TH2F *) mtof_tdc->Get(hname->Data());
}
tof_mon_tdc->cd(jb+1);
if(jb != 2) tof1d->Draw();
if(jb == 2) tof2d->Draw();
delete hname;
}
tof_mon_tdc->Update();
tof_mon_adc_tdc->Clear();
tof_mon_adc_tdc->Divide(2,1);
for(Int_t jc=0; jc<2; jc++) {
TString *hname = new TString("tof_");
if(jc==0) hname->Append("mapadctdc_");
if(jc==1) hname->Append("adc_tdc_");
hname->Append(cslab);
tof2d = (TH2F *) mtof->Get(hname->Data());
tof_mon_adc_tdc->cd(jc+1);
tof2d->Draw();
delete hname;
}
tof_mon_adc_tdc->Update();
}
void TFndTofMon::Streamer(TBuffer &R__b) {}
ROOT page - Class index - Top of the page
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.