|
//___________________________________________________________________________ // // BrDetectorParamsTOF is a BRAHMS data class providing storage and // access function for TOF specific digitasation parameters. // This allows modification of the BrDetectorParams content by the // user. // //___________________________________________________________________________ // // $Id: BrDetectorParamsTof.cxx,v 1.5 2001/11/05 08:28:36 ouerdane Exp $ // $Author: ouerdane $ // $Date: 2001/11/05 08:28:36 $ // #include <iostream.h> #include <iomanip.h> #include "BrDetectorParamsTof.h" #include "TString.h" #include "TMath.h" //___________________________________________________________________________ ClassImp(BrDetectorParamsTof) //___________________________________________________________________________ BrDetectorParamsTof::BrDetectorParamsTof() { // Constructor. Set counter and list data members to zero. // Don't use this constructor unless you have to and know // what you are doing // Use BrDetectorParams(Char_t, Char_t ) instead } //___________________________________________________________________________ BrDetectorParamsTof::BrDetectorParamsTof(Char_t *name, Char_t *title) : BrDetectorParamsBase(name, title) { // Standard constructor. // the name should be that of the associated detector e.g. "H1" SetDefaultParams(); } //___________________________________________________________________________ BrDetectorParamsTof::BrDetectorParamsTof(Char_t *name, Char_t *title, Char_t *filename) : BrDetectorParamsBase(name, title) { // Constructor which also reads parameters in from a configuration file // the name should be that of the associated detector e.g. "H1" SetDefaultParams(); ReadASCIIFile(filename); } //___________________________________________________________________________ BrDetectorParamsTof::~BrDetectorParamsTof() { } //___________________________________________________________________________ void BrDetectorParamsTof::SetDefaultParams() { // Set a set of reasonable default parameters. // This is mainly to ensure that the private members are // initialized with values that do not give rise to any // problems in the methods which uses these parameters; // fADCGainUp = 400.; // 1 Mip == channel 400 fADCGainDown = 400; // 1 Mip == channel 400 fSigmaTime = .080; // 80 psec fSigmaAdc = .020; // dAdc/Adc == 20% fTdcConv = 0.025; // 25 pico seconds per channel (Philips 7681) fTdcOffset = 10; // channel number for t0 fNoSlats = 40; // Number of slats for this detector. fNoPanels = 1; // number of panels fPanel = 0; // number of panels fMeVperMIP = 1.3; fAttLength = 80.0; fSignalSpeed = 0.050; // 50 psec/cm <==> 1 nsec==20cm. fTofWidth = 40; // TOF1 numbers (stolen from geant) fTofDepth = 2.9; // idem fSlatWidth = 1; // idem fSlatDepth = 1; // idem fScintLength = 20.0; // fInFs = kFALSE; if (!strcmp(GetName(), "TOF1") || !strcmp(GetName(), "TOF2")) fInFs = kTRUE; } //___________________________________________________________________________ void BrDetectorParamsTof::ListParameters() const { // ------------------------------------------------------ // List on stdout current values of detector parameters // Options are // "": detector parameters // S: simulation parameters // A: all, with slat positions cout << " -------- Tof Parameter Listing for " << GetName() << endl; cout << " * Simulation Parameters: " << endl << " ADC Gain Up " << fADCGainUp << " Channels per MIP" << endl << " ADC Gain Down " << fADCGainDown << " Channels per MIP" << endl << " TDC conversion " << fTdcConv*1000 << " psec per channel" << endl << " TDC Offset " << fTdcOffset << " channels" << endl << " sigma (ADC) " << fSigmaAdc*100 << " %" << endl << " sigma (TDC) " << fSigmaTime*1000 << " psec" << endl << endl; cout << " * Detector Parameters: " << endl << " No of slats " << fNoSlats << endl << " No of panels " << fNoPanels << endl << " Panel id " << fPanel << endl << " Tof width " << fTofWidth << " cm" << endl << " Tof depth " << fTofDepth << " cm" << endl << " Slat width " << fSlatWidth << " cm" << endl << " Slat depth " << fSlatDepth << " cm" << endl << " Slat height " << fScintLength << " cm" << endl; if (strcmp(GetName(), "TOFW")) { cout << " * Slat positions: " << endl; cout.setf(ios::fixed); for (Int_t s = 1; s <= fNoSlats; s++) { BrVector3D pos = GetSlatPos(s); cout << " slat " << setw(3) << s << " X: " << setw(7) << setprecision(3) << pos(0) << " Y: " << setw(7) << setprecision(3) << pos(1) << " Z: " << setw(7) << setprecision(3) << pos(2) << endl; } } cout << " -----------------------------------------------------------" << endl; } //___________________________________________________________________________ void BrDetectorParamsTof::SetASCIIParameters(Char_t *line) { //Interpret a line for DC params. Form is ParamName:value. Eg //Eg fTwopar:.20 or fEff: 0.95 Char_t ParamName[80]; //Find first non-blank character in the line (in case user didn't start in column 1 Int_t i; for(i = 0; i < (Int_t)strlen(line);i++) if(strncmp(&line[i]," ",1)) break; //Copy that to ParamName strcpy(ParamName,&line[i]); Char_t *iloc = strchr(ParamName,':'); Char_t *value_loc = iloc+1; if(iloc) { iloc[0] = 0; //blank out the semicolon if(!strcasecmp(ParamName,"fADCGainUp")) sscanf(value_loc,"%f",&fADCGainUp); else if(!strcasecmp(ParamName,"fADCGainDown")) sscanf(value_loc,"%f",&fADCGainDown); else if(!strcasecmp(ParamName,"fSigmaTime")) sscanf(value_loc,"%f",&fSigmaTime); else if(!strcasecmp(ParamName,"fSigmaAdc")) sscanf(value_loc,"%f",&fSigmaAdc); else if(!strcasecmp(ParamName,"fTdcConv")) sscanf(value_loc,"%f",&fTdcConv); else if(!strcasecmp(ParamName,"fTdcOffset")) sscanf(value_loc,"%f",&fTdcOffset); else if(!strcasecmp(ParamName,"fNoSlats")) sscanf(value_loc,"%d",&fNoSlats); else if(!strcasecmp(ParamName,"fNoPanels")) sscanf(value_loc,"%d",&fNoPanels); else if(!strcasecmp(ParamName,"fPanel")) sscanf(value_loc,"%d",&fPanel); else if(!strcasecmp(ParamName,"fTofWidth")) sscanf(value_loc,"%f",&fTofWidth); else if(!strcasecmp(ParamName,"fTofDepth")) sscanf(value_loc,"%f",&fTofDepth); else if(!strcasecmp(ParamName,"fSlatWidth")) sscanf(value_loc,"%f",&fSlatWidth); else if(!strcasecmp(ParamName,"fSlatDepth")) sscanf(value_loc,"%f",&fSlatDepth); else if(!strcasecmp(ParamName,"fScintLength")) sscanf(value_loc,"%f",&fScintLength); else if(!strcasecmp(ParamName,"fMeVperMIP")) sscanf(value_loc,"%f",&fMeVperMIP); else if(!strcasecmp(ParamName,"fAttLength")) sscanf(value_loc,"%f",&fAttLength); else if(!strcasecmp(ParamName,"fSignalSpeed")) sscanf(value_loc,"%f",&fSignalSpeed); else { cout<<"Error: "<<ParamName<<" is not one of the parameters"<<endl; return; } return; //this is a normal return } else { cout << "Error, : missing to delineate name from value" << endl; cout << "The string is " << line << endl; cout << "No value set!!!" << endl; return; } } //___________________________________________________________________________ BrVector3D BrDetectorParamsTof::GetSlatPos(Int_t slat) const { // ---------------------------------------------------- // returns the slat position in the TOF coord. system // meaning TOF1, TOF1, TFPn (0 < n < 7) // (code stolen from brag) // ---------------------------------------------------- // Note: you cannot use this method with TOFW!!! only with TFPn // in this case, the SLAT NUMBER should be LOCAL to the considered panel BrVector3D pos(0, 0, 0); if (slat < 1 || slat > fNoSlats) { if (0) Warning("GetSlatPos", "Slat number >> %d << is out of range!", slat); return pos; } if (fInFs) { pos.SetX(0.5*fTofWidth - fSlatWidth*(slat - 0.5)); pos.SetZ(0.5*(fTofDepth - fSlatDepth)*TMath::Power(-1., slat)); } else pos.SetX(0.5*fSlatWidth*(fNoSlats + 1 - 2*slat)); return pos; } //___________________________________________________________________________ Int_t BrDetectorParamsTof::GetSlatNo(Float_t x) const { // returns the slat number given an X position on the tof plane Int_t s = 0; if (fInFs) s = TMath::Nint(1/fSlatWidth * (0.5*fTofWidth - x) + 0.5); else s = TMath::Nint(0.5*(Float_t(fNoSlats) + 1) - x/fSlatWidth); return s; } //___________________________________________________________________________ // // $Log: BrDetectorParamsTof.cxx,v $ // Revision 1.5 2001/11/05 08:28:36 ouerdane // removed warning message // // Revision 1.4 2001/10/21 03:15:18 ouerdane // Added method GetSlatNo(Float_t x), it returns a slat number given an X value // // Revision 1.3 2001/10/19 15:23:05 ouerdane // Introduced new parameters: // fTofWidth, fTofDepth, fSlatWidth, fSlatDepth + corresponding setters and getters // // Added new method GetSlatPos(<slat no>) which works for TOF1, TOF2, TFPn // Don't use it if your param object is named TOFW. You do need TFPn instead since // it returns the panel local slat number. // // You can use the <brat_src_dir>/test/TestTofParams.C to check things: // // .L TestTofParams.C // Print("<tof name>", "<param file>") // // <tof name> can be TOF1, TOF2, TOFW, TFPn with 0 < n < 7 // <param file> is DetectorParameters.txt by default // // Incremented the class version number to 3 // // Revision 1.2 2001/10/02 20:16:40 ouerdane // added member fNoPanels to BrDetectorParamsTof with setter and getter. // Same for DetectorParameters*.txt : in 2000: fNoPanels = 4 // in the actual, it is set to 6. // class version number has been incremented from 1 to 2 // // Revision 1.1.1.1 2001/06/21 14:55:00 hagel // Initial revision of brat2 // // Revision 1.7 2000/05/17 10:28:48 ouerdane // see top of file // // Revision 1.6 2000/03/21 21:22:31 cholm // Several changes: A few hacks where needed to compile on Digital Unix, noticably // in my - Christian Holm - classes for the DB and Exceptions. Proberly still need // to do something to some of Konstantins stuff. Also, I removed a lot of warnings // from the compiler, by teddying up the code. Several places, old C-style indecies // in for loops were assumed. Corrected. Unused variables have been commented out. // // Revision 1.5 1999/11/30 22:23:32 videbaek // Modified method names. // // Revision 1.4 1999/03/07 00:00:45 hagel // // // Revision 1.3 1999/02/04 18:16:01 hagel // Added ReadASCIIFile() // // Revision 1.2 1998/08/24 19:35:43 videbaek // Expanded List method. // Inserted Id and Log cvs qyalifiers // // |
||||||
This page automatically generated by script docBrat by Christian Holm |
Copyright ; 2002 BRAHMS Collaboration
<brahmlib@rcf.rhic.bnl.gov>
|