Changeset 6232 for trunk/MagicSoft/Mars/mtemp/mmpi/SupercutsONOFFClasses/MFindSupercutsONOFFThetaLoop.cc
- Timestamp:
- 02/03/05 12:42:21 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mtemp/mmpi/SupercutsONOFFClasses/MFindSupercutsONOFFThetaLoop.cc
r4411 r6232 110 110 //--------------------------- 111 111 112 112 // ********************************* 113 // ** NOT TRUE ANY LONGER... ** // 113 114 // Cuts (low and up) in variable ThetaOrig.fVal 114 115 // The default is not cut, i.e. all values (0-1) are taken 115 116 // fThetaOrig.fVal is measured in Radians; thus 1 = 57 degrees. 116 117 118 // fThetaMin = 0.0; 119 // fThetaMax = 1.0; 120 // ********************************* 121 122 123 // For MAGIC new (July 2004) Theta is measured in degrees 124 117 125 fThetaMin = 0.0; 118 fThetaMax = 1.0; 126 fThetaMax = 90.0; 127 128 119 129 120 130 fAlphaSig = 20; // By default, signal is expected in alpha<20 for CT1 … … 545 555 546 556 547 // Give a "soft warning" if Vector has increasing values 548 // of CosThetas; which means decreasing values of Thetas 549 /* 550 if (fCosThetaRangeVector[0] <= fCosThetaRangeVector[1]) 551 { 552 *fLog << "MFindSupercutsONOFFThetaLoop::SetCosThetaRangeVector; " 553 << endl 554 << "Values in vector fCosThetaRangeVector are in increasing " 555 << "order, i.e., values in theta will be in decreasing order" 556 << endl 557 << "DO NOT forget it !!" << endl; 558 } 559 560 */ 557 561 558 562 559 // fCosThetaBinCenterVector is defined … … 622 619 // Now costheta values have to be converted to Radians 623 620 // Function TMath::ACos(x) gives angle in Radians 624 621 625 622 626 623 fThetaMin = TMath::ACos(fThetaMin); 627 624 fThetaMax = TMath::ACos(fThetaMax); 625 626 627 // For new MAGIC (July 2004), angles are given in degrees. 628 // So I convert angles into degrees by multiplying by a the 629 // conversion rad/degree 630 631 fThetaMin = fThetaMin * TMath::RadToDeg(); 632 fThetaMax = fThetaMax * TMath::RadToDeg(); 633 634 628 635 629 636 // If fThetaMin > fThetaMax means that fCosThetaRangeVector … … 644 651 << "MFindSupercutsONOFFThetaLoop::SetThetaRange; " << endl 645 652 << "Theta range for this iteration is set to " 646 << fThetaMin << "-" << fThetaMax << " Radians." << endl653 << fThetaMin << "-" << fThetaMax << " degrees." << endl 647 654 << "-------------------------------------------------"<< endl; 648 655 … … 932 939 933 940 934 // Histograms references are removed from the current directory 935 936 /* IT DOES NOT WORK !!! THESE STATEMENTS PRODUCE SEGMENTATION FAULT. 937 fNormFactorTrainHist -> SetDirectory(NULL); 938 939 fNormFactorTestHist -> SetDirectory(NULL); 940 941 fSigmaLiMaTrainHist -> SetDirectory(NULL); 942 943 fSigmaLiMaTestHist -> SetDirectory(NULL); 944 945 fSigmaLiMaTestHist -> SetDirectory(NULL); 946 947 fNexTestHist -> SetDirectory(NULL); 948 */ 941 949 942 950 943 … … 1059 1052 Double_t fofftest) 1060 1053 { 1054 1055 // Check that fractions set by user are within the expected limits 1056 1057 if (fontrain < 0.00 || fontrain > 1.00 || 1058 fontest < 0.00 || fontest > 1.00 || 1059 fofftrain < 0.00 || fofftrain > 1.00 || 1060 fofftest < 0.00 || fontest > 1.00) 1061 { 1062 *fLog << err 1063 << "MFindSupercutsONOFFThetaLoop::SetFractionTrainTestOnOffEvents: " 1064 << endl 1065 << "Fractions of ON/OFF data for TRAIN/TEST sample which were specified by user " << endl 1066 << "are outside the natural limits 0.0-1.0. " << endl 1067 << "Set reasonable fraction numbers for TRAIN/TEST please. The program will be aborted." 1068 << endl; 1069 1070 exit(1); 1071 1072 1073 } 1074 1075 1076 if((fontrain+fontest) > 1.00 || 1077 (fofftrain+fofftest) >1.00) 1078 1079 { 1080 *fLog << err 1081 << "MFindSupercutsONOFFThetaLoop::SetFractionTrainTestOnOffEvents: " 1082 << endl 1083 << "The sum of the fractions of TRAIN/TEST for ON or OFF data which were specified by user " << endl 1084 << "are larger than 1.0. " << endl 1085 << "Set reasonable fraction numbers for TRAIN/TEST please. The program will be aborted." 1086 << endl; 1087 1088 exit(1); 1089 1090 1091 } 1092 1061 1093 1062 1094 fWhichFractionTrain = fontrain; … … 1154 1186 1155 1187 // Path + "OptSCParametersONOFF" + "ThetaRange" 1156 // + int {(fThetaMin_fThetaMax) *1000} + ".root"1188 // + int {(fThetaMin_fThetaMax)} + ".root" 1157 1189 1158 1190 … … 1160 1192 1161 1193 // Path + "ON(OFF)Data" + "Train(Test)" + "Matrix" + Fraction 1162 // + "ThetaRange" + int {(fThetaMin_fThetaMax) *1000} + ".root"1194 // + "ThetaRange" + int {(fThetaMin_fThetaMax)} + ".root" 1163 1195 1164 1196 … … 1176 1208 1177 1209 1178 Int_t ThetaMinTimes1000 = 0; 1179 Int_t ThetaMaxTimes1000 = 0; 1210 // Int_t ThetaMinTimes1000 = 0; 1211 // Int_t ThetaMaxTimes1000 = 0; 1212 1213 // For MAGIC new (July 2004) Theta is given in deg 1214 1215 Int_t ThetaMinInt = 0; 1216 Int_t ThetaMaxInt = 0; 1217 1218 1180 1219 Int_t FractionONTrainTimes100 = 0; 1181 1220 Int_t FractionONTestTimes100 = 0; … … 1200 1239 1201 1240 1202 ThetaMinTimes1000 = int(fThetaMin*1000); 1203 ThetaMaxTimes1000 = int(fThetaMax*1000); 1204 sprintf(ThetaRangeString, "ThetaRange%d_%dmRad", 1205 ThetaMinTimes1000, ThetaMaxTimes1000); 1241 //ThetaMinTimes1000 = int(fThetaMin*1000); 1242 //ThetaMaxTimes1000 = int(fThetaMax*1000); 1243 //sprintf(ThetaRangeString, "ThetaRange%d_%dmRad", 1244 // ThetaMinTimes1000, ThetaMaxTimes1000); 1245 1246 // For New MAGIC (July 2004) 1247 // Theta is given in deg, no need to multiply by 1000 1248 1249 // 0.5 is added so that the rounding to integer is correct 1250 ThetaMinInt = int(fThetaMin + 0.5); 1251 ThetaMaxInt = int(fThetaMax + 0.5); 1252 sprintf(ThetaRangeString, "ThetaRange%d_%d_Degrees", 1253 ThetaMinInt, ThetaMaxInt); 1254 1255 1206 1256 1207 1257 fThetaRangeStringVector[i] = (ThetaRangeString); … … 1211 1261 // endtmp 1212 1262 1213 Double_t tmpdouble = 0.0; 1214 tmpdouble = fWhichFractionTrain*100 - int(fWhichFractionTrain*100); 1215 1216 FractionONTrainTimes100 = tmpdouble < 0.5 ? int(fWhichFractionTrain*100): 1217 int(fWhichFractionTrain*100) + 1; 1218 1219 1220 tmpdouble = fWhichFractionTest*100 - int(fWhichFractionTest*100); 1221 1222 FractionONTestTimes100 = tmpdouble < 0.5 ? int(fWhichFractionTest*100): 1223 int(fWhichFractionTest*100) + 1; 1224 1225 tmpdouble = fWhichFractionTrainOFF*100 - int(fWhichFractionTrainOFF*100); 1226 1227 FractionOFFTrainTimes100 = tmpdouble < 0.5 ? int(fWhichFractionTrainOFF*100): 1228 int(fWhichFractionTrainOFF*100) + 1; 1229 1230 tmpdouble = fWhichFractionTestOFF*100 - int(fWhichFractionTestOFF*100); 1231 FractionOFFTestTimes100 = tmpdouble < 0.5 ? int(fWhichFractionTestOFF*100): 1232 int(fWhichFractionTestOFF*100) + 1; 1263 // 0.5 is added so that the rounding to integer is correct 1264 1265 FractionONTrainTimes100 = int(fWhichFractionTrain*100 + 0.5); 1266 FractionONTestTimes100 = int(fWhichFractionTest*100 + 0.5); 1267 FractionOFFTrainTimes100 = int(fWhichFractionTrainOFF*100 + 0.5); 1268 FractionOFFTestTimes100 = int(fWhichFractionTestOFF*100 + 0.5); 1269 1270 1233 1271 1234 1272 … … 1525 1563 FindSupercuts.SetSizeRange(fSizeCutLow, fSizeCutUp); 1526 1564 1565 FindSupercuts.SetFilters(fLeakMax, fDistMax, fDistMin); 1527 1566 1528 1567 … … 1627 1666 << "Reading Data matrices from root files... " << endl; 1628 1667 1668 /* 1629 1669 FindSupercuts.ReadMatrix(fTrainMatrixONFilenameVector[i], 1630 1670 fTestMatrixONFilenameVector[i]); 1631 1671 FindSupercuts.ReadMatrixOFF(fTrainMatrixOFFFilenameVector[i], 1632 1672 fTestMatrixOFFFilenameVector[i]); 1673 */ 1674 1675 FindSupercuts.ReadMatrixTrain(fTrainMatrixONFilenameVector[i], 1676 fTrainMatrixOFFFilenameVector[i]); 1677 1678 if (fTestParameters) 1679 { 1680 FindSupercuts.ReadMatrixTest(fTestMatrixONFilenameVector[i], 1681 fTestMatrixOFFFilenameVector[i]); 1682 } 1633 1683 1634 1684 } … … 2325 2375 2326 2376 // TEMP 2327 // 2328 // 2377 //cout << NexVSAlphaNameTmp << endl; 2378 //cout << SignificanceVSAlphaNameTmp << endl; 2329 2379 // ENDTEMP 2330 2380 … … 2388 2438 2389 2439 AlphaOFFAfterCuts = (TH1F*) rootfile.Get(TmpAlphaOFFHistoName); 2440 2441 2442 2390 2443 2391 2444 … … 2885 2938 { 2886 2939 2940 2941 *fLog << endl << endl 2942 << "****************************************************************************" << endl 2943 << "Combining number of excess events and significance for the " << endl 2944 << "selected bins in theta angle using the function " << endl 2945 << " MFindSupercutsONOFFThetaLoop::ComputeOverallSignificance() " << endl 2946 << "****************************************************************************" << endl 2947 << endl; 2948 2949 2950 2951 2952 2953 2887 2954 // First of all let's check that we have the proper the "drinks" for the party 2888 2955 … … 2917 2984 // Remember that histogram index START AT 1 !!! 2918 2985 2986 2987 2988 // Histograms that will contain the alpha distributions 2989 // for the combined theta bins 2990 2991 2919 2992 TH1F* CombinedAlphaTrainON = NULL; 2920 TString CombinedAlphaTrainONName = (" CombinedAlphaTrainON");2993 TString CombinedAlphaTrainONName = ("TrainSampleAlphaONCombinedThetaBins"); 2921 2994 TH1F* CombinedAlphaTrainOFF = NULL; 2922 TString CombinedAlphaTrainOFFName = (" CombinedAlphaTrainOFF");2995 TString CombinedAlphaTrainOFFName = ("TrainSampleAlphaOFFCombinedThetaBins"); 2923 2996 2924 2997 TH1F* CombinedAlphaTestON = NULL; 2925 TString CombinedAlphaTestONName = (" CombinedAlphaTestON");2998 TString CombinedAlphaTestONName = ("TestSampleAlphaONCombinedThetaBins"); 2926 2999 2927 3000 TH1F* CombinedAlphaTestOFF = NULL; 2928 TString CombinedAlphaTestOFFName = (" CombinedAlphaTestOFF");3001 TString CombinedAlphaTestOFFName = ("TestSampleAlphaONCombinedThetaBins"); 2929 3002 2930 2931 3003 3004 2932 3005 2933 3006 … … 3089 3162 { 3090 3163 3164 3165 3166 *fLog << endl 3167 << "****************************************************************************" << endl 3168 << "Combining data for the TRAIN sample " << endl 3169 << "****************************************************************************" << endl 3170 << endl; 3171 3091 3172 // Retrieving NormFactorTrainHisto from root file. 3092 3173 … … 3489 3570 CombinedAlphaTrainOFF->SetEntries(tmpint); 3490 3571 3491 3572 // Check that the number of events in the combined normalized histogram is 3573 // that of the initial sample 3574 3575 /* 3492 3576 cout << "SILLY INFO FOR TRAIN SAMPLE: Total number of events Before nomralization and " 3493 3577 << " re-re normalized" << endl 3494 3578 << TotalNumberOFFTrain << " - " << EventCounter << endl; 3495 3579 3580 */ 3496 3581 } 3497 3582 … … 3506 3591 if (CombineTestData) 3507 3592 { 3593 3594 *fLog << endl 3595 << "****************************************************************************" << endl 3596 << "Combining data for the TEST sample " << endl 3597 << "****************************************************************************" << endl 3598 << endl; 3599 3508 3600 3509 3601 // Retrieving NormFactorTestHisto from root file. … … 3930 4022 3931 4023 4024 // Check that the number of events in the combined normalized histogram is 4025 // that of the initial sample 4026 4027 /* 3932 4028 cout << "SILLY INFO FOR TEST SAMPLE: Total number of events Before nomralization and " 3933 4029 << " re-re normalized" << endl 3934 4030 << TotalNumberOFFTest << " - " << EventCounter << endl; 4031 4032 */ 4033 3935 4034 3936 4035 /* … … 3982 4081 if (SuccessfulThetaBinsVector.GetSize() >= 1) 3983 4082 { 4083 4084 4085 *fLog << endl 4086 << "**************************************************************************************" << endl 4087 << "Computation of excess events and singnificance for the combined alpha histograms " << endl 4088 << "**************************************************************************************" << endl 4089 << endl; 4090 3984 4091 // There is, at least, ONE theta bin for which optimization of 3985 4092 // supercuts was SUCCESSFUL, and thus, it is worth to … … 4026 4133 4027 4134 // Name of psfile where Alpha plot will be stored 4028 TString psfilename = ("TRAINSampleCombined"); 4135 4136 TString psfilename = (fPathForFiles); 4137 psfilename += ("TRAINSampleCombinedThetaBins"); 4029 4138 4030 4139 findsig.FindSigmaONOFF(CombinedAlphaTrainON, CombinedAlphaTrainOFF, … … 4053 4162 4054 4163 // Name of psfile where Alpha plot will be stored 4055 TString psfilename = ("TESTSampleCombined"); 4164 TString psfilename = (fPathForFiles); 4165 psfilename += ("TESTSampleCombinedThetaBins"); 4056 4166 4057 4167 findsig.FindSigmaONOFF(CombinedAlphaTestON, CombinedAlphaTestOFF, … … 4075 4185 4076 4186 4187 *fLog << endl 4188 << "**************************************************************************************" << endl 4189 << "Alpha distributions (Train/Test and ON/OFF) for the combined " << endl 4190 << " theta bins are stored in the root file " << endl 4191 << fAlphaDistributionsRootFilename << endl 4192 << "**************************************************************************************" << endl 4193 << endl; 4194 4195 4196 4197 TFile rootfiletowrite(fAlphaDistributionsRootFilename, "UPDATE"); 4198 4199 4200 4201 // Histograms that will contain the Norm factors for the 4202 // combined TRAIN/TEST theta bins are created 4203 4204 4205 TString CombinedNormFactorTrainName = ("TrainSampleNormFactorCombinedThetaBins"); 4206 TH1F CombinedNormFactorTrain (CombinedNormFactorTrainName, 4207 CombinedNormFactorTrainName, 4208 1, 0.0, 1.0); 4209 4210 TString CombinedNormFactorTestName = ("TestSampleNormFactorCombinedThetaBins"); 4211 TH1F CombinedNormFactorTest (CombinedNormFactorTestName, 4212 CombinedNormFactorTestName, 4213 1, 0.0, 1.0); 4214 4215 4216 if (CombineTrainData) 4217 { 4218 4219 // Histogram that will contain the Norm factors for the 4220 // combined TRAIN theta bins are filled 4221 4222 4223 CombinedNormFactorTrain.Fill(0.5, MeanNormFactorTrain); 4224 4225 4226 // Train histos are written to root file 4227 4228 CombinedAlphaTrainON -> Write(); 4229 CombinedAlphaTrainOFF -> Write(); 4230 CombinedNormFactorTrain.Write(); 4231 4232 4233 4234 } 4235 4236 4237 if (CombineTestData) 4238 { 4239 4240 // Histogram that will contain the Norm factors for the 4241 // combined TEST theta bins are filled 4242 4243 4244 CombinedNormFactorTest.Fill(0.5, MeanNormFactorTest); 4245 4246 // Test histos are written to root file 4247 4248 CombinedAlphaTestON -> Write(); 4249 CombinedAlphaTestOFF -> Write(); 4250 CombinedNormFactorTest.Write(); 4251 4252 4253 } 4254 4255 4256 // Root file is closed 4257 4258 rootfiletowrite.Close(); 4259 4077 4260 4078 4261 }
Note:
See TracChangeset
for help on using the changeset viewer.