#include "TS800.h"
#include "TS800Map.h"
#include <iostream>
#include <math.h>
ClassImp(TS800Map);
TS800Map::TS800Map(const TS800Map & map) : TObject(map)
{
((TS800Map&)map).Copy(*this);
}
void TS800Map::Copy(TObject &map) const
{
TObject::Copy((TObject&)map);
for(Int_t i=0; i<TS800_TRACK_PARAMETERS; i++) ((TS800Map&)map).maxcoefficient[i] = maxcoefficient[i];
for(Int_t i=0; i<TS800_TRACK_PARAMETERS; i++){
for(Int_t j=0; j<TS800_TRACK_COEFFICIENTS; j++) { ((TS800Map&)map).order[i][j] = order[i][j];
((TS800Map&)map).coefficient[i][j] = coefficient[i][j];}}
for(Int_t i=0; i<TS800_TRACK_PARAMETERS; i++){
for(Int_t j=0; j<TS800_TRACK_PARAMETERS; j++){
for(Int_t k=0; k<TS800_TRACK_COEFFICIENTS; k++){((TS800Map&)map).exponent[i][j][k] = exponent[i][j][k];}}}
((TS800Map&)map).maxorder = maxorder;
for(Int_t i=0; i<120; i++) ((TS800Map&)map).title[i] = title[i];
}
void TS800Map::InitClass(TS800 *itop)
{
parent = itop;
for (Int_t i=0; i<TS800_TRACK_PARAMETERS; i++) {
maxcoefficient[i] = 0;
for (Int_t j=0; j<TS800_TRACK_COEFFICIENTS; j++) {
order[i][j] = 0;
coefficient[i][j] = 0;
for (Int_t k=0; k<TS800_TRACK_PARAMETERS; k++) {
exponent[i][k][j] = 0;
}
}
}
maxorder = 0;
}
Double_t* TS800Map::ReadMap(char* filename)
{
Double_t rVal[3] = {0,0,0};
FILE* file;
Char_t line[80];
Int_t index, ord, par, exp[6];
Double_t co;
file = fopen(filename, "r");
if (file == NULL) {
cout << "Sorry I couldn't find the file: " << filename << ". Aborting ..." << endl;
return 0;
}
fgets(title, 120, file);
sscanf(title,"S800 inverse map - Brho=%lf - M=%lf - Q=%lf - Exp. %*i",&rVal[0],&rVal[1],&rVal[2]);
while (strstr(line, "COEFFICIENT") == NULL) fgets(line, 80, file);
par = 0;
while (!feof(file)) {
fgets(line, 80, file);
while (strstr(line, "------------------") == NULL) {
sscanf(line, "%d %lf %d %d %d %d %d %d %d", &index, &co, &ord, &exp[0], &exp[1], &exp[2], &exp[3], &exp[4], &exp[5]);
if (index > TS800_TRACK_COEFFICIENTS) {
cout << "Too many coefficients in map. Increase TS800_TRACK_COEFFICIENTS." << endl;
break;
}
if (par > TS800_TRACK_PARAMETERS) {
cout << "Too many parameters in map. Increase TS800_TRACK_PARAMETERS." << endl;
break;
}
maxcoefficient[par] = index;
order[par][index-1] = ord;
coefficient[par][index-1] = co;
for (Int_t k=0; k<TS800_TRACK_PARAMETERS; k++) exponent[par][k][index-1] = exp[k];
fgets(line, 80, file);
}
if (ord > maxorder) maxorder = ord;
par++;
}
cout << " Done reading map from " << filename << "." << endl;
cout << " Title: " << title;
cout << " Order: " << maxorder << endl;
fclose(file);
parent->kBrho = rVal[0];
parent->fpTrack.mass = (Int_t) rVal[1];
parent->fpTrack.charge = (Int_t) rVal[2];
return rVal;
}
Double_t TS800Map::Calculate(Int_t calcorder, Int_t parameter, Double_t *input)
{
Double_t cumul=0;
Double_t multiplicator;
for (Int_t index=0; index<maxcoefficient[parameter]; index++) {
if (calcorder < order[parameter][index]) break;
multiplicator = 1;
for (Int_t nex=0; nex<TS800_TRACK_PARAMETERS; nex++) {
if (exponent[parameter][nex][index] != 0) {
multiplicator *= pow(input[nex], exponent[parameter][nex][index]);
}
}
cumul += multiplicator * coefficient[parameter][index];
}
return cumul;
}
Last change: Sun Dec 21 12:38:56 2008
Last generated: 2008-12-21 12:38
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.