/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/EventDisplay/BesVisLib/BesVisLib-00-04-04/src/TofROOTGeo.cxx

Go to the documentation of this file.
00001 //$id$
00002 /*
00003  *    2004/11/29   Zhengyun You      Peking University
00004  *                 Tof Geometry General for EventDisplay
00005  *
00006  *    2004/12/9    Zhengyun You      Peking University
00007  *                 named from TofGeo to TofROOTGeo
00008  *                 inherit from class SubDetectorROOTGeo
00009  */
00010 
00011 using namespace std;
00012 
00013 #include <string>
00014 #include <fstream>
00015 #include <iostream>
00016 #include <sstream>
00017 #include <vector>
00018 #include <iomanip>
00019 
00020 #include <TGeoManager.h>
00021 #include <TGeoTube.h>
00022 #include <TGeoArb8.h>
00023 #include <TMath.h>
00024 
00025 #include "BesVisLib/TofROOTGeo.h"
00026 #include "Identifier/TofID.h"
00027 #include "BesVisLib/BesEvent.h"
00028 #include "BesVisLib/BesView.h"
00029 #include "RawEvent/RawDataUtil.h"
00030 
00031 
00032 TofROOTGeo::TofROOTGeo()
00033         : SubDetectorROOTGeo()
00034 {
00035     // Default constructor.
00036     k_TMatch = kTRUE;
00037     k_QMatch = kTRUE;
00038     for (int part = 0; part < m_kPart; part++) {
00039         for (int layer = 0; layer < m_kLayerBr; layer++) {
00040             m_NodeAl[part][layer] = 0;
00041             m_NodeScin[part][layer] = 0;
00042             for (int scin = 0; scin < m_kScinBr; scin++) {
00043                 m_NodePVF[part][layer][scin] = 0;
00044                 m_PhysicalScin[part][layer][scin] = 0;
00045                 m_Tof2DScin[part][layer][scin] = 0;
00046             }
00047         }
00048     }
00049 
00050     m_TofColor    = 6;
00051     m_BucketColor = 4;
00052     m_ScinColor   = kYellow;
00053 }
00054 
00055 TofROOTGeo::~TofROOTGeo()
00056 { }
00057 
00058 void
00059 TofROOTGeo::InitFromGDML( const char *gdmlFile, const char *setupName )
00060 {
00061     m_ROOTGeoInit = 2;
00062 
00063     ReadGdml(gdmlFile, setupName);
00064     SetNode();
00065 }
00066 
00067 void
00068 TofROOTGeo::InitFromROOT( TGeoVolume *vol )
00069 {
00070     m_ROOTGeoInit = 1;
00071 
00072     SetVolumeTof(vol);
00073     SetNode();
00074 }
00075 
00076 void
00077 TofROOTGeo::Init2DGeometry()
00078 {
00079     if (m_ROOTGeoInit != 1 && m_ROOTGeoInit != 2) {
00080         cout << "TofROOTGeo::Init2DGeometry, ROOT Geometry not Initialized yet!" << endl;
00081         return;
00082     }
00083     m_2DGeoInit = 1;
00084 
00085     Double_t local[3] = {0.0, 0.0, 0.0};
00086     Double_t master[3] = {0.0, 0.0, 0.0};
00087     //Int_t    nPoints = 8;
00088     //Double_t  P[300] = {0.0};
00089     //Double_t  center[3] = {0.0, 0.0, 0.0};
00090     TString  name;
00091 
00092     // Tof Scintillators
00093     for (Int_t part = 0; part < m_kPart; part++) {
00094         for (Int_t layer = 0; layer < GetLayerNb(part); layer++) {
00095             for (int scin = 0; scin < GetScinNb(part); scin++) {
00096                 TGeoPhysicalNode *scinPhyNode = GetPhysicalScin(part, layer, scin);
00097                 if (part == 1) {
00098                     name = TString("Tof Part 1");
00099                     name += " Layer ";
00100                     name += layer;
00101                     name += " Phi ";
00102                     name += scin;
00103                 }
00104                 else {
00105                     if (part == 0) name = TString("EastEc");
00106                     else if (part == 2) name = TString("WestEc");
00107                     name = TString("Tof Part ");
00108                     name += part;
00109                     name += " Phi ";
00110                     name += scin;
00111                 }
00112                 TGeoArb8 *scinShape = (TGeoArb8*)scinPhyNode->GetShape();
00113                 Double_t *localArb8Point, masterArb8Point[24];
00114                 localArb8Point = scinShape->GetVertices();
00115 
00116                 for (Int_t i = 0; i < 8; i++) {
00117                     local[0] = localArb8Point[2*i];
00118                     local[1] = localArb8Point[2*i+1];
00119                     if (i < 4) local[2] = scinShape->GetDz() * (-1.0);
00120                     else local[2] = scinShape->GetDz();
00121 
00122                     //cout << i << " local x: " << local[0] << " y: " << local[1] << " z: " << local[2] << endl;
00123                     scinPhyNode->GetMatrix(-1*scinPhyNode->GetLevel())->LocalToMaster(local, &master[0]); // transform to top
00124                     //cout << " master x: " << master[0] << " y: " << master[1] << " z: " << master[2] << endl;
00125 
00126                     for (Int_t j = 0; j < 3; j++) {
00127                         masterArb8Point[3*i+j] = master[j];
00128                     }
00129                 }
00130 
00131                 m_Tof2DScin[part][layer][scin] = new Tof2DScin(name, name, 8, &masterArb8Point[0], part);
00132             }
00133         }
00134     }
00135 }
00136 
00137 void
00138 TofROOTGeo::SetNode()
00139 {
00140     if (m_ROOTGeoInit == 2) { // from GDML
00141         m_Tof = GetTopVolume();
00142         if (!m_Tof) std::cout << "m_Tof = 0" << std::endl;
00143 
00144         for (int part = 0; part < m_kPart; part++) {
00145             for (int layer = 0; layer < GetLayerNb(part); layer++) {
00146                 std::stringstream osnameAl;
00147                 if (part == 1)      osnameAl << "pv_" << "logical" << "AlBr" << layer+1 << "_0";
00148                 else if (part == 0)  osnameAl << "pv_" << "logical" << "AlEcEast" << "_0";
00149                 else                osnameAl << "pv_" << "logical" << "AlEcWest" << "_0";
00150                 m_NodeAl[part][layer] = GetNode( osnameAl.str() );
00151 
00152                 std::stringstream osnameScin;
00153                 if (part == 1)      osnameScin << "pv_" << "logical" << "ScinBr" << layer+1 << "_0";
00154                 else if (part == 0)  osnameScin << "pv_" << "logical" << "ScinEcEast" << "_0";
00155                 else                osnameScin << "pv_" << "logical" << "ScinEcWest" << "_0";
00156 
00157                 m_NodeScin[part][layer] = GetNode( osnameScin.str() );
00158 
00159                 for (int scin = 0; scin < GetScinNb(part); scin++) {
00160                     std::stringstream osnamePVF;
00161                     if (part == 1) {
00162                         osnamePVF << "pv_" << "logicalPVFBr"<< layer+1 << "_" << (2*m_kScinBr*3 - 1) - (layer*m_kScinBr + scin)*3;
00163                     }
00164                     else if (part == 2) {
00165                         osnamePVF << "pv_" << "logicalPVFEcWest" << "_" << (2*m_kScinEc - 1) - scin*2;
00166 
00167                     }
00168                     else if (part == 0) {
00169                         osnamePVF << "pv_" << "logicalPVFEcEast" << "_" << (2*m_kScinEc - 1) - scin*2;
00170                     }
00171                     m_NodePVF[part][layer][scin] = GetNode( osnamePVF.str() );
00172                 }
00173             }
00174         }
00175     }
00176     else if (m_ROOTGeoInit == 1) { // from ROOT object
00177         for (int part = 0; part < m_kPart; part++) {
00178             int ipart = 0;
00179             if (part == 1) ipart = 2;
00180             if (part ==2 ) ipart = 1;
00181             for (int layer = 0; layer < GetLayerNb(part); layer++) {
00182                 for (int scin = 0; scin < GetScinNb(part); scin++) {
00183                     int iNode = 0;
00184 //        if (part == 1) {
00185 //          iNode = layer*m_kScinBr + scin;
00186 //        }
00187 //        else if (part == 2) { // West placed first in Tof.gdml
00188 //          iNode = 2*m_kScinBr + scin;
00189 //        }
00190 //        else if (part == 0) {
00191 //          iNode = 2*m_kScinBr + m_kScinEc + scin;
00192 //        }
00193                     if (part != 1){
00194                         iNode = (2*m_kScinEc - 1) - scin*2;
00195                     }
00196                     if (part == 1) {
00197                         iNode = (2*m_kScinBr*3 - 1) - (layer*m_kScinBr + scin)*3;
00198                     }
00199 
00200                     m_NodePVF[part][layer][scin] = m_Tof->GetNode( ipart )->GetVolume()->GetNode(iNode);//fix me, change structure now
00201                 }
00202                 m_NodeAl[part][layer] = m_NodePVF[part][layer][0]->GetVolume()->GetNode(0);
00203                 //cout << m_NodeAl[part][layer]->GetName() << endl;
00204                 m_NodeScin[part][layer] = m_NodeAl[part][layer]->GetVolume()->GetNode(0);
00205                 //cout << m_NodeScin[part][layer]->GetName() << endl;
00206             }
00207         }
00208     }
00209 
00210     //std::cout << "TofROOTGeo::SetNode, end of set node" << std::endl;
00211 }
00212 
00213 void
00214 TofROOTGeo::SetVolumeDefaultVis()
00215 {
00216     //std::cout << "begin of set defaultvis" << std::endl;
00217 
00218     m_Tof->SetLineColor(m_TofColor);
00219     m_Tof->SetVisibility(0);
00220 
00221     for (int part = 0; part < m_kPart; part++) {
00222         GetVolumePart(part)->SetLineColor(m_ScinColor);
00223         GetVolumePart(part)->SetVisibility(0);
00224         for (int layer = 0; layer < GetLayerNb(part); layer++) {
00225             GetVolumePVF(part, layer)->SetLineColor(m_ScinColor);
00226             GetVolumePVF(part, layer)->SetVisibility(0);
00227 
00228             GetVolumeAl(part, layer)->SetLineColor(m_ScinColor);
00229             GetVolumeAl(part, layer)->SetVisibility(0);
00230 
00231             GetVolumeScin(part, layer)->SetLineColor(m_ScinColor);
00232             GetVolumeScin(part, layer)->SetVisibility(0);
00233 
00234             GetVolumeBucket(part, layer)->SetLineColor(m_BucketColor);
00235             GetVolumeBucket(part, layer)->SetVisibility(0);
00236         }
00237     }
00238     //std::cout << "end of set defaultvis" << std::endl;
00239 }
00240 
00241 void
00242 TofROOTGeo::SetTMatch(Bool_t input = false){
00243     k_TMatch = input;
00244 }
00245 
00246 void
00247 TofROOTGeo::SetQMatch(Bool_t input = false){
00248     k_QMatch = input;
00249 }
00250 
00251 void
00252 TofROOTGeo::SetAllVisible()
00253 {
00254     m_Tof->SetLineColor(m_TofColor);
00255     m_Tof->SetVisibility(0);
00256 
00257     for (int part = 0; part < m_kPart; part++) {
00258         for (int layer = 0; layer < GetLayerNb(part); layer++) {
00259             GetVolumePVF(part, layer)->SetLineColor(m_ScinColor);
00260             GetVolumePVF(part, layer)->SetVisibility(1);
00261 
00262             GetVolumeAl(part, layer)->SetLineColor(m_ScinColor);
00263             GetVolumeAl(part, layer)->SetVisibility(1);
00264 
00265             GetVolumeScin(part, layer)->SetLineColor(m_ScinColor);
00266             GetVolumeScin(part, layer)->SetVisibility(1);
00267 
00268             GetVolumeBucket(part, layer)->SetLineColor(m_BucketColor);
00269             GetVolumeBucket(part, layer)->SetVisibility(1);
00270         }
00271     }
00272 }
00273 
00274 void
00275 TofROOTGeo::SetQuarterVisible()
00276 {
00277     /*
00278     for (int part = 0; part < m_kPart; part++) {
00279       GetVolumeScin(part)->SetVisibility(1);
00280       GetVolumeBucket(part)->SetVisibility(1);
00281       
00282       int nScin = 0;
00283       if (part == 1) nScin = m_kAssemblyBr;
00284       else nScin = m_kAssemblyEc;
00285       for (int scin = 0; scin < nScin; scin++) {
00286         if (scin < nScin/4) GetScin(part, scin)->SetVisibility(0);
00287         else                GetScin(part, scin)->SetVisibility(1);
00288       
00289         int nBucket = 0;
00290         if (part == 1) nBucket = m_kBucketBr;
00291         else nBucket = m_kBucketEc;
00292         for (int bucket = 0; bucket < nBucket; bucket++) {
00293       if (scin < nScin/4) GetBucket(part, scin, bucket)->SetVisibility(0);
00294       else                GetBucket(part, scin, bucket)->SetVisibility(1);
00295         }
00296       }
00297     }
00298     */
00299 }
00300 
00301 void
00302 TofROOTGeo::SetHalfVisible()
00303 {
00304     /*
00305     for (int part = 0; part < m_kPart; part++) {
00306       GetVolumeScin(part)->SetVisibility(1);
00307       GetVolumeBucket(part)->SetVisibility(1);
00308       
00309       int nScin = 0;
00310       if (part == 1) nScin = m_kAssemblyBr;
00311       else nScin = m_kAssemblyEc;
00312       for (int scin = 0; scin < nScin; scin++) {
00313         if (scin < nScin/4+1 ||
00314         scin > nScin*3/4 ) GetScin(part, scin)->SetVisibility(1);
00315         else                   GetScin(part, scin)->SetVisibility(0);
00316       
00317         int nBucket = 0;
00318         if (part == 1) nBucket = m_kBucketBr;
00319         else nBucket = m_kBucketEc;
00320         for (int bucket = 0; bucket < nBucket; bucket++) {
00321       if (scin < nScin/4+1 ||
00322           scin > nScin*3/4 ) GetBucket(part, scin, bucket)->SetVisibility(1);
00323       else                   GetBucket(part, scin, bucket)->SetVisibility(0);
00324         }
00325       }
00326     }
00327     */
00328 }
00329 
00330 void
00331 TofROOTGeo::SetNoEndVisible()
00332 {
00333     /*
00334     int part = 1;
00335     GetVolumeScin(0)->SetVisibility(1);
00336     GetVolumeBucket(0)->SetVisibility(1);
00337       
00338     int nScin = 0;
00339     nScin = m_kAssemblyBr;
00340     for (int scin = 0; scin < nScin; scin++) {
00341       GetScin(part, scin)->SetVisibility(1);
00342 
00343       int nBucket = 0;
00344       nBucket = m_kBucketBr;
00345       for (int bucket = 0; bucket < nBucket; bucket++) {
00346         GetBucket(part, scin, bucket)->SetVisibility(1);
00347       }
00348     }
00349     */
00350 }
00351 
00352 void
00353 TofROOTGeo::SetPhysicalNode()
00354 {
00355     if (gGeoManager == 0) std::cout << "Create gGeoManager first" << std::endl;
00356     TGeoNode *bes = gGeoManager->GetTopNode();
00357     //std::cout << "Tof m_childNo " << m_childNo << std::endl;
00358     //TGeoNode *nodeTof = bes->GetVolume()->GetNode(0);
00359     TGeoNode *nodeTof = bes->GetDaughter(1);
00360     for (int part = 0; part < m_kPart; part++) {
00361 
00362 //     std::stringstream osnamePart;
00363 //     if (part == 1)      osnamePart << "pv_" << "logicalBrTof" << "_2";
00364 //     else if(part == 0)  osnamePart << "pv_" << "logicalEcTofEast" << "_0";
00365 //     else                osnamePart << "pv_" << "logicalEcTofWest" << "_1";
00366 
00367 //    TGeoNode *nodePart = GetNode( osnamePart.str() );
00368 
00369         int ipart = 0;
00370         if (part == 1) ipart = 2;
00371         if (part ==2 ) ipart = 1;
00372         TGeoNode *nodePart;
00373         nodePart = nodeTof->GetVolume()->GetNode(ipart);
00374 
00375         for (int layer = 0; layer < GetLayerNb(part); layer++) {
00376             TGeoNode *nodeAl   = GetAl(part, layer);
00377             TGeoNode *nodeScin = GetScin(part, layer);
00378             for (int scin = 0; scin < GetScinNb(part); scin++) {
00379                 TGeoNode *nodePVF = GetPVF(part, layer, scin);
00380                 m_PhysicalScin[part][layer][scin] = gGeoManager->MakePhysicalNode( TString("/") + bes->GetName() +
00381                                                     TString("/") + nodeTof->GetName() +
00382                                                     TString("/") + nodePart->GetName() +
00383                                                     TString("/") + nodePVF->GetName() +
00384                                                     TString("/") + nodeAl->GetName() +
00385                                                     TString("/") + nodeScin->GetName() );
00386                 //cout<<"in SetPhysicalNode() "<<part<<" "<<layer<<" "<<scin<<" "<<endl;
00387                 //cout<<"                     "<<bes->GetName()<<" "<<nodeTof->GetName()<<" "<<nodePVF->GetName()<<" "<<nodeAl->GetName()<<" "<<nodeScin->GetName()<<endl;
00388                 m_PhysicalScin[part][layer][scin]->SetVisibility(0);
00389                 m_PhysicalScin[part][layer][scin]->SetIsVolAtt(kFALSE);
00390                 m_PhysicalScin[part][layer][scin]->SetLineColor(m_ScinColor);
00391             }
00392         }
00393     }
00394 
00395     SetDetector();
00396 }
00397 
00398 void
00399 TofROOTGeo::SetDetector()
00400 {
00401     BesView *view = 0;
00402     if (gPad) view = (BesView*)gPad->GetView();
00403     //if (view) cout << "viewVisFull3DTof " << view->GetVisFull3DTof() << endl;
00404 
00405     m_DetectorsArray->Clear();
00406     for (int part = 0; part < m_kPart; part++) {
00407         for (int layer = 0; layer < GetLayerNb(part); layer++) {
00408             for (int scin = 0; scin < GetScinNb(part); scin++) {
00409                 TGeoPhysicalNode *phyNode = 0;
00410                 phyNode = GetPhysicalScin(part, layer, scin);
00411                 if (phyNode) {
00412                     phyNode->SetVisibility(0); // set all invisible before set any visible
00413                     if (part == 2 ||
00414                             (scin >= GetScinNb(part)*0/4 && scin < GetScinNb(part)*8/8)) {
00415                         m_DetectorsArray->Add( phyNode );
00416                     }
00417                     else if (view && view->GetVisFull3DTof()) {
00418                         m_DetectorsArray->Add( phyNode );
00419                     }
00420                 }
00421             }
00422         }
00423     }
00424 }
00425 
00426 void
00427 TofROOTGeo::SetHits()
00428 {
00429     // set previous event hits to default vis
00430     for (int i = 0; i < m_HitsArray->GetEntries(); i++) {
00431         TGeoPhysicalNode *phyNode = (TGeoPhysicalNode*)m_HitsArray->At(i);
00432         if (phyNode){
00433             //phyNode->SetLineColor(m_ScinColor);
00434             phyNode->SetVisibility(0);
00435         }
00436     }
00437     m_HitsArray->Clear("C");
00438 
00439     // set previous event 2D hits info to default
00440     for (int i = 0; i < m_2DHitsArray->GetEntries(); i++) {
00441       Tof2DScin *aScin = (Tof2DScin*)m_2DHitsArray->At(i);
00442       aScin->ClearInfo();
00443       aScin->AddInfo(aScin->GetTitle());
00444       aScin->CloseInfo();
00445       aScin->ResetTimeCharge();
00446     }
00447     m_2DHitsArray->Clear("C");
00448 
00449     if (gEvent) m_TofDigiCol = gEvent->GetTofDigiCol();
00450 
00451     for (int i = 0; i < m_TofDigiCol->GetEntries(); i++) {
00452       TTofDigi *aTofDigi = (TTofDigi*)m_TofDigiCol->At(i);
00453 
00454       Identifier atofID( aTofDigi->getIntId() );
00455       int part  = TofID::barrel_ec(  atofID );
00456       int layer = TofID::layer(      atofID );
00457       int scin  = TofID::phi_module( atofID );
00458 
00459       //Double_t charge = Double_t(aTofDigi->getChargeChannel()) / TOF_CHARGE_FACTOR;
00460       //Double_t time   = Double_t(aTofDigi->getTimeChannel())   / TOF_TIME_FACTOR;
00461 
00462       Double_t charge = RawDataUtil::TofCharge(aTofDigi->getChargeChannel());
00463       Double_t time   = RawDataUtil::TofTime(aTofDigi->getTimeChannel());
00464 
00465       TGeoPhysicalNode *phyNode = 0;
00466       phyNode = GetPhysicalScin( part, layer, scin );
00467       if (phyNode) {
00468         m_HitsArray->Add( phyNode );
00469       }
00470 
00471       Tof2DScin *aScin = 0;
00472       aScin = m_Tof2DScin[part][layer][scin];
00473       if (aScin) {
00474         char data[100];
00475 
00476         if (aScin->GetCharge() == 0.0) {
00477           aScin->ClearInfo();
00478           aScin->AddInfo(aScin->GetTitle());
00479           sprintf(data, "time1 = %-.3f ns, charge1 = %-.3f MeV", time, charge);
00480           aScin->AddInfo( TString(data) );
00481         }
00482         else {
00483           sprintf(data, "time2 = %-.3f ns, charge2 = %-.3f MeV", time, charge);
00484           aScin->AddInfo( TString(data) );
00485           sprintf(data, "Fired");
00486           aScin->AddInfo( TString(data) );
00487         }
00488 
00489         aScin->CloseInfo();
00490         aScin->SetCharge(aScin->GetCharge() + charge);
00491 
00492         m_2DHitsArray->Add(aScin);
00493       }
00494     }
00495 }
00496 
00497   void
00498 TofROOTGeo::SetVisTofDetector()
00499 {
00500   /*
00501      for (int part = 0; part < m_kPart; part++) {
00502      for (int layer = 0; layer < GetLayerNb(part); layer++) {
00503      for (int scin = 0; scin < GetScinNb(part); scin++) {
00504      TGeoPhysicalNode *phyNode = GetPhysicalScin(part, layer, scin);
00505      if (phyNode) phyNode->SetLineColor(m_ScinColor);
00506      }
00507      }
00508      }
00509      */
00510 
00511   BesView *view = 0;
00512   if (gPad) view = (BesView*)gPad->GetView();
00513 
00514   //cout << "VisTofEast " << view->GetVisTofEast() << endl;
00515   for (int i = 0; i < m_DetectorsArray->GetEntries(); i++) {
00516     TGeoPhysicalNode *phyNode = (TGeoPhysicalNode*)m_DetectorsArray->At(i);
00517     phyNode->SetVisibility(0);
00518     if (view && view->GetVisTofGlobal()) {
00519       int part = GetPart(phyNode);
00520       if (part == 0 && view->GetVisTofEast()   ||
00521           part == 1 && view->GetVisTofBarrel() ||
00522           part == 2 && view->GetVisTofWest()   )
00523         phyNode->SetVisibility(1);
00524     }
00525   }
00526 }
00527 
00528   void
00529 TofROOTGeo::SetVisTofHits()
00530 {
00531   BesView *view = 0;
00532   if (gPad) view = (BesView*)gPad->GetView();
00533 
00534   for (int i = 0; i < m_HitsArray->GetEntries(); i++) {
00535     TGeoPhysicalNode *phyNode = (TGeoPhysicalNode*)m_HitsArray->At(i);
00536     if (phyNode){
00537       if (view && view->GetVisTofHitsGlobal()) {
00538         int part = GetPart(phyNode);
00539         if (part == 0 && view->GetVisTofHitsEast()   ||
00540             part == 1 && view->GetVisTofHitsBarrel() ||
00541             part == 2 && view->GetVisTofHitsWest()   ) {
00542           phyNode->SetVisibility(1);
00543           phyNode->SetLineColor(kGreen);
00544           continue;
00545         }
00546       }
00547       phyNode->SetVisibility(0);
00548     }
00549   }
00550 }
00551 
00552   int
00553 TofROOTGeo::GetPartNb()
00554 {
00555   int nPart = m_kPart;
00556   return nPart;
00557 }
00558 
00559   int
00560 TofROOTGeo::GetScinNb(int part)
00561 {
00562   int nScin = m_kScinBr;
00563   if (part != 1) nScin = m_kScinEc;
00564   return nScin;
00565 }
00566 
00567   int
00568 TofROOTGeo::GetLayerNb(int part)
00569 {
00570   int nLayer = m_kLayerBr;
00571   if (part != 1) nLayer = m_kLayerEc;
00572   return nLayer;
00573 }
00574 
00575 /*
00576    TGeoVolumeAssembly*
00577    TofROOTGeo::GetVolumeAssembly( int part )
00578    {
00579    std::stringstream osname;
00580    if (part == 0 || part == 2) {
00581    osname << "logical" << "Tof" << "AssemblyEc";
00582    }
00583    else {
00584    if (part == 1) {
00585    osname << "logical" << "Tof" << "AssemblyBr";
00586    }
00587    }
00588 
00589    return GetAssemblyVolume( osname.str() );
00590    }
00591    */
00592 
00593   TGeoVolume*
00594 TofROOTGeo::GetVolumePart(int part)
00595 {
00596   std::stringstream osname;
00597   if (part == 1) {
00598     osname << "logicalBrTof";
00599   }
00600   else if (part == 0){
00601     osname << "logicalEcTofWest";
00602   }
00603   else {
00604     osname << "logicalEcTofEast";
00605   }
00606 
00607   return GetLogicalVolume( osname.str() );
00608 
00609 
00610 
00611 }
00612 
00613   TGeoVolume*
00614 TofROOTGeo::GetVolumePVF( int part, int layer )
00615 {
00616   std::stringstream osname;
00617   if (part == 0) {
00618     osname << "logical" << "PVFEcEast";
00619   }
00620   else if (part == 2){
00621     osname << "logical" << "PVFEcWest";
00622   }
00623   else {
00624     if (part == 1) {
00625       osname << "logical" << "PVFBr" << layer+1;
00626     }
00627   }
00628 
00629   return GetLogicalVolume( osname.str() );
00630 }
00631 
00632   TGeoVolume*
00633 TofROOTGeo::GetVolumeAl( int part, int layer )
00634 {
00635   std::stringstream osname;
00636   if (part == 0) {
00637     osname << "logical" << "AlEcEast";
00638   }
00639   else if (part == 2){
00640     osname << "logical" << "AlEcWest";
00641   }
00642   else {
00643     if (part == 1) {
00644       osname << "logical" << "AlBr" << layer+1;
00645     }
00646   }
00647 
00648   return GetLogicalVolume( osname.str() );
00649 }
00650 
00651   TGeoVolume*
00652 TofROOTGeo::GetVolumeScin( int part, int layer )
00653 {
00654   std::stringstream osname;
00655   if (part == 0) {
00656     osname << "logical" << "ScinEcEast";
00657   }
00658   else if (part == 2){
00659     osname << "logical" << "ScinEcWest";
00660   }
00661   else {
00662     if (part == 1) {
00663       osname << "logical" << "ScinBr" << layer+1;
00664     }
00665   }
00666 
00667   return GetLogicalVolume( osname.str() );
00668 }
00669 
00670   TGeoVolume*
00671 TofROOTGeo::GetVolumeBucket( int part, int layer )
00672 {
00673   std::stringstream osname;
00674   if (part == 0 || part == 2) {
00675     osname << "logical" << "BucketEc";
00676   }
00677   else {
00678     if (part == 1) {
00679       osname << "logical" << "BucketBr" << layer+1;
00680     }
00681   }
00682 
00683   return GetLogicalVolume( osname.str() );
00684 }
00685 
00686   TGeoNode*
00687 TofROOTGeo::GetPVF( int part, int layer, int scin )
00688 {
00689   if (m_NodePVF[part][layer][scin] != 0) {
00690     return m_NodePVF[part][layer][scin];
00691   }
00692   else {
00693     std::cout << "Node: " << "Part" << part << "Layer" << layer << "PVF" << scin << " not found" << std::endl;
00694     return 0;
00695   }
00696 
00697   return m_NodePVF[part][layer][scin];
00698 }
00699 
00700   TGeoNode*
00701 TofROOTGeo::GetAl( int part, int layer )
00702 {
00703   if (m_NodeAl[part][layer] != 0) {
00704     return m_NodeAl[part][layer];
00705   }
00706   else {
00707     std::cout << "Node: " << "Part" << part << "Layer" << layer << "Al" << " not found" << std::endl;
00708     return 0;
00709   }
00710 
00711   return m_NodeAl[part][layer];
00712 }
00713 
00714   TGeoNode*
00715 TofROOTGeo::GetScin( int part, int layer )
00716 {
00717   if (m_NodeScin[part][layer] != 0) {
00718     return m_NodeScin[part][layer];
00719   }
00720   else {
00721     std::cout << "Node: " << "Part" << part << "Layer" << layer << "Scin" << " not found" << std::endl;
00722     return 0;
00723   }
00724 
00725   return m_NodeScin[part][layer];
00726 }
00727 
00728 
00729 /*
00730    TGeoNode *
00731    TofROOTGeo::GetBucket( int part, int scin, int bucket )
00732    {
00733    std::stringstream osname;
00734    if (part == 0) {
00735    osname << "pv_" << "logical" << "Tof" << "BucketEc" << "_" << m_kAssemblyBr + m_kAssemblyEc + scin << "_1";
00736    }
00737    else if (part == 1) {
00738    osname << "pv_" << "logical" << "Tof" << "BucketBr" << "_" << scin << "_" << bucket+1;
00739    }
00740    else if (part == 2) {
00741    osname << "pv_" << "logical" << "Tof" << "BucketEc" << "_" << m_kAssemblyBr + scin << "_1";
00742    }
00743 
00744    return GetNode( osname.str() );
00745    }
00746    */
00747 
00748   TGeoPhysicalNode*
00749 TofROOTGeo::GetPhysicalScin( int part, int layer, int scin )
00750 {
00751   if (m_PhysicalScin[part][layer][scin] != 0) {
00752     return m_PhysicalScin[part][layer][scin];
00753   }
00754   else {
00755     std::cout << "PhysicalNode: " << "Part"
00756       << part << "Layer" << layer << "Scin"
00757       << scin << " not found" << std::endl;
00758     return 0;
00759   }
00760 }
00761 
00762   Tof2DScin*
00763 TofROOTGeo::Get2DScin( Int_t part, Int_t layer, Int_t scin)
00764 {
00765   if (m_Tof2DScin[part][layer][scin]) return m_Tof2DScin[part][layer][scin];
00766   else return 0;
00767 }
00768 
00769   Int_t
00770 TofROOTGeo::GetPart(TGeoPhysicalNode* phyNode)
00771 {
00772   for (Int_t part = 0; part < m_kPart; part++) {
00773     for (Int_t layer = 0; layer < GetLayerNb(part); layer++) {
00774       for (int scin = 0; scin < GetScinNb(part); scin++) {
00775         if (phyNode == GetPhysicalScin(part, layer, scin)) {
00776           //cout << "GetPart()" << part << endl;
00777           return part;
00778         }
00779       }
00780     }
00781   }
00782 
00783   cout << "TofROOTGeo::GetPart, this scintillator physical node does not exist!" << endl;
00784   return -1;
00785 }
00786 
00787   void
00788 TofROOTGeo::Draw(Option_t *option)
00789 {
00790   TString opt = option;
00791   opt.ToUpper();
00792 
00793   if (!m_2DGeoInit) cout << "TofROOTGeo::Draw2D(), 2D Geometry not initialized!" << endl;
00794   BesView *view = (BesView*)gPad->GetView();
00795   if (!view) cout << "TofROOTGeo::Draw(), BesView not found" << endl;
00796 
00797   if (view->GetVisTofGlobal()) { // TofVisGlobal
00798     TString scinOpt;
00799 
00800     //if (opt.Contains("XY")) {
00801     // west part drawn first usually
00802     for (Int_t part = m_kPart-1; part >= 0; part--) {
00803       for (Int_t layer = 0; layer < GetLayerNb(part); layer++) {
00804         for (int scin = 0; scin < GetScinNb(part); scin++) {
00805 
00806           if (m_Tof2DScin[part][layer][scin]) {
00807             //cout << "part " << part << " layer " << layer << " scin " << scin << endl;
00808             //m_Tof2DScin[part][layer][scin]->SetHighlighted(false);
00809             m_Tof2DScin[part][layer][scin]->SetFired(false);
00810             if ( (part == 0 && view->GetVisTofEast())   ||
00811                 (part == 1 && view->GetVisTofBarrel()) ||
00812                 (part == 2 && view->GetVisTofWest()) )
00813               m_Tof2DScin[part][layer][scin]->Draw(scinOpt);
00814           }
00815         }
00816       }
00817     }
00818   }
00819   }
00820 
00821   void
00822     TofROOTGeo::DrawHits(Option_t *option)
00823     {
00824       // cout << "Draw Hits" << endl;
00825       BesView *view = (BesView*)gPad->GetView();
00826       if (!view) cout << "TofROOTGeo::DrawHits(), BesView not found" << endl;
00827 
00828       //cout << "VisTofHitsGlobal " << view->GetVisTofHitsGlobal() << endl;
00829       //cout << "VisTofHitsEast   " << view->GetVisTofHitsEast()   << endl;
00830       //cout << "VisTofHitsBarrel " << view->GetVisTofHitsBarrel() << endl;
00831       //cout << "VisTofHitsWest   " << view->GetVisTofHitsWest()   << endl;
00832 
00833       if (view->GetVisTofHitsGlobal()) {
00834 
00835         // reset time and charge to zero
00836         for (Int_t part = m_kPart-1; part >= 0; part--) {
00837           for (Int_t layer = 0; layer < GetLayerNb(part); layer++) {
00838             for (int scin = 0; scin < GetScinNb(part); scin++) {
00839               if (m_Tof2DScin[part][layer][scin]) {
00840                 m_Tof2DScin[part][layer][scin]->ResetTimeCharge();
00841               }
00842             }
00843           }
00844         }
00845 
00846         if (m_TofDigiCol) {
00847           for (int i = 0; i < m_TofDigiCol->GetEntries(); i++) {
00848             TTofDigi *aTofDigi = (TTofDigi*)m_TofDigiCol->At(i);
00849 
00850             Identifier aTofID( aTofDigi->getIntId() );
00851             int part   = TofID::barrel_ec( aTofID );
00852             int layer  = TofID::layer( aTofID );
00853             int scin   = TofID::phi_module( aTofID );
00854 
00855             Double_t charge = Double_t(aTofDigi->getChargeChannel()) / TOF_CHARGE_FACTOR;
00856             //cout << "charge " << charge << endl;
00857 
00858             Tof2DScin *aScin = 0;
00859             aScin = m_Tof2DScin[part][layer][scin];
00860             // Mdc TQMatch for example
00861             //
00862             //if (aWire &&
00863             //        ((overflow == 0)||(overflow == 12))){
00864             //    if ((k_TMatch) &&
00865             //            (aMdcDigi->getTimeChannel() == 0x7FFFFFFF)){
00866             //        continue;
00867             //    }
00868             //    if ((k_QMatch) &&
00869             //            (aMdcDigi->getChargeChannel() == 0x7FFFFFFF)){
00870             //        continue;
00871             //    }
00872             //}
00873 
00874             if (aScin) {
00875               if ((k_TMatch)&&
00876                   (aTofDigi->getTimeChannel() == 0x7FFFFFFF)){
00877                 continue;
00878               }
00879               if ((k_QMatch)&&
00880                   (aTofDigi->getChargeChannel() == 0x7FFFFFFF)){
00881                 continue;
00882               }
00883 
00884               aScin->SetCharge(aScin->GetCharge() + charge);
00885 
00886               if ( (part == 0 && view->GetVisTofHitsEast())   ||
00887                   (part == 1 && view->GetVisTofHitsBarrel()) ||
00888                   (part == 2 && view->GetVisTofHitsWest()) ) {
00889                 aScin->SetFired(true);
00890                 aScin->Draw();
00891               }
00892             }
00893           }
00894         }
00895       }
00896     }

Generated on Tue Nov 29 22:58:01 2016 for BOSS_7.0.2 by  doxygen 1.4.7