//----------------------------------------------------------- // 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) : foutFile(outFile), fparamFile(paramFile), frBins(rBins), fzBins(zBins), fsplit(split) { if(fsplit >= 0 && split >= frBins) { //in the case split was manually set... std::cout << "PndTpcInhFieldDrifter::PndTpcInhFieldDrifter : " <<"invalid row number requested! ABORTING"<getGas())->VDrift(); double eNomZ = (eField->nominal()).Z(); ffriction = 1e-5 * eNomZ / vDrift; // friction term, see Rolandi Blum frunKut = new PndTpcRungeKutta(1e-16, 1e-6, 1e-2, 1e-3, fsc, eField,bField, ffriction); } PndTpcInhFieldDrifter:: PndTpcInhFieldDrifter(const char* eFieldFile, const char* bFieldFile, const char* outFile, const char* paramFile, const int rBins, const int zBins, const int split) : foutFile(outFile), fparamFile(paramFile), frBins(rBins), fzBins(zBins), fsplit(split) { if(fsplit >= 0 && split >= frBins) { //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(); ffriction = 1e-5 * eNomZ / vDrift; // friction term, see Rolandi Blum frunKut = new PndTpcRungeKutta(1e-16, 1e-6, 1e-2, 1e-3, fsc, eFieldFile,bFieldFile, ffriction); delete efield; } PndTpcInhFieldDrifter::~PndTpcInhFieldDrifter() { delete frunKut; int size = fvelocity_control->size(); for (int i=0; iat(i); delete fvelocity_control; } void PndTpcInhFieldDrifter::run() { // Calculate the Binning frBinWidth = (double)(ftpcMaxR - ftpcMinR) / frBins; fzBinWidth = (double)(ftpcMaxZ - ftpcMinZ) / fzBins; // Init the fields //TODO: dangerous!!! change to pointers inside for (int nr = 0; nr < frBins; nr++) { fdevX.push_back(std::vector(fzBins, 0)); fdevY.push_back(std::vector(fzBins, 0)); ftime.push_back(std::vector(fzBins, 0)); fstepCount.push_back(std::vector(fzBins, 0)); fpathLength.push_back(std::vector(fzBins, 0)); } fvelocity_control = new std::vector*>; fvelocity_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]>(ftpcMaxZ)/100. || x[5]<(ftpcMinZ/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 = frunKut->getTimeStep();//store BEFORE step if (frunKut->getTimeStep() == 0) frunKut->setTimeStep(1e-16); if (frunKut->stepForwards(x)) //try until successful break; } ftime.at(nr).at(nz) += time_temp;; fstepCount.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]; fpathLength.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)frBins/2) && nz == (int) std::floor((double)fzBins/2)) { if ((fstepCount.at(nr).at(nz))%100 == 0) { std::vector* temp_vec = new std::vector(4); for(int ii = 0; i <= 2; ii++) temp_vec->at(ii) = x[ii]; //fill vector with components of V temp_vec->at(3) = frunKut->getTimeStep(); fvelocity_control->push_back(temp_vec); } } } if(x[3]==xCopy[3] && x[4]==xCopy[4]) errorcount++; // Now fill the 2 deviation fields with the values fdevX.at(nr).at(nz) = (x[3]-xCopy[3]) * 100; //[cm] fdevY.at(nr).at(nz) = (x[4]-xCopy[4]) * 100; } std::cout<<"* "<= 0) { std::string s; std::stringstream stream; stream << fsplit; stream >> s; filename += s; } std::ofstream outfile(filename.c_str(), std::fstream::out); if(fsplit == 0 || fsplit == -1) { outfile<=0) { if (nr != fsplit) continue; } for (int nz=0; nzsize(); // for (int a=0; aat(a)->at(0)*1e-7<<" " // <at(a)->at(1)*1e-7<<" " // <at(a)->at(2)*1e-7<<" " // <at(a)->at(3)*1e9; // } // outfile2<open(fparamFile, "in"); //create dummy run manager and load database FairRunAna* fRun = new FairRunAna(); FairRuntimeDb* rtdb = fRun->GetRuntimeDb(); rtdb->setFirstInput(input); fpar = (PndTpcDigiPar*) rtdb->getContainer("PndTpcDigiPar"); fpar->FairParSet::init(); //read in parameters ftpcMinR = fpar->getRMin(); ftpcMaxR = fpar->getRMax(); ftpcMinZ = fpar->getZGem(); ftpcMaxZ = fpar->getZMax(); std::cout<<"\n\nPndTpcInhFieldDrifter::initParams()\n" <<"---------- Used Parameters ---------------------------"<