In [1]:
%jsroot on
In [2]:
#include "Riostream.h"
#include "TString.h"
#include "TFile.h"
#include "TTree.h"
#include "TSystem.h"
#include <stdio.h>
#include <stdlib.h>
In [3]:
//This two lines can be commented out. You just need it once, and in case the CVS file was not provided already
system("rm outreach.csv");
system("wget http://opendata.atlas.cern/visualisations/CrossFilter/outreach.csv");
//If the file is downloaded with the line above, you *need* to remove the first line of the outreach.csv
--2017-11-23 23:32:48-- http://opendata.atlas.cern/visualisations/CrossFilter/outreach.csv
Resolving opendata.atlas.cern... 188.184.64.13
Connecting to opendata.atlas.cern|188.184.64.13|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8802904 (8.4M) [text/csv]
Saving to: ‘outreach.csv’
0K .......... .......... .......... .......... .......... 0% 2.86M 3s
50K .......... .......... .......... .......... .......... 1% 4.97M 2s
100K .......... .......... .......... .......... .......... 1% 5.29M 2s
150K .......... .......... .......... .......... .......... 2% 4.96M 2s
200K .......... .......... .......... .......... .......... 2% 5.50M 2s
250K .......... .......... .......... .......... .......... 3% 4.80M 2s
300K .......... .......... .......... .......... .......... 4% 6.63M 2s
350K .......... .......... .......... .......... .......... 4% 5.37M 2s
400K .......... .......... .......... .......... .......... 5% 7.38M 2s
450K .......... .......... .......... .......... .......... 5% 6.91M 2s
500K .......... .......... .......... .......... .......... 6% 6.94M 1s
550K .......... .......... .......... .......... .......... 6% 7.02M 1s
600K .......... .......... .......... .......... .......... 7% 6.93M 1s
650K .......... .......... .......... .......... .......... 8% 8.07M 1s
700K .......... .......... .......... .......... .......... 8% 8.81M 1s
750K .......... .......... .......... .......... .......... 9% 7.70M 1s
800K .......... .......... .......... .......... .......... 9% 6.43M 1s
850K .......... .......... .......... .......... .......... 10% 11.4M 1s
900K .......... .......... .......... .......... .......... 11% 4.63M 1s
950K .......... .......... .......... .......... .......... 11% 11.4M 1s
1000K .......... .......... .......... .......... .......... 12% 5.20M 1s
1050K .......... .......... .......... .......... .......... 12% 19.7M 1s
1100K .......... .......... .......... .......... .......... 13% 5.88M 1s
1150K .......... .......... .......... .......... .......... 13% 11.4M 1s
1200K .......... .......... .......... .......... .......... 14% 6.10M 1s
1250K .......... .......... .......... .......... .......... 15% 13.8M 1s
1300K .......... .......... .......... .......... .......... 15% 9.50M 1s
1350K .......... .......... .......... .......... .......... 16% 5.94M 1s
1400K .......... .......... .......... .......... .......... 16% 13.0M 1s
1450K .......... .......... .......... .......... .......... 17% 8.18M 1s
1500K .......... .......... .......... .......... .......... 18% 10.8M 1s
1550K .......... .......... .......... .......... .......... 18% 12.0M 1s
1600K .......... .......... .......... .......... .......... 19% 8.33M 1s
1650K .......... .......... .......... .......... .......... 19% 11.4M 1s
1700K .......... .......... .......... .......... .......... 20% 4.63M 1s
1750K .......... .......... .......... .......... .......... 20% 98.4M 1s
1800K .......... .......... .......... .......... .......... 21% 10.4M 1s
1850K .......... .......... .......... .......... .......... 22% 9.39M 1s
1900K .......... .......... .......... .......... .......... 22% 26.5M 1s
1950K .......... .......... .......... .......... .......... 23% 7.69M 1s
2000K .......... .......... .......... .......... .......... 23% 14.9M 1s
2050K .......... .......... .......... .......... .......... 24% 11.1M 1s
2100K .......... .......... .......... .......... .......... 25% 12.8M 1s
2150K .......... .......... .......... .......... .......... 25% 8.15M 1s
2200K .......... .......... .......... .......... .......... 26% 9.65M 1s
2250K .......... .......... .......... .......... .......... 26% 9.20M 1s
2300K .......... .......... .......... .......... .......... 27% 9.92M 1s
2350K .......... .......... .......... .......... .......... 27% 13.4M 1s
2400K .......... .......... .......... .......... .......... 28% 10.2M 1s
2450K .......... .......... .......... .......... .......... 29% 11.7M 1s
2500K .......... .......... .......... .......... .......... 29% 12.9M 1s
2550K .......... .......... .......... .......... .......... 30% 6.31M 1s
2600K .......... .......... .......... .......... .......... 30% 73.1M 1s
2650K .......... .......... .......... .......... .......... 31% 7.48M 1s
2700K .......... .......... .......... .......... .......... 31% 6.94M 1s
2750K .......... .......... .......... .......... .......... 32% 13.6M 1s
2800K .......... .......... .......... .......... .......... 33% 15.2M 1s
2850K .......... .......... .......... .......... .......... 33% 6.33M 1s
2900K .......... .......... .......... .......... .......... 34% 14.9M 1s
2950K .......... .......... .......... .......... .......... 34% 15.0M 1s
3000K .......... .......... .......... .......... .......... 35% 13.2M 1s
3050K .......... .......... .......... .......... .......... 36% 7.61M 1s
3100K .......... .......... .......... .......... .......... 36% 12.3M 1s
3150K .......... .......... .......... .......... .......... 37% 11.1M 1s
3200K .......... .......... .......... .......... .......... 37% 12.4M 1s
3250K .......... .......... .......... .......... .......... 38% 18.4M 1s
3300K .......... .......... .......... .......... .......... 38% 11.3M 1s
3350K .......... .......... .......... .......... .......... 39% 4.78M 1s
3400K .......... .......... .......... .......... .......... 40% 55.8M 1s
3450K .......... .......... .......... .......... .......... 40% 25.6M 1s
3500K .......... .......... .......... .......... .......... 41% 18.1M 1s
3550K .......... .......... .......... .......... .......... 41% 13.5M 1s
3600K .......... .......... .......... .......... .......... 42% 8.27M 1s
3650K .......... .......... .......... .......... .......... 43% 19.8M 1s
3700K .......... .......... .......... .......... .......... 43% 14.4M 1s
3750K .......... .......... .......... .......... .......... 44% 13.7M 1s
3800K .......... .......... .......... .......... .......... 44% 8.97M 1s
3850K .......... .......... .......... .......... .......... 45% 12.3M 1s
3900K .......... .......... .......... .......... .......... 45% 13.9M 1s
3950K .......... .......... .......... .......... .......... 46% 16.8M 1s
4000K .......... .......... .......... .......... .......... 47% 14.7M 0s
4050K .......... .......... .......... .......... .......... 47% 11.2M 0s
4100K .......... .......... .......... .......... .......... 48% 13.6M 0s
4150K .......... .......... .......... .......... .......... 48% 13.1M 0s
4200K .......... .......... .......... .......... .......... 49% 14.9M 0s
4250K .......... .......... .......... .......... .......... 50% 9.20M 0s
4300K .......... .......... .......... .......... .......... 50% 13.3M 0s
4350K .......... .......... .......... .......... .......... 51% 11.0M 0s
4400K .......... .......... .......... .......... .......... 51% 23.4M 0s
4450K .......... .......... .......... .......... .......... 52% 13.7M 0s
4500K .......... .......... .......... .......... .......... 52% 11.9M 0s
4550K .......... .......... .......... .......... .......... 53% 13.6M 0s
4600K .......... .......... .......... .......... .......... 54% 13.3M 0s
4650K .......... .......... .......... .......... .......... 54% 18.1M 0s
4700K .......... .......... .......... .......... .......... 55% 10.1M 0s
4750K .......... .......... .......... .......... .......... 55% 3.86M 0s
4800K .......... .......... .......... .......... .......... 56% 14.8M 0s
4850K .......... .......... .......... .......... .......... 56% 14.2M 0s
4900K .......... .......... .......... .......... .......... 57% 9.43M 0s
4950K .......... .......... .......... .......... .......... 58% 16.9M 0s
5000K .......... .......... .......... .......... .......... 58% 10.3M 0s
5050K .......... .......... .......... .......... .......... 59% 15.9M 0s
5100K .......... .......... .......... .......... .......... 59% 14.6M 0s
5150K .......... .......... .......... .......... .......... 60% 16.6M 0s
5200K .......... .......... .......... .......... .......... 61% 11.1M 0s
5250K .......... .......... .......... .......... .......... 61% 10.5M 0s
5300K .......... .......... .......... .......... .......... 62% 12.5M 0s
5350K .......... .......... .......... .......... .......... 62% 15.0M 0s
5400K .......... .......... .......... .......... .......... 63% 14.8M 0s
5450K .......... .......... .......... .......... .......... 63% 14.6M 0s
5500K .......... .......... .......... .......... .......... 64% 14.3M 0s
5550K .......... .......... .......... .......... .......... 65% 11.2M 0s
5600K .......... .......... .......... .......... .......... 65% 14.4M 0s
5650K .......... .......... .......... .......... .......... 66% 14.5M 0s
5700K .......... .......... .......... .......... .......... 66% 18.2M 0s
5750K .......... .......... .......... .......... .......... 67% 15.2M 0s
5800K .......... .......... .......... .......... .......... 68% 14.5M 0s
5850K .......... .......... .......... .......... .......... 68% 14.6M 0s
5900K .......... .......... .......... .......... .......... 69% 16.4M 0s
5950K .......... .......... .......... .......... .......... 69% 7.94M 0s
6000K .......... .......... .......... .......... .......... 70% 48.1M 0s
6050K .......... .......... .......... .......... .......... 70% 6.39M 0s
6100K .......... .......... .......... .......... .......... 71% 18.1M 0s
6150K .......... .......... .......... .......... .......... 72% 15.1M 0s
6200K .......... .......... .......... .......... .......... 72% 10.6M 0s
6250K .......... .......... .......... .......... .......... 73% 14.2M 0s
6300K .......... .......... .......... .......... .......... 73% 19.8M 0s
6350K .......... .......... .......... .......... .......... 74% 13.5M 0s
6400K .......... .......... .......... .......... .......... 75% 16.9M 0s
6450K .......... .......... .......... .......... .......... 75% 14.8M 0s
6500K .......... .......... .......... .......... .......... 76% 13.8M 0s
6550K .......... .......... .......... .......... .......... 76% 15.4M 0s
6600K .......... .......... .......... .......... .......... 77% 8.90M 0s
6650K .......... .......... .......... .......... .......... 77% 15.0M 0s
6700K .......... .......... .......... .......... .......... 78% 16.4M 0s
6750K .......... .......... .......... .......... .......... 79% 11.5M 0s
6800K .......... .......... .......... .......... .......... 79% 20.4M 0s
6850K .......... .......... .......... .......... .......... 80% 15.8M 0s
6900K .......... .......... .......... .......... .......... 80% 11.3M 0s
6950K .......... .......... .......... .......... .......... 81% 14.7M 0s
7000K .......... .......... .......... .......... .......... 82% 11.6M 0s
7050K .......... .......... .......... .......... .......... 82% 18.8M 0s
7100K .......... .......... .......... .......... .......... 83% 15.2M 0s
7150K .......... .......... .......... .......... .......... 83% 15.2M 0s
7200K .......... .......... .......... .......... .......... 84% 12.5M 0s
7250K .......... .......... .......... .......... .......... 84% 17.4M 0s
7300K .......... .......... .......... .......... .......... 85% 17.0M 0s
7350K .......... .......... .......... .......... .......... 86% 17.5M 0s
7400K .......... .......... .......... .......... .......... 86% 10.2M 0s
7450K .......... .......... .......... .......... .......... 87% 15.5M 0s
7500K .......... .......... .......... .......... .......... 87% 12.2M 0s
7550K .......... .......... .......... .......... .......... 88% 12.1M 0s
7600K .......... .......... .......... .......... .......... 88% 13.0M 0s
7650K .......... .......... .......... .......... .......... 89% 19.0M 0s
7700K .......... .......... .......... .......... .......... 90% 15.0M 0s
7750K .......... .......... .......... .......... .......... 90% 17.6M 0s
7800K .......... .......... .......... .......... .......... 91% 14.9M 0s
7850K .......... .......... .......... .......... .......... 91% 14.8M 0s
7900K .......... .......... .......... .......... .......... 92% 14.7M 0s
7950K .......... .......... .......... .......... .......... 93% 15.5M 0s
8000K .......... .......... .......... .......... .......... 93% 14.6M 0s
8050K .......... .......... .......... .......... .......... 94% 17.5M 0s
8100K .......... .......... .......... .......... .......... 94% 15.1M 0s
8150K .......... .......... .......... .......... .......... 95% 227K 0s
8200K .......... .......... .......... .......... .......... 95% 11.3M 0s
8250K .......... .......... .......... .......... .......... 96% 11.6M 0s
8300K .......... .......... .......... .......... .......... 97% 173M 0s
8350K .......... .......... .......... .......... .......... 97% 116M 0s
8400K .......... .......... .......... .......... .......... 98% 134M 0s
8450K .......... .......... .......... .......... .......... 98% 173M 0s
8500K .......... .......... .......... .......... .......... 99% 41.9M 0s
8550K .......... .......... .......... .......... ...... 100% 124M=1.0s
2017-11-23 23:32:49 (8.61 MB/s) - ‘outreach.csv’ saved [8802904/8802904]
In [4]:
TString dir = gSystem->UnixPathName(__FILE__);
dir.ReplaceAll("outreach.C","");
dir.ReplaceAll("/./","/");
TFile *f = new TFile("outreach.root","RECREATE");
In [5]:
TTree *tree = new TTree("ntuple","data from csv file");
// The file inside has ----> type, Channel, NJets, MET, Mll, LepDeltaPhi, METLLDeltaPhi, SumLepPt, BTags, weight
tree->ReadFile("outreach.csv","type/I:Channel/I:NJets/I:MET/F:Mll/F:LepDeltaPhi/F:METLLDeltaPhi/F:SumLepPt/F:BTags/F:weight/F",',');
f->Write();
Warning in <TTree::ReadStream>: Couldn't read formatted data in "type" for branch type on line 1; ignoring line
Warning in <TTree::ReadStream>: Read too few columns (1 < 10) in line 1; ignoring line
In [6]:
system("ls -lhrt outreach.*");
-rw-r--r--@ 1 arturos staff 8.4M Jan 15 2017 outreach.csv
-rw-r--r-- 1 arturos staff 3.0M Nov 23 23:32 outreach.root
In [7]:
TFile *_file0 = TFile::Open("outreach.root");
In [8]:
TCanvas *c3D = new TCanvas("c3D","c3D",10,10,400,400);
ntuple->Draw("MET:Mll:LepDeltaPhi","MET>0.");
c3D->Draw();
In [9]:
TCanvas *cz = new TCanvas("cz","cz",10,10,400,400);
ntuple->Draw("Mll:MET","weight>-999","colz");
In [10]:
cz->Draw();
In [11]:
TCanvas *c2D = new TCanvas("c2D","c2D",10,10,400,400);
ntuple->Draw("Mll:LepDeltaPhi","MET>0.","colz");
c2D->Draw();
Below you can try to create a more complex analysis, following what is done in notebook_micro_HEP_analysis_cpp_example.ipynb
Content source: artfisica/notebooks
Similar notebooks: