/belle2/masterclass/index.php |
---|
15,8 → 15,8 |
<script src="js/Blob.js"></script> |
<!-- <script type="text/javascript" src="jsroot/scripts/JSRootCore.js?2d&onload=startGUI""></script> --> |
<script type="text/javascript" src="https://root.cern/js/latest/scripts/JSRootCore.js?2d&onload=startGUI"></script> |
<!-- <script type="text/javascript" src="js/JSRootCore.js?2d&onload=startGUI""></script> --> |
<script type="text/javascript" src="https://root.cern/js/latest/scripts/JSRootCore.js?2d&onload=startGUI"></script> |
<script type = "text/javascript" language = "javascript"> |
var es; |
51,6 → 51,7 |
var r = document.getElementById('results'); |
if ( r.style.display == 'none' ) switchTask(); |
r.innerHTML = ''; |
document.getElementById('drawing').innerHTML = ''; |
Blockly.JavaScript.INFINITE_LOOP_TRAP = null; |
90,11 → 91,15 |
var jsonobj = JSROOT.parse(result.message); |
var sframe = 'rh'+ (cnt++); |
addLog('ROOT_JSON object '+ sframe ); |
var r = document.getElementById('results'); |
r.insertAdjacentHTML('beforeend', '<div id="' + sframe +'" style="width:60%; height:60%;"></div>'); |
//var r = document.getElementById('results'); |
var r = document.getElementById('drawing'); |
r.insertAdjacentHTML('beforeend', '<div id="' + sframe +'" style="width:60%; height:60%;"></div><br/>'); |
var frame = document.getElementById(sframe); |
JSROOT.draw(frame, jsonobj, "hist"); |
//JSROOT.draw(frame, jsonobj, "hist"); |
JSROOT.draw(sframe, jsonobj, "hist"); |
//addLog('JSON :' + JSON.stringify(jsonobj)+ '<br>'); |
frame.scrollIntoView(); |
} |
} |
314,6 → 319,6 |
</script> |
<div id="drawing" style="width:800px; height:600px"></div> |
</body> |
</html> |
/belle2/masterclass/js/belle2_def.js |
---|
44,7 → 44,7 |
.appendField(new Blockly.FieldDropdown([["-1", "-1"], ["0", "0"], ["1", "1"]]), "chargelist"); |
this.appendDummyInput() |
.appendField("Type") |
.appendField(new Blockly.FieldDropdown([["electron", "ELECTRON"], ["muon", "MUON"], ["pion", "PION"], ["kaon", "KAON"], ["proton", "PROTON"], ["photon", "PHOTON"], ["Ks", "KS"], ["D", "D"], ["D*", "DSTAR"], ["J/Psi", "JPSI"]]), "simplepid"); |
.appendField(new Blockly.FieldDropdown([["electron", "ELECTRON"], ["muon", "MUON"], ["pion", "PION"], ["kaon", "KAON"], ["proton", "PROTON"], ["photon", "PHOTON"], ["Ks", "KS"], ["D", "D"], ["D*", "DSTAR"], ["J/Psi", "JPSI"], ["all particles", "ALL"]]), "simplepid"); |
this.appendValueInput("histogram") |
.setCheck("histogram") |
.appendField("Histogram"); |
/belle2/masterclass/runscript.php |
---|
112,7 → 112,8 |
// (This makes sure that we have no duplicate rows (which would be a waste) and can determine the visitor's location, respectively) |
// ...We insert the values returned by our function into the database, escaping any possible dangerous input |
if(!mysql_fetch_row($user) && $userinfo) |
mysql_query($msql) or die(mysql_error()); |
mysql_query($msql); |
// or die(mysql_error()); |
} |
/belle2/masterclass/runscript.sh |
---|
12,6 → 12,11 |
h1->FillRandom("gaus",10000); |
TString json = TBufferJSON::ConvertToJSON(h1); |
cout << "Data" << json.Data() << endl; |
FILE *fp=fopen("hpx.json","wb"); |
if (fp){ |
json.Puts(fp); |
fclose(fp); |
} |
EOL |
for ((i=0;i<5;i++)) ; do echo $i; sleep 1; done; |
/belle2/masterclass/src/BParticle.cc |
---|
1,7 → 1,6 |
//+ |
// File : BParticle.cc |
// Description : Implementation of BTrack class // |
// Description : Ryosuke Itoh, IPNS, KEK // Date : 28 - Jan - 2004 |
//- |
#include "BParticle.h" |
24,12 → 23,12 |
switch (pid){ |
case PHOTON: return 0; |
case ELECTRON: return 0.51; |
case ELECTRON: return 0.51; |
case PION: return 0.139; |
case MUON: return 0.105; |
case MUON: return 0.105; |
case KAON: return 0.497; |
case PROTON: return 0.938; |
case JPSI: return 3.1; |
case JPSI: return 3.1; |
case D: return 1.86; |
case DSTAR: return 2.01; |
case B: return 5.27; |
/belle2/masterclass/src/BParticle.h |
---|
11,7 → 11,7 |
#include "TObject.h" |
#include "TClonesArray.h" |
enum SIMPLEPID {PHOTON, ELECTRON, PION, MUON, KAON, PROTON, JPSI, D, DSTAR, B,KS }; |
enum SIMPLEPID {PHOTON, ELECTRON, PION, MUON, KAON, PROTON, JPSI, D, DSTAR, B,KS, ALL }; |
class BParticle : public TObject { |
32,6 → 32,7 |
float py() const { return m_py; }; |
float pz() const { return m_pz; }; |
float e() const { return m_e; }; |
float GetMomentum() const { return sqrt(m_px*m_px+m_py*m_py+m_pz*m_pz); }; |
float charge() const { return m_charge; }; |
SIMPLEPID pid() const { return m_pid; }; |
float GetMass(SIMPLEPID pid); |
/belle2/masterclass/src/Blab2.cc |
---|
22,8 → 22,10 |
class Blab2 { |
public: |
UInt_t fNeve; |
UInt_t fNfirst; |
int fData; |
TH1F *fH[100]; |
UInt_t fHtype[100]; |
TClonesArray *fList[100]; |
Blab2(); |
35,6 → 37,7 |
int selector(int pin, int charge, SIMPLEPID particlename, int hid, int pout ); |
int combiner(int id0 ,int id1 , SIMPLEPID particlename, double min, double max, int hid, int id ); |
int fix_mass(int id); |
int Fill(int hid, BParticle *p); |
void plist(int i); |
43,15 → 46,38 |
ClassImp(Blab2) |
Blab2::Blab2():fNeve(0), fData(0){ |
Blab2::Blab2():fNfirst(0), fNeve(0), fData(0){ |
Process(); |
}; |
void Blab2::h1d(const char *varname, const char *name, int nbins, double min, double max, int id ){ |
fH[id]= new TH1F(TString::Format("h%d",id), name, nbins, min, max); |
TString svar(varname); |
TString axis[3]={"mass (GeV/c2)","momentum (GeV/c)","energy (GeV)"}; |
fHtype[id] = 0; |
if (svar.Contains("GetMass" )) fHtype[id]=0; |
if (svar.Contains("GetMomentum")) fHtype[id]=1; |
if (svar.Contains("GetEnergy" )) fHtype[id]=2; |
fH[id]= new TH1F(TString::Format("h%d",id), TString::Format("%s;%s;N",name,axis[fHtype[id]].Data()), nbins, min, max); |
} |
int Blab2::Fill(int hid, BParticle *p){ |
if (hid>=0 && fH[hid]) { |
float val; |
switch (fHtype[hid]){ |
case 0: val = p->GetMass(); break; |
case 1: val = p->GetMomentum(); break; |
case 2: val = p->e(); break; |
default : val = 0 ; break; |
} |
fH[hid]->Fill(val); |
} |
return 0; |
} |
int Blab2::combiner(int _p0, int _p1,SIMPLEPID pid, double min, double max, int hid, int _p2 ){ |
// Loop over all the particles in both lists. |
if (_p0 < 0 ) _p0 =0; |
72,7 → 98,7 |
p.SetPid(pid); |
TClonesArray& list = *fList[_p2]; |
new (list[nprt++]) BParticle ( p ); // create a new entry in kslist list of particles |
if (hid>=0 && fH[hid]) fH[hid]->Fill(p.GetMass()); |
Fill(hid, &p); |
} |
} |
85,15 → 111,14 |
int Blab2::selector(int pin, int charge, SIMPLEPID type , int hid, int pout ){ |
if (pin < 0 ) pin =0; |
fList[pout]->Clear(); |
int nprt=0; |
for(TIter next(fList[pin]); BParticle * p =(BParticle *) next();) { |
if (p->charge()== charge && p->pid()== type ) { |
if (p->charge()== charge && ( p->pid()== type || type == ALL )) { |
TClonesArray& list = *fList[pout]; |
new (list[nprt++]) BParticle ( *p ); |
if (hid>=0 && fH[hid]) fH[hid]->Fill(p->GetMass()); |
Fill(hid, p); |
} |
} |
return pout; |
128,6 → 153,7 |
void Blab2::Process(){ |
for (int i=0;i<100;i++) fH[i]=NULL; |
for (int i=0;i<100;i++) fHtype[i]=0; |
for (int i=0;i<100;i++) fList[i]=NULL; |
Init(); |
138,18 → 164,32 |
BEvent * mevent = new BEvent(); // Create a "BEvent" object where data from the file will be loaded |
TBranch * branch = t-> GetBranch( "BEvent"); // Obtain a branch for "BEvent" in the tree |
branch-> SetAddress(&mevent); // Register created "BEvent" object to the branch |
TH1F *fHnprt= new TH1F("h100", "Number of particles in the event;N particles;N events", 50, -0.5, 49.5); |
TH1F *fHid= new TH1F("h101", "Particle type;ID;N particles", 6, -0, 6); |
const char *names[6]={"PHOTON", "ELECTRON", "PION", "MUON", "KAON", "PROTON"}; |
for (int i=1;i<=6;i++) fHid->GetXaxis()->SetBinLabel(i,names[i-1]); |
send_message(0, TString::Format("Number of Entries in the file %lld\n", t->GetEntries() ),0); |
TStopwatch timer; |
timer.Start(); |
int i=0; |
int cNeve=TMath::Min(fNeve, (UInt_t) t-> GetEntries()); |
int i =TMath::Min(fNfirst, (UInt_t) t-> GetEntries()); |
int cNeve=TMath::Min(fNfirst+fNeve, (UInt_t) t-> GetEntries()); |
while (i<cNeve){ |
t-> GetEntry(i); // Read the content of the event from the file |
fList[0]= mevent->GetParticleList(); |
event(); |
if (i%10000==0) send_message(2, TString::Format("Event %d\n",i), (100*i)/cNeve); |
int nprt=0; |
for(TIter next(fList[0]); BParticle * p =(BParticle *) next();) { |
nprt++; |
fHid->Fill(p->pid()); |
} |
fHnprt->Fill(nprt); |
mevent-> Clear(); // Clear the memory. |
for (int k=0;k<100;k++) if (fList[k]!=0) fList[k]->Clear(); |
i++; |
157,7 → 197,8 |
send_message(2, TString::Format("Number of events processed %d\n", i ),100); |
for (int i=0;i<100;i++) if (fH[i]!=0) send_message(1,TBufferJSON::ConvertToJSON(fH[i]),100 ); |
send_message(1,TBufferJSON::ConvertToJSON(fHnprt),100 ); |
send_message(1,TBufferJSON::ConvertToJSON(fHid),100 ); |
TDatime d; |
timer.Stop(); |
send_message(3, TString::Format("'%s', %d, %f, %f", d.AsSQLString(),i, timer.RealTime(), timer.CpuTime() ),100); |