STEER/TFndGeometry.h

00001 // @(#)fROOT/STEER:$Name:  $:$Id: TFndGeometry.h,v 1.19 2007/09/05 11:09:42 Diego_Faso Exp $
00002 // Author: Diego Faso <mailto:faso@to.infn.it>, 2006/07/05
00003 
00004 #ifndef FROOT_TFndGeometry
00005 #define FROOT_TFndGeometry
00006 
00008 //                                                                         //
00009 //                             TFndGeometry                                //
00010 //                                                                         //
00011 //                                                                         //
00013 
00014 #include "TApplication.h"
00015 #include "TGeoManager.h"
00016 
00017 #include "TObject.h"
00018 #include "TCanvas.h"
00019 
00020 #include "FROOT.h"
00021 using namespace FROOT;
00022 
00023 class TFndGeometry: public TObject{
00024 
00025  public:
00026   
00027   // if you change the following "enum" check also TFndEvd::fDetectorVisibililty
00028   enum EFndGeoLayers { FGEO_BEAM_PIPE = 0,                 // Beam-pipe beryllium part
00029                        FGEO_TOFINO,                        // TOFINO active part (scintillators)
00030                        FGEO_ISIM, FGEO_TARGETS, FGEO_OSIM, // Vertex region
00031                        FGEO_INNER_LMD, FGEO_OUTER_LMD,     // inner and outer layers of LMD
00032                        FGEO_STRAW_TUBES,                   // View region occupied by straw tubes (all layers)
00033                        FGEO_STRAW_TUBES_1,FGEO_STRAW_TUBES_2,FGEO_STRAW_TUBES_3, // every straw-tubes layer
00034                        FGEO_STRAW_TUBES_4,FGEO_STRAW_TUBES_5,FGEO_STRAW_TUBES_6, // (memory consuming!!!)
00035                        FGEO_TOFONE };                         // TOFONE active part (scintillators)
00036   
00037   enum EFndGeoSetup { FGEO_2003 = 1, FGEO_2006 };
00038   
00039   TString GetLayerName(EFndGeoLayers lay)
00040     {
00041       switch(lay){
00042       case FGEO_BEAM_PIPE: return "BEAM-PIPE";
00043       case FGEO_TOFINO: return "TOFINO";
00044       case FGEO_ISIM: return "ISIM";
00045       case FGEO_TARGETS: return "TARGETS";
00046       case FGEO_OSIM: return "OSIM";
00047       case FGEO_INNER_LMD: return "INNER-LMD";
00048       case FGEO_OUTER_LMD: return "OUTER-LMD";
00049       case FGEO_STRAW_TUBES: return "STB";
00050       case FGEO_STRAW_TUBES_1: return "STB Layer 1";
00051       case FGEO_STRAW_TUBES_2: return "STB Layer 2";
00052       case FGEO_STRAW_TUBES_3: return "STB Layer 3";
00053       case FGEO_STRAW_TUBES_4: return "STB Layer 4";
00054       case FGEO_STRAW_TUBES_5: return "STB Layer 5";
00055       case FGEO_STRAW_TUBES_6: return "STB Layer 6";
00056       case FGEO_TOFONE: return "TOFONE";
00057       default: return 0;
00058       } 
00059     }
00060 
00061   // the following definitions are needed to drive
00062   // the event-display by using gFndGeom
00063   typedef struct{
00064     Int_t det; 
00065     Int_t ch;
00066   } FinEvdHit_t;
00067   enum EFndGeoHitMode { FGEO_HIT_DETECTED = 0, FGEO_HIT_RECONSTRUCTED };
00068 
00069 
00070  protected:
00071   Int_t fVerboseLevel;
00072   Int_t fSetup; // data-taking setup (see TFndGeometry::EFndGeoSetup)
00073   TGeoNode   *fPromptNode; // The prompt-node ("FIDA_1") is used a lot of times by several methods (do not delete it)
00074   TGeoVolume *fPromptVolume; // The prompt-volume ("FIDA") is used a lot of times by several methods (do not delete it)
00075   TGeoNode   *fCurDetNode; // Current detector node (set by the "SelectDetectorNode" method)
00076 
00077   TGeoNode *fTgtNodes[8]; // node array for targets (they change depending on the data-taking [2003/2006])
00078 
00079   // --- roto-traslation matrices (loaded one time only from gGeoManager)
00080   // TOF
00081   TGeoHMatrix *fGeoMatr_Top_Tof[2][K_N_TOFONE_SLABS]; // MRS->Tof.RF (0:TOFINO; 1:TOFONE)
00082   // SIL
00083   TGeoMatrix *fGeoMatr_Top_Sil[2][K_N_Sil_Modules]; // indices: [layer:isim/osim][module]
00084   // LMD
00085   TGeoMatrix *fGeoMatr_Top_Lmd[K_N_LMD_LAYERS][K_N_LMD_CHAMS_PER_LAYER]; // MRS->Lmd.RF
00086   TGeoMatrix *fGeoMatr_InnerLmd_Wire[K_N_LMD_CHAMS_PER_LAYER][K_N_LMD_INNER_WIRES]; // InnerLmd.RF->Wire.RF
00087   TGeoMatrix *fGeoMatr_OuterLmd_Wire[K_N_LMD_CHAMS_PER_LAYER][K_N_LMD_OUTER_WIRES]; // OuterLmd.RF->Wire.RF
00088   TGeoHMatrix *fGeoMatr_Top_InnerLmdWire[K_N_LMD_CHAMS_PER_LAYER][K_N_LMD_INNER_WIRES]; // MRS->InnerWire.RF
00089   TGeoHMatrix *fGeoMatr_Top_OuterLmdWire[K_N_LMD_CHAMS_PER_LAYER][K_N_LMD_OUTER_WIRES]; // MRS->OuterWire.RF
00090   // STB
00091   TGeoMatrix *fGeoMatr_Top_StbWire[K_N_STB_CROWNS][K_N_STB_TUBES]; // MRS->StbWire.RF
00092   
00093 
00094   TCanvas *fMainCanvas;  // canvas for drawing the geometry
00095 
00096   
00097  private:
00098   void Init();
00099   TString GetSetupName(Int_t set){
00100     switch(set){
00101     case (Int_t)FGEO_2003: return "2003 (first data-taking)";
00102     case (Int_t)FGEO_2006: return "2006 (second data-taking)";
00103     default:
00104       Error("GetSetupName","Maybe you have just found a BUG!");
00105       gApplication->Terminate();
00106     }
00107   }
00108 
00109   void LoadGeoMatrices();
00110 
00111   Int_t PrintNode(TGeoNode *node,Int_t id_subnum,const Int_t level);
00112 
00113   void SetStbLayVis(Int_t lay,Bool_t visible,Bool_t detailed);
00114   void SetLmdLayVis(Int_t lay,Bool_t visible,Bool_t detailed);
00115     
00116  public:
00117   
00118   TFndGeometry();
00119   ~TFndGeometry();
00120   void SetVerboseLevel(Int_t lev) { fVerboseLevel = lev; }
00121   TString GetCurrentSetup() { return GetSetupName(fSetup); }
00122   TCanvas *GetMainCanvas() { return fMainCanvas; }
00123 
00124   TGeoNode   *GetPromptNode() { return fPromptNode; }
00125   TGeoVolume *GetPromptVolume() { return fPromptVolume; }
00126   TGeoNode *GetCurrentNode() { return fCurDetNode; } // previousely set by SelectDetectorNode
00127   TGeoNode *SelectDetectorNode(const Int_t &det, const Int_t &ch);
00128 
00129   static Double_t GetTofinoSlabAngle() { return (Double_t) ( 360./(Double_t)(K_N_TOFINO_SLABS) ); } // angle of every slab (deg)
00130   static Double_t GetTofoneSlabAngle() { return (Double_t) ( 360./(Double_t)(K_N_TOFONE_SLABS) ); } // angle of every slab (deg)
00131   static Double_t GetTofinoRotAngles(Int_t slab);
00132   static Double_t GetTofoneRotAngles(Int_t slab);
00133 
00134   // --- Reference System changes
00135   static Double_t SilPositionStrip(const Int_t &side, const Double_t &barcha);
00136 
00137   void RefSys_TofSlabToMRS(const Int_t &channel,const Double_t* local, Double_t* master);
00138   void RefSys_SilModToMRS(const Int_t &layer,const Int_t &module,const Double_t* local, Double_t* master);
00139   void RefSys_LmdWireToMRS(const Int_t &channel,const Double_t* local, Double_t* master);
00140   void RefSys_StbWireToMRS(const Int_t &channel,const Double_t* local, Double_t* master);
00141 
00142   static Int_t ConvertFromGeant3(TString root_geom_filename="fin_spec_geom.root", TString geant3_geom_path="fin_spec.geom",Bool_t CleanTmp=kTRUE);
00143   void PrintStructure(const Int_t levels=7);
00144   void PrintGeoMatrices(Int_t det,Int_t verbose_lev); // local verbose level is used
00145 
00146   Int_t LoadGeometry(TString filename="$FROOTSYS/geom/fin_spec_geom.root");
00147   Int_t ShowGeometry(Option_t *option="ogl",Int_t vis_level=7);
00148 
00149   void SetLayerVisibility(Int_t layer,Bool_t visible,Bool_t detailed=kFALSE);
00150   void SetStructureVisibility(Bool_t visible,Int_t detail_lev=0);
00151 
00152   Int_t SetDefaultColors();
00153   Int_t SetDefaultVisibility();
00154 
00155 
00156   // The following pure virtual methods were used in order to 
00157   // drive the event display by using the global pointer gFndGeom
00158   //   (see TFndEvd for the relative documentation)
00159   // they are now commented in order to provide the possibility
00160   // of loading geometry without creating an object of TFndEvd (March 13, 2007 - D. Faso)
00161   /*   virtual void HitDetector(Int_t det, Int_t ch, Int_t mode=FGEO_HIT_DETECTED,Bool_t refresh_display=kTRUE) = 0; */
00162   /*   virtual void RemoveHit(Int_t det, Int_t ch,Bool_t refresh_display=kTRUE) = 0; */
00163   /*   virtual void RemoveAllHits(Bool_t reset_default_view=kFALSE,Bool_t refresh_display=kTRUE) = 0;   */
00164   /*   virtual void PrintHits(Bool_t Selected) = 0; */
00165   /*   virtual void DisplayRandomEvent(Bool_t keep_current_hits=kFALSE) = 0; */
00166   
00167   ClassDef(TFndGeometry,0)
00168 };
00169 R__EXTERN  TFndGeometry *gFndGeom;
00170 #endif // FROOT_TFndGeometry

Generated on Tue Oct 16 15:40:48 2007 by  doxygen 1.5.2