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

GfxShowerList.cxx

Go to the documentation of this file.
00001 #include "GfxShowerList.h"
00002 #include "GfxShowerListCfg.h"
00003 #include "GfxProxy.h"
00004 #include "ViewState.h"
00005 #include "GfxShower.h"
00006 #include <Midad/Base/Mint.h>
00007 #include <Midad/Gui/GuiSlider.h>
00008 #include <RecoBase/CandShowerHandle.h>
00009 #include <RecoBase/CandShowerListHandle.h>
00010 #include "GfxShowerListMenu.h"
00011 #include <TClonesArray.h>
00012 #include <Record/RecArrayAllocator.h>
00013 #include <MessageService/MsgService.h>
00014 
00015 #include <DataUtil/CDL2STL.h>
00016 using namespace DataUtil;
00017 
00018 #include <sigc++/sigc++.h>
00019 #include <sigc++/class_slot.h>
00020 using namespace SigC;
00021 
00022 
00023 #include <Buttons.h> // part of ROOT
00024 
00025 static GfxProxy<GfxShowerList> 
00026 gsGfxShowerListProxy("ShowerList", new GfxShowerListMenu());
00027 
00028 GfxShowerList::GfxShowerList()
00029     :fCfg(0)
00030      ,fHideShowers(false)
00031 {
00032     fCfg = new GfxShowerListCfg();
00033     fCfg->modified_signal.connect
00034         (SigC::slot_class(*this,&GfxShowerList::ReConfigure));
00035     RecArrayAllocator& a = RecArrayAllocator::Instance();
00036     fShowerCA = a.GetArray("GfxShower");
00037 } 
00038 
00039 GfxShowerList::~GfxShowerList()
00040 {
00041   RecArrayAllocator& a = RecArrayAllocator::Instance();
00042   if (fShowerCA) {a.ReleaseArray(fShowerCA); fShowerCA = 0;}
00043 }
00044 
00045 
00046 void GfxShowerList::Init(PageDisplay& pd, EVD& mp)
00047 {
00048 
00049   fEVD= &mp;
00050   fPageDisplay= &pd;
00051   ViewState* vs = this->GetViewState();
00052   vs->spatial_metric.connect(slot_class(*this,&GfxShowerList::ReConfigure));
00053 }
00054 
00055 void GfxShowerList::Configure(Mint& mint)
00056 {
00057 
00058   
00059   this->ClearShowerList();
00060   const CandShowerListHandle* ctlh = mint.GetShowers();
00061   if (!ctlh) return;  
00062 
00063   Mint::ShowerVector_t tv = CDL2STLvector<CandShowerHandle>(*ctlh);
00064   RangeDouble& time_range = 
00065         fPageDisplay->GetTimeSlider().GetRangeCtrl().GetRange();
00066 
00067   if (fShowers.size()) this->ClearShowerList();
00068 
00069   int siz = tv.size();
00070   for (int ind = 0; ind < siz; ++ind) {
00071 
00072     const CandShowerHandle & csh=*tv[ind];
00073     bool addshower=true;
00074     if(GetEVD()->GetCandSlice()){
00075       CandSliceHandle slc1 =  *(GetEVD()->GetCandSlice());
00076       CandSliceHandle slc2;
00077       if(csh.GetCandSlice()) slc2=*(csh.GetCandSlice());
00078       if(slc1!=slc2 && !slc1.IsCloneOf(slc2)){
00079         addshower=false;
00080       }
00081     }
00082     else  if(GetEVD()->GetCandEvent()){
00083       addshower=false;
00084       for( Int_t ishower=0;ishower<=GetEVD()->GetCandEvent()->GetLastShower();ishower++){
00085         const CandShowerHandle *evshower = dynamic_cast<const CandShowerHandle *>(GetEVD()->GetCandEvent()->GetShower(ishower));
00086         if (*evshower==csh){
00087                 addshower=true;
00088                 break;
00089         }
00090       }
00091     }
00092 
00093     int last = fShowerCA->GetLast()+1;
00094     if(addshower && time_range.InRange(tv[ind]->GetVtxT())|| GetEVD()->GetNumSlices()<2){
00095       new ((*fShowerCA)[last]) GfxShower(*tv[ind],*this);
00096       GfxShower* gs = dynamic_cast<GfxShower*>(fShowerCA->UncheckedAt(last));
00097       fShowers.push_back( gs);
00098     }
00099   }
00100 
00101   this->ReConfigure();
00102 
00103 }
00104 void GfxShowerList::ReConfigure()
00105 {
00106     for (ShowerList_t::iterator it=fShowers.begin(); it != fShowers.end(); ++it) {
00107       if (fHideShowers) return;
00108         (*it)->Configure();
00109     }
00110 }
00111 
00112 void GfxShowerList::ClearShowerList() 
00113 {
00114 
00115     fShowers.clear();
00116     fShowerCA->Clear("C");
00117 }
00118 
00119 void GfxShowerList::Draw(Option_t* option)
00120 {
00121 //    cerr << "GfxShowerList::Draw("<<option<<")\n";
00122   Int_t nshower =0;
00123     for (ShowerList_t::iterator it=fShowers.begin(); it != fShowers.end(); ++it) {
00124         (*it)->Draw(option);
00125         nshower ++;
00126     }
00127 }
00128 
00129 void GfxShowerList::ExecuteEvent(int event, int /*px*/, int /*py*/, GfxShower* shower)
00130 {
00131     switch (event) {
00132     case kMouseEnter: {
00133 
00134 
00135       const CandShowerHandle & csh = shower->GetShower();
00136 
00137       text_info.emit(Form("%s: %d strips, PE sum=%.1f   Energy=%.1f",
00138                           "shower", csh.GetNDaughters(),
00139                           csh.GetCharge(CalStripType::kPE),
00140                           csh.GetEnergy()));
00141       break;
00142     }
00143     default: // nothing
00144         break;
00145     }
00146     
00147 }
00148 
00149 void GfxShowerList::HideShowers(bool hide)
00150 {
00151     fHideShowers = hide;
00152     this->ReConfigure();
00153     if(GetGraphicsView()==GraphicsView::kXY)fEVD->UpdateCanvas();
00154 }

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