|
// $Id: BrDetectorDC.cxx,v 1.2 2002/02/26 08:58:09 cholm Exp $ // // // #include "BrDetectorDC.h" #include "BrGeometryDbManager.h" #include "BrDetectorVolume.h" #include "BrDataTable.h" #include "BrGeantHit.h" #include "TGeometry.h" #include "TMixture.h" #include "TRotMatrix.h" #include "TBRIK.h" #include "BrDetectorTrack.h" #include "BrVector3D.h" #include "BrPlane3D.h" #include "BrLine3D.h" #include <iostream.h> /////////////////////////////////////////////////////////// // // BrDetectorDC // // BRAHMS DC Detector Class // // This is a detector class envisioned to be used for event // displays and the like for DC's. It might also be expanded for other uses. // // Author : K. Hagel // Created: 4-Nov-1998 // Version: 1.0 // /////////////////////////////////////////////////////////// ClassImp(BrDetectorDC) BrDetectorDC::BrDetectorDC() { // Vanilla constructor; Should not be called within the ROOT environment. // fPolyMarker = NULL; f3DPoints = NULL; for(Int_t i=0;i<MaxTracksToDraw;i++) fPolyLine[i] = NULL; } BrDetectorDC::BrDetectorDC(const Char_t *name, const Char_t *title, const Char_t *det_name) //,BrDetectorVolume *vol, BrDetectorVolume *vol1, BrDetectorVolume *vol2, BrDetectorVolume *vol3) { // // Constructor. This is the default constructor to use. // BrDetectorVolume *vol,*vol1,*vol2,*vol3; SetName(name); SetTitle(title); if(!det_name) det_name = StrDup(name); BrGeometryDbManager *gGeomDb = BrGeometryDbManager::Instance(); //Get the main volume Char_t volname[32]; strcpy(volname,det_name); vol = (BrDetectorVolume*)gGeomDb->GetDetectorVolume("BrDetectorVolume",volname); //Get the sub volumes sprintf(volname,"%sA1",det_name); vol1 = (BrDetectorVolume*)gGeomDb->GetDetectorVolume("BrDetectorVolume",volname); sprintf(volname,"%sA2",det_name); vol2 = (BrDetectorVolume*)gGeomDb->GetDetectorVolume("BrDetectorVolume",volname); sprintf(volname,"%sA3",det_name); vol3 = (BrDetectorVolume*)gGeomDb->GetDetectorVolume("BrDetectorVolume",volname); Char_t intname[64]; Char_t inttitle[64]; TNode *cursav = gGeometry->GetCurrentNode(); //save the current node so we can put it back later if(!cursav) { cursav = new TNode("BRAHMS Master Node","BRAHMS Master Node",new TShape()); cursav->cd(); } strcpy(intname,name); strcpy(inttitle,title); Char_t mixname[64]; sprintf(mixname,"%s Mixture",name); fMixture = new TMixture(mixname,"Ne-CH4-CO2",4); fMixture->DefineElement(0,20.18,10,.8581148); fMixture->DefineElement(1,12.01,6,.0567446); fMixture->DefineElement(2,1.01,1,.0095441); fMixture->DefineElement(3,16,8,.0755965); const BrRotMatrix* bMatrix = vol->GetRotMatrix(); // Cheat code - just use theta, though we may have the other // Euler angles in place. Root TRotMatrix does not have the // Euler angle constructor. This is a problem. fv 9/16/00 // Is this not done in the constructor of the BaseClass ? // //First set the master volume fMatrix = new TRotMatrix(intname,inttitle,0,0,0,0,bMatrix->GetTheta(),0); Float_t *size; size = vol->GetSize(); fShape = new TBRIK(intname,inttitle,inttitle,size[0]/2.,size[1]/2.,size[2]/2.); BrVector3D pos = vol->GetPosition(); //this->BrBaseDetector::BrBaseDetector(name,title,fShape,pos[0],pos[1],pos[2],fMatrix,""); ExecuteTNodeConstructor(name,title,fShape,pos[0],pos[1],pos[2],fMatrix,""); this->cd(); Char_t subnodename[64]; pos = vol1->GetPosition(); size = vol1->GetSize(); sprintf(subnodename,"%s A1",name); fDc1Shape = new TBRIK(subnodename,subnodename,mixname,size[0]/2.,size[1]/2.,size[2]/2.); fDCSubModule[0] = new TNode(subnodename,subnodename,fDc1Shape,pos[0],pos[1],pos[2],0); fDCSubModule[0]->SetLineColor(kBlue); pos = vol2->GetPosition(); size = vol2->GetSize(); sprintf(subnodename,"%s A2",name); fDc2Shape = new TBRIK(subnodename,subnodename,mixname,size[0]/2.,size[1]/2.,size[2]/2.); fDCSubModule[1] = new TNode(subnodename,subnodename,fDc2Shape,pos[0],pos[1],pos[2],0); fDCSubModule[1]->SetLineColor(kGreen); pos = vol3->GetPosition(); size = vol1->GetSize(); sprintf(subnodename,"%s A3",name); fDc3Shape = new TBRIK(subnodename,subnodename,mixname,size[0]/2.,size[1]/2.,size[2]/2.); fDCSubModule[2] = new TNode(subnodename,subnodename,fDc3Shape,pos[0],pos[1],pos[2],0); fDCSubModule[2]->SetLineColor(kRed); cursav->cd(); fPolyMarker = new TPolyMarker3D(); f3DPoints = NULL; for(Int_t i=0;i<MaxTracksToDraw;i++) fPolyLine[i] = new TPolyLine3D(); } BrDetectorDC::~BrDetectorDC() { // // default destructor if(fPolyMarker) delete fPolyMarker; if(f3DPoints) delete [] f3DPoints; for(Int_t i=0;i<MaxTracksToDraw;i++) if(fPolyLine[i]) delete fPolyLine[i]; } void BrDetectorDC::EventDisplay() { //This is a test. It is only a test. Don't take what you see in here too seriously //except to learn how to do things which is what I used it for. fPolyMarker = new TPolyMarker3D(12); printf("Starting to set pointsn"); // set points fPolyMarker->SetPoint(0, 0, 0, 0); fPolyMarker->SetPoint(1, 1, 1, 1); fPolyMarker->SetPoint(2, 2, 2, 2); fPolyMarker->SetPoint(3, 3, 3, 3); fPolyMarker->SetPoint(4, 4, 4, 4); fPolyMarker->SetPoint(5, 6, 6, 6); fPolyMarker->SetPoint(6, 8, 8, 8); fPolyMarker->SetPoint(7, 10, 10, 10); fPolyMarker->SetPoint(8, 14, 14, 14); fPolyMarker->SetPoint(9, 18, 18, 18); fPolyMarker->SetPoint(10, 22, 22, 22); fPolyMarker->SetPoint(11, 26, 26, 26); // set marker size, color & style fPolyMarker->SetMarkerSize(2); fPolyMarker->SetMarkerColor(4); fPolyMarker->SetMarkerStyle(2); // draw fPolyMarker->Draw(); } void BrDetectorDC::Clear() { #if ROOT_VERSION_CODE < ROOT_VERSION(2,25,0) fPolyMarker->SetPolyMarker(0,0,2); for(Int_t i=0;i<MaxTracksToDraw;i++) fPolyLine[i]->SetPolyLine(0,0,""); #else Float_t marker = 0; fPolyMarker->SetPolyMarker(0,&marker,2); for(Int_t i=0;i<MaxTracksToDraw;i++) fPolyLine[i]->SetPolyLine(0,&marker,""); #endif } void BrDetectorDC::DrawGeantHits(BrDataTable *ghits[3]) { Int_t idet; Int_t NumHits; Int_t TotalHits; Int_t hitnum,ihit; BrGeantHit *ghit_p; Float_t x1,x2,y1,y2,z1,z2; //Figure out how many Geant Hits we have. TotalHits = 0; for(idet=0;idet<3;idet++) { if(!ghits[idet]) printf("ghits[%d] = 0!!!n",idet); if(ghits[idet]) TotalHits += 2 * ghits[idet]->GetEntries(); //2* since we have in and out } if(f3DPoints) delete [] f3DPoints; f3DPoints = new Float_t [3 * TotalHits]; hitnum = 0; for(idet=0;idet<3;idet++) { if(ghits[idet]) { NumHits = ghits[idet]->GetEntries(); if(DebugLevel()>0) { cout<<"Starting to draw Geant Hits for "<<GetName()<<" Module # "<<idet<<endl; for(ihit=0;ihit<NumHits;ihit++) { cout<<(BrGeantHit*)ghits[idet]->At(ihit); } } for( ihit=0;ihit<NumHits;ihit++) { ghit_p = (BrGeantHit*)ghits[idet]->At(ihit); x1 = ghit_p->LocalPosIn()[0]; y1 = ghit_p->LocalPosIn()[1]; z1 = ghit_p->LocalPosIn()[2] + fDCSubModule[idet]->GetZ(); x2 = ghit_p->LocalPosOut()[0]; y2 = ghit_p->LocalPosOut()[1]; z2 = ghit_p->LocalPosOut()[2] + fDCSubModule[idet]->GetZ(); Int_t n = hitnum * 3; f3DPoints[n] = x1; f3DPoints[n+1] = y1; f3DPoints[n+2] = z1; f3DPoints[n+3] = x2; f3DPoints[n+4] = y2; f3DPoints[n+5] = z2; hitnum += 2; } } } // set marker size, color & style fPolyMarker->SetMarkerSize(2); fPolyMarker->SetMarkerColor(4); fPolyMarker->SetMarkerStyle(2); fPolyMarker->SetPolyMarker(hitnum,f3DPoints,2); //test // draw fPolyMarker->Draw(); } void BrDetectorDC::DrawLocalTracks(BrDataTable *tracktable) { Int_t NumTracks; Int_t itrack; BrDetectorTrack *titr_p; if(tracktable) { if(f3DPoints) delete [] f3DPoints; f3DPoints = new Float_t [6]; NumTracks = tracktable->GetEntries(); if(NumTracks > MaxTracksToDraw) NumTracks = MaxTracksToDraw; Double_t zin = fDCSubModule[0]->GetZ() - ((TBRIK*)fDCSubModule[0]->GetShape())->GetDz(); Double_t zout = fDCSubModule[2]->GetZ()+ ((TBRIK*)fDCSubModule[2]->GetShape())->GetDz(); BrPlane3D entranceplane(0,0,zin,1,0,zin,0,1,zin); BrPlane3D exitplane(0,0,zout,1,0,zout,0,1,zout); for(itrack=0;itrack<NumTracks;itrack++) { titr_p = (BrDetectorTrack*)tracktable->At(itrack); BrLine3D trackline(titr_p->GetPos(),titr_p->GetAlpha()); BrVector3D int1 = entranceplane.GetIntersectionWithLine(trackline); BrVector3D int2 = exitplane.GetIntersectionWithLine(trackline); f3DPoints[0] = int1[0]; f3DPoints[1] = int1[1]; f3DPoints[2] = int1[2]; f3DPoints[3] = int2[0]; f3DPoints[4] = int2[1]; f3DPoints[5] = int2[2]; fPolyLine[itrack]->SetPolyLine(2,f3DPoints,""); // Set attributes fPolyLine[itrack]->SetLineWidth(3); fPolyLine[itrack]->SetLineColor(5); fPolyLine[itrack]->Draw(); } } } ///////////////////////////////////////////////////////////////////// // // $Log: BrDetectorDC.cxx,v $ // Revision 1.2 2002/02/26 08:58:09 cholm // Added const'ness to many methods - needed by ISO C++ // // Revision 1.1.1.1 2001/06/21 14:55:07 hagel // Initial revision of brat2 // // Revision 1.8 2000/09/18 21:30:50 videbaek // Remove calls to GetAngle GetPos - replace by getPosition i.e. a 3D vector. // replace calls with rotation matrix calls. // // Revision 1.7 2000/08/29 15:41:08 hagel // Changes to make compile with root v2.25 // // Revision 1.6 1999/02/28 22:14:37 hagel // Changes to make event display more robust and seamless // // Revision 1.5 1999/02/11 03:11:42 hagel // Debug Event Display for Linux // // Revision 1.4 1998/12/17 22:09:16 hagel // Add CVS headers |
||||||
This page automatically generated by script docBrat by Christian Holm |
Copyright ; 2002 BRAHMS Collaboration
<brahmlib@rcf.rhic.bnl.gov>
|