| /belle2/masterclass/js/belle2_def.js |
|---|
| 38,6 → 38,51 |
| } |
| }; |
| Blockly.Blocks['particle_combiner3'] = { |
| init: function() { |
| this.appendDummyInput() |
| .appendField("Combine 3 particles"); |
| this.appendValueInput("list1") |
| .setCheck("particle list") |
| .setAlign(Blockly.ALIGN_RIGHT) |
| .appendField("Particle 1"); |
| this.appendValueInput("list2") |
| .setCheck("particle list") |
| .setAlign(Blockly.ALIGN_RIGHT) |
| .appendField("Particle 2"); |
| this.appendValueInput("list3") |
| .setCheck("particle list") |
| .setAlign(Blockly.ALIGN_RIGHT) |
| .appendField("Particle 3"); |
| this.appendDummyInput() |
| .appendField("Same particle lists?") |
| .appendField(new Blockly.FieldDropdown([["No", "0"], ["Yes", "1"]]), "sameparticles"); |
| this.appendDummyInput() |
| .appendField("Set identity to") |
| .appendField(new Blockly.FieldDropdown([["electron", "ELECTRON"], ["muon", "MUON"], ["pion", "PION"], ["kaon", "KAON"], |
| ["proton", "PROTON"], ["photon", "PHOTON"], ["Phi meson", "PHI"], ["D meson", "D"], |
| ["D* meson", "DSTAR"], ["J/Psi meson", "JPSI"],["B meson","B"], ["Lambda 0","LAMBDA0"]]), "simplepid"); |
| this.appendDummyInput() |
| .setAlign(Blockly.ALIGN_RIGHT) |
| .appendField("Min mass [GeV/c2] :") |
| .appendField(new Blockly.FieldNumber(0, 0, Infinity, 0.0001), "mass0"); |
| this.appendDummyInput() |
| .setAlign(Blockly.ALIGN_RIGHT) |
| .appendField("Max mass [GeV/c2] :") |
| .appendField(new Blockly.FieldNumber(0, 0, Infinity, 0.0001), "mass1"); |
| //this.appendValueInput("histogram").setCheck("histogram").appendField("Histogram"); |
| this.appendDummyInput().appendField("Histograms"); |
| this.appendStatementInput("histogram") |
| .setCheck("histogram"); |
| this.setInputsInline(false); |
| this.setOutput(true, "particle list"); |
| this.setColour(0); |
| this.setTooltip('Combine three particles in the new particle by making combinations between particles in three input lists. If the input connector is empty, the full particle list will be used'); |
| this.setHelpUrl('http://belle.jp/'); |
| } |
| }; |
| Blockly.Blocks['particle_selector'] = { |
| init: function() { |
| this.appendDummyInput() |
| /belle2/masterclass/js/belle2_gen.js |
|---|
| 15,6 → 15,24 |
| return [code, Blockly.JavaScript.ORDER_NONE]; |
| }; |
| Blockly.JavaScript['particle_combiner3'] = function(block) { |
| var value_list1 = Blockly.JavaScript.valueToCode(block, 'list1', Blockly.JavaScript.ORDER_ATOMIC); |
| if (value_list1.length==0) value_list1='""'; |
| var value_list2 = Blockly.JavaScript.valueToCode(block, 'list2', Blockly.JavaScript.ORDER_ATOMIC); |
| if (value_list2.length==0) value_list2='""'; |
| var value_list3 = Blockly.JavaScript.valueToCode(block, 'list3', Blockly.JavaScript.ORDER_ATOMIC); |
| if (value_list3.length==0) value_list3='""'; |
| var dropdown_simplepid = block.getFieldValue('simplepid'); |
| var dropdown_sameparticles = block.getFieldValue('sameparticles'); |
| var number_mass0 = block.getFieldValue('mass0'); |
| var number_mass1 = block.getFieldValue('mass1'); |
| var histograms = Blockly.JavaScript.statementToCode(block, 'histogram'); |
| var code = '{"combiner3":{"list1":' + value_list1 + ',"list2":' + value_list2 + ',"list3":' + value_list3 ; |
| code += ',"sameparticles":"'+ dropdown_sameparticles +'","pid":"' + dropdown_simplepid ; |
| code += '","m0":"' + number_mass0 + '","m1":"' + number_mass1 + '","histogram":[' + histograms + ']}}\n'; |
| return [code, Blockly.JavaScript.ORDER_NONE]; |
| }; |
| Blockly.JavaScript['particle_selector'] = function(block) { |
| var value_list1 = Blockly.JavaScript.valueToCode(block, 'list1', Blockly.JavaScript.ORDER_ATOMIC); |
| if (value_list1.length==0) value_list1='""'; |
| /belle2/masterclass/runscript.php |
|---|
| 247,7 → 247,7 |
| $xpath = new DOMXpath($dom); |
| $nodelist = $xpath->query('//selector|//combiner'); |
| $nodelist = $xpath->query('//selector|//combiner|//combiner3'); |
| $cnt=1; |
| foreach ($nodelist as $plist) { |
| $newnode=$dom->createElement("plist","$cnt"); |
| 257,7 → 257,7 |
| $cnt++; |
| } |
| $nodelist = $xpath->query('//list|//list1|//list2'); |
| $nodelist = $xpath->query('//list|//list1|//list2|//list3'); |
| $cnt=1; |
| foreach ($nodelist as $plist) { |
| if( $plist->childNodes->length === 0){ |
| /belle2/masterclass/src/Blab2.cc |
|---|
| 55,6 → 55,8 |
| int selector(int pin, int charge, SIMPLEPID particlename, std::vector<int> hid, int pout ); |
| int combiner(int id0 ,int id1 , int same, SIMPLEPID particlename, double min, double max, int hid, int id ); |
| int combiner(int id0 ,int id1 , int same, SIMPLEPID particlename, double min, double max, std::vector<int>hid, int id ); |
| int combiner3(int id0 ,int id1 , int id2, int same, SIMPLEPID particlename, double min, double max, int hid, int id ); |
| int combiner3(int id0 ,int id1 , int id2, int same, SIMPLEPID particlename, double min, double max, std::vector<int>hid, int id ); |
| int fix_mass(int id); |
| int Fill(std::vector<int> hid, BParticle *p); |
| void plist(int i); |
| 140,6 → 142,11 |
| return combiner(_p0,_p1,same,pid,min,max,a,_p2); |
| } |
| int Blab2::combiner3(int _p0, int _p1, int _p2, int same, SIMPLEPID pid, double min, double max, int hid, int _p3 ){ |
| std::vector<int> a; |
| return combiner3(_p0,_p1,_p2, same,pid,min,max,a,_p3); |
| } |
| int Blab2::combiner(int _p0, int _p1,int same, SIMPLEPID pid, double min, double max, std::vector<int> hid, int _p2 ){ |
| // Loop over all the particles in both lists. |
| if (_p0 < 0 ) _p0 =0; |
| 171,6 → 178,40 |
| } |
| int Blab2::combiner3(int _p0, int _p1,int _p2, int same, SIMPLEPID pid, double min, double max, std::vector<int> hid, int _p3 ){ |
| // Loop over all the particles in both lists. |
| if (_p0 < 0 ) _p0 =0; |
| if (_p1 < 0 ) _p1 =0; |
| if (_p2 < 0 ) _p2 =0; |
| fList[_p2]->Clear(); |
| int nprt=0; |
| for(TIter next1(fList[_p0]);BParticle * p1 =(BParticle *) next1();) { |
| // the second loop |
| // in the case the second parti |
| for(TIter next2 = (_p0!=_p1 && same==0) ? TIter(fList[_p1]): TIter(next1) ; BParticle * p2 =(BParticle *) next2();) { |
| if (p1==p2) continue; // do not use the same particle in the combinations |
| for(TIter next3 = (_p1!=_p2 && same==0) ? TIter(fList[_p2]): TIter(next2) ; BParticle * p3 =(BParticle *) next3();) { |
| if (p2==p3) continue; // do not use the same particle in the combinations |
| BParticle p = *p1 + *p2 + *p3; // Combine two particles into a new particle |
| if (p.InMassRange(min, max)){ |
| Fill(hid, &p); |
| p.SetPid(pid); // set PID to particlename to fix the particle mass |
| p.SetEnergyFromPid(); |
| TClonesArray& list = *fList[_p3]; |
| new (list[nprt++]) BParticle ( p ); // create a new entry in kslist list of particles |
| } |
| } |
| } |
| } |
| return _p3; |
| } |
| int Blab2::selector(int pin, int charge, SIMPLEPID type , int hid, int pout ){ |
| std::vector<int> a; |
| return selector(pin,charge,type,a,pout); |
| /belle2/masterclass/toolbox.xml |
|---|
| 20,5 → 20,10 |
| <field name="mass0">0</field> |
| <field name="mass1">5</field> |
| </block> |
| <block type="particle_combiner3"> |
| <field name="simplepid">ELECTRON</field> |
| <field name="mass0">0</field> |
| <field name="mass1">5</field> |
| </block> |
| </category> |
| </xml> |