//----------------------------------------------------------- // File and Version Information: // $Id$ // // Description: // Implementation of class PndTpcInhFieldDrifter // // Environment: // Software developed for the PANDA Detector at FAIR. // // Author List: // Felix Boehmer TUM (original author) // //----------------------------------------------------------- // This Class' Header ------------------ #include "PndTpcInhFieldDrifter.h" // Collaborating Class Headers -------- #include #include #include #include #include #include #include "PndTpcEFieldCyl.h" #include "PndTpcGas.h" #include "FairParAsciiFileIo.h" #include "FairRunAna.h" #include "FairParSet.h" #include "FairRuntimeDb.h" #include "PndTpcDigiPar.h" #include "PndTpcRungeKutta.h" // Class Member definitions ----------- PndTpcInhFieldDrifter:: PndTpcInhFieldDrifter(PndTpcEFieldCyl* eField, PndMultiField* bField, const char* outFile, const char* paramFile, const int rBins, const int zBins, const int split) : _outFile(outFile), _paramFile(paramFile), _rBins(rBins), _zBins(zBins), _split(split) { if(_split >= 0 && split >= _rBins) { //in the case split was manually set... std::cout << "PndTpcInhFieldDrifter::PndTpcInhFieldDrifter : " <<"invalid row number requested! ABORTING"<getGas())->VDrift(); double eNomZ = (eField->nominal()).Z(); _friction = 1e-5 * eNomZ / vDrift; // friction term, see Rolandi Blum _runKut = new PndTpcRungeKutta(1e-16, 1e-6, 1e-2, 1e-3, _sc, eField,bField, _friction); } PndTpcInhFieldDrifter:: PndTpcInhFieldDrifter(const char* eFieldFile, const char* bFieldFile, const char* outFile, const char* paramFile, const int rBins, const int zBins, const int split) : _outFile(outFile), _paramFile(paramFile), _rBins(rBins), _zBins(zBins), _split(split) { if(_split >= 0 && split >= _rBins) { //in the case split was manually set... std::cout << "PndTpcInhFieldDrifter::PndTpcInhFieldDrifter : " <<"invalid row number requested! ABORTING"<getGas())->VDrift(); PndTpcEFieldCyl* efield = new PndTpcEFieldCyl(eFieldFile); double eNomZ = (efield->nominal()).Z(); _friction = 1e-5 * eNomZ / vDrift; // friction term, see Rolandi Blum _runKut = new PndTpcRungeKutta(1e-16, 1e-6, 1e-2, 1e-3, _sc, eFieldFile,bFieldFile, _friction); delete efield; } PndTpcInhFieldDrifter::~PndTpcInhFieldDrifter() { delete _runKut; int size = _velocity_control->size(); for (int i=0; iat(i); delete _velocity_control; } void PndTpcInhFieldDrifter::run() { // Calculate the Binning _rBinWidth = (double)(_tpcMaxR - _tpcMinR) / _rBins; _zBinWidth = (double)(_tpcMaxZ - _tpcMinZ) / _zBins; // Init the fields //TODO: dangerous!!! change to pointers inside for (int nr = 0; nr < _rBins; nr++) { _devX.push_back(std::vector(_zBins, 0)); _devY.push_back(std::vector(_zBins, 0)); _time.push_back(std::vector(_zBins, 0)); _stepCount.push_back(std::vector(_zBins, 0)); _pathLength.push_back(std::vector(_zBins, 0)); } _velocity_control = new std::vector*>; _velocity_control->push_back(new std::vector(4, 0)); //first position std::cout << "\nCalculating the Deviation Map with Runge-Kutta "<setTimeStep(1e-16); double time_temp; for (int i=0; ; i++) // get serious { if (x[5]>(_tpcMaxZ)/100. || x[5]<(_tpcMinZ/100.)) break; // finished when we reach the "Pads" double xTemp[3]; //needed for the drift path monitoring for (int n=0; n<3; n++) xTemp[n] = x[n+3]; for (int j=0; ; j++) //one step of RungeKutta { time_temp = _runKut->getTimeStep();//store BEFORE step if (_runKut->getTimeStep() == 0) _runKut->setTimeStep(1e-16); if (_runKut->stepForwards(x)) //try until successful break; } _time.at(nr).at(nz) += time_temp;; _stepCount.at(nr).at(nz) ++; dx = x[3] - xTemp[0]; dy = x[4] - xTemp[1]; //coordinate changes of the last RK step dz = x[5] - xTemp[2]; _pathLength.at(nr).at(nz) += sqrt(dx*dx + dy*dy + dz*dz); //build the velocity-control array (in just one bin) if (nr == (int) std::floor((double)_rBins/2) && nz == (int) std::floor((double)_zBins/2)) { if ((_stepCount.at(nr).at(nz))%100 == 0) { std::vector* temp_vec = new std::vector(4); for(int i = 0; i <= 2; i++) temp_vec->at(i) = x[i]; //fill vector with components of V temp_vec->at(3) = _runKut->getTimeStep(); _velocity_control->push_back(temp_vec); } } } if(x[3]==xCopy[3] && x[4]==xCopy[4]) errorcount++; // Now fill the 2 deviation fields with the values _devX.at(nr).at(nz) = (x[3]-xCopy[3]) * 100; //[cm] _devY.at(nr).at(nz) = (x[4]-xCopy[4]) * 100; } std::cout<<"* "<= 0) { std::string s; std::stringstream stream; stream << _split; stream >> s; filename += s; } std::ofstream outfile(filename.c_str(), std::fstream::out); if(_split == 0 || _split == -1) { outfile<=0) { if (nr != _split) continue; } for (int nz=0; nz<_zBins; nz++) { outfile<size(); // for (int a=0; aat(a)->at(0)*1e-7<<" " // <<_velocity_control->at(a)->at(1)*1e-7<<" " // <<_velocity_control->at(a)->at(2)*1e-7<<" " // <<_velocity_control->at(a)->at(3)*1e9; // } // outfile2<open(_paramFile, "in"); //create dummy run manager and load database FairRunAna* fRun = new FairRunAna(); FairRuntimeDb* rtdb = fRun->GetRuntimeDb(); rtdb->setFirstInput(input); _par = (PndTpcDigiPar*) rtdb->getContainer("PndTpcDigiPar"); _par->FairParSet::init(); //read in parameters _tpcMinR = _par->getRMin(); _tpcMaxR = _par->getRMax(); _tpcMinZ = _par->getZGem(); _tpcMaxZ = _par->getZMax(); std::cout<<"\n\nPndTpcInhFieldDrifter::initParams()\n" <<"---------- Used Parameters ---------------------------"<