Exemplo n.º 1
0
        static void Main(string[] args)
        {
            WriteLine("Finding the files");
            var backgroundEvents = Files.GetJZ(2).Select(e => e.Data);
            //var signalHV125pi15Events = Files.Get125pi15();
            //var signalHV125pi40Events = Files.Get125pi40();
            var signalHV600pi100Events = Files.Get600pi150lt9m();
            //var signalGet200pi25lt5mEvents = Files.Get200pi25lt5m();

            //
            // Do a simple cut training here
            //

            var t = TrainingIQueriable(signalHV600pi100Events, true)
                .AsSignal("HV600pi100")
                .Background(TrainingIQueriable(backgroundEvents, false), "J2Z")
                .IgnoreVariables(p => p.lowestPtTrack);

            var mCuts = t.AddMethod(ROOTNET.Interface.NTMVA.NTypes.EMVA.kCuts, "SimpleCuts")
                .Option("!H:V:FitMethod=MC:EffSel:SampleSize=200000:VarTransform=Decorrelate")
                .ParameterOption(p => p.logR, "VarProp", "FSmart")
                .ParameterOption(p => p.nTracks, "VarProp", "FSmart")
                .ParameterOption(p => p.lowestPtTrack, "VarProp", "FSmart");

            var mMVA = t.AddMethod(ROOTNET.Interface.NTMVA.NTypes.EMVA.kBDT, "SimpleBDT")
                .Option("MaxDepth=3");

            t.Train("VerySimpleTraining");

            // Lets make a measurement of the efficiency for the standard cut.
            var effResults = new FutureTFile(Path.Combine(FileInfoUtilities.FindDirectoryWithFileMatching("*.sln").FullName,"trainingResults.root"));
            var stdCutVale = CalcEff(effResults.mkdir("std"), td => (td.logR > 1.2 && td.nTracks == 0) ? 1.0 : 0.0, 0.5, TrainingIQueriable(backgroundEvents, false), TrainingIQueriable(signalHV600pi100Events, true));

            // Next, do it with a reader

#if false
            var r = new ROOTNET.NTMVA.NReader();
            var s = new FileInfo("C:\\Users\\gordo\\Documents\\Code\\calratio2015\\JetCutStudies\\SimpleJetCutTraining\\bin\\x86\\Debug\\weights\\VerySimpleTraining_SimpleCuts.weights.xml");
            float[] logR = new float[2];
            float[] nTracks = new float[2];
            r.AddVariable("logR".AsTS(), logR);
            r.AddVariable("nTracks".AsTS(), nTracks);
            r.BookMVA("SimpleCuts".AsTS(), s.FullName.AsTS());
            Expression<Func<TrainingData, double>> simpleCutsReader = tv => TMVAReaders.TMVASelectorSimpleCutsTest(r, tv.logR, tv.lowestPtTrack, stdCutVale.Value);
#else
            Expression<Func<TrainingData, double>> simpleCutsReader = tv => TMVAReaders.TMVASelectorSimpleCuts(tv.logR, tv.nTracks, 0.72);
#endif
            var simpleCutValue = CalcEff(effResults.mkdir("SimpleCuts"), simpleCutsReader, 0.5, TrainingIQueriable(backgroundEvents, false), TrainingIQueriable(signalHV600pi100Events, true));

            // Next, we need to get the MVA and figure out the efficiency.
            Expression<Func<TrainingData, double>> simpleMVAReader = tv => TMVAReaders.TMVASelectorSimpleBDT(tv.logR, tv.nTracks);
            var simpleBDTValue = CalcEff(effResults.mkdir("SimpleBDT"), simpleMVAReader, 0.99999, TrainingIQueriable(backgroundEvents, false), TrainingIQueriable(signalHV600pi100Events, true));

            // Write out everything
            effResults.Write();
            effResults.Close();

            //Emit();
        }
Exemplo n.º 2
0
        public void FutureFileEmpty()
        {
            // Create an empty TFile, make sure that is good!
            var f = new FileInfo("FutureFileEmpty.root");
            if (f.Exists)
            {
                f.Delete();
            }

            var ftf = new FutureTFile(f);
            ftf.Write();
            ftf.Close();

            f.Refresh();
            Assert.IsTrue(f.Exists);
        }
Exemplo n.º 3
0
        public void FutureFileWriteWithClose()
        {
            var f = new FileInfo("FutureFileWriteWithClose.root");
            if (f.Exists)
            {
                f.Delete();
            }
            while (f.Exists)
            {
                f.Refresh();
            }

            using (var ftf = new FutureTFile(f))
            {
                ftf.Close();
            }

            f.Refresh();
            Assert.IsTrue(f.Exists);
        }