| 1 | /* ======================================================================== *\
|
|---|
| 2 | !
|
|---|
| 3 | ! *
|
|---|
| 4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
|---|
| 5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
|---|
| 6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
|---|
| 7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
|---|
| 8 | ! *
|
|---|
| 9 | ! * Permission to use, copy, modify and distribute this software and its
|
|---|
| 10 | ! * documentation for any purpose is hereby granted without fee,
|
|---|
| 11 | ! * provided that the above copyright notice appear in all copies and
|
|---|
| 12 | ! * that both that copyright notice and this permission notice appear
|
|---|
| 13 | ! * in supporting documentation. It is provided "as is" without express
|
|---|
| 14 | ! * or implied warranty.
|
|---|
| 15 | ! *
|
|---|
| 16 | !
|
|---|
| 17 | !
|
|---|
| 18 | ! Author(s): Thomas Bretz, 2003 <mailto:tbretz@astro.uni-wuerzburg.de>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2003
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | //
|
|---|
| 27 | // MBending
|
|---|
| 28 | //
|
|---|
| 29 | // Double_t fIe ; // [rad] Index Error in Elevation
|
|---|
| 30 | // Double_t fIa ; // [rad] Index Error in Azimuth
|
|---|
| 31 | //
|
|---|
| 32 | // Double_t fFlop ; // [rad] Vertical Sag
|
|---|
| 33 | // * do not use if not data: Zd<0
|
|---|
| 34 | //
|
|---|
| 35 | // Double_t fNpae ; // [rad] Az-El Nonperpendicularity
|
|---|
| 36 | //
|
|---|
| 37 | // Double_t fCa ; // [rad] Left-Right Collimation Error
|
|---|
| 38 | //
|
|---|
| 39 | // Double_t fAn ; // [rad] Azimuth Axis Misalignment (N-S)
|
|---|
| 40 | // Double_t fAw ; // [rad] Azimuth Axis Misalignment (E-W)
|
|---|
| 41 | //
|
|---|
| 42 | // Double_t fTf ; // [rad] Tube fluxture (sin)
|
|---|
| 43 | // * same as ecec if no data: Zd<0
|
|---|
| 44 | // Double_t fTx ; // [rad] Tube fluxture (tan)
|
|---|
| 45 | // * do not use with NPAE if no data: Zd<0
|
|---|
| 46 | //
|
|---|
| 47 | // Double_t fNrx ; // [rad] Nasmyth rotator displacement, horizontan
|
|---|
| 48 | // Double_t fNry ; // [rad] Nasmyth rotator displacement, vertical
|
|---|
| 49 | //
|
|---|
| 50 | // Double_t fCrx ; // [rad] Alt/Az Coude Displacement (N-S)
|
|---|
| 51 | // Double_t fCry ; // [rad] Alt/Az Coude Displacement (E-W)
|
|---|
| 52 | //
|
|---|
| 53 | // Double_t fEces ; // [rad] Elevation Centering Error (sin)
|
|---|
| 54 | // Double_t fAces ; // [rad] Azimuth Centering Error (sin)
|
|---|
| 55 | // Double_t fEcec ; // [rad] Elevation Centering Error (cos)
|
|---|
| 56 | // Double_t fAcec ; // [rad] Azimuth Centering Error (cos)
|
|---|
| 57 | //
|
|---|
| 58 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 59 | #include "MBending.h"
|
|---|
| 60 |
|
|---|
| 61 | #include <fstream.h>
|
|---|
| 62 | #include <iomanip.h>
|
|---|
| 63 | #include <TVector3.h>
|
|---|
| 64 |
|
|---|
| 65 | #include <TMinuit.h>
|
|---|
| 66 |
|
|---|
| 67 | #include "MTime.h"
|
|---|
| 68 |
|
|---|
| 69 | ClassImp(MBending);
|
|---|
| 70 |
|
|---|
| 71 | #undef DEBUG
|
|---|
| 72 | //#define DEBUG(txt) txt
|
|---|
| 73 | #define DEBUG(txt)
|
|---|
| 74 |
|
|---|
| 75 | const Int_t MBending::fNumPar=19;
|
|---|
| 76 |
|
|---|
| 77 | void MBending::Init()
|
|---|
| 78 | {
|
|---|
| 79 | fCoeff = new Double_t*[fNumPar];
|
|---|
| 80 | fName = new TString[fNumPar];
|
|---|
| 81 | fDescr = new TString[fNumPar];
|
|---|
| 82 |
|
|---|
| 83 | fCoeff[ 0] = &fIa; fName[ 0] = "IA";
|
|---|
| 84 | fCoeff[ 1] = &fIe; fName[ 1] = "IE";
|
|---|
| 85 | fCoeff[ 2] = &fFlop; fName[ 2] = "FLOP";
|
|---|
| 86 | fCoeff[ 3] = &fAn; fName[ 3] = "AN";
|
|---|
| 87 | fCoeff[ 4] = &fAw; fName[ 4] = "AW";
|
|---|
| 88 | fCoeff[ 5] = &fNpae; fName[ 5] = "NPAE";
|
|---|
| 89 | fCoeff[ 6] = &fCa; fName[ 6] = "CA";
|
|---|
| 90 | fCoeff[ 7] = &fTf; fName[ 7] = "TF";
|
|---|
| 91 | fCoeff[ 8] = &fTx; fName[ 8] = "TX";
|
|---|
| 92 | fCoeff[ 9] = &fEces; fName[ 9] = "ECES";
|
|---|
| 93 | fCoeff[10] = &fAces; fName[10] = "ACES";
|
|---|
| 94 | fCoeff[11] = &fEcec; fName[11] = "ECEC";
|
|---|
| 95 | fCoeff[12] = &fAcec; fName[12] = "ACEC";
|
|---|
| 96 | fCoeff[13] = &fNrx; fName[13] = "NRX";
|
|---|
| 97 | fCoeff[14] = &fNry; fName[14] = "NRY";
|
|---|
| 98 | fCoeff[15] = &fCrx; fName[15] = "CRX";
|
|---|
| 99 | fCoeff[16] = &fCry; fName[16] = "CRY";
|
|---|
| 100 | fCoeff[17] = &fMagic1; fName[17] = "MAGIC1";
|
|---|
| 101 | fCoeff[18] = &fMagic2; fName[18] = "MAGIC2";
|
|---|
| 102 |
|
|---|
| 103 | fDescr[ 0] = "Index Error Azimuth";
|
|---|
| 104 | fDescr[ 1] = "Index Error Zenith Distance";
|
|---|
| 105 | fDescr[ 2] = "Vertical Sag";
|
|---|
| 106 | fDescr[ 3] = "Azimuth Axis Misalignment (N-S)";
|
|---|
| 107 | fDescr[ 4] = "Azimuth Axis Misalignment (E-W)";
|
|---|
| 108 | fDescr[ 5] = "Az-El Nonperpendicularity";
|
|---|
| 109 | fDescr[ 6] = "Left-Right Collimation Error";
|
|---|
| 110 | fDescr[ 7] = "Tube fluxture (sin)";
|
|---|
| 111 | fDescr[ 8] = "Tube fluxture (tan)";
|
|---|
| 112 | fDescr[ 9] = "Elevation Centering Error (sin)";
|
|---|
| 113 | fDescr[10] = "Azimuth Centering Error (sin)";
|
|---|
| 114 | fDescr[11] = "Elevation Centering Error (cos)";
|
|---|
| 115 | fDescr[12] = "Azimuth Centering Error (cos)";
|
|---|
| 116 | fDescr[13] = "Nasmyth rotator displacement (horizontal)";
|
|---|
| 117 | fDescr[14] = "Nasmyth rotator displacement (vertical)";
|
|---|
| 118 | fDescr[15] = "Alt/Az Coude Displacement (N-S)";
|
|---|
| 119 | fDescr[16] = "Alt/Az Coude Displacement (E-W)";
|
|---|
| 120 | fDescr[17] = "n/a";
|
|---|
| 121 | fDescr[18] = "n/a";
|
|---|
| 122 | }
|
|---|
| 123 | void MBending::Reset()
|
|---|
| 124 | {
|
|---|
| 125 | Clear();
|
|---|
| 126 | }
|
|---|
| 127 |
|
|---|
| 128 | void MBending::Load(const char *name)
|
|---|
| 129 | {
|
|---|
| 130 | /*
|
|---|
| 131 | ! MMT 1987 July 8
|
|---|
| 132 | ! T 36 7.3622 41.448 -0.0481
|
|---|
| 133 | ! IA -37.5465 20.80602
|
|---|
| 134 | ! IE -13.9180 1.25217
|
|---|
| 135 | ! NPAE +7.0751 26.44763
|
|---|
| 136 | ! CA -6.9149 32.05358
|
|---|
| 137 | ! AN +0.5053 1.40956
|
|---|
| 138 | ! AW -2.2016 1.37480
|
|---|
| 139 | ! END
|
|---|
| 140 | */
|
|---|
| 141 |
|
|---|
| 142 | ifstream fin(name);
|
|---|
| 143 | if (!fin)
|
|---|
| 144 | {
|
|---|
| 145 | cout << "Error: Cannot open file '" << name << "'" << endl;
|
|---|
| 146 | return;
|
|---|
| 147 | }
|
|---|
| 148 |
|
|---|
| 149 | char c;
|
|---|
| 150 | while (fin && fin.get()!='\n');
|
|---|
| 151 | fin >> c;
|
|---|
| 152 |
|
|---|
| 153 | if (c!='S' && c!='s')
|
|---|
| 154 | {
|
|---|
| 155 | cout << "Error: This in not a model correcting the star position (" << c << ")" << endl;
|
|---|
| 156 | return;
|
|---|
| 157 | }
|
|---|
| 158 |
|
|---|
| 159 | Clear();
|
|---|
| 160 |
|
|---|
| 161 | cout << endl;
|
|---|
| 162 |
|
|---|
| 163 | Double_t val;
|
|---|
| 164 | fin >> val;
|
|---|
| 165 | cout << "Number of observed stars: " << val << endl;
|
|---|
| 166 | fin >> val;
|
|---|
| 167 | cout << "Sky RMS: " << val << "\"" << endl;
|
|---|
| 168 | fin >> val;
|
|---|
| 169 | cout << "Refraction Constant A: " << val << "\"" << endl;
|
|---|
| 170 | fin >> val;
|
|---|
| 171 | cout << "Refraction Constant B: " << val << "\"" << endl;
|
|---|
| 172 |
|
|---|
| 173 | cout << endl;
|
|---|
| 174 |
|
|---|
| 175 | cout << " & = Name Value Sigma" << endl;
|
|---|
| 176 | cout << "--------------------------------------------------" << endl;
|
|---|
| 177 |
|
|---|
| 178 | while (fin)
|
|---|
| 179 | {
|
|---|
| 180 | TString str;
|
|---|
| 181 | fin >> str;
|
|---|
| 182 |
|
|---|
| 183 | if (str=="END")
|
|---|
| 184 | break;
|
|---|
| 185 |
|
|---|
| 186 | if (str[0]=='&')
|
|---|
| 187 | {
|
|---|
| 188 | cout << " & ";
|
|---|
| 189 | str.Remove(0);
|
|---|
| 190 | }
|
|---|
| 191 | else
|
|---|
| 192 | cout << " ";
|
|---|
| 193 |
|
|---|
| 194 | if (str[1]=='=')
|
|---|
| 195 | {
|
|---|
| 196 | cout << "= ";
|
|---|
| 197 | str.Remove(0);
|
|---|
| 198 | }
|
|---|
| 199 | else
|
|---|
| 200 | cout << " ";
|
|---|
| 201 |
|
|---|
| 202 | fin >> val;
|
|---|
| 203 | cout << str << "\t" << setw(11) << val << "° \t";
|
|---|
| 204 | val *= kDeg2Rad;
|
|---|
| 205 |
|
|---|
| 206 | Double_t *dest=NULL;
|
|---|
| 207 |
|
|---|
| 208 | if (str=="IA") dest = &fIa;
|
|---|
| 209 | if (str=="IE") dest = &fIe;
|
|---|
| 210 | if (str=="FLOP") dest = &fFlop;
|
|---|
| 211 | if (str=="NPAE") dest = &fNpae;
|
|---|
| 212 | if (str=="CA") dest = &fCa;
|
|---|
| 213 | if (str=="AN") dest = &fAn;
|
|---|
| 214 | if (str=="AW") dest = &fAw;
|
|---|
| 215 | if (str=="TF") dest = &fTf;
|
|---|
| 216 | if (str=="TX") dest = &fTx;
|
|---|
| 217 | if (str=="NRX") dest = &fNrx;
|
|---|
| 218 | if (str=="NRY") dest = &fNry;
|
|---|
| 219 | if (str=="CRX") dest = &fCrx;
|
|---|
| 220 | if (str=="CRY") dest = &fCry;
|
|---|
| 221 | if (str=="ECES") dest = &fEces;
|
|---|
| 222 | if (str=="ACES") dest = &fAces;
|
|---|
| 223 | if (str=="ECEC") dest = &fEcec;
|
|---|
| 224 | if (str=="ACEC") dest = &fAcec;
|
|---|
| 225 |
|
|---|
| 226 | if (dest)
|
|---|
| 227 | *dest = val;
|
|---|
| 228 |
|
|---|
| 229 | fin >> val;
|
|---|
| 230 | cout << setw(9) << val << "°" << endl;
|
|---|
| 231 |
|
|---|
| 232 | // Find corresponding error
|
|---|
| 233 | for (int i=0; i<MBending::GetNumPar(); i++)
|
|---|
| 234 | if (dest==fCoeff[i])
|
|---|
| 235 | {
|
|---|
| 236 | fError[i] = val*kDeg2Rad;
|
|---|
| 237 | break;
|
|---|
| 238 | }
|
|---|
| 239 | }
|
|---|
| 240 | cout << endl;
|
|---|
| 241 | }
|
|---|
| 242 |
|
|---|
| 243 | void MBending::Save(const char *name)
|
|---|
| 244 | {
|
|---|
| 245 | /*
|
|---|
| 246 | ! MMT 1987 July 8
|
|---|
| 247 | ! T 36 7.3622 41.448 -0.0481
|
|---|
| 248 | ! IA -37.5465 20.80602
|
|---|
| 249 | ! IE -13.9180 1.25217
|
|---|
| 250 | ! NPAE +7.0751 26.44763
|
|---|
| 251 | ! CA -6.9149 32.05358
|
|---|
| 252 | ! AN +0.5053 1.40956
|
|---|
| 253 | ! AW -2.2016 1.37480
|
|---|
| 254 | ! END
|
|---|
| 255 | */
|
|---|
| 256 |
|
|---|
| 257 | ofstream fout(name);
|
|---|
| 258 | if (!fout)
|
|---|
| 259 | {
|
|---|
| 260 | cout << "Error: Cannot open file '" << name << "'" << endl;
|
|---|
| 261 | return;
|
|---|
| 262 | }
|
|---|
| 263 |
|
|---|
| 264 | MTime t;
|
|---|
| 265 | t.Now();
|
|---|
| 266 |
|
|---|
| 267 | fout << "MAGIC1 " << t << endl;
|
|---|
| 268 | fout << "S 00 000000 000000 0000000" << endl;
|
|---|
| 269 | fout << setprecision(8);
|
|---|
| 270 | for (int i=0; i<fNumPar; i++)
|
|---|
| 271 | {
|
|---|
| 272 | fout << " " << setw(6) << GetName(i) << " ";
|
|---|
| 273 | fout << setw(13) << *fCoeff[i]*kRad2Deg << " ";
|
|---|
| 274 | fout << setw(11) << fError[i]*kRad2Deg << endl;
|
|---|
| 275 | }
|
|---|
| 276 | fout << "END" << endl;
|
|---|
| 277 | }
|
|---|
| 278 |
|
|---|
| 279 | Double_t MBending::Sign(Double_t val, Double_t alt)
|
|---|
| 280 | {
|
|---|
| 281 | // Some pointing corrections are defined as Delta ZA, which
|
|---|
| 282 | // is (P. Wallace) defined [0,90]deg while Alt is defined
|
|---|
| 283 | // [0,180]deg
|
|---|
| 284 | return (TMath::Pi()/2-alt < 0 ? -val : val);
|
|---|
| 285 | }
|
|---|
| 286 |
|
|---|
| 287 | AltAz MBending::AddOffsets(const AltAz &aa) const
|
|---|
| 288 | {
|
|---|
| 289 | // Correct [rad]
|
|---|
| 290 | // zdaz [rad]
|
|---|
| 291 | AltAz p = aa;
|
|---|
| 292 |
|
|---|
| 293 | const AltAz I(fIe, fIa);
|
|---|
| 294 | p += I;
|
|---|
| 295 |
|
|---|
| 296 | return p;
|
|---|
| 297 | }
|
|---|
| 298 |
|
|---|
| 299 | AltAz MBending::SubtractOffsets(const AltAz &aa) const
|
|---|
| 300 | {
|
|---|
| 301 | // Correct [rad]
|
|---|
| 302 | // zdaz [rad]
|
|---|
| 303 | AltAz p = aa;
|
|---|
| 304 |
|
|---|
| 305 | const AltAz I(fIe, fIa);
|
|---|
| 306 | p -= I;
|
|---|
| 307 |
|
|---|
| 308 | return p;
|
|---|
| 309 | }
|
|---|
| 310 |
|
|---|
| 311 | AltAz MBending::CalcAnAw(const AltAz &p, Int_t sign) const
|
|---|
| 312 | {
|
|---|
| 313 | // Corrections for AN and AW without approximations
|
|---|
| 314 | // as done by Patrick Wallace. The approximation cannot
|
|---|
| 315 | // be used for MAGIC because the correctioon angle
|
|---|
| 316 | // AW (~1.5deg) is not small enough.
|
|---|
| 317 |
|
|---|
| 318 | // Vector in cartesian coordinates
|
|---|
| 319 | TVector3 v1;
|
|---|
| 320 |
|
|---|
| 321 | // Set Azimuth and Elevation
|
|---|
| 322 | v1.SetMagThetaPhi(1, TMath::Pi()/2-p.Alt(), p.Az());
|
|---|
| 323 |
|
|---|
| 324 |
|
|---|
| 325 | TVector3 v2(v1);
|
|---|
| 326 | // cout << sign << endl;
|
|---|
| 327 |
|
|---|
| 328 | // cout << "v1: " << v1.Theta()*TMath::RadToDeg() << " " << v1.Phi()*TMath::RadToDeg() << endl;
|
|---|
| 329 |
|
|---|
| 330 | // Rotate around the x- and y-axis
|
|---|
| 331 | v1.RotateY(sign*fAn);
|
|---|
| 332 | v1.RotateX(sign*fAw);
|
|---|
| 333 |
|
|---|
| 334 | // cout << "v1: " << v1.Theta()*TMath::RadToDeg() << " " << v1.Phi()*TMath::RadToDeg() << endl;
|
|---|
| 335 | // cout << "v2: " << v2.Theta()*TMath::RadToDeg() << " " << v2.Theta()*TMath::RadToDeg() << endl;
|
|---|
| 336 |
|
|---|
| 337 | // cout << "dv: " << (v2.Theta()-v1.Theta())*TMath::RadToDeg() << " " << (v2.Phi()-v1.Phi())*TMath::RadToDeg() << endl;
|
|---|
| 338 |
|
|---|
| 339 | Double_t dalt = v1.Theta()-v2.Theta();
|
|---|
| 340 | Double_t daz = v1.Phi() -v2.Phi();
|
|---|
| 341 |
|
|---|
| 342 | //cout << dalt*TMath::RadToDeg() << " " << daz*TMath::RadToDeg() << endl;
|
|---|
| 343 |
|
|---|
| 344 | if (daz>TMath::Pi())
|
|---|
| 345 | daz -= TMath::TwoPi();
|
|---|
| 346 | if (daz<-TMath::Pi())
|
|---|
| 347 | daz += TMath::TwoPi();
|
|---|
| 348 |
|
|---|
| 349 | // if (daz>TMath::Pi()/2)
|
|---|
| 350 | // {
|
|---|
| 351 | // }
|
|---|
| 352 |
|
|---|
| 353 | AltAz d(dalt, daz);
|
|---|
| 354 | return d;
|
|---|
| 355 |
|
|---|
| 356 | // Calculate Delta Azimuth and Delta Elevation
|
|---|
| 357 | /*
|
|---|
| 358 | AltAz d(TMath::Pi()/2-v1.Theta(), v1.Phi());
|
|---|
| 359 |
|
|---|
| 360 | cout << "p : " << p.Alt()*TMath::RadToDeg() << " " << p.Az()*TMath::RadToDeg() << endl;
|
|---|
| 361 | cout << "d : " << d.Alt()*TMath::RadToDeg() << " " << d.Az()*TMath::RadToDeg() << endl;
|
|---|
| 362 | d -= p;
|
|---|
| 363 | cout << "d-p: " << d.Alt()*TMath::RadToDeg() << " " << d.Az()*TMath::RadToDeg() << endl;
|
|---|
| 364 | d *= sign;
|
|---|
| 365 | cout << "d* : " << d.Alt()*TMath::RadToDeg() << " " << d.Az()*TMath::RadToDeg() << endl;
|
|---|
| 366 |
|
|---|
| 367 |
|
|---|
| 368 | cout << "p2: " << 90-p.Alt()*TMath::RadToDeg() << " " << p.Az()*TMath::RadToDeg() << endl;
|
|---|
| 369 | cout << "d2: " << 90-d.Alt()*TMath::RadToDeg() << " " << d.Az()*TMath::RadToDeg() << endl;
|
|---|
| 370 |
|
|---|
| 371 | Int_t s1 = 90-d.Alt()*TMath::RadToDeg() < 0 ? -1 : 1;
|
|---|
| 372 | Int_t s2 = 90-p.Alt()*TMath::RadToDeg() < 0 ? -1 : 1;
|
|---|
| 373 |
|
|---|
| 374 |
|
|---|
| 375 | if (s1 != s2)
|
|---|
| 376 | {
|
|---|
| 377 | //90-d.Alt() <-- -90+d.Alt()
|
|---|
| 378 |
|
|---|
| 379 | d.Alt(d.Alt()-TMath::Pi());
|
|---|
| 380 | cout << "Alt-" << endl;
|
|---|
| 381 | }
|
|---|
| 382 | cout << "d': " << 90-d.Alt()*TMath::RadToDeg() << " " << d.Az()*TMath::RadToDeg() << endl;
|
|---|
| 383 | /*
|
|---|
| 384 | // Fix 'direction' of output depending on input vector
|
|---|
| 385 | if (TMath::Pi()/2-sign*p.Alt()<0)
|
|---|
| 386 | {
|
|---|
| 387 | d.Alt(d.Alt()-TMath::Pi());
|
|---|
| 388 | cout << "Alt-" << endl;
|
|---|
| 389 | }
|
|---|
| 390 | //if (TMath::Pi()/2-sign*p.Alt()>TMath::Pi())
|
|---|
| 391 | //{
|
|---|
| 392 | // d.Alt(TMath::Pi()-d.Alt());
|
|---|
| 393 | // cout << "Alt+" << endl;
|
|---|
| 394 | //}
|
|---|
| 395 |
|
|---|
| 396 | // Align correction into [-180,180]
|
|---|
| 397 | while (d.Az()>TMath::Pi())
|
|---|
| 398 | {
|
|---|
| 399 | d.Az(d.Az()-TMath::Pi()*2);
|
|---|
| 400 | cout << "Az-" << endl;
|
|---|
| 401 | }
|
|---|
| 402 | while (d.Az()<-TMath::Pi())
|
|---|
| 403 | {
|
|---|
| 404 | d.Az(d.Az()+TMath::Pi()*2);
|
|---|
| 405 | cout << "Az+" << endl;
|
|---|
| 406 | }
|
|---|
| 407 | */
|
|---|
| 408 | return d;
|
|---|
| 409 | }
|
|---|
| 410 |
|
|---|
| 411 |
|
|---|
| 412 | AltAz MBending::Correct(const AltAz &aa) const
|
|---|
| 413 | {
|
|---|
| 414 | // Correct [rad]
|
|---|
| 415 | // zdaz [rad]
|
|---|
| 416 | AltAz p = aa;
|
|---|
| 417 |
|
|---|
| 418 | DEBUG(cout << setprecision(16));
|
|---|
| 419 | DEBUG(cout << "Bend7: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
|---|
| 420 |
|
|---|
| 421 | const AltAz CRX(-fCrx*sin(p.Az()-p.Alt()), fCrx*cos(p.Az()-p.Alt())/cos(p.Alt()));
|
|---|
| 422 | const AltAz CRY(-fCry*cos(p.Az()-p.Alt()), -fCry*sin(p.Az()-p.Alt())/cos(p.Alt()));
|
|---|
| 423 | p += CRX;
|
|---|
| 424 | p += CRY;
|
|---|
| 425 |
|
|---|
| 426 | DEBUG(cout << "Bend6: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
|---|
| 427 |
|
|---|
| 428 | const AltAz NRX(fNrx*sin(p.Alt()), -fNrx);
|
|---|
| 429 | const AltAz NRY(fNry*cos(p.Alt()), -fNry*tan(p.Alt()));
|
|---|
| 430 | p += NRX;
|
|---|
| 431 | p += NRY;
|
|---|
| 432 |
|
|---|
| 433 | DEBUG(cout << "Bend5: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
|---|
| 434 |
|
|---|
| 435 | const AltAz CES(-fEces*sin(p.Alt()), -fAces*sin(p.Az()));
|
|---|
| 436 | const AltAz CEC(-fEcec*cos(p.Alt()), -fAcec*cos(p.Az()));
|
|---|
| 437 | p += CES;
|
|---|
| 438 | p += CEC;
|
|---|
| 439 |
|
|---|
| 440 | DEBUG(cout << "Bend4: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
|---|
| 441 |
|
|---|
| 442 | const AltAz TX(Sign(fTx/tan(p.Alt()), p.Alt()), 0);
|
|---|
| 443 | const AltAz TF(Sign(fTf*cos(p.Alt()), p.Alt()), 0);
|
|---|
| 444 | //p += TX;
|
|---|
| 445 | p += TF;
|
|---|
| 446 |
|
|---|
| 447 |
|
|---|
| 448 | DEBUG(cout << "Bend3: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
|---|
| 449 |
|
|---|
| 450 | /*
|
|---|
| 451 | //New Corrections for NPAE and CA:
|
|---|
| 452 | TVector3 v(1.,1.,1.); // Vector in cartesian coordinates
|
|---|
| 453 |
|
|---|
| 454 | //Set Azimuth and Elevation
|
|---|
| 455 | v.SetPhi(p.Az());
|
|---|
| 456 | v.SetTheta(TMath::Pi()/2-p.Alt());
|
|---|
| 457 | //Rotation Vectors:
|
|---|
| 458 | TVector3 vNpae( cos(p.Az()), sin(p.Az()), 0);
|
|---|
| 459 | TVector3 vCa( -cos(p.Az())*cos(p.Alt()), -sin(p.Az())*cos(p.Alt()), sin(p.Alt()));
|
|---|
| 460 | //Rotate around the vectors vNpae and vCa
|
|---|
| 461 | v.Rotate(fNpae, vNpae);
|
|---|
| 462 | v.Rotate(fCa, vCa);
|
|---|
| 463 |
|
|---|
| 464 | p.Az(v.Phi());
|
|---|
| 465 | p.Alt(TMath::Pi()/2-v.Theta());
|
|---|
| 466 | */
|
|---|
| 467 |
|
|---|
| 468 | //Old correction terms for Npae and Ca:
|
|---|
| 469 | const AltAz CA(0, -fCa/cos(p.Alt()));
|
|---|
| 470 | p += CA;
|
|---|
| 471 |
|
|---|
| 472 | const AltAz NPAE(0, -fNpae*tan(p.Alt()));
|
|---|
| 473 | p += NPAE;
|
|---|
| 474 |
|
|---|
| 475 | DEBUG(cout << "Bend2: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
|---|
| 476 |
|
|---|
| 477 | const AltAz ANAW(CalcAnAw(p, -1));
|
|---|
| 478 | p += ANAW;
|
|---|
| 479 |
|
|---|
| 480 | /* Old correction terms for An and Aw:
|
|---|
| 481 | const AltAz AW( fAw*sin(p.Az()), -fAw*cos(p.Az())*tan(p.Alt()));
|
|---|
| 482 | const AltAz AN(-fAn*cos(p.Az()), -fAn*sin(p.Az())*tan(p.Alt()));
|
|---|
| 483 | p += AW;
|
|---|
| 484 | p += AN;
|
|---|
| 485 | */
|
|---|
| 486 |
|
|---|
| 487 | DEBUG(cout << "Bend1: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
|---|
| 488 |
|
|---|
| 489 | const AltAz FLOP(Sign(fFlop, p.Alt()), 0);
|
|---|
| 490 | p += FLOP;
|
|---|
| 491 |
|
|---|
| 492 | //const AltAz MAGIC1(fMagic1*sin(p.Az()), 0);
|
|---|
| 493 | //p += MAGIC1;
|
|---|
| 494 |
|
|---|
| 495 | const AltAz I(fIe, fIa);
|
|---|
| 496 | p += I;
|
|---|
| 497 |
|
|---|
| 498 | DEBUG(cout << "Bend0: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
|---|
| 499 |
|
|---|
| 500 | return p;
|
|---|
| 501 | }
|
|---|
| 502 |
|
|---|
| 503 | AltAz MBending::CorrectBack(const AltAz &aa) const
|
|---|
| 504 | {
|
|---|
| 505 | // Correct [rad]
|
|---|
| 506 | // zdaz [rad]
|
|---|
| 507 | AltAz p = aa;
|
|---|
| 508 |
|
|---|
| 509 | DEBUG(cout << setprecision(16));
|
|---|
| 510 | DEBUG(cout << "Back0: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
|---|
| 511 |
|
|---|
| 512 | const AltAz I(fIe, fIa);
|
|---|
| 513 | p -= I;
|
|---|
| 514 |
|
|---|
| 515 | //const AltAz MAGIC1(fMagic1*sin(p.Az()), 0);
|
|---|
| 516 | //p -= MAGIC1;
|
|---|
| 517 |
|
|---|
| 518 | const AltAz FLOP(Sign(fFlop, p.Alt()), 0);
|
|---|
| 519 | p -= FLOP;
|
|---|
| 520 |
|
|---|
| 521 | DEBUG(cout << "Back1: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
|---|
| 522 |
|
|---|
| 523 | /* Old correction terms for An and Aw:
|
|---|
| 524 | const AltAz AN(-fAn*cos(p.Az()), -fAn*sin(p.Az())*tan(p.Alt()));
|
|---|
| 525 | const AltAz AW( fAw*sin(p.Az()), -fAw*cos(p.Az())*tan(p.Alt()));
|
|---|
| 526 | p -= AN;
|
|---|
| 527 | p -= AW;
|
|---|
| 528 | */
|
|---|
| 529 |
|
|---|
| 530 | const AltAz ANAW(CalcAnAw(p, -1));
|
|---|
| 531 | p -= ANAW;
|
|---|
| 532 |
|
|---|
| 533 | DEBUG(cout << "Back2: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
|---|
| 534 |
|
|---|
| 535 | //Old Correction terms for Npae and Ca:
|
|---|
| 536 | const AltAz NPAE(0, -fNpae*tan(p.Alt()));
|
|---|
| 537 | p -= NPAE;
|
|---|
| 538 |
|
|---|
| 539 | const AltAz CA(0, -fCa/cos(p.Alt()));
|
|---|
| 540 | p -= CA;
|
|---|
| 541 |
|
|---|
| 542 | /*
|
|---|
| 543 | //New Correction term for Npae and Ca:
|
|---|
| 544 | TVector3 v2(1.,1.,1.); // Vector in cartesian coordinates
|
|---|
| 545 | //Set Azimuth and Elevation
|
|---|
| 546 | v2.SetPhi(p.Az());
|
|---|
| 547 | v2.SetTheta(TMath::Pi()/2-p.Alt());
|
|---|
| 548 | //Rotation Vectors:
|
|---|
| 549 | TVector3 vNpae( cos(p.Az()), sin(p.Az()), 0);
|
|---|
| 550 | TVector3 vCa( -cos(p.Az())*cos(p.Alt()), -sin(p.Az())*cos(p.Alt()), sin(p.Alt()));
|
|---|
| 551 | //Rotate around the vectors vCa and vNpae
|
|---|
| 552 | v2.Rotate(-fCa, vCa);
|
|---|
| 553 | v2.Rotate(-fNpae, vNpae);
|
|---|
| 554 |
|
|---|
| 555 | p.Az(v2.Phi());
|
|---|
| 556 | p.Alt(TMath::Pi()/2-v2.Theta());
|
|---|
| 557 | */
|
|---|
| 558 |
|
|---|
| 559 | DEBUG(cout << "Back3: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
|---|
| 560 |
|
|---|
| 561 | const AltAz TF(Sign(fTf*cos(p.Alt()), p.Alt()), 0);
|
|---|
| 562 | const AltAz TX(Sign(fTx/tan(p.Alt()), p.Alt()), 0);
|
|---|
| 563 | p -= TF;
|
|---|
| 564 | //p -= TX;
|
|---|
| 565 |
|
|---|
| 566 | DEBUG(cout << "Back4: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
|---|
| 567 |
|
|---|
| 568 | const AltAz CEC(-fEcec*cos(p.Alt()), -fAcec*cos(p.Az()));
|
|---|
| 569 | const AltAz CES(-fEces*sin(p.Alt()), -fAces*sin(p.Az()));
|
|---|
| 570 | p -= CEC;
|
|---|
| 571 | p -= CES;
|
|---|
| 572 |
|
|---|
| 573 | DEBUG(cout << "Back5: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
|---|
| 574 |
|
|---|
| 575 | const AltAz NRY(fNry*cos(p.Alt()), -fNry*tan(p.Alt()));
|
|---|
| 576 | const AltAz NRX(fNrx*sin(p.Alt()), -fNrx);
|
|---|
| 577 | p -= NRY;
|
|---|
| 578 | p -= NRX;
|
|---|
| 579 |
|
|---|
| 580 | DEBUG(cout << "Back6: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
|---|
| 581 |
|
|---|
| 582 | const AltAz CRY(-fCry*cos(p.Az()-p.Alt()), -fCry*sin(p.Az()-p.Alt())/cos(p.Alt()));
|
|---|
| 583 | const AltAz CRX(-fCrx*sin(p.Az()-p.Alt()), fCrx*cos(p.Az()-p.Alt())/cos(p.Alt()));
|
|---|
| 584 | p -= CRY;
|
|---|
| 585 | p -= CRX;
|
|---|
| 586 |
|
|---|
| 587 | DEBUG(cout << "Back7: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
|---|
| 588 |
|
|---|
| 589 | return p;
|
|---|
| 590 | }
|
|---|
| 591 |
|
|---|
| 592 | ZdAz MBending::Correct(const ZdAz &zdaz) const
|
|---|
| 593 | {
|
|---|
| 594 | // Correct [rad]
|
|---|
| 595 | // zdaz [rad]
|
|---|
| 596 | AltAz p(TMath::Pi()/2-zdaz.Zd(), zdaz.Az());
|
|---|
| 597 | AltAz c = Correct(p);
|
|---|
| 598 | return ZdAz(TMath::Pi()/2-c.Alt(), c.Az());
|
|---|
| 599 | }
|
|---|
| 600 |
|
|---|
| 601 | ZdAz MBending::CorrectBack(const ZdAz &zdaz) const
|
|---|
| 602 | {
|
|---|
| 603 | // Correct [rad]
|
|---|
| 604 | // zdaz [rad]
|
|---|
| 605 | AltAz p(TMath::Pi()/2-zdaz.Zd(), zdaz.Az());
|
|---|
| 606 | AltAz c = CorrectBack(p);
|
|---|
| 607 | return ZdAz(TMath::Pi()/2-c.Alt(), c.Az());
|
|---|
| 608 | }
|
|---|
| 609 |
|
|---|
| 610 | void MBending::SetParameters(const Double_t *par, Int_t n)
|
|---|
| 611 | {
|
|---|
| 612 | Clear();
|
|---|
| 613 |
|
|---|
| 614 | while (n--)
|
|---|
| 615 | *fCoeff[n] = par[n]/kRad2Deg;
|
|---|
| 616 | }
|
|---|
| 617 |
|
|---|
| 618 | void MBending::GetParameters(Double_t *par, Int_t n) const
|
|---|
| 619 | {
|
|---|
| 620 | while (n--)
|
|---|
| 621 | par[n] = *fCoeff[n]*kRad2Deg;
|
|---|
| 622 | }
|
|---|
| 623 |
|
|---|
| 624 | void MBending::SetMinuitParameters(TMinuit &m, Int_t n=-1) const
|
|---|
| 625 | {
|
|---|
| 626 | if (n<0)
|
|---|
| 627 | n = fNumPar;
|
|---|
| 628 |
|
|---|
| 629 | Int_t ierflg = 0;
|
|---|
| 630 |
|
|---|
| 631 | while (n--)
|
|---|
| 632 | m.mnparm(n, fName[n], *fCoeff[n]*kRad2Deg, 1, -360, 360, ierflg);
|
|---|
| 633 | }
|
|---|
| 634 |
|
|---|
| 635 | void MBending::GetMinuitParameters(TMinuit &m, Int_t n=-1)
|
|---|
| 636 | {
|
|---|
| 637 | if (n<0 || n>m.GetNumPars())
|
|---|
| 638 | n = m.GetNumPars();
|
|---|
| 639 |
|
|---|
| 640 | while (n--)
|
|---|
| 641 | {
|
|---|
| 642 | m.GetParameter(n, *fCoeff[n], fError[n]);
|
|---|
| 643 | *fCoeff[n] /= kRad2Deg;
|
|---|
| 644 | fError[n] /= kRad2Deg;
|
|---|
| 645 | }
|
|---|
| 646 | }
|
|---|
| 647 | /*
|
|---|
| 648 | void FormatPar(TMinuit &m, Int_t n)
|
|---|
| 649 | {
|
|---|
| 650 | Double_t par, err;
|
|---|
| 651 | m.GetParameter(n, par, err);
|
|---|
| 652 |
|
|---|
| 653 | int expp = (int)log10(par);
|
|---|
| 654 | int expe = (int)log10(err);
|
|---|
| 655 |
|
|---|
| 656 | if (err<2*pow(10, expe))
|
|---|
| 657 | expe--;
|
|---|
| 658 |
|
|---|
| 659 | Int_t exp = expe>expp ? expp : expe;
|
|---|
| 660 |
|
|---|
| 661 | par = (int)(par/pow(10, exp)) * pow(10, exp);
|
|---|
| 662 | err = (int)(err/pow(10, exp)) * pow(10, exp);
|
|---|
| 663 |
|
|---|
| 664 | cout << par << " +- " << err << flush;
|
|---|
| 665 | }
|
|---|
| 666 | */
|
|---|
| 667 | void MBending::PrintMinuitParameters(TMinuit &m, Int_t n=-1) const
|
|---|
| 668 | {
|
|---|
| 669 | if (n<0)
|
|---|
| 670 | n = m.GetNumPars();
|
|---|
| 671 |
|
|---|
| 672 | cout << setprecision(3);
|
|---|
| 673 |
|
|---|
| 674 | Double_t par, err;
|
|---|
| 675 |
|
|---|
| 676 | while (n--)
|
|---|
| 677 | {
|
|---|
| 678 | m.GetParameter(n, par, err);
|
|---|
| 679 | cout << Form(" %2d %6s: ", n, (const char*)fName[n]);
|
|---|
| 680 | cout << setw(8) << par << " \xb1 " << setw(6) << err << endl;
|
|---|
| 681 | }
|
|---|
| 682 | }
|
|---|