Subversion Repositories f9daq

Compare Revisions

Ignore whitespace Rev 272 → Rev 273

/belle2/masterclass/js/belle2_def.js
81,7 → 81,7
.appendField(new Blockly.FieldNumber(0, -Infinity, Infinity, 0.0001), "max");
this.appendDummyInput()
.appendField("Variable")
.appendField(new Blockly.FieldDropdown([["mass", "GetMass"], ["momentum", "GetMomentum"], ["energy", "GetEnergy"],["charge", "GetCharge"], ["identity", "GetPid"],["px", "GetXMomentum"],["py", "GetYMomentum"],["pz", "GetZMomentum"],["pT", "GetTransverseMomentum"]]), "varname");
.appendField(new Blockly.FieldDropdown([["mass", "GetMass"], ["momentum", "GetMomentum"], ["energy", "GetEnergy"],["charge", "GetCharge"], ["identity", "GetPid"],["polar angle", "GetTheta"],["cos(polar ang.)", "GetCosTheta"],["px", "GetXMomentum"],["py", "GetYMomentum"],["pz", "GetZMomentum"],["pT", "GetTransverseMomentum"]]), "varname");
this.setInputsInline(true);
this.setOutput(true, "histogram");
this.setColour(20);
/belle2/masterclass/src/BParticle.h
33,6 → 33,7
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 GetTransverseMomentum() const { return sqrt(m_px*m_px+m_py*m_py); };
float charge() const { return m_charge; };
SIMPLEPID pid() const { return m_pid; };
float GetMass(SIMPLEPID pid);
/belle2/masterclass/src/Blab2.cc
7,6 → 7,7
#include <TTree.h>
#include <TBranch.h>
#include <TBufferJSON.h>
#include <TMath.h>
 
#include "BParticle.h"
#include "BEvent.h"
57,7 → 58,16
 
void Blab2::h1d(const char *varname, const char *name, int nbins, double min, double max, int id ){
TString svar(varname);
TString axis[]={"mass (GeV/c2)","momentum (GeV/c)","energy (GeV)","charge","identity","momentum (GeV/c)","momentum (GeV/c)","momentum (GeV/c)","momentum (GeV/c)"};
TString axis[]={"mass (GeV/c2)",
"momentum (GeV/c)",
"energy (GeV)","charge",
"identity",
"momentum (GeV/c)",
"momentum (GeV/c)",
"momentum (GeV/c)",
"momentum (GeV/c)",
"angle (deg.)",
"cos(theta)"};
fHtype[id] = 0;
if (svar.Contains("GetMass" )) fHtype[id]=0;
if (svar.Contains("GetMomentum")) fHtype[id]=1;
68,6 → 78,8
if (svar.Contains("GetYMomentum")) fHtype[id]=6;
if (svar.Contains("GetZMomentum")) fHtype[id]=7;
if (svar.Contains("GetTranverseMomentum")) fHtype[id]=8;
if (svar.Contains("GetTheta")) fHtype[id]=9;
if (svar.Contains("GetCosTheta")) fHtype[id]=10;
 
fH[id]= new TH1F(TString::Format("h%d",id), TString::Format("%s;%s;N",name,axis[fHtype[id]].Data()), nbins, min, max);
82,20 → 94,22
}
 
int Blab2::Fill(int hid, BParticle *p){
if (hid>=0 && fH[hid]) {
float val;
if (hid>=0 && fH[hid]) {
double val;
switch (fHtype[hid]){
case 0: val = p->GetMass(); break;
case 1: val = p->GetMomentum(); break;
case 2: val = p->e(); break;
case 3: val = p->charge(); break;
case 4: val = p->pid(); break;
case 5: val = p->px(); break;
case 6: val = p->py(); break;
case 7: val = p->pz(); break;
case 8: val = sqrt(p->px()*p->px()+p->py()*p->py()); break;
default : val = 0 ; break;
}
case 0 : val = p->GetMass(); break;
case 1 : val = p->GetMomentum(); break;
case 2 : val = p->e(); break;
case 3 : val = p->charge(); break;
case 4 : val = p->pid(); break;
case 5 : val = p->px(); break;
case 6 : val = p->py(); break;
case 7 : val = p->pz(); break;
case 8 : val = p->GetTransverseMomentum(); break;
case 9 : val = (p->GetMomentum()!=0) ? p->pz()/p->GetMomentum() : 0; val = 180*acos(val)/TMath::Pi(); break;
case 10: val = (p->GetMomentum()!=0) ? p->pz()/p->GetMomentum() : 0; break;
default: val = 0 ; break;
}
fH[hid]->Fill(val);
}
 
202,6 → 216,8
int nev = 0;
int i =TMath::Min(fNfirst, (UInt_t) t-> GetEntries());
int cNeve=TMath::Min(fNfirst+fNeve, (UInt_t) t-> GetEntries());
int fPart = fPrint;
int totaltracks = 0;
while (i<cNeve){
t-> GetEntry(i); // Read the content of the event from the file
fList[0]= mevent->GetParticleList();
218,7 → 234,8
nprt++;
if (fPrint) sprintf(sList,"%s<tr><td>%d<td>%g<td>%g<td>%g<td>%g<td>%g<td>%1.0f<td>%s</tr>",sList,nprt, p->px(),p->py(),p->pz(),p->GetMomentum(),p->e(), p->charge(),names[p->pid()] );
}
fHnprt->Fill(nprt);
if (fPart) fHnprt->Fill(nprt);
totaltracks += nprt;
if (fPrint) {
sprintf(sList,"%s</table>",sList);
send_message(0, TString(sList),progress);
228,12 → 245,12
for (int k=0;k<100;k++) if (fList[k]!=0) fList[k]->Clear();
i++;
}
double avgtracks=(i)?float(totaltracks)/i:0;
send_message(0, TString::Format("Number of events processed: %d<br/>\nNumber of particles: %d<br/>\nAverage number of particles per event %f<br/>\n", i, totaltracks, avgtracks ),100);
 
send_message(2, TString::Format("Number of events processed %d\n", i ),100);
if (fPart) send_message(1,TBufferJSON::ConvertToJSON(fHnprt),100 );
 
send_message(1,TBufferJSON::ConvertToJSON(fHnprt),100 );
 
 
for (int i=0;i<100;i++) if (fH[i]!=0) send_message(1,TBufferJSON::ConvertToJSON(fH[i]),100 );
 
TDatime d;