Changeset 8719
- Timestamp:
- 08/28/07 13:03:04 (17 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r8711 r8719 18 18 19 19 -*-*- END OF LINE -*-*- 20 2007/08/28 Thomas Bretz 21 22 * mbase/MEnv.[h,cc]: 23 - added handling an Include-resource. Note, that there is no 24 check for recursions, they can crash your program. 25 26 * sponde.cc: 27 - check for batch mode and no output file 28 - changed title 29 - moved HasWritePermission to MJSpectrum.cc 30 31 * mdata/MDataPhrase.cc: 32 - fixed a bug which caused a variable (eg. [0]) at the beginning 33 of a line not be detected correctly 34 35 * mhbase/MHn.cc: 36 - added some comments 37 38 * mhflux/MHDisp.[h,cc]: 39 - changed axis titles from x/y to dx/dy 40 - changed cutting out a part of the cake into stamping a hole 41 at the source position (currently with a fix PSF!) 42 - for the moment display everything in Wobble-mode (to be fixed!) 43 44 * mhflux/MMcSpectrumWeight.cc: 45 - some cosmetics to output 46 47 * mjobs/MJCut.cc: 48 - check if output file is writeable (necessary in on/off mode 49 to detect that incident before filling the source plot) 50 51 * mjobs/MJob.cc: 52 - added a comment 53 - fixed a bug in HasWritePermission (it must be fOverwrite not 54 !fOverwrite) 55 56 * mjobs/MJSpectrum.cc: 57 - replaced #cdot by a dot (it seems it is not supported anymore??) 58 - set a proper display name 59 - print an error message if writing the result failed 60 61 * mjtrain/MJTrainDisp.[h,cc]: 62 - a further small step to unify all MJOptim classes 63 - let the user change the theta-cut for the displayed efficiency 64 65 * macros/train/traindisp.C: 66 - added comment about new SetThetaCut 67 68 * mjtrain/MJTrainEnergy.[h,cc] 69 - a further small step to unify all MJOptim classes 70 - removed obsolete columns for Impact and TelescopeTheta 71 (MHEnergyEst doesn't read from the matrix here) 72 - set palette 73 74 * mpointing/MSrcPosCalc.[h,cc]: 75 - replaced CalcXYinCamera by MAstro::GetDistOnPlain. It has the 76 same accuracy and is not remarkably slower 77 78 * mpointing/MSrcPosCorrect.[h,cc]: 79 - changed comments 80 - made sure that any possible anti-source position in the camera 81 is handled correctly (maybe we should move it before 82 MSrcPosCalc and skip the anti-source here???) 83 84 85 86 20 87 2007/08/27 Markus Meyer 21 88 22 89 * mmuon/MHMuonPar.cc: 23 90 - Reference lines changed 91 92 93 94 2007/08/27 Thomas Bretz 95 96 * resources/starguider00000001.txt, resources/starguider0085240.txt, 97 resources/starguider00089180.txt: 98 - added more starguider calibration files 99 100 * resources/starguider.txt: 101 - removed obsolete old one 102 103 104 105 2007/08/26 Thomas Bretz 106 107 * mranforest/MRFEnergyEst.[h,cc]: 108 - removed obsolete files 24 109 25 110 -
trunk/MagicSoft/Mars/mdata/MDataPhrase.cc
r8717 r8719 321 321 idx++; 322 322 } 323 323 /* 324 325 // * HOW DO WE PROCESS THE FILTERS? 326 // * DO WE NEED THIS FOR MData derived classes? Is there any need for it? 327 // * MAYBE FIRST FILTERS (MF?) MUST REPLACE {name[class]} BEFORE 328 // THE DATA PHRASSE IS CREATED? 329 // --> MFDataPhrase must have a list of MFilter. In Process first 330 // all self created MFilter are processed (see MF). Then 331 // they are evaluated and the result is given to the MDataPhrase. 332 // Can this be done using MDataMember? We replace {Name[class]} 333 // by Name.IsExpressionTrue and we need a way that MDataPhrase 334 // gets the coresponding pointer. 335 // --> Alternatively we can create a MDataPhrase which allows 336 // Pre/Processing 337 // 338 // We convert {Name[Class]} to Name.IsExpressionTrue. To process these 339 // data/filters we need a request from MFDataPhrase (new virtual 340 // memeber function?) 341 // 342 // {} Is alreaqdy used in ReadEnv. 343 // 344 // Enhance ReadEnv to allow Cut1.5 to be just a class. 345 // 346 // The difference between MFDataPhrase is 347 // MFDataPhrase only knows MDataPhrase, while 348 // MF also knows a filter-class. 349 // 350 351 p = 0; 352 353 // And now we check for other phrases or filters 354 // They are defined by a [, a pribtable character and 355 // any numer of word characters (a-zA-Z0-9_) and a closing ] 356 reg = TPRegexp("{[A-Za-z}\\w+(\\[[A-Za-z]\\w+\\])?}"); 357 while (1) 358 { 359 // If some indices are already existing 360 // initialize them by a MDataValue 361 idx = CheckForVariable(phrase, idx); 362 363 // Check whether expression is found 364 if (reg.Match(phrase, mods, p, 130, &pos)==0) 365 break; 366 367 // Get expression from phrase 368 TString expr = phrase(pos[0], pos[1]-pos[0]); 369 370 // Zerlegen: {Name[Class]} 371 372 // Create a new MData object of kind 373 MData *dat = (MData*)GetNewObject(cls, MData::Class()); 374 if (!dat) 375 return ""; 376 dat->SetName(name); 377 378 // Add a corresponding MDataMember to our list 379 fMembers.AddLast(dat); 380 381 // Make the expression "Regular expression proofed" 382 expr.ReplaceAll("[", "\\["); 383 expr.ReplaceAll("]", "\\]"); 384 385 // Find other occurances of arg by this regexp 386 // and start next search behind first match 387 p = pos[0] + Substitute(phrase, expr, idx); 388 389 // Step forward to the next argument 390 idx++; 391 } 392 */ 324 393 // Now we have to check if there are additional indices [idx] 325 394 // This is mainly important if the rule has indices only! -
trunk/MagicSoft/Mars/mhbase/MHn.cc
r8709 r8719 317 317 } 318 318 319 // -------------------------------------------------------------------------- 320 // 321 // Set additional scale factors for the current histogram 322 // 319 323 void MHn::SetScale(Double_t x, Double_t y, Double_t z) const 320 324 { … … 323 327 } 324 328 329 // -------------------------------------------------------------------------- 330 // 331 // Enable or disable displaying log-scale for the current histogram. 332 // Normally it is retrieved from the corresponding MBinning 333 // 325 334 void MHn::SetLog(Bool_t x, Bool_t y, Bool_t z) const 326 335 { … … 328 337 fHist[fNum-1]->SetLog(x, y, z); 329 338 } 339 340 // -------------------------------------------------------------------------- 341 // 342 // Set the axis range in Finalize automatically to the histogram region 343 // containing contents. This is the default for the x-axis. 344 // This function can be used to enable this behaviour also for the other 345 // axis, or disable it for the x-axis of the current histogram. 346 // 330 347 void MHn::SetAutoRange(Bool_t x, Bool_t y, Bool_t z) const 331 348 { … … 334 351 } 335 352 353 // -------------------------------------------------------------------------- 354 // 355 // Call Sumw2 for trhe current histogram, enabling errors. 356 // 336 357 void MHn::Sumw2() const 337 358 { … … 340 361 } 341 362 363 // -------------------------------------------------------------------------- 364 // 365 // Force the given binning(s) for the current histogram. The binnings 366 // do not get owned. The user is responsible for deleting them. 367 // 342 368 void MHn::SetBinnings(MBinning *x, MBinning *y, MBinning *z) const 343 369 { -
trunk/MagicSoft/Mars/mhflux/MHDisp.cc
r7616 r8719 70 70 // 71 71 MHDisp::MHDisp(const char *name, const char *title) 72 : fDisp(0), fDeviation(0), fS mearing(-1), fWobble(kFALSE),72 : fDisp(0), fDeviation(0), fSrcAnti(0), fSmearing(-1), fWobble(kFALSE), 73 73 fScaleMin(0.325), fScaleMax(0.475) 74 74 { … … 81 81 fHist.SetName("Alpha"); 82 82 fHist.SetTitle("3D-plot of ThetaSq vs x, y"); 83 fHist.SetXTitle(" x [\\circ]");84 fHist.SetYTitle(" y [\\circ]");83 fHist.SetXTitle("dx [\\circ]"); 84 fHist.SetYTitle("dy [\\circ]"); 85 85 fHist.SetZTitle("Eq.cts"); 86 86 … … 112 112 } 113 113 114 if (fWobble) 115 { 116 fSrcAnti = (MSrcPosCam*)plist->FindObject("MSrcPosAnti", "MSrcPosCam"); 117 if (!fSrcAnti) 118 { 119 *fLog << err << "MSrcPosAnti [MSrcPosCam] not found... abort." << endl; 120 return kFALSE; 121 } 122 123 *fLog << inf << "Wobble mode initialized. " << endl; 124 } 125 114 126 fDeviation = (MPointingDev*)plist->FindObject("MPointingDev"); 115 127 if (!fDeviation) … … 132 144 // -------------------------------------------------------------------------- 133 145 // 134 // Calculate the delta angle between fSrcPos->GetXY() and v.135 // Return result in deg.136 //137 Double_t MHDisp::DeltaPhiSrc(const TVector2 &v) const138 {139 return TMath::Abs(fSrcPos->GetXY().DeltaPhi(v))*TMath::RadToDeg();140 }141 142 // --------------------------------------------------------------------------143 //144 146 // Fill the histogram. For details see the code or the class description 145 147 // … … 162 164 TVector2 pos1 = hil->GetMean()*fMm2Deg + hil->GetNormAxis()*fDisp->GetVal(); 163 165 166 const TVector2 src = fSrcPos->GetXY()*fMm2Deg; 167 164 168 Double_t w0 = 1; 165 169 if (fWobble) 166 170 { 167 const Double_t delta = DeltaPhiSrc(pos1);171 const TVector2 anti = fSrcAnti->GetXY()*fMm2Deg; 168 172 169 173 // Skip off-data not in the same half than the source (here: anti-source) … … 171 175 if (!fHistOff) 172 176 { 173 if (delta>180-25) 177 Double_t r = anti.Mod()>0.2*1.7 ? 0.2*1.7 : anti.Mod(); 178 179 // In wobble mode processing the off-data, the anti-source 180 // position is our source position. Check if this is a possible 181 // gamma. If it is, do not fill it into our off-data histogram 182 if ((pos1-anti).Mod()<r) 174 183 return kTRUE; 175 184 … … 181 190 // increased uncertainty 182 191 // FIXME: The delta stuff could be replaced by a 2*antitheta cut... 183 w0 = delta>25 ? 1 : 2; 184 } 192 //w0 = delta>25 ? 1 : 2; 193 194 w0 = (pos1+anti).Mod()<r ? 2 : 1; 195 } 196 197 // When processing off-data the anti-source is the real source 198 const TVector2 srcpos = fHistOff ? src : anti; 185 199 186 200 // Define by the source position which histogram to fill 187 if ( DeltaPhiSrc(fFormerSrc)>90)201 if (TMath::Abs(srcpos.DeltaPhi(fFormerSrc))*TMath::RadToDeg()>90) 188 202 fHalf = !fHalf; 189 fFormerSrc = fSrcPos->GetXY();203 fFormerSrc = srcpos; 190 204 } 191 205 … … 202 216 { 203 217 // m: Position of the camera center in the FS plot 204 m = fSrcPos->GetXY().Rotate(-rho)*fMm2Deg;218 m = src.Rotate(-rho); 205 219 pos1 -= m; 206 220 } … … 410 424 const TAxis &axey = *h2.GetYaxis(); 411 425 412 const Double_t rmax = (fWobble ? axex.GetXmax() -0.4: axex.GetXmax()) - axex.GetBinWidth(1);426 const Double_t rmax = (fWobble ? axex.GetXmax()/*-0.7*/ : axex.GetXmax()) - axex.GetBinWidth(1); 413 427 414 428 for (int x=1; x<=axex.GetNbins(); x++) -
trunk/MagicSoft/Mars/mhflux/MHDisp.h
r7616 r8719 25 25 MPointingDev *fDeviation; //! 26 26 //MSrcPosCam *fAxis; //! 27 MSrcPosCam *fSrcAnti; //! 28 27 29 28 30 TH2D fHistBg; … … 41 43 // MHDisp 42 44 Double_t GetOffSignal(TH1 &h) const; 43 Double_t DeltaPhiSrc(const TVector2 &v) const;44 45 45 46 void Update(); -
trunk/MagicSoft/Mars/mhflux/MMcSpectrumWeight.cc
r8709 r8719 493 493 if (hasold) 494 494 { 495 *fLog << " Old Spectrum: " << GetFormulaSpecOldX();495 *fLog << " Old Spectrum: " << GetFormulaSpecOldX(); 496 496 if (fEnergyMin>=0 && fEnergyMax>0) 497 497 *fLog << " (I=" << GetSpecOldIntegral() << ")"; … … 500 500 if (hasnew) 501 501 { 502 *fLog << " New Spectrum: " << GetFormulaSpecNewX();502 *fLog << " New Spectrum: " << GetFormulaSpecNewX(); 503 503 if (fEnergyMin>=0 && fEnergyMax>0) 504 504 *fLog << " (I=" << GetSpecNewIntegral() << ")"; … … 506 506 } 507 507 if (fFunc) 508 *fLog << " Weight func: " << fFunc->GetTitle() << endl;508 *fLog << " Weight func: " << fFunc->GetTitle() << endl; 509 509 } 510 510 -
trunk/MagicSoft/Mars/mjobs/MJCut.cc
r8709 r8719 550 550 return kFALSE; 551 551 } 552 553 if (!HasWritePermission(GetOutputFile(set.GetNumAnalysis()))) 554 return kFALSE; 552 555 553 556 CheckEnv(); -
trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc
r8709 r8719 1009 1009 spectrum.SetMarkerStyle(kFullDotMedium); 1010 1010 spectrum.SetTitle("Differential flux times E^{2}"); 1011 spectrum.SetYTitle("E^{2} #cdot dN/dE [N#cdotTeV/sm^{2}]");1011 spectrum.SetYTitle("E^{2}·dN/dE [N·TeV/sm^{2}]"); 1012 1012 spectrum.SetDirectory(0); 1013 1013 spectrum.DrawCopy(); … … 1316 1316 } 1317 1317 1318 if (!HasWritePermission(GetPathOut())) 1319 return kFALSE; 1320 1318 1321 CheckEnv(); 1319 1322 … … 1324 1327 *fLog << "Compile Monte Carlo Sample (data set " << set.GetName() << ")" << endl; 1325 1328 *fLog << endl; 1329 1330 if (fDisplay) 1331 fDisplay->SetWindowName(fName); 1326 1332 1327 1333 // Setup everything which is read from the ganymed file … … 1616 1622 tlist2.SetAccelerator(MTask::kAccDontReset|MTask::kAccDontTime); 1617 1623 1618 MEvtLoop loop2( "FillMonteCarlo"); // ***** fName *****1624 MEvtLoop loop2(fName); // ***** fName ***** 1619 1625 loop2.SetParList(&plist); 1620 1626 loop2.SetDisplay(fDisplay); … … 1685 1691 cont.Add(fDisplay); 1686 1692 1687 return WriteContainer(cont, "", "RECREATE"); 1688 } 1693 if (!WriteContainer(cont, "", "RECREATE")) 1694 { 1695 *fLog << err << GetDescriptor() << ": Writing result failed." << endl; 1696 return kFALSE; 1697 } 1698 1699 *fLog << all << GetDescriptor() << ": Done." << endl; 1700 *fLog << endl << endl; 1701 1702 return kTRUE; 1703 } -
trunk/MagicSoft/Mars/mjobs/MJob.cc
r8644 r8719 329 329 // 330 330 // Checks whether write permissions to fname exists including 331 // the fOverwrite data amember.331 // the fOverwrite data member. Empty file names return kTRUE 332 332 // 333 333 Bool_t MJob::HasWritePermission(TString fname) const … … 346 346 } 347 347 348 if ( !fOverwrite)348 if (fOverwrite) 349 349 return kTRUE; 350 350 -
trunk/MagicSoft/Mars/mjtrain/MJTrainDisp.cc
r8704 r8719 43 43 // opt.Train("rf-disp.root", set, 30000); // Number of train events 44 44 // 45 // // Two of the displayed histograms show the cut efficiency for 46 // // a given Theta-Cut. The default is 0.215. It can be overwritten 47 // // by 48 // opt.SetThetaCut(0.165); 49 // 45 50 // 46 51 // Random Numbers: … … 227 232 Bool_t MJTrainDisp::Train(const char *out, const MDataSet &set, Int_t num) 228 233 { 229 SetTitle(Form("Train Disp: %s", out));234 SetTitle(Form("Train%s: %s", fNameOutput.Data(), out)); 230 235 231 236 if (fDisplay) … … 282 287 283 288 // ------------------------ Train RF -------------------------- 284 MRanForestCalc rf("Train Disp", fTitle);289 MRanForestCalc rf("Train", fTitle); 285 290 rf.SetNumTrees(fNumTrees); 286 291 rf.SetNdSize(fNdSize); … … 292 297 rf.SetFileName(out); 293 298 rf.SetDebug(fDebug>1); 294 rf.SetNameOutput("Disp"); 299 rf.SetNameOutput(fNameOutput); 300 rf.SetFunction(fResultFunction); 295 301 296 302 /* … … 319 325 320 326 MParameterD par("ThetaSquaredCut"); 321 par.SetVal( 0.215*0.215);327 par.SetVal(fThetaCut*fThetaCut); 322 328 plist.AddToList(&par); 323 329 -
trunk/MagicSoft/Mars/mjtrain/MJTrainDisp.h
r8656 r8719 17 17 18 18 TString fTrainParameter; 19 TString fResultFunction; 20 21 Float_t fThetaCut; 22 23 // To be moved to a base class 24 TString fNameOutput; 19 25 20 26 void DisplayHist(TCanvas &c, Int_t i, MH3 &mh3) const; … … 22 28 23 29 public: 24 MJTrainDisp() : fTrainParameter(fgTrainParameter) { }30 MJTrainDisp() : fTrainParameter(fgTrainParameter), fResultFunction("x"), fThetaCut(0.215), fNameOutput("Disp") { } 25 31 26 32 void SetTrainParameter(const char *txt) { fTrainParameter=txt; } 33 34 void SetThetaCut(Float_t cut=0.215) { fThetaCut=cut; } 27 35 28 36 Bool_t Train(const char *out, const MDataSet &set, Int_t num); -
trunk/MagicSoft/Mars/mjtrain/MJTrainEnergy.cc
r8704 r8719 89 89 Bool_t MJTrainEnergy::Train(const char *out, const MDataSet &set, Int_t num) 90 90 { 91 SetTitle(Form("Train Energy: %s", out));91 SetTitle(Form("Train%s: %s", fNameOutput.Data(), out)); 92 92 93 93 if (fDisplay) … … 128 128 if (fEnableWeights) 129 129 train.AddColumn("MWeight.fVal"); 130 train.AddColumn("MMcEvt.fImpact/100");131 train.AddColumn("MMcEvt.fTelescopeTheta*TMath::RadToDeg()");132 130 train.AddColumn(fTrainParameter); 133 134 131 135 132 // ----------------------- Fill Matrix RF ---------------------- … … 147 144 148 145 // ------------------------ Train RF -------------------------- 149 MRanForestCalc rf("Train Energy", fTitle);146 MRanForestCalc rf("Train", fTitle); 150 147 rf.SetNumTrees(fNumTrees); 151 148 rf.SetNdSize(fNdSize); 152 149 rf.SetNumTry(fNumTry); 153 rf.SetNumObsoleteVariables( 3);150 rf.SetNumObsoleteVariables(1); 154 151 rf.SetLastDataColumnHasWeights(fEnableWeights); 155 152 rf.SetDisplay(fDisplay); … … 157 154 rf.SetFileName(out); 158 155 rf.SetDebug(fDebug>1); 159 rf.SetNameOutput( "MEnergyEst");156 rf.SetNameOutput(fNameOutput); 160 157 rf.SetFunction(fResultFunction); 161 158 … … 175 172 176 173 gLog.Separator("Test"); 174 175 MH::SetPalette("pretty"); 177 176 178 177 MParList plist; -
trunk/MagicSoft/Mars/mjtrain/MJTrainEnergy.h
r8704 r8719 14 14 TString fResultFunction; 15 15 16 // To be moved to a base class 17 TString fNameOutput; 18 16 19 public: 17 MJTrainEnergy() { SetTrainLin(); }20 MJTrainEnergy() : fNameOutput("MEnergyEst") { SetTrainLin(); } 18 21 19 22 void SetTrainLog() { SetTrainFunc("log10(MMcEvt.fEnergy)", "pow(10, x)"); } -
trunk/MagicSoft/Mars/mpointing/MSrcPosCalc.cc
r8636 r8719 178 178 *fLog << inf; 179 179 *fLog << "MSourcePos [MPointPos] not found... The source position" << endl; 180 *fLog << "set in MSrcPosCam will be set to (0/0) or in the case" << endl;180 *fLog << "set in MSrcPosCam will be set to (0/0) or in the case" << endl; 181 181 *fLog << "of Monte Carlo set to the appropriate wobble position." << endl; 182 182 return kTRUE; … … 331 331 332 332 return kTRUE; 333 }334 335 // --------------------------------------------------------------------------336 //337 // Loc0LocToCam338 //339 // Input : (theta0, phi0) direction for the position (0,0) in the camera340 // ( theta, phi) some other direction341 //342 // Output : (X, Y) position in the camera corresponding to (theta, phi)343 //344 TVector2 MSrcPosCalc::CalcXYinCamera(const MVector3 &pos0, const MVector3 &pos) const345 {346 const Double_t theta0 = pos0.Theta();347 const Double_t phi0 = pos0.Phi();348 349 const Double_t theta = pos.Theta();350 const Double_t phi = pos.Phi();351 352 //--------------------------------------------353 354 /* --- OLD ---355 const Double_t YC0 = TMath::Cos(theta0)*TMath::Tan(theta)*TMath::Cos(phi-phi0) - TMath::Sin(theta0);356 const Double_t YC1 = TMath::Cos(theta0) + TMath::Sin(theta0)*TMath::Tan(theta);357 const Double_t YC = YC0 / YC1;358 359 const Double_t XC0 = TMath::Cos(theta0) - YC*TMath::Sin(theta0);360 const Double_t XC = -TMath::Sin(phi-phi0) * TMath::Tan(theta) * XC0;361 */362 363 /* --- NEW --- Same as MSrcPosCorrect::CalcXYinCamera */364 const Double_t XC0 = TMath::Sin(theta)*TMath::Sin(phi-phi0);365 const Double_t XC1 = TMath::Cos(theta0)*TMath::Cos(theta);366 const Double_t XC2 = TMath::Sin(theta0)*TMath::Sin(theta)*TMath::Cos(phi-phi0);367 368 const Double_t YC0 = TMath::Sin(theta0)*TMath::Cos(theta);369 const Double_t YC1 = TMath::Cos(theta0)*TMath::Sin(theta)*TMath::Cos(phi-phi0);370 371 const Double_t XC = - XC0 / (XC1 + XC2);372 const Double_t YC = (-YC0+YC1) / (XC1 + XC2);373 374 //--------------------------------------------375 return TVector2(XC, YC);376 333 } 377 334 … … 428 385 429 386 // Calculate source position in camera, and convert to mm: 430 TVector2 v = CalcXYinCamera(pos0, pos)*fGeom->GetCameraDist()*1000;387 TVector2 v = MAstro::GetDistOnPlain(pos0, pos, -fGeom->GetCameraDist()*1000); 431 388 432 389 if (fDeviation) -
trunk/MagicSoft/Mars/mpointing/MSrcPosCalc.h
r8636 r8719 53 53 void SetSrcPos(TVector2 v=TVector2()) const; 54 54 TVector2 Rotate(TVector2 v, Int_t pass, Int_t num) const; 55 TVector2 CalcXYinCamera(const MVector3 &pos0, const MVector3 &pos) const;56 55 TString GetRaDec(const MPointingPos &pos) const; 57 56 Bool_t GetCoordinate(TString str, Double_t &ret) const; -
trunk/MagicSoft/Mars/mpointing/MSrcPosCorrect.cc
r7388 r8719 18 18 ! Author(s): Thomas Bretz 6/2005 <mailto:tbretz@astro.uni-wuerzburg.de> 19 19 ! 20 ! Copyright: MAGIC Software Development, 2000-200 520 ! Copyright: MAGIC Software Development, 2000-2007 21 21 ! 22 22 ! … … 27 27 // MSrcPosCorrect 28 28 // 29 // For more details see Process() 30 // 31 ////////////////////////////////////////////////////////////////////////////// 32 #include "MSrcPosCorrect.h" 33 34 #include <TVector2.h> 35 36 #include "MParList.h" 37 38 #include "MLog.h" 39 #include "MLogManip.h" 40 41 #include "MGeomCam.h" 42 #include "MSrcPosCam.h" 43 #include "MRawRunHeader.h" 44 #include "MReportStarguider.h" 45 46 ClassImp(MSrcPosCorrect); 47 48 using namespace std; 49 50 // -------------------------------------------------------------------------- 51 // 52 MSrcPosCorrect::MSrcPosCorrect(const char *name, const char *title) 53 : fSrcPosCam(NULL), fSrcPosAnti(NULL), fAxis(NULL), fGeom(NULL) 54 , fDx(-14.24) , fDy(-9.495) 55 56 { 57 fName = name ? name : "MSrcPosCorrect"; 58 fTitle = title ? title : "Calculates the source position in the camera"; 59 } 60 61 // -------------------------------------------------------------------------- 62 // 63 // Search and if necessary create MSrcPosCam in the parameter list. Search 64 // MSourcePos. If not found, do nothing else, and skip the task. If MSrcPosCam 65 // did not exist before and has been created here, it will contain as source 66 // position the camera center (0,0). 67 // In the case that MSourcePos is found, go ahead in searching the rest of 68 // necessary containers. The source position will be calculated for each 69 // event in Process. 70 // 71 Int_t MSrcPosCorrect::PreProcess(MParList *pList) 72 { 73 fSrcPosCam = (MSrcPosCam*)pList->FindObject("MSrcPosCam"); 74 if (!fSrcPosCam) 75 { 76 *fLog << err << "MSrcPosCam not found... aborting." << endl; 77 return kFALSE; 78 } 79 80 fSrcPosAnti = (MSrcPosCam*)pList->FindObject("MSrcPosAnti", "MSrcPosCam"); 81 82 fAxis = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam", "OpticalAxis"); 83 if (!fAxis) 84 return kFALSE; 85 86 return kTRUE; 87 } 88 89 // -------------------------------------------------------------------------- 90 // 91 // Checking for file type. If the file type is Monte Carlo the 92 // source position is arbitrarily determined from the MC headers. 93 // 94 Bool_t MSrcPosCorrect::ReInit(MParList *plist) 95 { 96 MRawRunHeader *run = (MRawRunHeader*)plist->FindObject("MRawRunHeader"); 97 if (!run) 98 { 99 *fLog << err << "MRawRunHeader not found... aborting." << endl; 100 return kFALSE; 101 } 102 103 fRunType = run->GetRunType(); 104 fRunNumber = run->GetRunNumber(); 105 106 if (fRunNumber<56161 && fRunNumber>53832) 107 { 108 *fLog << inf << "Run Number " << fRunNumber << " between 53832 and 56161." << endl; 109 *fLog << "A misfocussing correction (" << fDx << "mm/" << fDy << "mm) will be applied." << endl; 110 } 111 112 return kTRUE; 113 } 114 115 // -------------------------------------------------------------------------- 116 // 117 // Performs source position correction in the camera. 29 // Performs a misfocussing correction for source and anti-source position 30 // in the camera, i.e. it is assumed that the telscope is pointing well 31 // (all starguider and other corrections are already applied to the 32 // source positon) but the mirror is not focussing to the center of 33 // the camera. 34 // 118 35 // Due to missfocussing a shift of 119 36 // dx=0.048deg and dy=0.034deg … … 121 38 // dx=14.24mm and dy=9.495mm 122 39 // is added between run 53832 (excl) and 56161 (excl) 40 // 123 41 // 124 42 // See also: Runbook … … 153 71 // W-Comae 154 72 // 73 // 74 // For more details see Process() 75 // 76 // Input: 77 // MSrcPosCam 78 // MSrcPosAnti [MSrcPosCam] 79 // 80 // Output: 81 // OpticalAxis [MSrcPosCam] 82 // MSrcPosCam 83 // MSrcPosAnti [MSrcPosCam] 84 // 85 ////////////////////////////////////////////////////////////////////////////// 86 #include "MSrcPosCorrect.h" 87 88 #include <TVector2.h> 89 90 #include "MParList.h" 91 92 #include "MLog.h" 93 #include "MLogManip.h" 94 95 #include "MGeomCam.h" 96 #include "MSrcPosCam.h" 97 #include "MRawRunHeader.h" 98 #include "MReportStarguider.h" 99 100 ClassImp(MSrcPosCorrect); 101 102 using namespace std; 103 104 // -------------------------------------------------------------------------- 105 // 106 MSrcPosCorrect::MSrcPosCorrect(const char *name, const char *title) 107 : fSrcPosCam(NULL), fSrcPosAnti(NULL), fAxis(NULL), fGeom(NULL) 108 , fDx(-14.24) , fDy(-9.495) 109 110 { 111 fName = name ? name : "MSrcPosCorrect"; 112 fTitle = title ? title : "Calculates the source position in the camera"; 113 } 114 115 // -------------------------------------------------------------------------- 116 // 117 // Search and if necessary create MSrcPosCam in the parameter list. Search 118 // MSourcePos. If not found, do nothing else, and skip the task. If MSrcPosCam 119 // did not exist before and has been created here, it will contain as source 120 // position the camera center (0,0). 121 // In the case that MSourcePos is found, go ahead in searching the rest of 122 // necessary containers. The source position will be calculated for each 123 // event in Process. 124 // 125 Int_t MSrcPosCorrect::PreProcess(MParList *pList) 126 { 127 fSrcPosCam = (MSrcPosCam*)pList->FindObject("MSrcPosCam"); 128 if (!fSrcPosCam) 129 { 130 *fLog << err << "MSrcPosCam not found... aborting." << endl; 131 return kFALSE; 132 } 133 134 fSrcPosAnti = (MSrcPosCam*)pList->FindObject("MSrcPosAnti", "MSrcPosCam"); 135 136 fAxis = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam", "OpticalAxis"); 137 if (!fAxis) 138 return kFALSE; 139 140 return kTRUE; 141 } 142 143 // -------------------------------------------------------------------------- 144 // 145 // Checking for file type. If the file type is Monte Carlo the 146 // source position is arbitrarily determined from the MC headers. 147 // 148 Bool_t MSrcPosCorrect::ReInit(MParList *plist) 149 { 150 MRawRunHeader *run = (MRawRunHeader*)plist->FindObject("MRawRunHeader"); 151 if (!run) 152 { 153 *fLog << err << "MRawRunHeader not found... aborting." << endl; 154 return kFALSE; 155 } 156 157 fRunType = run->GetRunType(); 158 fRunNumber = run->GetRunNumber(); 159 160 if (fRunNumber<56161 && fRunNumber>53832) 161 { 162 *fLog << inf << "Run Number " << fRunNumber << " between 53832 and 56161." << endl; 163 *fLog << "A misfocussing correction (" << fDx << "mm/" << fDy << "mm) will be applied." << endl; 164 } 165 166 return kTRUE; 167 } 168 169 // -------------------------------------------------------------------------- 170 // 171 // The offset fDx/fDy is subtracted from the source position. The anti- 172 // source position is shifted away from the camera-center and rotated 173 // around the camera center according to this correction, because it 174 // should always be symmetric w.r.t. the camera-center, but it is not 175 // necessary on the other side of the camera (e.g. three off-regions). 176 // 155 177 Int_t MSrcPosCorrect::Process() 156 178 { … … 158 180 return kTRUE; 159 181 160 TVector2 d; 161 if (fRunNumber<56161 && fRunNumber>53832) 162 { 163 // dx=-0.048deg, dy=0.034deg, d=0.059deg 164 static const TVector2 dxy(fDx, fDy); 165 166 d -= dxy; 167 } 168 169 fAxis->SetXY(d); 170 fSrcPosCam->Add(d); 171 if (fSrcPosAnti) 172 { 173 d *= -1; // Anti-Source position should always be symetric 174 fSrcPosAnti->Add(d); 175 } 182 if (fRunNumber<=53832 || fRunNumber>=56161) 183 return kTRUE; 184 185 // dx=-0.048deg, dy=0.034deg, d=0.059deg 186 const TVector2 dxy(-fDx, -fDy); 187 188 const TVector2 s1(fSrcPosCam->GetXY()); 189 const TVector2 a1(fSrcPosAnti->GetXY()); 190 const TVector2 s2 = s1 + dxy; 191 192 193 // Anti-Source position should always be symetric w.r.t. camera center 194 TVector2 a2; 195 a2.SetMagPhi(a1.Mod()+s2.Mod()-s1.Mod(), a1.Phi()+s2.DeltaPhi(s1)); 196 197 fAxis->SetXY(dxy); 198 fSrcPosCam->SetXY(s2); 199 fSrcPosAnti->SetXY(s2); 176 200 177 201 return kTRUE; 178 202 } 179 203 204 // -------------------------------------------------------------------------- 205 // 206 // MSrcPosCorrect.Dx: -14.24 207 // MSrcPosCorrect.Dy: -9.495 208 // 209 // For a detailed description see the class reference. 210 // 180 211 Int_t MSrcPosCorrect::ReadEnv(const TEnv &env, TString prefix, Bool_t print) 181 212 { -
trunk/MagicSoft/Mars/mpointing/MSrcPosCorrect.h
r7388 r8719 14 14 { 15 15 private: 16 MSrcPosCam *fSrcPosCam; //! 17 MSrcPosCam *fSrcPosAnti; //! 18 MSrcPosCam *fAxis; //! 16 MSrcPosCam *fSrcPosCam; //! Source position 17 MSrcPosCam *fSrcPosAnti; //! Anti source position 18 MSrcPosCam *fAxis; //! New "center of camera" 19 19 20 MGeomCam *fGeom; //! 20 MGeomCam *fGeom; //! Camera geometry 21 21 22 22 UShort_t fRunType; //! Run Type to decide where to get pointing position from 23 UInt_t fRunNumber; 23 UInt_t fRunNumber; //! Current run number 24 24 25 Float_t fDx; 26 Float_t fDy; 25 Float_t fDx; // [mm] Correction in x 26 Float_t fDy; // [mm] Correction in y 27 27 28 28 // MTask … … 36 36 MSrcPosCorrect(const char *name=NULL, const char *title=NULL); 37 37 38 ClassDef(MSrcPosCorrect, 0) // Corrects MSrcP OsCam for missfocussing38 ClassDef(MSrcPosCorrect, 0) // Corrects MSrcPosCam for missfocussing 39 39 }; 40 40 -
trunk/MagicSoft/Mars/sponde.cc
r8709 r8719 144 144 const TString kOutfile = arg.GetArgumentStr(2); 145 145 146 if (kOutfile.IsNull() && kBatch) 147 { 148 gLog << err << "Writing no outputfile but running in batch mode is nonsense." << endl; 149 return 2; 150 } 151 146 152 if (gSystem->AccessPathName(kInfile, kFileExists)) 147 153 { … … 211 217 } 212 218 213 MJSpectrum job(Form(" MJSpectrum #%d", seq.GetNumAnalysis()));219 MJSpectrum job(Form("Spectrum - %s", seq.GetName())); 214 220 job.SetEnv(&env); 215 221 job.SetEnvDebug(kDebugEnv); … … 221 227 job.ForceTheta(kForceTheta); 222 228 223 if (!job.HasWritePermission(kOutfile))224 return 2;225 226 229 if (!job.Process(seq)) 227 230 {
Note:
See TracChangeset
for help on using the changeset viewer.