|
// $Id: BrDetectorTPC.cxx,v 1.2 2002/02/26 08:58:14 cholm Exp $ // $Author: cholm $ // $Date: 2002/02/26 08:58:14 $ // //_______________________________________________________________________ // // BrDetectorTPC // // BRAHMS TPC Detector Class // // This is a detector class to be used for event // displays and the like for TPC's. It might also be expanded for other uses. // // Author : K. Hagel // Created: 4-Nov-1998 // Version: 1.0 // #include "BrDetectorTPC.h" #ifndef BRAT_BrGeometryDbManager #include "BrGeometryDbManager.h" #endif #ifndef BRAT_BrDetectorVolume # include "BrDetectorVolume.h" #endif #ifndef BRAT_BrDataTable # include "BrDataTable.h" #endif #ifndef BRAT_BrGeantHit # include "BrGeantHit.h" #endif #include "TGeometry.h" #include "TMixture.h" #include "TRotMatrix.h" #include "TBRIK.h" #include "TNode.h" #include "BrDetectorTrack.h" #include "BrVector3D.h" #include "BrPlane3D.h" #include "BrLine3D.h" #include <iostream.h> //_______________________________________________________________________ ClassImp(BrDetectorTPC) //_______________________________________________________________________ BrDetectorTPC::BrDetectorTPC() { // 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; } //_______________________________________________________________________ BrDetectorTPC::BrDetectorTPC(const Char_t *name, const Char_t *title, const Char_t *det_name) //,BrDetectorVolume *vol) { // // Constructor. This is the default constructor to use. // BrDetectorVolume *vol; 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); 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 ? // fMatrix = new TRotMatrix(intname,inttitle,0,0,0,0,bMatrix->GetTheta(),0); //First set the master volume //fMatrix = new TRotMatrix(intname,inttitle,0,0,0,0,vol->GetAngle(),0); Float_t* 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,""); cursav->cd(); fPolyMarker = new TPolyMarker3D(); f3DPoints = NULL; for(Int_t i=0;i<MaxTracksToDraw;i++) fPolyLine[i] = new TPolyLine3D(); } //_______________________________________________________________________ BrDetectorTPC::~BrDetectorTPC() { // // 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 BrDetectorTPC::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 Double_t marker = 0; fPolyMarker->SetPolyMarker(0,&marker,2); for(Int_t i=0;i<MaxTracksToDraw;i++) fPolyLine[i]->SetPolyLine(0,&marker,""); #endif } //_______________________________________________________________________ void BrDetectorTPC::DrawGeantHits(BrDataTable *ghits) { 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. if(ghits) { TotalHits = 2 * ghits->GetEntries(); if(f3DPoints) delete [] f3DPoints; f3DPoints = new Float_t [3 * TotalHits]; hitnum = 0; NumHits = ghits->GetEntries(); if(DebugLevel()>0) { cout<<"Starting to draw Geant Hits for "<<GetName()<<endl; cout<<"There are "<<NumHits<<" Geant Hits in this event"<<endl; for(ihit=0;ihit<NumHits;ihit++) { cout<<(BrGeantHit*)ghits->At(ihit); } } for( ihit=0;ihit<NumHits;ihit++) { ghit_p = (BrGeantHit*)ghits->At(ihit); x1 = ghit_p->LocalPosIn()[0]; y1 = ghit_p->LocalPosIn()[1]; z1 = ghit_p->LocalPosIn()[2]; x2 = ghit_p->LocalPosOut()[0]; y2 = ghit_p->LocalPosOut()[1]; z2 = ghit_p->LocalPosOut()[2]; 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(1.0); fPolyMarker->SetMarkerColor(4); fPolyMarker->SetMarkerStyle(2); fPolyMarker->SetPolyMarker(hitnum, f3DPoints, 2); //test // draw fPolyMarker->Draw(); } } //_______________________________________________________________________ void BrDetectorTPC::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 = -((TBRIK*)GetShape())->GetDz(); Double_t zout = ((TBRIK*)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: BrDetectorTPC.cxx,v $ // Revision 1.2 2002/02/26 08:58:14 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.11 2000/10/02 17:07:55 pchristi // Cleaned up headers and source files in the tpc dir // // Revision 1.10 2000/09/18 21:29:20 videbaek // ce getAngle with info from Rotation Matrix. // // Revision 1.9 2000/08/29 15:41:22 hagel // Changes to make compile with root v2.25 // // Revision 1.8 2000/08/28 18:09:15 videbaek // Move CVS log to end of file // // Revision 1.7 1999/03/07 00:00:45 hagel // 1. Implemented BrFSTrackingModule. Started with BrMRSTrackingModule and made // appropriate changes to handle the forward spectrometer. It uses the new // track classes as well as extensively using geometry classes. It also uses // new methods and functionality as described below. // 2. Changed BrMagnetVolume // a. Added method SwimBack(BrLine3D &,Double_t momentum): takes a // track at the exit of magnet and given the momentum, calculates // where the track would come into the front of the magnet. // b. Added method GlobalToLocal(BrLine3D &): does a combination of // GlobalToLocal(BrVector3D &,BrVector3D&,0) and // GlobalToLocal(BrVector3D &,BrVector3D&,1) // c. Added method LocalToGlobal(BrLine3D &): does a combination of // LocalToGlobal(BrVector3D &,BrVector3D&,0) and // LocalToGlobal(BrVector3D &,BrVector3D&,1) // d. Changed BrDetectorVolume: same additions of methods GlobalToLocal // and LocalToGlobal as in BrMagnetVolume // 2. Added a parameter base class BrDetectorParamsBase: helps when reading // in database files. Declared ASCII reading routines to be virtual. // Has main ReadASCIIFile which decodes the ASCII parameter files, then // calls the detector specific methods SetASCIIParameter // 3. Implemented SetASCIIParameter in BrDetectorParamsDC, BrDetectorParamsTPC, // BrDetectorParamsTof, BrDetectorParamsBB // 4. Implemented BrParameterDbManager. It currently works similarly to // BrGeometryDbManager and creates the BrDetectorParamsXXX objects when // called. These objects then read in ASCII parameter files with a currently // "well defined" format using the above implemented routines using a constructor: // BrDetectorParamsXXX(Char_t *name, Char_t *title,Char_t *ASCIIFileName); // 5. If no parameter file is specified, it executes the constructor we // have been using so far, namely BrDetectorParamsXXX(Char_t *name,Char_t *title). // These constructors generate default parameters and are semi-intelligent // which means they generate approximately appropriate parameters depending // upon which detector they are. I should say that the parameters were // deemed appropriate at the time of writing the SetDefaultParams routine. // a. It is used in the same way as BrGeometryDbManager, that is: // BrParameterDbManager *gParamDb = BrParameterDbManager::Instance(); // gParamDb->SetDbParameterFileName("DetectorParameters.txt"); // 6. Added a new directory, params, in BRAT. This directory has the file // DetectorParameters.txt in it. If the BrParameterDbManager is started // and the DetectorParameter.txt file is specified, it will look in the // $BRATSYS/params directory if it cannot find the file in the directory // that the user has set default to. // 7. Implemented BrParameterDbManager in DC digitize and tracking code. The // SetDetectorParams methods have been moved to private and can no longer be // used from the macro or program. // 8. Implemented BrParameterDbManager in TPC digitize and tracking code. // 9. Implemented BrParameterDbManager in Tof Calibrate and GeneratePid code. // 10 Changed the GetEntries() in BrDataTable to use the GetLast()+1 method in // TObjArray. This should be much faster, but has the caveat that it assumes // that all slots in TObjArray are full. That seems to me to be the case // in how we use TObjArray at least in BrDataTable, but if problems arise due // to this change, it can always be easily changed back. It has been used a // fair amount before checking in and no problems were found. // // Modified Files: // base/inc/BrBase_LinkDef.h base/inc/BrDataTable.h // base/inc/BrDetectorVolume.h base/inc/BrMagnetVolume.h // base/inc/LinkDefBratBaseINC.h base/src/BrDataTable.cxx // base/src/BrDetectorVolume.cxx base/src/BrEventNode.cxx // base/src/BrMagnetVolume.cxx base/src/BrTableManager.cxx // base/src/Makefile bb/inc/BrDetectorParamsBB.h // bb/src/BrDetectorParamsBB.cxx db/inc/BrParameterDbManager.h // db/src/BrParameterDbManager.cxx dc/inc/BrDetectorParamsDC.h // dc/src/BrDetectorDC.cxx dc/src/BrDetectorParamsDC.cxx // dc/src/BrDigitizeDC.cxx dc/src/BrLocalTrackDC.cxx // geometry/inc/BrPlane3D.h geometry/src/BrPlane3D.cxx // params/DetectorParameters.txt tof/inc/BrDetectorParamsTof.h // tof/src/BrDetectorParamsTof.cxx tof/src/BrGeneratePid.cxx // tpc/inc/BrDetectorParamsTPC.h tpc/src/BrDetectorParamsTPC.cxx // tpc/src/BrDetectorTPC.cxx tpc/src/BrDigitizeTPC.cxx // tpc/src/BrLocalTrackTPC.cxx track/inc/BrDetectorTrack.h // track/inc/BrFSTrackingModule.h // track/inc/BrSpectrometerTracks.h track/src/BrDetectorTrack.cxx // track/src/BrFSTrackingModule.cxx // track/src/BrSpectrometerTracks.cxx // // Revision 1.6 1999/02/28 22:14:37 hagel // Changes to make event display more robust and seamless // // Revision 1.5 1999/02/25 14:53:15 videbaek // Inserted code for using BrTPCSequnece instead of BrDigTPC for both // TPC digitization and the TPC local track reconstruction. // // Revision 1.4 1999/02/11 03:11:43 hagel // Debug Event Display for Linux // // Revision 1.3 1999/01/28 21:28:13 videbaek // Added BrTPSSqquences to libraries. Not yet in use, though. Expected to // replace BrDigTPC objects // Added cvs flags // Changed name of BrDigTPC data tables. // // Revision 1.2 1999/01/08 19:53:27 hagel // Add DrawLocalTracks in BrLocalTrackTPC // // Revision 1.1 1999/01/06 23:19:55 hagel // Add BrDetectorTPC // // // |
||||||
This page automatically generated by script docBrat by Christian Holm |
Copyright ; 2002 BRAHMS Collaboration
<brahmlib@rcf.rhic.bnl.gov>
|