Changeset 7173
- Timestamp:
- 06/28/05 10:22:44 (20 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r7172 r7173 21 21 22 22 -*-*- END OF LINE -*-*- 23 24 2005/06/28 Thomas Bretz 25 26 * mfilter/MFMagicCuts.[h,cc]: 27 - first full implemtation... updates to come. 28 29 * mhbase/MH.[h,cc]: 30 - added new member function to set several palettes 31 32 * mhflux/MHDisp.[h,cc]: 33 - fixed z-axis dscription 34 - rotate filling off data by 180 deg. 35 - implemented subtracting off-data from on-data 36 - set different palettes 37 38 23 39 24 40 2005/06/27 Thomas Bretz -
trunk/MagicSoft/Mars/NEWS
r7172 r7173 12 12 13 13 - general: MHCamera now displays the profiles in deg instead of mm 14 15 - general: MH::SetPalette offers a lot of new palettes 14 16 15 17 - callisto: MCalibrationHiLoCam can now be printed from its context … … 27 29 argument 28 30 31 - ganymed: The first version of MFMagicCuts have been released 32 29 33 - ganymed: the Conc1 plot was incorrectly scaled in MHVsSize 30 34 … … 32 36 of bins for the signal region (NumBinsSignal) and the number of 33 37 total bins (NumBInsTital) in the MHThetaSq histogram 38 39 - ganymed: optimized palettes for MHDisp 34 40 35 41 - sponde: the zenith angle distribution is now weighted instead of -
trunk/MagicSoft/Mars/mfilter/MFMagicCuts.cc
r6898 r7173 30 30 #include "MFMagicCuts.h" 31 31 32 #include <fstream> 33 34 #include "MHMatrix.h" 35 36 #include "MLog.h" 37 #include "MLogManip.h" 38 39 #include "MParList.h" 40 41 #include "MGeomCam.h" 42 #include "MHillasSrc.h" 43 #include "MHillasExt.h" 44 #include "MParameters.h" 45 #include "MPointingPos.h" 46 32 47 ClassImp(MFMagicCuts); 33 48 34 49 using namespace std; 35 50 36 37 51 // -------------------------------------------------------------------------- 38 52 // … … 40 54 // 41 55 MFMagicCuts::MFMagicCuts(const char *name, const char *title) 56 : fHil(0), fHilSrc(0), fHilAnti(0), fHilExt(0), fThetaSq(0), 57 fDisp(0), fPointing(0), fMatrix(0), fVariables(30), fThetaCut(kNone), 58 fHadronnessCut(kAll) 42 59 { 43 60 fName = name ? name : "MFMagicCuts"; 44 61 fTitle = title ? title : "Class to evaluate the MagicCuts"; 45 } 62 63 fMatrix = NULL; 64 65 AddToBranchList("MHillas.fWidth"); 66 AddToBranchList("MHillas.fLength"); 67 AddToBranchList("MHillas.fSize"); 68 AddToBranchList("MHillasSrc.fAlpha"); 69 AddToBranchList("MHillasSrcAnti.fAlpha"); 70 AddToBranchList("MPointingPos.fZd"); 71 AddToBranchList("MHillasExt.fMaxDist"); 72 AddToBranchList("MHillasExt.fM3Long"); 73 74 fVariables[0] = 1.42547; // Xi 75 fVariables[1] = 0.233773; // Theta^2 76 fVariables[2] = 0.2539460; // Area[0] 77 fVariables[3] = 5.2149800; // Area[1] 78 fVariables[4] = 0.1139130; // Area[2] 79 fVariables[5] = -0.0889; // M3long 80 fVariables[6] = 0.18; // Xi(theta) 81 } 82 83 // -------------------------------------------------------------------------- 84 // 85 // The theta cut value GetThetaSqCut() is propageted to the parameter list 86 // as 'ThetaSquaredCut' as MParameterD so that it can be used somewhere else. 87 // 88 Int_t MFMagicCuts::PreProcess(MParList *pList) 89 { 90 MGeomCam *cam = (MGeomCam*)pList->FindObject("MGeomCam"); 91 if (!cam) 92 { 93 *fLog << err << "MGeomCam not found... aborting." << endl; 94 return kFALSE; 95 } 96 97 fMm2Deg = cam->GetConvMm2Deg(); 98 99 fThetaSq = (MParameterD*)pList->FindCreateObj("MParameterD", "ThetaSquared"); 100 if (!fThetaSq) 101 return kFALSE; 102 fDisp = (MParameterD*)pList->FindCreateObj("MParameterD", "Disp"); 103 if (!fDisp) 104 return kFALSE; 105 106 // propagate Theta cut to the parameter list 107 // so that it can be used somewhere else 108 MParameterD *thetacut = (MParameterD*)pList->FindCreateObj("MParameterD", "ThetaSquaredCut"); 109 if (!thetacut) 110 return kFALSE; 111 thetacut->SetVal(GetThetaSqCut()); 112 //thetacut->SetReadyToSave(); 113 114 MParameterD *m3lcut = (MParameterD*)pList->FindCreateObj("MParameterD", "M3lCut"); 115 if (!m3lcut) 116 return kFALSE; 117 m3lcut->SetVal(fVariables[5]); 118 119 MParameterD *dispxi = (MParameterD*)pList->FindCreateObj("MParameterD", "DispXi"); 120 if (!dispxi) 121 return kFALSE; 122 dispxi->SetVal(fVariables[0]); 123 124 dispxi = (MParameterD*)pList->FindCreateObj("MParameterD", "DispXiTheta"); 125 if (!dispxi) 126 return kFALSE; 127 dispxi->SetVal(fVariables[6]); 128 129 Print(); 130 131 if (fMatrix) 132 return kTRUE; 133 134 //----------------------------------------------------------- 135 136 fHil = (MHillas*)pList->FindObject("MHillas"); 137 if (!fHil) 138 { 139 *fLog << err << "MHillas not found... aborting." << endl; 140 return kFALSE; 141 } 142 143 fHilExt = (MHillasExt*)pList->FindObject("MHillasExt"); 144 if (!fHilExt) 145 { 146 *fLog << err << "MHillasExt not found... aborting." << endl; 147 return kFALSE; 148 } 149 150 fPointing = (MPointingPos*)pList->FindObject("MPointingPos"); 151 if (!fPointing) 152 { 153 *fLog << err << "MPointingPos not found... aborting." << endl; 154 return kFALSE; 155 } 156 157 fHilSrc = (MHillasSrc*)pList->FindObject("MHillasSrc"); 158 if (!fHilSrc) 159 { 160 *fLog << err << "MHillasSrc not found... aborting." << endl; 161 return kFALSE; 162 } 163 164 if (fThetaCut&kOff) 165 { 166 fHilAnti = (MHillasSrc*)pList->FindObject("MHillasSrcAnti", "MHillasSrc"); 167 if (!fHilAnti) 168 { 169 *fLog << warn << "MHillasSrcAnti [MHillasSrc] not found... aborting." << endl; 170 return kFALSE; 171 } 172 } 173 174 return kTRUE; 175 } 176 177 // -------------------------------------------------------------------------- 178 // 179 // Returns the mapped value from the Matrix 180 // 181 Double_t MFMagicCuts::GetVal(Int_t i) const 182 { 183 return (*fMatrix)[fMap[i]]; 184 } 185 186 // -------------------------------------------------------------------------- 187 // 188 // You can use this function if you want to use a MHMatrix instead of the 189 // given containers. This function adds all necessary columns to the 190 // given matrix. Afterward you should fill the matrix with the corresponding 191 // data (eg from a file by using MHMatrix::Fill). If you now loop 192 // through the matrix (eg using MMatrixLoop) MEnergyEstParam::Process 193 // will take the values from the matrix instead of the containers. 194 // 195 void MFMagicCuts::InitMapping(MHMatrix *mat) 196 { 197 if (fMatrix) 198 return; 199 200 fMatrix = mat; 201 202 fMap[kESize] = fMatrix->AddColumn("log10(MHillas.fSize)"); 203 fMap[kEArea] = fMatrix->AddColumn("MHillas.GetArea*MGeomCam.fConvMm2Deg*MGeomCam.fConvMm2Deg"); 204 fMap[kEM3Long] = fMatrix->AddColumn("MHillasExt.fM3Long*sign(MHillasSrc.fCosDeltaAlpha)*MGeomCam.fConvMm2Deg"); 205 fMap[kEWdivL] = fMatrix->AddColumn("MHillas.fWidth/MHillas.fLength"); 206 fMap[kEZd] = fMatrix->AddColumn("MPointingPos.GetZdRad"); 207 208 fMap[kEAlpha] = fMatrix->AddColumn("MHillasSrc.fAlpha"); 209 fMap[kEDist] = fMatrix->AddColumn("MHillasSrc.fDist*MGeomCam.fConvMm2Deg"); 210 //fMap[kDCA] = fMatrix->AddColumn("MHillasSrc.fDCA*MGeomCam.fConvMm2Deg"); 211 if (fThetaCut&kOff) 212 { 213 fMap[kEAlphaAnti] = fMatrix->AddColumn("MHillasSrcAnti.fAlpha"); 214 fMap[kEDistAnti] = fMatrix->AddColumn("MHillasSrcAnti.fDist*MGeomCam.fConvMm2Deg"); 215 fMap[kEM3LongAnti] = fMatrix->AddColumn("MHillasExt.fM3Long*sign(MHillasSrcAnti.fCosDeltaAlpha)*MGeomCam.fConvMm2Deg"); 216 //fMap[kDCAAnti] = fMatrix->AddColumn("MHillasSrcAnti.fDCA*MGeomCam.fConvMm2Deg"); 217 } 218 219 //fMap[kLength] = fMatrix->AddColumn("MHillas.fLength*MGeomCam.fConvMm2Deg"); 220 //fMap[kWidth] = fMatrix->AddColumn("MHillas.fWidth*MGeomCam.fConvMm2Deg"); 221 } 222 223 // -------------------------------------------------------------------------- 224 // 225 // Returns theta squared based on the formula: 226 // p := c*(1-width/length) 227 // return d*d + p*p - 2*d*p*cos(a*TMath::DegToRad()); 228 // 229 // If par!=NULL p is stored in this MParameterD 230 // 231 Double_t MFMagicCuts::GetThetaSq(Double_t c, Double_t wl, Double_t d, Double_t a, MParameterD *par) const 232 { 233 // wl = width/l [1] 234 // d = dist [deg] 235 // a = alpha [deg] 236 const Double_t p = c*(1-wl); 237 if (par) 238 par->SetVal(p); 239 return d*d + p*p - 2*d*p*cos(a*TMath::DegToRad()); 240 } 241 242 // -------------------------------------------------------------------------- 243 // 244 // Returns squared cut value in theta: fVariables[1]^2 245 // 246 Double_t MFMagicCuts::GetThetaSqCut() const 247 { 248 return fVariables[1]*fVariables[1]; 249 } 250 251 // --------------------------------------------------------------------------- 252 // 253 // Evaluate dynamical magic-cuts 254 // 255 Int_t MFMagicCuts::Process() 256 { 257 // Get some variables 258 const Double_t wdivl = fMatrix ? GetVal(kEWdivL) : fHil->GetWidth()/fHil->GetLength(); 259 const Double_t lgsize = fMatrix ? GetVal(kESize) : TMath::Log10(fHil->GetSize()); 260 const Double_t zd = fMatrix ? GetVal(kEZd) : fPointing->GetZdRad(); 261 262 // For simplicity 263 const Double_t *c = fVariables.GetArray(); 264 265 // Value for Theta cut 266 const Double_t cut = GetThetaSqCut(); //c[1]*c[1]; 267 const Double_t xi = (c[0]+c[8]*(lgsize-c[7])*(lgsize-c[7])) - c[6]*zd*zd; 268 269 // Default if we return before the end 270 fResult = kFALSE; 271 272 // ------------------- Most efficient cut ----------------------- 273 // ---------------------- Theta cut ON -------------------------- 274 const Double_t dist = fMatrix ? GetVal(kEDist) : fHilSrc->GetDist()*fMm2Deg; 275 const Double_t alpha = fMatrix ? GetVal(kEAlpha) : fHilSrc->GetAlpha(); 276 277 const Double_t thetasq = GetThetaSq(xi, wdivl, dist, alpha, fDisp); 278 279 fThetaSq->SetVal(thetasq); 280 281 if (fThetaCut&kOn && thetasq >= cut) 282 return kTRUE; 283 284 // --------------------- Efficient cut ------------------------- 285 // ---------------------- Area/M3l cut -------------------------- 286 if (fHadronnessCut&kArea) 287 { 288 const Double_t area = fMatrix ? GetVal(kEArea) : fHil->GetArea()*fMm2Deg*fMm2Deg; 289 const Double_t A = lgsize>c[3] ? c[2] : c[2]*(1 - c[4]*(lgsize-c[3])*(lgsize-c[3])); 290 if (area>=A) 291 return kTRUE; 292 } 293 if (fHadronnessCut&kM3Long) 294 { 295 const Double_t m3long = fMatrix ? GetVal(kEM3Long) : fHilExt->GetM3Long()*TMath::Sign(fMm2Deg, fHilSrc->GetCosDeltaAlpha()); 296 if (m3long<=c[5]) 297 return kTRUE; 298 } 299 300 // ------------------- Least efficient cut ----------------------- 301 // ---------------------- Theta cut OFF -------------------------- 302 if (fThetaCut&kOff) 303 { 304 const Double_t distanti = fMatrix ? GetVal(kEDistAnti) : fHilAnti->GetDist()*fMm2Deg; 305 const Double_t alphaanti = fMatrix ? GetVal(kEAlphaAnti) : fHilAnti->GetAlpha(); 306 const Double_t thetasqanti = GetThetaSq(xi, wdivl, distanti, alphaanti); 307 const Double_t m3lanti = fMatrix ? GetVal(kEM3LongAnti) : fHilExt->GetM3Long()*TMath::Sign(fMm2Deg, fHilAnti->GetCosDeltaAlpha()); 308 309 if (thetasqanti<cut && (fHadronnessCut&kM3Long || m3lanti>c[5])) 310 return kTRUE; 311 } 312 313 fResult = kTRUE; 314 315 return kTRUE; 316 } 317 318 void MFMagicCuts::SetVariables(const TArrayD &arr) 319 { 320 fVariables = arr; 321 } 322 323 TString MFMagicCuts::GetParam(Int_t i) const 324 { 325 if (i>=fVariables.GetSize()) 326 return ""; 327 328 return Form("Param[%2d]=%+f", i, fVariables[i]); 329 } 330 331 void MFMagicCuts::Print(Option_t *o) const 332 { 333 *fLog << all << GetDescriptor() << ":" << setiosflags(ios::left) << endl; 334 335 *fLog << "Using Theta cut: "; 336 switch (fThetaCut) 337 { 338 case kNone: 339 *fLog << "none" << endl; 340 break; 341 case kOn: 342 *fLog << "on" << endl; 343 break; 344 case kOff: 345 *fLog << "off" << endl; 346 break; 347 case kWobble: 348 *fLog << "on and off (wobble)" << endl; 349 break; 350 } 351 *fLog << "Using hadronness cut: "; 352 switch (fHadronnessCut) 353 { 354 case kNoCut: 355 *fLog << "none" << endl; 356 break; 357 case kArea: 358 *fLog << "area" << endl; 359 break; 360 case kM3Long: 361 *fLog << "m3long" << endl; 362 break; 363 case kAll: 364 *fLog << "all" << endl; 365 break; 366 } 367 *fLog << "Filter is" << (IsInverted()?"":" not") << " inverted." << endl; 368 369 const Int_t n = fVariables.GetSize(); 370 for (int i=0; i<n; i+=3) 371 { 372 *fLog << setw(25) << GetParam(i); 373 *fLog << setw(25) << GetParam(i+1); 374 *fLog << setw(25) << GetParam(i+2); 375 *fLog << endl; 376 } 377 *fLog << setiosflags(ios::right); 378 } 379 380 Bool_t MFMagicCuts::CoefficentsRead(const char *fname) 381 { 382 ifstream fin(fname); 383 if (!fin) 384 { 385 *fLog << err << "Cannot open file " << fname << ": "; 386 *fLog << strerror(errno) << endl; 387 return kFALSE; 388 } 389 390 for (int i=0; i<fVariables.GetSize(); i++) 391 { 392 fin >> fVariables[i]; 393 if (!fin) 394 { 395 *fLog << err << "ERROR - Not enough coefficients in file " << fname << endl; 396 return kERROR; 397 } 398 } 399 return kTRUE; 400 } 401 402 Bool_t MFMagicCuts::CoefficentsWrite(const char *fname) const 403 { 404 ofstream fout(fname); 405 if (!fout) 406 { 407 *fLog << err << "Cannot open file " << fname << ": "; 408 *fLog << strerror(errno) << endl; 409 return kFALSE; 410 } 411 412 for (int i=0; i<fVariables.GetSize(); i++) 413 fout << setw(11) << fVariables[i] << endl; 414 415 return kTRUE; 416 } 417 418 Int_t MFMagicCuts::ReadEnv(const TEnv &env, TString prefix, Bool_t print) 419 { 420 if (MFilter::ReadEnv(env, prefix, print)==kERROR) 421 return kERROR; 422 423 424 Bool_t rc = kFALSE; 425 if (IsEnvDefined(env, prefix, "ThetaCut", print)) 426 { 427 TString str = GetEnvValue(env, prefix, "ThetaCut", ""); 428 str.ToLower(); 429 str=str.Strip(TString::kBoth); 430 431 if (str==(TString)"nocut" || str==(TString)"none") 432 fThetaCut = kNone; 433 if (str==(TString)"on") 434 fThetaCut = kOn; 435 if (str==(TString)"off") 436 fThetaCut = kOff; 437 if (str==(TString)"wobble") 438 fThetaCut = kWobble; 439 rc = kTRUE; 440 } 441 if (IsEnvDefined(env, prefix, "HadronnessCut", print)) 442 { 443 TString str = GetEnvValue(env, prefix, "HadronnessCut", ""); 444 str.ToLower(); 445 str=str.Strip(TString::kBoth); 446 447 if (str==(TString)"nocut" || str==(TString)"none") 448 fHadronnessCut = kNoCut; 449 if (str==(TString)"area") 450 fHadronnessCut = kArea; 451 if (str==(TString)"m3long") 452 fHadronnessCut = kM3Long; 453 if (str==(TString)"all") 454 fHadronnessCut = kAll; 455 456 rc = kTRUE; 457 } 458 459 if (IsEnvDefined(env, prefix, "File", print)) 460 { 461 const TString fname = GetEnvValue(env, prefix, "File", ""); 462 if (!CoefficentsRead(fname)) 463 return kERROR; 464 465 return kTRUE; 466 } 467 468 for (int i=0; i<fVariables.GetSize(); i++) 469 { 470 if (IsEnvDefined(env, prefix, Form("Param%d", i), print)) 471 { 472 // It is important that the last argument is a floating point 473 fVariables[i] = GetEnvValue(env, prefix, Form("Param%d", i), 0.0); 474 rc = kTRUE; 475 } 476 } 477 return rc; 478 //return kTRUE; // means: can use default values 479 //return rc; // means: require something in resource file 480 } -
trunk/MagicSoft/Mars/mfilter/MFMagicCuts.h
r6957 r7173 6 6 #endif 7 7 8 #ifndef ROOT_TArrayD 9 #include <TArrayD.h> 10 #endif 11 12 class MParList; 13 14 class MHillas; 15 class MHillasSrc; 16 class MHillasExt; 17 class MParameterD; 18 class MPointingPos; 8 19 class MHMatrix; 9 20 10 21 class MFMagicCuts : public MFilter 11 22 { 23 public: 24 // Possible kind of theta cuts 25 enum ThetaCut_t { 26 kNone =BIT(0), 27 kOn =BIT(1), 28 kOff =BIT(2), 29 kWobble=kOn|kOff 30 }; 31 // Possible kind of hadronness cuts 32 enum HadronnessCut_t { 33 kNoCut =BIT(0), 34 kArea =BIT(1), 35 kM3Long=BIT(2), 36 kAll =kArea|kM3Long 37 }; 38 12 39 private: 40 // Elements for mapping. kLastElement must not be used and must be 41 // the last on in the list. It is used as counter for fMap. 42 enum { 43 kESize, kEAlpha, kEAlphaAnti, kEArea, kEDist, 44 kEM3Long, kEM3LongAnti, kEDistAnti, kEWdivL, kEZd, 45 kLastElement 46 }; 13 47 14 virtual Bool_t IsExpressionTrue() const { return kTRUE; } 48 MHillas *fHil; //! Pointer to MHillas container 49 MHillasSrc *fHilSrc; //! Pointer to MHillasSrc container 50 MHillasSrc *fHilAnti; //! Pointer to MHillasSrc container called MHillasSrcAnti 51 MHillasExt *fHilExt; //! Pointer to MHillasExt container 52 MParameterD *fThetaSq; //! Pointer to MParameterD container called ThetaSq 53 MParameterD *fDisp; //! Pointer to MParameterD container called Disp 54 MPointingPos *fPointing; //! Pointer to MPointingPos container 55 56 Float_t fMm2Deg; //! Conversion factor from mm to deg, from MGeomCam 57 Bool_t fResult; //! Result of the filter evaluation 58 59 Int_t fMap[kLastElement]; //! Mapping table for fast optimization 60 MHMatrix *fMatrix; //! Matrix thorugh which the mapped elements are accessed 61 62 TArrayD fVariables; // Coefficients of cuts 63 64 ThetaCut_t fThetaCut; // Which kind of theta cut should be evaluated 65 HadronnessCut_t fHadronnessCut; // Which kind of hadronness cut should be evaluated 66 67 // MTask 68 Int_t PreProcess(MParList *pList); 69 Int_t Process(); 70 71 // MFilter 72 Bool_t IsExpressionTrue() const { return fResult; } 73 74 // MFMagicCuts 75 Double_t GetVal(Int_t i) const; 76 TString GetParam(Int_t i) const; 77 Double_t GetThetaSq(Double_t c, Double_t wl, Double_t d, Double_t a, MParameterD *par=0) const; 15 78 16 79 public: 17 80 MFMagicCuts(const char *name=NULL, const char *title=NULL); 18 81 19 void InitMapping(MHMatrix *mat) { }20 void StopMapping() { InitMapping(NULL); }82 // Getter 83 Double_t GetThetaSqCut() const; 21 84 22 ClassDef(MFMagicCuts, 0) // A filter to evaluate the MagicCuts 85 // Setter 86 void SetThetaCut(ThetaCut_t c) { fThetaCut=c; } 87 void SetHadronnessCut(HadronnessCut_t c) { fHadronnessCut=c; } 88 89 // MFMagicCuts 90 void InitMapping(MHMatrix *mat); 91 void StopMapping() { InitMapping(NULL); } 92 93 Bool_t CoefficentsRead(const char *fname); 94 Bool_t CoefficentsWrite(const char *fname) const; 95 96 // MParContainer 97 void SetVariables(const TArrayD &arr); 98 99 Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE); 100 101 // TObject 102 void Print(Option_t *o="") const; 103 104 ClassDef(MFMagicCuts, 1) // A filter to evaluate the MagicCuts 23 105 }; 24 106 -
trunk/MagicSoft/Mars/mhbase/MH.cc
r6978 r7173 1204 1204 // -------------------------------------------------------------------------- 1205 1205 // 1206 // M.Gaug added this withouz Documentation1206 // 1207 1207 // 1208 1208 TH1I* MH::ProjectArray(const TArrayF &array, Int_t nbins, … … 1251 1251 // -------------------------------------------------------------------------- 1252 1252 // 1253 // M.Gaug added this withouz Documentation1253 // 1254 1254 // 1255 1255 TH1I* MH::ProjectArray(const TArrayD &array, Int_t nbins, const char* name, const char* title) … … 1297 1297 // -------------------------------------------------------------------------- 1298 1298 // 1299 // M.Gaug added this withouz Documentation1299 // 1300 1300 // 1301 1301 TH1I* MH::ProjectArray(const MArrayF &array, Int_t nbins, … … 1307 1307 // -------------------------------------------------------------------------- 1308 1308 // 1309 // M.Gaug added this withouz Documentation1309 // 1310 1310 // 1311 1311 TH1I* MH::ProjectArray(const MArrayD &array, Int_t nbins, const char* name, const char* title) … … 1324 1324 *fLog << "%) Evts skipped: " << str << endl; 1325 1325 } 1326 1327 // -------------------------------------------------------------------------- 1328 // 1329 // Calls gStyle->SetPalette. Allowed palettes are: 1330 // pretty 1331 // deepblue: darkblue -> lightblue 1332 // lightblue: black -> blue -> white 1333 // greyscale: black -> white 1334 // glow1: black -> darkred -> orange -> yellow -> white 1335 // glow2: 1336 // glowsym: lightblue -> blue -> black -> darkred -> orange -> yellow -> white 1337 // redish: darkred -> lightred 1338 // bluish: darkblue -> lightblue 1339 // small1: 1340 // 1341 // If the palette name contains 'inv' the order of the colors is inverted. 1342 // 1343 // The second argument determines the number of colors for the palette. 1344 // The default is 50. 'pretty' always has 50 colors. 1345 // 1346 // (Remark: Drawing 3D object like TH2D with surf3 allows a maximum 1347 // of 99 colors) 1348 // 1349 void MH::SetPalette(TString paletteName, Int_t ncol) 1350 { 1351 Bool_t found=kFALSE; 1352 1353 paletteName.ToLower(); 1354 1355 const Bool_t inverse = paletteName.Contains("inv"); 1356 1357 if (paletteName.Contains("pretty")) 1358 { 1359 gStyle->SetPalette(1, 0); 1360 ncol=50; 1361 found=kTRUE; 1362 } 1363 1364 if (paletteName.Contains("deepblue")) 1365 { 1366 Double_t s[5] = { 0.00, 0.34, 0.61, 0.84, 1.00 }; 1367 Double_t r[5] = { 0.00, 0.09, 0.18, 0.09, 0.00 }; 1368 Double_t g[5] = { 0.01, 0.02, 0.39, 0.68, 0.97 }; 1369 Double_t b[5] = { 0.17, 0.39, 0.62, 0.79, 0.97 }; 1370 gStyle->CreateGradientColorTable(5, s, r, g, b, ncol); 1371 found=kTRUE; 1372 } 1373 1374 if (paletteName.Contains("lightblue")) 1375 { 1376 Double_t s[5] = { 0.00, 0.34, 0.61, 0.84, 1.00 }; 1377 Double_t r[5] = { 0.00, 0.09, 0.18, 0.09, 0.00 }; 1378 Double_t g[5] = { 0.00, 0.02, 0.40, 0.70, 1.00 }; 1379 Double_t b[5] = { 0.00, 0.27, 0.51, 0.81, 1.00 }; 1380 gStyle->CreateGradientColorTable(5, s, r, g, b, ncol); 1381 found=kTRUE; 1382 } 1383 1384 if (paletteName.Contains("greyscale")) 1385 { 1386 double s[2] = {0.00, 1.00}; 1387 double r[2] = {0.00, 1.00}; 1388 double g[2] = {0.00, 1.00}; 1389 double b[2] = {0.00, 1.00}; 1390 gStyle->CreateGradientColorTable(2, s, r, g, b, ncol); 1391 found=kTRUE; 1392 } 1393 1394 if (paletteName.Contains("glow1")) 1395 { 1396 double s[5] = {0., 0.10, 0.45, 0.75, 1.00}; 1397 double r[5] = {0., 0.35, 0.85, 1.00, 1.00}; 1398 double g[5] = {0., 0.10, 0.20, 0.73, 1.00}; 1399 double b[5] = {0., 0.03, 0.06, 0.00, 1.00}; 1400 gStyle->CreateGradientColorTable(5, s, r, g, b, ncol); 1401 found=kTRUE; 1402 } 1403 1404 if (paletteName.Contains("glow2")) 1405 { 1406 double s[4] = {0.00, 0.50, 0.75, 1.00}; 1407 double r[4] = {0.24, 0.67, 1.00, 1.00}; 1408 double g[4] = {0.03, 0.04, 0.80, 1.00}; 1409 double b[4] = {0.03, 0.04, 0.00, 1.00}; 1410 gStyle->CreateGradientColorTable(4, s, r, g, b, ncol); 1411 found=kTRUE; 1412 } 1413 1414 if (paletteName.Contains("glowsym")) 1415 { 1416 double s[8] = {0.00, 0.17, 0.39, 0.50, 0.55, 0.72, 0.88, 1.00}; 1417 double r[8] = {0.09, 0.18, 0.09, 0.00, 0.35, 0.85, 1.00, 1.00}; 1418 double g[8] = {0.70, 0.40, 0.02, 0.00, 0.10, 0.20, 0.73, 1.00}; 1419 double b[8] = {0.81, 0.51, 0.27, 0.00, 0.03, 0.06, 0.00, 1.00}; 1420 gStyle->CreateGradientColorTable(8, s, r, g, b, ncol); 1421 found=kTRUE; 1422 } 1423 1424 if (paletteName.Contains("redish")) 1425 { 1426 double s[3] = {0., 0.5, 1.}; 1427 double r[3] = {0., 1.0, 1.}; 1428 double g[3] = {0., 0.0, 1.}; 1429 double b[3] = {0., 0.0, 1.}; 1430 gStyle->CreateGradientColorTable(3, s, r, g, b, ncol); 1431 found=kTRUE; 1432 } 1433 1434 if (paletteName.Contains("bluish")) 1435 { 1436 double s[3] = {0., 0.5, 1.}; 1437 double r[3] = {0., 0.0, 1.}; 1438 double g[3] = {0., 0.0, 1.}; 1439 double b[3] = {0., 1.0, 1.}; 1440 gStyle->CreateGradientColorTable(3, s, r, g, b, ncol); 1441 found=kTRUE; 1442 } 1443 1444 if (paletteName.Contains("small1")) 1445 { 1446 double s[4] = {0.00, 0.50, 0.95, 1.}; 1447 double r[4] = {0.04, 0.28, 0.98, 1.}; 1448 double g[4] = {0.28, 0.93, 0.03, 1.}; 1449 double b[4] = {0.79, 0.11, 0.03, 1.}; 1450 gStyle->CreateGradientColorTable(4, s, r, g, b, ncol); 1451 found=kTRUE; 1452 } 1453 1454 if (inverse) 1455 { 1456 TArrayI c(ncol); 1457 for (int i=0; i<ncol; i++) 1458 c[ncol-i-1] = gStyle->GetColorPalette(i); 1459 gStyle->SetPalette(ncol, c.GetArray()); 1460 } 1461 1462 if (!found) 1463 gLog << warn << "MH::SetPalette: Palette " << paletteName << " unknown... ignored." << endl; 1464 } -
trunk/MagicSoft/Mars/mhbase/MH.h
r6978 r7173 117 117 static TObject *FindObjectInPad(const char *name, TVirtualPad *pad=NULL); 118 118 119 static void SetPalette(TString paletteName, Int_t ncol=50); 120 119 121 ClassDef(MH, 2) //A base class for Mars histograms 120 122 }; -
trunk/MagicSoft/Mars/mhflux/MHDisp.cc
r7145 r7173 64 64 // 65 65 MHDisp::MHDisp(const char *name, const char *title) 66 : fHilExt(0), fDisp(0) 66 : fHilExt(0), fDisp(0)//, fIsWobble(kFALSE) 67 67 { 68 68 // … … 78 78 fHist.SetXTitle("x [\\circ]"); 79 79 fHist.SetYTitle("y [\\circ]"); 80 fHist.SetZTitle(" \\vartheta [deg^{2}]");80 fHist.SetZTitle("Eq.cts"); 81 81 } 82 82 … … 130 130 return kFALSE; 131 131 } 132 133 //const Double_t xmax = fHist.GetXaxis()->GetXmax(); 132 134 133 135 // Initialize all bins with a small (=0) value otherwise 134 136 // these bins are not displayed 135 137 for (int x=0; x<fHist.GetNbinsX(); x++) 136 for (int y=0; y<fHist.GetNbinsX(); y++) 137 fHist.Fill(fHist.GetXaxis()->GetBinCenter(x+1), 138 fHist.GetYaxis()->GetBinCenter(y+1), 139 0.0, 1e-10); 138 for (int y=0; y<fHist.GetNbinsY(); y++) 139 { 140 const Double_t cx = fHist.GetXaxis()->GetBinCenter(x+1); 141 const Double_t cy = fHist.GetYaxis()->GetBinCenter(y+1); 142 //if (TMath::Hypot(cx, cy)<xmax) 143 fHist.Fill(cx, cy, 0.0, 1e-10); 144 } 140 145 141 146 return kTRUE; … … 160 165 rho = fPointPos->RotationAngle(*fObservatory, *fTime); 161 166 167 // FIXME: Do wobble-rotation when subtracting? 168 if (!fHistOff/* && fIsWobble*/) 169 rho += TMath::Pi(); 170 162 171 // Get Disp from Parlist 163 172 const Double_t disp = fDisp->GetVal(); 164 173 165 // Calculate where disp is pointing174 // Calculate both postiions where disp could point 166 175 TVector2 pos1(hil->GetCosDelta(), hil->GetSinDelta()); 167 176 TVector2 pos2(hil->GetCosDelta(), hil->GetSinDelta()); 168 pos1 *= disp; 169 pos2 *= -disp; 170 177 pos1 *= disp; // Vector of length disp in direction of shower 178 pos2 *= -disp; // Vector of length -disp in direction of shower 179 180 // Move origin of vector to center-of-gravity of shower 171 181 pos1 += hil->GetMean()*fMm2Deg; 172 182 pos2 += hil->GetMean()*fMm2Deg; … … 207 217 srcp = fSrcPos->GetXY(); 208 218 219 // Derotate all position around camera center by -rho 209 220 if (rho!=0) 210 221 { … … 214 225 } 215 226 227 // Shift the source position to 0/0 216 228 pos1 -= srcp*fMm2Deg; 217 229 pos2 -= srcp*fMm2Deg; 218 230 219 fHist.Fill(pos1.X(), pos1.Y(), 0.0, w*gweight); 220 fHist.Fill(pos2.X(), pos2.Y(), 0.0, w*(1-gweight)); 231 //const Double_t xmax = fHist.GetXaxis()->GetXmax(); 232 233 // Fill histograms 234 //if (pos1.Mod()<xmax) 235 fHist.Fill(pos1.X(), pos1.Y(), 0.0, w*gweight); 236 //if (pos2.Mod()<xmax) 237 fHist.Fill(pos2.X(), pos2.Y(), 0.0, w*(1-gweight)); 221 238 222 239 return kTRUE; 223 240 } 224 /* 225 static Double_t FcnGauss2d(Double_t *x, Double_t *par) 226 { 227 TVector2 v = TVector2(x[0], x[1]).Rotate(par[5]*TMath::DegToRad()); 228 229 const Double_t g0 = TMath::Gaus(v.X(), par[1], par[2]); 230 const Double_t g1 = TMath::Gaus(v.Y(), par[3], par[4]); 231 232 //Gaus(Double_t x, Double_t mean=0, Double_t sigma=1, Bool_t norm=kFALSE); 233 return par[0]*g0*g1 + par[6]*(v.X()*v.X() + v.Y()*v.Y()) + par[7]; 234 }*/ 241 242 Double_t MHDisp::GetOffSignal(TH1 &h) const 243 { 244 const TAxis &axex = *h.GetXaxis(); 245 const TAxis &axey = *h.GetYaxis(); 246 247 Double_t sum = 0; 248 for (int x=0; x<h.GetNbinsX(); x++) 249 for (int y=0; y<h.GetNbinsY(); y++) 250 { 251 if (TMath::Hypot(axex.GetBinCenter(x+1), axey.GetBinCenter(y+1))>0.35) 252 sum += h.GetBinContent(x+1,y+1); 253 } 254 255 return sum; 256 } 235 257 236 258 void MHDisp::Paint(Option_t *o) … … 240 262 pad->cd(1); 241 263 264 // Project on data onto yx-plane 242 265 fHist.GetZaxis()->SetRange(0,9999); 243 266 TH1 *h1=fHist.Project3D("yx_on"); 244 gStyle->SetPalette(1, 0); 267 268 // Set Glow-palette (PaintSurface doesn't allow more than 99 colors) 269 MH::SetPalette(fHistOff?"glowsym":"glow1", 99); 270 h1->SetContour(99); 271 272 Double_t scale = 1; 273 if (fHistOff) 274 { 275 // Project off data onto yx-plane and subtract it from on-data 276 fHistOff->GetZaxis()->SetRange(0,9999); 277 TH1 *h=fHistOff->Project3D("yx_off"); 278 279 scale = -1; 280 281 //if (!fIsWobble) 282 { 283 const Double_t h1off = GetOffSignal(*h1); 284 const Double_t hoff = GetOffSignal(*h); 285 scale = hoff==0?-1:-h1off/hoff; 286 } 287 288 h1->Add(h, scale); 289 delete h; 290 291 // Force calculation of minimum, maximum 292 h1->SetMinimum(); 293 h1->SetMaximum(); 294 295 // Find maximum 296 const Double_t max = TMath::Max(TMath::Abs(h1->GetMinimum()), 297 TMath::Abs(h1->GetMaximum())); 298 299 // Set new minimum, maximum 300 h1->SetMinimum(-max); 301 h1->SetMaximum( max); 302 } 245 303 246 304 Int_t ix, iy, iz; … … 304 362 const Double_t s = MMath::SignificanceLiMa(e, b); 305 363 306 h2->SetTitle(Form("P=(%.2f\\circ/%.2f\\circ) \\omega=%.2f\\circ \\sigma=%.1f E=%.0f B=%.0f ", x0, y0, func.GetParameter(2), s, e-b, b));364 h2->SetTitle(Form("P=(%.2f\\circ/%.2f\\circ) \\omega=%.2f\\circ \\sigma=%.1f E=%.0f B=%.0f f=%.2f", x0, y0, func.GetParameter(2), s, e-b, b, scale)); 307 365 } 308 366 /* … … 386 444 h->Draw(); 387 445 } 446 447 // -------------------------------------------------------------------------- 448 // 449 // The following resources are available: 450 // 451 // MHDisp.Wobble: on/off 452 // 453 /* 454 Int_t MHFalseSource::ReadEnv(const TEnv &env, TString prefix, Bool_t print) 455 { 456 Bool_t rc = kFALSE; 457 if (IsEnvDefined(env, prefix, "DistMin", print)) 458 { 459 rc = kTRUE; 460 SetMinDist(GetEnvValue(env, prefix, "DistMin", fMinDist)); 461 } 462 if (IsEnvDefined(env, prefix, "DistMax", print)) 463 { 464 rc = kTRUE; 465 SetMaxDist(GetEnvValue(env, prefix, "DistMax", fMaxDist)); 466 } 467 468 if (IsEnvDefined(env, prefix, "DWMin", print)) 469 { 470 rc = kTRUE; 471 SetMinDW(GetEnvValue(env, prefix, "DWMin", fMinDist)); 472 } 473 if (IsEnvDefined(env, prefix, "DWMax", print)) 474 { 475 rc = kTRUE; 476 SetMaxDW(GetEnvValue(env, prefix, "DWMax", fMaxDist)); 477 } 478 479 return rc; 480 } 481 */ -
trunk/MagicSoft/Mars/mhflux/MHDisp.h
r7114 r7173 13 13 { 14 14 private: 15 MHillasExt *fHilExt; //!16 MParameterD *fDisp; //!15 MHillasExt *fHilExt; //! 16 MParameterD *fDisp; //! 17 17 18 Double_t fM3lCut; //! 19 Double_t fXi; //! 20 Double_t fXiTheta; //! 18 Double_t fM3lCut; //! 19 Double_t fXi; //! 20 Double_t fXiTheta; //! 21 22 //Bool_t fIsWobble; 23 24 // MHDisp 25 Double_t GetOffSignal(TH1 &h) const; 21 26 22 27 public: … … 27 32 Bool_t Fill(const MParContainer *par, const Stat_t w=1); 28 33 34 // TObject 29 35 void Paint(Option_t *o=""); 30 36 void Draw(Option_t *o=""); 37 38 // MParContainer 39 //Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE); 31 40 32 41 ClassDef(MHDisp, 1) //3D-histogram in alpha, x and y
Note:
See TracChangeset
for help on using the changeset viewer.