00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef STTOFRGEOMETRY_H
00040 #define STTOFRGEOMETRY_H
00041
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00054 #include "TObject.h"
00055 #include "TList.h"
00056 #include "TNode.h"
00057 #include "TBRIK.h"
00058 #include "TGeometry.h"
00059 #include "StThreeVectorD.hh"
00060 #include "StHelixD.hh"
00061 #include "TVolume.h"
00062 #include "TVolumePosition.h"
00063 #include "TVolumeView.h"
00064 #include "TVolumeViewIter.h"
00065
00066 #include <vector>
00067 #ifndef ST_NO_NAMESPACES
00068 using std::vector;
00069 #endif
00070 #ifndef __CINT__
00071 #if !defined(ST_NO_TEMPLATE_DEF_ARGS)
00072 typedef vector<Int_t> IntVec;
00073 typedef vector<Double_t> DoubleVec;
00074 typedef vector<StThreeVector<double> > PointVec;
00075 #else
00076 typedef vector<Int_t, allocator<Int_t> > IntVec;
00077 typedef vector<Double_t, allocator<Double_t> > DoubleVec;
00078 typedef vector<StThreeVector<double>, allocator<StThreeVector<double>>> PointVec;
00079 #endif
00080 #endif
00081 class StTofrNode;
00082 class StTofrGeomNode;
00083 class StTofrGeomTray;
00084 class StTofrGeomSensor;
00085
00086 class StTofrGeometry;
00087
00088
00090
00091
00092
00093
00095
00096 #if 0
00097 class StTofrGeomNode : public TNode {
00098 protected:
00099 Double_t mTransMRS[3];
00100 Double_t mRotMRS[9];
00101 Bool_t mTransFlag;
00102
00103
00104
00105 Double_t mEtaMin;
00106 Double_t mEtaMax;
00107 Double_t mPhiMin;
00108 Double_t mPhiMax;
00109
00110
00111 static Bool_t mDebug;
00112
00113 protected:
00114 StTofrGeomNode(const char* name, const char* title, TBRIK* brik,
00115 const Double_t x, const Double_t y, const Double_t z,
00116 TRotMatrix* matrix=0);
00117 void UpdateMatrix();
00118 void BuildMembers();
00119
00120 public:
00121 StTofrGeomNode() {}
00122 ~StTofrGeomNode();
00123
00124 static void DebugOn() { mDebug = kTRUE; }
00125 static void DebugOff() { mDebug = kFALSE; }
00126 static Bool_t IsDebugOn() { return mDebug; }
00127
00128 static void CalcMatrix(TNode* son, Double_t* trans, Double_t* rot,
00129 StTofrGeomNode* mother=0);
00130 static void ConvertPos( TNode* from, const Double_t* pos_from,
00131 StTofrGeomNode* to, Double_t* pos_to);
00132 void Local2Master(const Double_t* local, Double_t* master);
00133 void Master2Local(const Double_t* master, Double_t* local);
00134
00135 StThreeVectorD YZPlaneNormal();
00136 StThreeVectorD GetCenterPosition() const;
00137
00138
00139
00140 Double_t GetEtaMin() const { return mEtaMin; }
00141 Double_t GetEtaMax() const { return mEtaMax; }
00142 Double_t GetPhiMin() const { return mPhiMin; }
00143 Double_t GetPhiMax() const { return mPhiMax; }
00144 Bool_t IsLocalPointIn(const Double_t x, const Double_t y,
00145 const Double_t z) const;
00146 Bool_t IsGlobalPointIn(const StThreeVectorD &global);
00147 Bool_t HelixCross(const StHelixD &helix,
00148 Double_t &pathLen, StThreeVectorD &cross);
00149 virtual void Print() const;
00150
00151 #ifdef __ROOT__
00152 C_l_assDef(StTofrGeomNode,2)
00153 #endif
00154 };
00155 #endif
00156
00157 class TVolumeView;
00158
00160
00161
00162
00163
00165
00166 class StTofrNode : public TObject {
00167 protected:
00168 TVolumeView *fView;
00169 TVolumePosition *pView;
00170 TVolumeView *mMasterNode;
00171
00172 Double_t mTransMRS[3];
00173 Double_t mRotMRS[9];
00174 Bool_t mTransFlag;
00175
00176
00177
00178 Double_t mEtaMin;
00179 Double_t mEtaMax;
00180 Double_t mPhiMin;
00181 Double_t mPhiMax;
00182
00183
00184 static Bool_t mDebug;
00185
00186 protected:
00187
00188 StTofrNode(TVolumeView *element, TVolumeView *top);
00189
00190 StTofrNode& operator=(const StTofrNode&);
00191
00192 void UpdateMatrix();
00193 void BuildMembers();
00194
00195 public:
00196 StTofrNode() {}
00197 ~StTofrNode();
00198
00199 TVolumeView* GetfView() const { return fView; }
00200 TVolumePosition* GetpView() const { return pView; }
00201 TVolumeView* GetTopNode() const { return mMasterNode; }
00202 static void DebugOn() { mDebug = kTRUE; }
00203 static void DebugOff() { mDebug = kFALSE; }
00204 static Bool_t IsDebugOn() { return mDebug; }
00205
00206 static void CalcMatrix(StTofrNode* son, Double_t* trans, Double_t* rot,
00207 StTofrNode* mother=0);
00208 static void ConvertPos(StTofrNode* from, const Double_t* pos_from,
00209 StTofrNode* to, Double_t* pos_to);
00210 void Local2Master(const Double_t* local, Double_t* master);
00211 void Master2Local(const Double_t* master, Double_t* local);
00212 TShape *GetShape() const { return fView->GetPosition()->GetNode()->GetShape();}
00213
00214 StThreeVectorD YZPlaneNormal();
00215 StThreeVectorD GetCenterPosition() const;
00216
00217
00218
00219 Double_t GetEtaMin() const { return mEtaMin; }
00220 Double_t GetEtaMax() const { return mEtaMax; }
00221 Double_t GetPhiMin() const { return mPhiMin; }
00222 Double_t GetPhiMax() const { return mPhiMax; }
00223 Bool_t IsLocalPointIn(const Double_t x, const Double_t y,
00224 const Double_t z);
00225 Bool_t IsGlobalPointIn(const StThreeVectorD &global);
00226 Bool_t HelixCross(const StHelixD &helix,
00227 Double_t &pathLen, StThreeVectorD &cross);
00228 virtual void Print(const Option_t *opt="") const;
00229
00230 #ifdef __ROOT__
00231 ClassDef(StTofrNode,2)
00232 #endif
00233 };
00234
00235
00237
00238
00239
00240
00242
00243 class StTofrGeomTray : public StTofrNode {
00244 friend class StTofrGeometry;
00245
00246 private:
00247 Int_t mTrayIndex;
00248 Int_t mBTOHIndex;
00249 Int_t mSectorsInBTOH;
00250
00251 protected:
00252 static Bool_t mDebug;
00253
00254 protected:
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268 public:
00269 StTofrGeomTray(const Int_t ibtoh, TVolumeView *sector, TVolumeView *top);
00270 StTofrGeomTray() {}
00271 ~StTofrGeomTray();
00272
00273 StTofrGeomTray& operator=(const StTofrGeomTray&);
00274 static void DebugOn() { mDebug = kTRUE; }
00275 static void DebugOff() { mDebug = kFALSE; }
00276 static Bool_t IsDebugOn() { return mDebug; }
00277
00278 Int_t BTOHIndex() const { return mBTOHIndex; }
00279 Int_t Index() const { return mTrayIndex; }
00280 StTofrGeomSensor* GetSensor(const Int_t imodule) const;
00281 virtual void Print(const Option_t *opt="") const;
00282
00283 #ifdef __ROOT__
00284 ClassDef(StTofrGeomTray,1)
00285 #endif
00286 };
00287
00288
00290
00291
00292
00293
00295
00296 class StTofrGeomSensor : public StTofrNode {
00297 friend class StTofrGeomTray;
00298
00299 private:
00300 Int_t mModuleIndex;
00301 static Int_t const mCells = 6;
00302 Double_t mCellY[mCells+1];
00303 static Double_t const mSensorDy;
00304
00305 protected:
00306 static Bool_t mDebug;
00307
00308 protected:
00309
00310
00311
00312
00313
00314
00315
00316 void CreateGeomCells();
00317
00318 public:
00319 StTofrGeomSensor(TVolumeView *element, TVolumeView *top);
00320
00321 StTofrGeomSensor() {}
00322 ~StTofrGeomSensor();
00323
00324 StTofrGeomSensor& operator=(const StTofrGeomSensor&);
00325 static void DebugOn() { mDebug = kTRUE; }
00326 static void DebugOff() { mDebug = kFALSE; }
00327 static Bool_t IsDebugOn() { return mDebug; }
00328
00329 static Int_t GetCells() { return mCells; }
00330
00331 Int_t Index() const { return mModuleIndex; }
00332 Double_t GetCellYMin(const Int_t icell) const;
00333 Double_t GetCellYMax(const Int_t icell) const;
00334 Int_t FindCellIndex(const Double_t* local);
00335 Int_t PrevCellIndex(const Int_t icell) const;
00336 Int_t NextCellIndex(const Int_t icell) const;
00337 StThreeVectorD GetCellPosition(const Int_t icell);
00338 virtual void Print(Option_t *opt="") const ;
00339
00340 #ifdef __ROOT__
00341 ClassDef(StTofrGeomSensor,2)
00342 #endif
00343 };
00344
00345
00346 inline Int_t StTofrGeomSensor::PrevCellIndex(const Int_t icell)
00347 const
00348 {
00349 Int_t ret = -1;
00350 if (icell>mCells) ret=mCells;
00351 else if (icell>0) ret=icell-1;
00352 return ret;
00353 }
00354
00355
00356 inline Int_t StTofrGeomSensor::NextCellIndex(const Int_t icell)
00357 const
00358 {
00359 Int_t ret = -1;
00360 if (icell<0) ret=0;
00361 else if (icell<mCells) ret=icell+1;
00362 return ret;
00363 }
00364
00366
00367
00368
00369
00371
00372 class StTofrGeometry : public TNamed {
00373 private:
00374 TNamed* mGeoNamed;
00375 static Int_t const mNTrays = 120;
00376 static Int_t const mNModules = 33;
00377
00378 protected:
00379
00380
00381 TVolumeView* mTopNode;
00382 const char* mRootFile;
00383 Int_t mSectorsInBTOH;
00384 Int_t mTrays;
00385 Int_t mModulesInTray;
00386 Int_t mCellsInModule;
00387 Bool_t mInitFlag;
00388 TVolume* mStarHall;
00389 Int_t mTofrConf;
00390
00391 StTofrGeomTray* mTofrTray[mNTrays];
00392 StTofrGeomSensor* mTofrSensor[mNTrays][mNModules];
00393 Int_t mNValidTrays;
00394 Int_t mNValidModules;
00395
00396 static Int_t const mY03TrayIndex = 83;
00397
00398 static Bool_t mDebug;
00399
00400 static char* const sectorPref ;
00401 static char* const trayPref ;
00402 static char* const senPref ;
00403
00404 protected:
00405
00406
00407
00408
00409
00410 public:
00411 StTofrGeometry(const char* name="tofrGeo",
00412 const char* title="Simplified Tofr Geometry");
00413 ~StTofrGeometry();
00414
00415
00416
00417
00418 Bool_t IsBSEC(const TVolume* element) const
00419 { return !(strcmp(element->GetName(), sectorPref)); }
00420 Bool_t IsBTRA(const TVolume* element) const
00421 { return !(strcmp(element->GetName(), trayPref)); }
00422 Bool_t IsBRMD(const TVolume* element) const
00423 { return !(strcmp(element->GetName(), senPref)); }
00424
00425 Bool_t ContainOthers(TVolume *element);
00426
00427 static Bool_t LackThis(const char* fromWhere);
00428
00429 static void DebugOn() { mDebug = kTRUE; }
00430 static void DebugOff() { mDebug = kFALSE; }
00431 static Bool_t IsDebugOn() { return mDebug; }
00432
00433
00434
00435
00436 void Init(TVolume *starHall);
00437 void InitFromStar(TVolume *starHall);
00438
00439
00440 Bool_t IsInitDone() const { return mInitFlag; }
00441 Bool_t IsCellValid(const Int_t icell) const;
00442 Bool_t IsSensorValid(const Int_t imodule) const;
00443 Bool_t IsTrayValid(const Int_t itray) const;
00444
00445 Int_t CalcCellId(const Int_t volumeId, const Double_t* local) const;
00446 Int_t CalcCellId(const Int_t volumeId, const Float_t* local) const;
00447 Int_t CalcSensorId(const Int_t imodule, const Int_t itray=0) const;
00448 Int_t PrevCellId(const Int_t cellId) const;
00449 Int_t NextCellId(const Int_t cellId) const;
00450
00451
00452 Int_t CalcCellId(const Int_t icell, const Int_t imodule,
00453 const Int_t itray=0) const;
00454 void DecodeVolumeId(const Int_t volumeId,
00455 Int_t &imodule, Int_t &itray) const;
00456 Bool_t DecodeSensorId(const Int_t sensorId, Int_t &imodule,
00457 Int_t &itray) const;
00458 Bool_t DecodeCellId(const Int_t cellId, Int_t &icell,
00459 Int_t &imodule, Int_t &itray) const;
00460 Int_t GetCellIndex(const Int_t cellId) const;
00461
00462 Int_t CellsInModule(const Int_t imodule=0, const Int_t itray=0) const
00463 { return StTofrGeomSensor::GetCells(); }
00464 Int_t ModulesInTray(const Int_t itray=0) const
00465 { return mModulesInTray; }
00466 Int_t Trays() const { return mTrays; }
00467
00468 const char* GeoRootFile() { return mRootFile; }
00469 virtual void Print(Option_t *opt="") const ;
00470
00471 TVolumeView* GetTopNode() const { return mTopNode; }
00472 StTofrGeomSensor* GetGeomCell(const Int_t cellId) const;
00473 StTofrGeomSensor* GetGeomSensor(const Int_t imodule,
00474 const Int_t itray=0) const;
00475 StTofrGeomTray* GetGeomTray(const Int_t itray=0) const;
00476 StTofrGeomTray* GetGeomTrayAt(const Int_t idx=0) const;
00477 Int_t GetAtOfTray(const Int_t itray=0) const;
00478
00479 Int_t CellIdPointIn(const StThreeVectorD& point) const;
00480 #ifndef __CINT__
00481 Bool_t HelixCrossCellIds(const StHelixD &helix, IntVec &idVec,
00482 DoubleVec &pathVec, PointVec &crossVec) const;
00483 Bool_t HelixCrossCellIds(const StHelixD &helix, IntVec validModuleVec, IntVec projTrayVec, IntVec &idVec, DoubleVec &pathVec, PointVec &crossVec) const;
00484 Bool_t HelixCross(const StHelixD &helix) const;
00485 Bool_t HelixCross(const StHelixD &helix, IntVec validModuleVec, IntVec projTrayVec) const;
00486 Bool_t projTrayVector(const StHelixD &helix, IntVec &trayVec) const;
00487 #endif
00488 #ifdef __ROOT__
00489 ClassDef(StTofrGeometry,2)
00490 #endif
00491 };
00492
00493 R__EXTERN StTofrGeometry* gTofrGeometry;
00494
00495 #endif //end of STTOFRGEOMETRY_H