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

EventAdcTab.cxx

Go to the documentation of this file.
00001 // $Id: EventAdcTab.cxx,v 1.2 2008/09/05 15:42:33 rustem Exp $
00002 
00003 // C++
00004 #include <cmath>
00005 #include <iostream>
00006 
00007 // ROOT
00008 #include "TDirectory.h"
00009 #include "TCanvas.h"
00010 #include "TH1F.h"
00011 #include "TH2F.h"
00012 #include "TGraph.h"
00013 
00014 // Local
00015 #include "DrawUtil.h"
00016 #include "PhysicsNtuple/Factory.h"
00017 #include "EventAdcTab.h"
00018 
00019 REGISTER_ANP_OBJECT(EventTab,EventAdcTab)
00020 
00021 using namespace std;
00022 
00023 //----------------------------------------------------------------------
00024 Anp::EventAdcTab::EventAdcTab()
00025    :fInit(false),
00026     fDraw(true),
00027     fCanvas(0),
00028     fPadU(0),
00029     fPadV(0),
00030     f2hU(0),
00031     f2hV(0)
00032 {
00033 }
00034 
00035 //----------------------------------------------------------------------
00036 Anp::EventAdcTab::~EventAdcTab()
00037 {
00038    for(std::vector<TObject *>::iterator it = fObjVec.begin(); it != fObjVec.begin(); ++it)
00039    {
00040       TObject *obj = *it;
00041       delete obj;
00042    }
00043 }
00044 
00045 //----------------------------------------------------------------------
00046 void Anp::EventAdcTab::Set(const Event& event, const Record& record)
00047 {  
00048    if(!fInit)
00049    {
00050       Init(record);
00051    }
00052    else
00053    {
00054       Reset();
00055    }
00056 
00057    if(!f2hU || !f2hV)
00058    {
00059       return;
00060    }
00061 
00062    fSpan.FindSpan(event, record);
00063 
00064    const StripVec uvec = GetStrip(event, record, "U");
00065    const StripVec vvec = GetStrip(event, record, "V");
00066 
00067    if(uvec.empty() || vvec.empty())
00068    {
00069       cerr << "EventAdcTab::SetEvent() - no strips matching a track" << endl;
00070       return;
00071    }    
00072 
00073    for(Draw::SIter sit = uvec.begin(); sit != uvec.end(); ++sit)
00074    {
00075       f2hU -> Fill((*sit) -> ZPos(), (*sit) -> TPos(), (*sit) -> SigCor());
00076    }
00077 
00078    for(Draw::SIter sit = vvec.begin(); sit != vvec.end(); ++sit)
00079    {
00080       f2hV -> Fill((*sit) -> ZPos(), (*sit) -> TPos(), (*sit) -> SigCor());
00081    }
00082 }   
00083 
00084 //------------------------------------------------------------------------------------------
00085 void Anp::EventAdcTab::Init(TCanvas *canvas)
00086 {
00087    if(!canvas)
00088    {
00089       cerr << "EventAdcTab::Expose(): null TCanvas pointer" << endl;
00090       return;
00091    }
00092    if(fPadU || fPadV || fCanvas)
00093    {
00094       cerr << "EventAdcTab::Expose(): pads have been already initialized" << endl;
00095       return;
00096    }
00097 
00098    fCanvas = canvas;
00099 
00100    fCanvas -> Divide(0, 2);
00101 
00102    fPadU = dynamic_cast<TPad *> (canvas -> cd(1));
00103    fPadV = dynamic_cast<TPad *> (canvas -> cd(2));
00104    
00105    if(!fPadU || !fPadV)
00106    {
00107       cerr << "EventAdcTab::Expose(): failed to create new pads" << endl;
00108       fCanvas = 0;
00109       fPadU = 0;
00110       fPadV = 0;
00111       return;
00112    }
00113 
00114    Draw::Config(fPadU, "", fConfig);
00115    Draw::Config(fPadV, "", fConfig);
00116 }
00117 
00118 //------------------------------------------------------------------------------------------
00119 void Anp::EventAdcTab::Expose()
00120 {
00121    if(!fInit)
00122    {
00123       return;
00124    }
00125 
00126    if(!fPadU || !fPadV)
00127    {
00128       return;
00129    }
00130    
00131    if(fDraw)
00132    {
00133       fPadU -> cd();   
00134       f2hU -> Draw("colz");
00135       
00136       fPadV -> cd();   
00137       f2hV -> Draw("colz");
00138 
00139       fDraw = false;
00140    }
00141 
00142    fCanvas -> cd();
00143    fCanvas -> Modified();
00144    fCanvas -> Update();
00145 }
00146 
00147 //----------------------------------------------------------------------
00148 void Anp::EventAdcTab::Config(const Registry &reg)
00149 {
00150    fConfig.UnLockValues();
00151    fConfig.Merge(reg); 
00152    fConfig.LockValues();
00153 }
00154 
00155 //----------------------------------------------------------------------
00156 bool Anp::EventAdcTab::Init(const Record &record)
00157 {
00158    if(fInit)
00159    {
00160       cerr << "EventAdcTab is already initialized" << endl;
00161       return false;
00162    }
00163 
00164    fInit = true;
00165 
00166    f2hU = Draw::CreateTH2("Uview", fConfig, record.GetHeader());
00167    f2hV = Draw::CreateTH2("Vview", fConfig, record.GetHeader());
00168 
00169    fObjVec.push_back(f2hU);
00170    fObjVec.push_back(f2hV);
00171 
00172    return true;
00173 }
00174 
00175 //----------------------------------------------------------------------
00176 void Anp::EventAdcTab::Reset()
00177 {
00178    fDraw = true;
00179 
00180    fSpan.Reset();
00181 
00182    if(f2hU)
00183    {
00184       f2hU -> Reset();
00185    }
00186    if(f2hV)
00187    {
00188       f2hV -> Reset();
00189    }
00190 }
00191 
00192 //----------------------------------------------------------------------
00193 void Anp::EventAdcTab::ZoomIn()
00194 {
00195    fDraw = true;
00196 
00197    static double ZoomBorderScale = 1.2;
00198    static double ZoomBorderWidth = 0.1;
00199 
00200    static bool init = false;
00201    if(!init)
00202    {
00203       init = true;
00204       ZoomBorderScale = Draw::Read("ZoomBorderScale", ZoomBorderScale, fConfig);
00205       ZoomBorderWidth = Draw::Read("ZoomBorderWidth", ZoomBorderWidth, fConfig);
00206 
00207       if(ZoomBorderScale < 1.0) ZoomBorderScale = 1.2;
00208       if(ZoomBorderWidth < 0.0) ZoomBorderWidth = 0.1;
00209    }
00210 
00211    if(fSpan.InitU())
00212    {
00213       fSpan.SetRangeU(f2hU -> GetYaxis(), ZoomBorderScale, ZoomBorderWidth);
00214    }
00215    if(fSpan.InitZ())
00216    {
00217       fSpan.SetRangeZ(f2hU -> GetXaxis(), ZoomBorderScale, ZoomBorderWidth);
00218    }
00219    if(fSpan.InitV())
00220    {
00221       fSpan.SetRangeV(f2hV -> GetYaxis(), ZoomBorderScale, ZoomBorderWidth);
00222    }
00223    if(fSpan.InitZ())
00224    {
00225       fSpan.SetRangeZ(f2hV -> GetXaxis(), ZoomBorderScale, ZoomBorderWidth);
00226    }
00227 }
00228 
00229 //----------------------------------------------------------------------
00230 void Anp::EventAdcTab::ZoomOut()
00231 {
00232    fDraw = true;
00233 
00234    if(f2hU)
00235    {
00236       f2hU -> GetXaxis() -> UnZoom();
00237       f2hU -> GetYaxis() -> UnZoom();
00238    }
00239 
00240    if(f2hV)
00241    {
00242       f2hV -> GetXaxis() -> UnZoom();
00243       f2hV -> GetYaxis() -> UnZoom();
00244    }
00245 }

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