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

TridCratePage.cxx

Go to the documentation of this file.
00001 // Root stuff:
00002 #include <TStyle.h>
00003 #include <TColor.h>
00004 #include <TROOT.h>
00005 #include <TGeoManager.h>
00006 
00007 #include "TridCratePage.h"
00008 #include "TridFlatGLFrame.h"
00009 #include "TridSketches.h"
00010 #include "TridModelCrate.h"
00011 #include "TridControl.h"
00012 #include "TridModelMaker.h"
00013 
00014 #include "Midad/Base/PageProxy.h"
00015 #include "Midad/Gui/GuiBox.h"
00016 #include "Midad/Gui/GuiCanvas.h"
00017 #include "Midad/Gui/GuiMainWindow.h"
00018 #include "Midad/Base/Mint.h"
00019 
00020 #include <DataUtil/GetCandidate.h>
00021 #include <JobControl/JobC.h>
00022 
00023 #include <sigc++/sigc++.h>
00024 #include <sigc++/class_slot.h>
00025 
00026 #include "MessageService/MsgService.h"
00027 #include "MinosObjectMap/MomNavigator.h"
00028 #include "Plex/PlexHandle.h"
00029 #include "Plex/PlexSEIdAltL.h"
00030 #include "Plex/PlexStripEndId.h"
00031 #include "Plex/PlexPixelSpotId.h"
00032 
00033 #include "CandData/CandRecord.h"
00034 #include "CandDigit/CandDigitListHandle.h"
00035 #include "CandDigit/CandDigitHandle.h"
00036 #include "RawData/RawChannelId.h"
00037 
00038 using namespace SigC;
00039 
00040 const double kSizeCrate_x = 2;
00041 const double kSizeCrate_y = 2;
00042 
00043 const double kSizeVarc_x  = 0.3;
00044 const double kSizeVarc_y  = 1.8;
00045 const double kSizeVmm_x   = kSizeVarc_x;
00046 const double kSizeVmm_y   = kSizeVarc_y/6;
00047 const double kSizeVfb_x   = kSizeVmm_x/2;
00048 const double kSizeVfb_y   = kSizeVmm_y*0.9;
00049 
00050 const double kSizeMaster_x = 0.1;
00051 const double kSizeMaster_y = 1.8;
00052 const double kSizeMinder_x = 0.09;
00053 const double kSizeMinder_y = 0.2;
00054 
00055 CVSID("$Id: TridCratePage.cxx,v 1.24 2006/04/20 00:37:39 tagg Exp $");
00056 
00057 static PageProxy<TridCratePage> gsTridCratePageProxy("TridCrate");
00058 
00059 TridCratePage::TridCratePage()
00060   :    TridPage()
00061 { 
00062   // Default view.
00063   fViewModesSupported = kView2D | kView3D;
00064   fViewMode = kView2D;
00065   fWindowName = "TridCrate";
00066   fFullPOV.Set(1.0, 0, 0, 9, 90, 0 );  
00067   fAutoPOV.Set(1.0, 0, 0, 9, 90, 0 );  
00068 }
00069 
00070 TridCratePage::~TridCratePage()
00071 { 
00072 }
00073 
00074 TObject* TridCratePage::Init(Mint* mint, PageDisplay* pageDisplay, GuiBox& box)
00075 {
00076   MSG("TriD",Msg::kDebug) << "TridCratePage: Init()\n";
00077   return TridPage::Init(mint, pageDisplay, box);
00078 }
00079 
00080 
00081 TridGLFrame* TridCratePage::CreateNewGLFrame( TridPage::ViewMode_t mode )
00082 {
00083   TridPOV min(0,             0,-kSizeCrate_y,   0, 0,-180);
00084   TridPOV max(kSizeCrate_x*8,0,+kSizeCrate_y,1000,90, 180);
00085   
00086   if(mode==kView2D) {
00087     MSG("TriD",Msg::kDebug) << "Changing to 2D" << endl;
00088     return new TridFlatGLFrame(this,*fGuiBox,fTridControl,min,max,1.5);
00089   };
00090 
00091   MSG("TriD",Msg::kDebug) << "Changing to 3D" << endl;
00092   return new TridGLFrame(this,*fGuiBox,fTridControl,min,max);
00093 }
00094 
00095 
00096 void TridCratePage::ChannelToCoords(RawChannelId chan, 
00097                                  TVector3& pos, 
00098                                  double &width, 
00099                                  double &height )
00100 {
00101   // 
00102   // Finds 2d coords of a channel in my map space.
00103   //
00104   int ix, iy;
00105   double x = 0;
00106   double y = 0;
00107   if(chan.GetElecType()==ElecType::kQIE) {
00108   
00109     // QIE
00110 
00111     // Offset into pixel
00112     x = kSizeMinder_x/2;
00113     y = kSizeMinder_y/2;
00114 
00115     //Which minder in master.
00116     x += PlaceInBox(kSizeMaster_x,kSizeMinder_x);
00117     y += PlaceInBox(kSizeMaster_y,kSizeMinder_y,chan.GetMasterChannel(),8);
00118     
00119     // Which master in crate
00120     x += PlaceInBox(kSizeCrate_x,kSizeMaster_x,chan.GetGeographicAddress()-9,12); // Masters in slots 9 to 20
00121     y += PlaceInBox(kSizeCrate_y,kSizeMaster_y);
00122     
00123     width = kSizeMinder_x;
00124     height = kSizeMinder_y;
00125 
00126   }  else if(chan.GetElecType()==ElecType::kVA) {  
00127       
00128     // VA electronics
00129     
00130     // Offset into pixel
00131     x=kSizeVfb_x/2.;
00132     y=kSizeVfb_y/2.;
00133 
00134     // Which Vfb in Vmm
00135     ix = chan.GetVaAdcSel();
00136     x += PlaceInBox(kSizeVmm_x,kSizeVfb_x,ix,2);
00137     y += PlaceInBox(kSizeVmm_y,kSizeVfb_y,0,1);
00138     
00139     // Which vmm in varc.
00140     iy = chan.GetVmm();
00141     x += PlaceInBox(kSizeVarc_x,kSizeVmm_x,0,1);
00142     y += PlaceInBox(kSizeVarc_y,kSizeVmm_y,iy,6);
00143     
00144     // Which varc in crate
00145     x+= PlaceInBox(kSizeCrate_x,kSizeVarc_x,chan.GetVarcId(),4);
00146     y+= PlaceInBox(kSizeCrate_y,kSizeVarc_y,0,1);
00147 
00148     width  = kSizeVfb_x;
00149     height = kSizeVfb_y;
00150   }
00151   
00152   // Which crate.
00153   if(fContext.GetDetector()==Detector::kFar) {
00154     ix = chan.GetCrate() / 2;
00155     iy = - chan.GetCrate() % 2;
00156   } else {
00157     iy = 0;
00158     ix = chan.GetCrate();
00159   }
00160   
00161   x+= (double)ix * kSizeCrate_x;
00162   y+= (double)iy * kSizeCrate_y;
00163 
00164   // put into xz plane instead of xy plane.
00165   pos.SetXYZ(x,0,y);
00166   return;
00167 }
00168 
00169 void TridCratePage::CreateModels() 
00170 {
00171   fModels.Clear();
00172   fTridControl->ClearPicked();
00173   fTridControl->ClearSelected();
00174 
00175   TridModelMaker maker;
00176   maker.Prepare(&(fMint->GetJobC().Mom));
00177   maker.CreateChannelModels(&(fMint->GetJobC().Mom),fModels);
00178 
00179 }
00180 
00181 
00182 void TridCratePage::CreateSketches()
00183 {  
00184   fModels.ClearAssociations();
00185 
00186   TridModel* basemodel;
00187   TridModelItr itr = fModels.GetIterator();
00188   while( (basemodel = itr.Next()) ) {    
00189     // Make a new sketch for this model.
00190     TridModelCrate* model = dynamic_cast<TridModelCrate*>(basemodel);
00191     if(model==NULL){
00192       MSG("TriD",Msg::kError) << "CreateSketches() -> Unknown model type!" << endl;
00193       continue;
00194     }
00195 
00196     TVector3 pos;
00197     double w,h;
00198     ChannelToCoords(model->fChannel,pos,w,h);
00199     w *=0.9;
00200     h *=0.9;
00201     
00202     double depth = 0.2*model->GetOccupancy();
00203     pos.SetY(depth/2);
00204     
00205     TridSketch* sk = new TridSketchBox(pos,
00206                                        kv_x, w/2.,
00207                                        kv_z, h/2.,
00208                                        kv_y, depth/2.
00209                                        );
00210     sk->SetTime(model->GetEarliestTime());
00211     //float c = model->GetOccupancy() / 4;
00212     //sk->SetColor(GetColor(c));
00213     
00214     fGLFrame->AddSketch(sk);  
00215     fModels.AssociateModel(model,sk->GetId());    
00216   }
00217 
00218   // Add color and trans info.
00219   ModifySketches();
00220   
00221   if(fContext.GetDetector()==Detector::kCalDet) {
00222      fFullPOV.Set(1.0, 0, 0, 9, 90, 0 );  
00223      fAutoPOV.Set(1.0, 0, 0, 9, 90, 0 );  
00224   } else if(fContext.GetDetector()==Detector::kFar) {    
00225      fFullPOV.Set(8.0, 0, 0, 12, 90, 0 );
00226      fAutoPOV.Set(8.0, 0, 0, 12, 90, 0 );
00227   } else {
00228      fFullPOV.Set(4.0, 0, 0, 12, 90, 0 );
00229      fAutoPOV.Set(4.0, 0, 0, 12, 90, 0 );
00230   }
00231   
00232 }
00233 
00234 void TridCratePage::CreateScenery()
00235 {
00236   TridSketch::SetDefaultColor(fTridControl->GetForegroundColor());
00237   TridSketch::StartScenery();
00238 
00239     // Put a black quad behind everything so mouse movement works better.
00240   TridSketch* backplane = new TridSketchPlane
00241     ( TVector3(kSizeCrate_x* 4., -1.0, 0.0),
00242       kv_x, kSizeCrate_x * 10,
00243       kv_z, kSizeCrate_y * 4 
00244       );
00245   backplane->SetColor(fTridControl->GetBackgroundColor());
00246   //fGLFrame->AddSketch(backplane);
00247 
00248 
00249   // Create the scenery.
00250   TridSketch* l;
00251   TridSketch::SetDefaultColor(1,1,1);
00252 
00253   l = new TridSketchLine( TVector3(0,             0,0),
00254                           TVector3(8*kSizeCrate_x,0,0) );
00255   fGLFrame->AddSketch(l);
00256   
00257   l = new TridSketchLine( TVector3(0,             0,kSizeCrate_y),
00258                           TVector3(8*kSizeCrate_x,0,kSizeCrate_y) );
00259   fGLFrame->AddSketch(l);
00260 
00261   if(fContext.GetDetector()==Detector::kFar) {
00262     l = new TridSketchLine( TVector3(0,             0, -kSizeCrate_y),
00263                             TVector3(8*kSizeCrate_x,0, -kSizeCrate_y) );
00264     fGLFrame->AddSketch(l);
00265   }
00266 
00267 
00268   for(int i=0;i<9;i++) {
00269     TVector3 top(kSizeCrate_x * i, 0, kSizeCrate_y );
00270     TVector3 bottom(kSizeCrate_x * i, 0, 0 );
00271     if(fContext.GetDetector()==Detector::kFar)  bottom.SetXYZ(kSizeCrate_x * i, 0, -kSizeCrate_y );
00272     
00273     l = new TridSketchLine( bottom, top );
00274     l->SetColor(1,1,1);
00275     fGLFrame->AddSketch(l); 
00276   }
00277 
00278   for (int i =0; i<8;i++) {
00279     char buff[20];
00280     TridSketchText* txt;
00281 
00282     if(fContext.GetDetector()==Detector::kFar) 
00283       sprintf(buff,"Crate %d",i*2);
00284     else 
00285       sprintf(buff,"Crate %d",i);
00286       
00287     txt = new TridSketchText( TVector3( kSizeCrate_x * (i+0.5), 0, kSizeCrate_y *1.2 ),
00288                               -kv_z, kv_y,
00289                               buff);
00290     txt->SetScale(0.15);
00291     txt->SetThickness(0.001);
00292     fGLFrame->AddSketch(txt);
00293 
00294     if(fContext.GetDetector()==Detector::kFar) {
00295       sprintf(buff,"Crate %d",i*2 + 1);
00296       txt = new TridSketchText( TVector3( kSizeCrate_x * (i+0.5),  0, -kSizeCrate_y *1.2 ),
00297                                 -kv_z, kv_y,
00298                                 buff);
00299       txt->SetScale(0.15);
00300       txt->SetThickness(0.001);
00301       fGLFrame->AddSketch(txt);
00302     }
00303   }
00304 
00305   TridSketch::StopScenery();
00306 }
00307 
00308 

Generated on Mon Feb 15 11:07:43 2010 for loon by  doxygen 1.3.9.1