15 #include "TObjArray.h"
27 fPmin(0), fPmax(0), fPstep(0),
28 fXmin(0), fXmax(0), fXstep(0),
29 fYmin(0), fYmax(0), fYstep(0),
30 fTmin(0), fTmax(0), fTstep(0),
31 fFmin(0), fFmax(0), fFstep(0),
32 fNp(0), fNx(0), fNy(0), fNt(0), fNf(0),
33 fBetaMean(NULL), fBetaSig(NULL), fBetaEff(NULL)
57 fPmin(0), fPmax(0), fPstep(0),
58 fXmin(0), fXmax(0), fXstep(0),
59 fYmin(0), fYmax(0), fYstep(0),
60 fTmin(0), fTmax(0), fTstep(0),
61 fFmin(0), fFmax(0), fFstep(0),
62 fNp(0), fNx(0), fNy(0), fNt(0), fNf(0),
63 fBetaMean(NULL), fBetaSig(NULL), fBetaEff(NULL)
66 TString dir = getenv(
"VMCWORKDIR");
67 fFileName = dir +
"/detectors/rich/" + mapName;
68 if ( fileType[0] ==
'R' )
fFileName +=
".root";
80 fPmin(0), fPmax(0), fPstep(0),
81 fXmin(0), fXmax(0), fXstep(0),
82 fYmin(0), fYmax(0), fYstep(0),
83 fTmin(0), fTmax(0), fTstep(0),
84 fFmin(0), fFmax(0), fFstep(0),
85 fNp(0), fNx(0), fNy(0), fNt(0), fNf(0),
86 fBetaMean(NULL), fBetaSig(NULL), fBetaEff(NULL)
90 LOG(ERROR) <<
"PndRichCalDb::PndRichCalDb: empty parameter container!";
97 TString dir = getenv(
"VMCWORKDIR");
98 fFileName = dir +
"/detectors/rich/" + Name +
".root";
108 fFileName(L.fFileName),
109 fPmin(L.fPmin), fPmax(L.fPmax), fPstep(L.fPstep),
110 fXmin(L.fXmin), fXmax(L.fXmax), fXstep(L.fXstep),
111 fYmin(L.fYmin), fYmax(L.fYmax), fYstep(L.fYstep),
112 fTmin(L.fTmin), fTmax(L.fTmax), fTstep(L.fTstep),
113 fFmin(L.fFmin), fFmax(L.fFmax), fFstep(L.fFstep),
114 fNp(L.fNp), fNx(L.fNx), fNy(L.fNy), fNt(L.fNt), fNf(L.fNf),
115 fBetaMean(L.fBetaMean), fBetaSig(L.fBetaSig), fBetaEff(L.fBetaEff)
138 LOG(ERROR) <<
"-E- PndRichCalDb::Init: No proper file name defined! ("<<
fFileName.Data()<<
")";
139 Fatal(
"Init",
"No proper file name");
165 if (x>=0&&y<0) { f = 360 -
f; y = -
y; }
166 if (x<0&&y>=0) { f = 180 -
f; x = -
x; }
167 if (x<0&&y<0) { f = 180 +
f; x = -
x; y = -
y; }
171 if (
IsInside(p, x, y, t, f, ip, ix, iy, it, iq, dp, dx, dy, dt, df) ) {
174 pq[0][1] = dp; pq[0][0] = 1 - pq[0][1];
175 pq[1][1] =
dx; pq[1][0] = 1 - pq[1][1];
176 pq[2][1] =
dy; pq[2][0] = 1 - pq[2][1];
177 pq[3][1] = dt; pq[3][0] = 1 - pq[3][1];
178 pq[4][1] = df; pq[4][0] = 1 - pq[4][1];
182 for(Int_t
bp=0;
bp<2;
bp++ ) {
183 for(Int_t bx=0; bx<2; bx++ ) {
184 for(Int_t by=0; by<2; by++ ) {
185 for(Int_t bt=0; bt<2; bt++ ) {
186 for(Int_t bf=0; bf<2; bf++ ) {
193 value +=
fBetaMean->At(index)*pq[0][
bp]*pq[1][bx]*pq[2][by]*pq[3][bt]*pq[4][bf];
230 if (x>=0&&y<0) { f = 360 -
f; y = -
y; }
231 if (x<0&&y>=0) { f = 180 -
f; x = -
x; }
232 if (x<0&&y<0) { f = 180 +
f; x = -
x; y = -
y; }
236 if (
IsInside(p, x, y, t, f, ip, ix, iy, it, iq, dp, dx, dy, dt, df) ) {
239 pq[0][1] = dp; pq[0][0] = 1 - pq[0][1];
240 pq[1][1] =
dx; pq[1][0] = 1 - pq[1][1];
241 pq[2][1] =
dy; pq[2][0] = 1 - pq[2][1];
242 pq[3][1] = dt; pq[3][0] = 1 - pq[3][1];
243 pq[4][1] = df; pq[4][0] = 1 - pq[4][1];
247 for(Int_t
bp=0;
bp<2;
bp++ ) {
248 for(Int_t bx=0; bx<2; bx++ ) {
249 for(Int_t by=0; by<2; by++ ) {
250 for(Int_t bt=0; bt<2; bt++ ) {
251 for(Int_t bf=0; bf<2; bf++ ) {
258 value +=
fBetaSig->At(index)*pq[0][
bp]*pq[1][bx]*pq[2][by]*pq[3][bt]*pq[4][bf];
294 if (x>=0&&y<0) { f = 360 -
f; y = -
y; }
295 if (x<0&&y>=0) { f = 180 -
f; x = -
x; }
296 if (x<0&&y<0) { f = 180 +
f; x = -
x; y = -
y; }
300 if (
IsInside(p, x, y, t, f, ip, ix, iy, it, iq, dp, dx, dy, dt, df) ) {
303 pq[0][1] = dp; pq[0][0] = 1 - pq[0][1];
304 pq[1][1] =
dx; pq[1][0] = 1 - pq[1][1];
305 pq[2][1] =
dy; pq[2][0] = 1 - pq[2][1];
306 pq[3][1] = dt; pq[3][0] = 1 - pq[3][1];
307 pq[4][1] = df; pq[4][0] = 1 - pq[4][1];
311 for(Int_t
bp=0;
bp<2;
bp++ ) {
312 for(Int_t bx=0; bx<2; bx++ ) {
313 for(Int_t by=0; by<2; by++ ) {
314 for(Int_t bt=0; bt<2; bt++ ) {
315 for(Int_t bf=0; bf<2; bf++ ) {
322 value +=
fBetaEff->At(index)*pq[0][
bp]*pq[1][bx]*pq[2][by]*pq[3][bt]*pq[4][bf];
343 Int_t& ip, Int_t& ix, Int_t& iy, Int_t& it, Int_t& iq,
352 ip = ix = iy = it = iq = 0;
353 dp = dx = dy = dt = df = 0.;
389 LOG(INFO) <<
"PndRichCalDb: Writing field map to ASCII file "<<fileName;
390 ofstream mapFile(fileName);
391 if ( ! mapFile.is_open() ) {
392 LOG(ERROR) <<
"PndRichCalDb:ReadAsciiFile: Could not open file! ";
397 mapFile.precision(4);
398 mapFile << showpoint;
409 cout <<
"-I- PndRichCalDb: " <<
fNp*
fNx*
fNy*
fNt*
fNf <<
" entries to write... "
410 << setw(3) << 0 <<
" % ";
414 for(Int_t ip=0; ip<
fNp; ip++) {
415 for(Int_t ix=0; ix<
fNx; ix++) {
416 for(Int_t iy=0; iy<
fNy; iy++) {
417 for(Int_t it=0; it<
fNt; it++) {
418 for(Int_t iq=0; iq<
fNf; iq++) {
434 <<
" " <<
fBetaEff->At(index) << endl;
449 const char* mapName) {
452 TFile* oldFile = gFile;
453 TFile*
file =
new TFile(fileName,
"RECREATE");
456 if(oldFile) oldFile->cd();
466 if ( fType == 2 ) type =
"Soleniod Map ";
467 if ( fType == 3 ) type =
"Dipole Map ";
468 if ( fType == 4 ) type =
"Trans Map ";
469 cout <<
"======================================================" << endl;
472 cout <<
"---- " << fTitle <<
" : " << fName << endl;
473 cout <<
"----" << endl;
474 cout <<
"---- Field type : " << type << endl;
475 cout <<
"----" << endl;
476 cout <<
"---- Field map grid : " << endl;
477 cout <<
"---- p = " << setw(4) <<
fPmin <<
" to " << setw(4) <<
fPmax
478 <<
" , " <<
fNp <<
" grid points, dp = " <<
fPstep <<
" " << endl;
479 cout <<
"---- x = " << setw(4) <<
fXmin <<
" to " << setw(4) <<
fXmax
480 <<
" cm, " <<
fNx <<
" grid points, dx = " <<
fXstep <<
" cm" << endl;
481 cout <<
"---- y = " << setw(4) <<
fYmin <<
" to " << setw(4) <<
fYmax
482 <<
" cm, " <<
fNy <<
" grid points, dy = " <<
fYstep <<
" cm" << endl;
483 cout <<
"---- t = " << setw(4) <<
fTmin <<
" to " << setw(4) <<
fTmax
484 <<
" , " <<
fNt <<
" grid points, dt = " <<
fTstep <<
" " << endl;
485 cout <<
"---- f = " << setw(4) <<
fFmin <<
" to " << setw(4) <<
fFmax
486 <<
" , " <<
fNf <<
" grid points, df = " <<
fFstep <<
" " << endl;
495 cout <<
"======================================================" << endl;
519 cout <<
"-I- PndRichCalDb: Reading field map from ASCII file "
521 ifstream mapFile(fileName);
522 if ( ! mapFile.is_open() ) {
523 cerr <<
"-E- PndRichCalDb:ReadAsciiFile: Could not open file! " << endl;
524 Fatal(
"ReadAsciiFile",
"Could not open file");
541 fBetaMean =
new TArrayF(fNp * fNx * fNy * fNt * fNf);
542 fBetaSig =
new TArrayF(fNp * fNx * fNy * fNt * fNf);
543 fBetaEff =
new TArrayF(fNp * fNx * fNy * fNt * fNf);
547 Int_t nTot = fNp * fNx * fNy * fNt *
fNf;
548 cout <<
"-I- PndRichCalDb: " << nTot <<
" entries to read... "
549 << setw(3) << 0 <<
" % ";
554 for (Int_t ip=0; ip<
fNp; ip++) {
555 for (Int_t ix=0; ix<
fNx; ix++) {
556 for (Int_t iy = 0; iy<
fNy; iy++) {
557 for (Int_t it = 0; it<
fNt; it++) {
558 for (Int_t iq = 0; iq<
fNf; iq++) {
559 if (! mapFile.good()) cerr <<
"-E- PndRichCalDb::ReadAsciiFile: "
560 <<
"I/O Error at " << ip <<
" " << ix <<
" "
561 << iy <<
" " << it <<
" " << iq << endl;
576 mapFile >> m >> s >> e;
578 cout << index <<
" " << m <<
" " << s <<
" " << e << endl;
582 if ( mapFile.eof() ) {
583 cerr << endl <<
"-E- PndRichCalDb::ReadAsciiFile: EOF"
584 <<
" reached at " << ip <<
" " << ix <<
" " << iy <<
" " << it <<
" " << iq << endl;
594 cout <<
" " << index+1 <<
" read" << endl;
605 const char* mapName) {
608 TFile* oldFile = gFile;
611 LOG(INFO) <<
"PndRichCalDb: Reading field map from ROOT file "<<fileName;
612 TFile*
file =
new TFile(fileName,
"READ");
613 if (file->IsZombie()) {
614 LOG(ERROR) <<
"-E- PndRichCalDb::ReadRootfile: Cannot read from file! (" << fileName <<
")";
615 Fatal(
"ReadRootFile",
"Cannot read from file");
620 file->GetObject(mapName, data);
622 LOG(ERROR) <<
"PndRichCalDb::ReadRootFile: data object " << fileName <<
" not found in file! ";
633 if ( oldFile ) oldFile->cd();
644 std::cout <<
"fType = " << fType <<
" " << data->
GetType() << std::endl;
646 if ( data->
GetType() != fType ) {
647 LOG(ERROR) <<
"PndRichCalDb::SetField: Incompatible map types Field map is of type "<<fType<<
" \n but map on file is of type " << data->
GetType();
648 Fatal(
"SetField",
"Incompatible map types");
cout<< "-----------------------------------------------> Quarter VOLUME<<endl;name="QuarterShape";QuarterShape=newTGeoArb8(name,dz,vertQuar);name="Quarter4Vol";TStringmedium="air";QuarterVol=newTGeoVolumeAssembly(name);name="SubunitShape";SubunitShape=newTGeoArb8(name,dz,vertSub);TStringmedium="air";name="SubunitVol";name1="SubunitVol1";name2="SubunitVol2";name3="SubunitVol3";name4="SubunitVol4";name5="SubunitVol5";name6="SubunitVol6";name7="SubunitVol7";name8="SubunitVol8";name9="SubunitVol9";SubunitVol=newTGeoVolumeAssembly(name);SubunitVol1=newTGeoVolumeAssembly(name1);SubunitVol2=newTGeoVolumeAssembly(name2);SubunitVol3=newTGeoVolumeAssembly(name3);SubunitVol4=newTGeoVolumeAssembly(name4);SubunitVol5=newTGeoVolumeAssembly(name5);SubunitVol6=newTGeoVolumeAssembly(name6);SubunitVol7=newTGeoVolumeAssembly(name7);SubunitVol8=newTGeoVolumeAssembly(name8);SubunitVol9=newTGeoVolumeAssembly(name9);name="BoxShape";BoxShape=newTGeoArb8(name,dz,vertBox);TStringmedium="air";name="BoxVol";BoxVol=newTGeoVolumeAssembly(name);name1="BoxVol1";name2="BoxVol2";name3="BoxVol3";name4="BoxVol4";BoxVol1=newTGeoVolumeAssembly(name1);BoxVol2=newTGeoVolumeAssembly(name2);BoxVol3=newTGeoVolumeAssembly(name3);BoxVol4=newTGeoVolumeAssembly(name4);for(Int_tb=0;b<kNumOfBoxes;b++){cout<<""<<endl;cout<<"---------------->BOXnumber:"<<b<<endl;if(b==0){trBox=newTGeoTranslation(tr+kSpaceInSub+kAlveoleThickness+0.5*kSpaceInBox,tr+kSpaceInSub+kAlveoleThickness+0.5*kSpaceInBox,0.);rotBox=newTGeoRotation();rotBox.RotateX(0.465518);rotBox.RotateY(-0.465518);}if(b==1){trBox=newTGeoTranslation(-tr-kSpaceInSub-kAlveoleThickness-0.5*kSpaceInBox,-tr-kSpaceInSub-kAlveoleThickness-0.5*kSpaceInBox,0.);rotBox=newTGeoRotation();rotBox.RotateX(-0.465518);rotBox.RotateY(0.465518);}if(b==2){trBox=newTGeoTranslation(tr+kSpaceInSub+kAlveoleThickness+0.5*kSpaceInBox,-tr-kSpaceInSub-kAlveoleThickness-0.5*kSpaceInBox,0.);rotBox=newTGeoRotation();rotBox.RotateX(-0.465518);rotBox.RotateY(-0.465518);}if(b==3){trBox=newTGeoTranslation(-tr-kSpaceInSub-kAlveoleThickness-0.5*kSpaceInBox,tr+kSpaceInSub+kAlveoleThickness+0.5*kSpaceInBox,0.);rotBox=newTGeoRotation();rotBox.RotateX(0.465518);rotBox.RotateY(0.465518);}TGeoCombiTrans*trrotBox=newTGeoCombiTrans(trBox,rotBox);name="BoxVol";name+=b;trrotBox->SetName(name);trrotBox->RegisterYourself();SubunitVol->AddNode(BoxVol,b,trrotBox);if(b==1){name+=b;trrotBox->SetName(name);trrotBox->RegisterYourself();SubunitVol1->AddNode(BoxVol,b,trrotBox);}if(b==2){name+=b;trrotBox->SetName(name);trrotBox->RegisterYourself();SubunitVol2->AddNode(BoxVol1,b,trrotBox);}if(b==0){name+=b;trrotBox-> SetName(name)
TArrayF * GetBetaSig() const
void ReadRootFile(const char *fileName, const char *mapName)
TArrayF * GetBetaSig() const
void ReadAsciiFile(const char *fileName)
TArrayF * GetBetaMean() const
TArrayF * GetBetaEff() const
void WriteAsciiFile(const char *fileName)
TArrayF * GetBetaMean() const
virtual Bool_t IsInside(Double_t p, Double_t x, Double_t y, Double_t t, Double_t f, Int_t &ip, Int_t &ix, Int_t &iy, Int_t &it, Int_t &iq, Double_t &dp, Double_t &dx, Double_t &dy, Double_t &dt, Double_t &df)
void WriteRootFile(const char *fileName, const char *mapName)
void MapName(TString &name)
TArrayF * GetBetaEff() const
void SetCalDb(const PndRichCalDbData *data)