Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

MeuHistos.cxx

Go to the documentation of this file.
00001 
00002 
00003 // Coded by Jeff Hartnell Apr/2007
00004 //
00005 // Contact: j.j.hartnell@rl.ac.uk
00007 
00008 #include "TH2F.h"
00009 #include "TF1.h"
00010 #include "TProfile2D.h"
00011 #include "TROOT.h"
00012 
00013 #include "MessageService/MsgService.h"
00014 #include "StandardNtuple/NtpStRecord.h"
00015 
00016 #include "MeuCal/MeuHistos.h"
00017 #include "MeuCal/MeuSummary.h"
00018 #include <cmath>
00019 
00020 using std::endl;
00021 using std::cout;
00022 
00023 CVSID("$Id: MeuHistos.cxx,v 1.4 2007/05/09 14:08:38 hartnell Exp $");
00024 
00025 //......................................................................
00026 
00027 MeuHistos::MeuHistos()
00028 {
00029   MSG("MeuHistos",Msg::kDebug)
00030     <<"Running MeuHistos Constructor..."<<endl;
00031 
00032 
00033   MSG("MeuHistos",Msg::kDebug)
00034     <<"Finished MeuHistos Constructor"<<endl;
00035 }
00036 
00037 //......................................................................
00038 
00039 MeuHistos::~MeuHistos()
00040 {
00041   MSG("MeuHistos",Msg::kDebug)
00042     <<"Running MeuHistos Destructor..."<<endl;
00043   
00044 
00045   MSG("MeuHistos",Msg::kDebug)
00046     <<"Finished MeuHistos Destructor"<<endl;
00047 }
00048 
00049 //......................................................................
00050 
00051 void MeuHistos::FillGeneralHistos(const NtpStRecord& ntp) const
00052 {
00053   //histogram for recording which detector
00054   static TH1F* hDetector=0;
00055   static TH1F* hSimFlag=0;
00056   static TH1F* hTrigSrc=0;
00057   static TH1F* hRun=0;
00058 
00059   if (!hDetector){
00060     hDetector=new TH1F("hDetector","hDetector",40,-20,20);
00061     hSimFlag=new TH1F("hSimFlag","hSimFlag",40,-20,20);
00062     
00063     hTrigSrc=new TH1F("hTrigSrc","hTrigSrc",7000,-1,70000);
00064     //hTrigSrc->SetBit(TH1::kCanRebin);
00065     
00066     //1,0000,0000 is the largest run defined by the daq file name
00067     //e.g. N00007764_0011.spill.sntp.R1_18_2.0.root
00068     hRun=new TH1F("hRun","hRun",1000,0,100000000);
00069   }
00070 
00071   //record which detector and simflag - useful in plotting macros
00072   hDetector->Fill(ntp.GetHeader().GetVldContext().GetDetector());
00073   hSimFlag->Fill(ntp.GetHeader().GetVldContext().GetSimFlag());
00074   hTrigSrc->Fill(ntp.GetHeader().GetTrigSrc());
00075 
00076   Int_t run=ntp.GetHeader().GetRun();  
00077   static Int_t lastRun=-1;
00078   if (run!=lastRun){
00079     hRun->Fill(run);
00080     MSG("MeuHistos",Msg::kInfo)
00081       <<"Found new run="<<run<<", lastRun="<<lastRun
00082       <<", total runs found="<<hRun->GetEntries()<<endl;
00083     lastRun=run;
00084   }
00085 }
00086 
00087 //......................................................................
00088 
00089 void MeuHistos::FillMeuHistos(const MeuSummary& s) const
00090 {
00091   static TH1F* hWinSigMap=0;
00092   static TH1F* hWinSigCor=0;
00093   static TH1F* hWinSigLin=0;
00094   static TH1F* hWinAdc=0;
00095   static TH1F* hWinPe=0;
00096   static TH1F* hWinSigLinOnly=0;
00097   static TH1F* hWinSigDrf=0;
00098 
00099   if (!hWinSigMap) {
00100     hWinSigMap=new TH1F("hWinSigMap","hWinSigMap",3000,-1,4000);
00101     hWinSigMap->SetTitle("hWinSigMap");
00102     hWinSigMap->GetXaxis()->SetTitle("hWinSigMap");
00103     hWinSigMap->GetXaxis()->CenterTitle();
00104     hWinSigMap->SetFillColor(0);
00105     hWinSigMap->SetLineWidth(3);
00106     //hWinSigMap->SetBit(TH1::kCanRebin);
00107   
00108     hWinSigCor=new TH1F("hWinSigCor","hWinSigCor",3000,-1,4000);
00109     hWinSigCor->SetTitle("hWinSigCor");
00110     hWinSigCor->GetXaxis()->SetTitle("hWinSigCor");
00111     hWinSigCor->GetXaxis()->CenterTitle();
00112     hWinSigCor->SetFillColor(0);
00113     hWinSigCor->SetLineWidth(3);
00114     //hWinSigCor->SetBit(TH1::kCanRebin);
00115   
00116     hWinSigLin=new TH1F("hWinSigLin","hWinSigLin",3000,-1,4000);
00117     hWinSigLin->SetTitle("hWinSigLin");
00118     hWinSigLin->GetXaxis()->SetTitle("hWinSigLin");
00119     hWinSigLin->GetXaxis()->CenterTitle();
00120     hWinSigLin->SetFillColor(0);
00121     hWinSigLin->SetLineWidth(3);
00122     //hWinSigLin->SetBit(TH1::kCanRebin);
00123 
00124     hWinAdc=new TH1F("hWinAdc","hWinAdc",3000,-1,4000);
00125     hWinAdc->SetTitle("hWinAdc");
00126     hWinAdc->GetXaxis()->SetTitle("hWinAdc");
00127     hWinAdc->GetXaxis()->CenterTitle();
00128     hWinAdc->SetFillColor(0);
00129     hWinAdc->SetLineWidth(3);
00130     //hWinAdc->SetBit(TH1::kCanRebin);
00131 
00132     hWinPe=new TH1F("hWinPe","hWinPe",3000,-1,400);
00133     hWinPe->SetTitle("hWinPe");
00134     hWinPe->GetXaxis()->SetTitle("hWinPe");
00135     hWinPe->GetXaxis()->CenterTitle();
00136     hWinPe->SetFillColor(0);
00137     hWinPe->SetLineWidth(3);
00138     //hWinPe->SetBit(TH1::kCanRebin);
00139 
00140     hWinSigLinOnly=new TH1F("hWinSigLinOnly","hWinSigLinOnly",3000,-1,4000);
00141     hWinSigLinOnly->SetTitle("hWinSigLinOnly");
00142     hWinSigLinOnly->GetXaxis()->SetTitle("hWinSigLinOnly");
00143     hWinSigLinOnly->GetXaxis()->CenterTitle();
00144     hWinSigLinOnly->SetFillColor(0);
00145     hWinSigLinOnly->SetLineWidth(3);
00146     //hWinSigLinOnly->SetBit(TH1::kCanRebin);
00147 
00148     hWinSigDrf=new TH1F("hWinSigDrf","hWinSigDrf",3000,-1,4000);
00149     hWinSigDrf->SetTitle("hWinSigDrf");
00150     hWinSigDrf->GetXaxis()->SetTitle("hWinSigDrf");
00151     hWinSigDrf->GetXaxis()->CenterTitle();
00152     hWinSigDrf->SetFillColor(0);
00153     hWinSigDrf->SetLineWidth(3);
00154     //hWinSigDrf->SetBit(TH1::kCanRebin);
00155   }
00156 
00157   //fill the histos
00158   hWinSigMap->Fill(s.WinSigMap);
00159   hWinSigCor->Fill(s.WinSigCor);
00160   hWinSigLin->Fill(s.WinSigLin);
00161   hWinAdc->Fill(s.WinAdc);
00162   hWinPe->Fill(s.WinPe);
00163   hWinSigLinOnly->Fill(s.WinSigLinOnly);
00164   hWinSigDrf->Fill(s.WinSigDrf);
00165 }
00166 
00167 //......................................................................
00168 
00169 void MeuHistos::PrintMeuValues() const
00170 {
00171   Double_t quantile=0.5;//quantile to compute
00172 
00173   TH1F* hWinSigMap=static_cast<TH1F*>(gROOT->FindObject("hWinSigMap"));
00174   TH1F* hWinSigCor=static_cast<TH1F*>(gROOT->FindObject("hWinSigCor"));
00175   TH1F* hWinSigLin=static_cast<TH1F*>(gROOT->FindObject("hWinSigLin"));
00176   TH1F* hWinAdc=static_cast<TH1F*>(gROOT->FindObject("hWinAdc"));
00177   TH1F* hWinPe=static_cast<TH1F*>(gROOT->FindObject("hWinPe"));
00178   
00179   Double_t meuWinSigMap=-1;
00180   hWinSigMap->GetQuantiles(1,&meuWinSigMap,&quantile);
00181   Double_t errWinSigMap=hWinSigMap->GetRMS()/
00182     sqrt(hWinSigMap->GetEntries());
00183   Double_t relErrWinSigMap=errWinSigMap/meuWinSigMap;
00184   
00185   Double_t meuWinSigCor=-1;
00186   hWinSigCor->GetQuantiles(1,&meuWinSigCor,&quantile);
00187   Double_t errWinSigCor=hWinSigCor->GetRMS()/
00188     sqrt(hWinSigCor->GetEntries());
00189   Double_t relErrWinSigCor=errWinSigCor/meuWinSigCor;
00190 
00191   Double_t meuWinSigLin=-1;
00192   hWinSigLin->GetQuantiles(1,&meuWinSigLin,&quantile);
00193   Double_t errWinSigLin=hWinSigLin->GetRMS()/
00194     sqrt(hWinSigLin->GetEntries());
00195   Double_t relErrWinSigLin=errWinSigLin/meuWinSigLin;
00196 
00197   Double_t meuWinAdc=-1;
00198   hWinAdc->GetQuantiles(1,&meuWinAdc,&quantile);
00199   Double_t errWinAdc=hWinAdc->GetRMS()/
00200     sqrt(hWinAdc->GetEntries());
00201   Double_t relErrWinAdc=errWinAdc/meuWinAdc;
00202 
00203   Double_t meuWinPe=-1;
00204   hWinPe->GetQuantiles(1,&meuWinPe,&quantile);
00205   Double_t errWinPe=hWinPe->GetRMS()/
00206     sqrt(hWinPe->GetEntries());
00207   Double_t relErrWinPe=errWinPe/meuWinPe;
00208 
00209   hWinPe->Fit("gaus");
00210   TF1* fPe=hWinPe->GetFunction("gaus");
00211   Double_t errWinPe2=fPe->GetParameter(2)/sqrt(hWinPe->GetEntries());
00212   
00213   //cout<<"RESOLUTIONS (from Gaussian fit):"<<endl
00214   //<<"ADCs:   "<<fAdc->GetParameter(2)/fAdc->GetParameter(1)<<endl
00215   //<<"PEs:    "<<fPe->GetParameter(2)/fPe->GetParameter(1)<<endl
00216   
00217   MSG("MeuHistos",Msg::kInfo) 
00218     <<endl<<"*** MEU VALUES ***"<<endl
00219     //<<"Raw MEU="<<meu<<" +/- "<<err<<" ("<<100.*relErr<<"%)"<<endl
00220     <<"Raw MEU (WinSigMap)="<<meuWinSigMap<<" +/- "<<errWinSigMap
00221     <<" ("<<100.*relErrWinSigMap<<"%)"<<endl
00222     <<"Raw MEU (WinSigCor)="<<meuWinSigCor<<" +/- "<<errWinSigCor
00223     <<" ("<<100.*relErrWinSigCor<<"%)"<<endl
00224     <<"Raw MEU (WinSigLin)="<<meuWinSigLin<<" +/- "<<errWinSigLin
00225     <<" ("<<100.*relErrWinSigLin<<"%)"<<endl
00226     <<"Raw MEU (WinAdc)   ="<<meuWinAdc<<" +/- "<<errWinAdc
00227     <<" ("<<100.*relErrWinAdc<<"%)"<<endl
00228     <<"Raw MEU (WinPe)    ="<<meuWinPe<<" +/- "<<errWinPe
00229     <<" ("<<100.*relErrWinPe<<"%), fitErr="<<errWinPe2<<endl;
00230 }
00231 
00232 //......................................................................

Generated on Mon Feb 15 11:06:59 2010 for loon by  doxygen 1.3.9.1