| 1 | #include "flowmodex.h"
|
|---|
| 2 | #include "pi2dvec.h"
|
|---|
| 3 |
|
|---|
| 4 | #include <typeinfo>
|
|---|
| 5 |
|
|---|
| 6 | #include <vector>
|
|---|
| 7 | #include <string>
|
|---|
| 8 | #include "nobjmgr.h"
|
|---|
| 9 | #include "ntuple.h"
|
|---|
| 10 |
|
|---|
| 11 | #include "pidrawer.h"
|
|---|
| 12 | #include "nomgadapter.h"
|
|---|
| 13 | #include "servnobjm.h"
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 | /* --Methode-- */
|
|---|
| 17 | FlowModExecutor::FlowModExecutor(PIACmd* mpiac, PIStdImgApp* app)
|
|---|
| 18 | {
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 | //cout << " FlowModExecutor::FlowModExecutor() mpiac = " << (unsigned long)mpiac << endl;
|
|---|
| 22 | cout << " registration of flow chart commands "<<endl;
|
|---|
| 23 | string hgrp,kw,usage;
|
|---|
| 24 | hgrp = "Obj. Display";
|
|---|
| 25 |
|
|---|
| 26 | kw = "nt2dvec";
|
|---|
| 27 | usage = "Creates and displays a flow chart from ntuple variables";
|
|---|
| 28 | usage += "\n Usage: nt2dvec x y vx vy [graphic_att] ";
|
|---|
| 29 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 | hgrp = "Expr. Plotting";
|
|---|
| 33 | kw = "plot2dvec";
|
|---|
| 34 | usage = "Creates and displays a flow chart from ntuple expressions ";
|
|---|
| 35 | usage += "\n Usage: plot2dvec ntuple expx expy expvx expvy [cut graphic_att loop_par]";
|
|---|
| 36 |
|
|---|
| 37 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
|---|
| 38 |
|
|---|
| 39 | //cout << " Out of ContModExecutor::ContModExecutor() " << endl;
|
|---|
| 40 |
|
|---|
| 41 | }
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 | /* --Methode-- */
|
|---|
| 46 | FlowModExecutor::~FlowModExecutor()
|
|---|
| 47 | {
|
|---|
| 48 | }
|
|---|
| 49 |
|
|---|
| 50 | /* --Methode-- */
|
|---|
| 51 | int FlowModExecutor::Execute(string& kw, vector<string>& tokens, string& toks)
|
|---|
| 52 | {
|
|---|
| 53 |
|
|---|
| 54 | int nz=-1;
|
|---|
| 55 | double z0,dz;
|
|---|
| 56 | PI2dVecDrawer *p2dv;
|
|---|
| 57 | string dopt="";
|
|---|
| 58 | NamedObjMgr omg;
|
|---|
| 59 |
|
|---|
| 60 | if ( kw == "nt2dvec") {
|
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 | if (tokens.size() < 5) {
|
|---|
| 64 | cout << "Usage: nt2dvec ntuple x y vx vy [graphic_att]" << endl;
|
|---|
| 65 | return(0);
|
|---|
| 66 | }
|
|---|
| 67 | NObjMgrAdapter* obja = omg.GetObjAdapter(tokens[0]);
|
|---|
| 68 | if (obja == NULL) {
|
|---|
| 69 | cout << "contour Error , No object with name " << tokens[0] << endl;
|
|---|
| 70 | return(0);
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 73 | if (tokens.size() > 5) dopt = tokens[5];
|
|---|
| 74 | bool adel;
|
|---|
| 75 |
|
|---|
| 76 | NTupleInterface *ntin = obja->GetNTupleInterface(adel);
|
|---|
| 77 |
|
|---|
| 78 | p2dv = new PI2dVecDrawer(ntin,adel);
|
|---|
| 79 | string expx,expy;
|
|---|
| 80 | expx = tokens[1];
|
|---|
| 81 | expy = tokens[2];
|
|---|
| 82 | int ret = p2dv->SelectXY(expx.c_str(),expy.c_str());
|
|---|
| 83 | if(ret<0){ cout << "Usage: nt2dvec ntuple x y vx vy [graphic_att]" << endl; return(0);}
|
|---|
| 84 | expx = tokens[3];
|
|---|
| 85 | expy = tokens[4];
|
|---|
| 86 | ret = p2dv->SelectVW(expx.c_str(),expy.c_str());
|
|---|
| 87 | if(ret<0){ cout << "Usage: nt2dvec ntuple x y vx vy [graphic_att ]" << endl; return(0);}
|
|---|
| 88 |
|
|---|
| 89 | // On affiche le Drawer
|
|---|
| 90 | int wrsid = 0;
|
|---|
| 91 | string name = "ChampVec";
|
|---|
| 92 |
|
|---|
| 93 | wrsid = omg.GetImgApp()->DispScDrawer(p2dv , name, dopt);
|
|---|
| 94 | omg.AddWRsId(tokens[0], wrsid);
|
|---|
| 95 |
|
|---|
| 96 | }else if(kw == "plot2dvec"){
|
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 | if (tokens.size() < 5) {
|
|---|
| 100 | cout << "Usage: plot2dvec ntuple expx expy expvx expvy [cut graphic_att loop_par]" << endl;
|
|---|
| 101 | return(0);
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 | NObjMgrAdapter* obja=NULL;
|
|---|
| 106 | obja = omg.GetObjAdapter(tokens[0]);
|
|---|
| 107 | if (obja == NULL) {
|
|---|
| 108 | cout << "plot2dvec Error , No object with name " << tokens[0] << endl;
|
|---|
| 109 | return(0);
|
|---|
| 110 | }
|
|---|
| 111 |
|
|---|
| 112 | Services2NObjMgr* srvo = omg.GetServiceObj();
|
|---|
| 113 |
|
|---|
| 114 | bool adel=true;
|
|---|
| 115 | //NTupleInterface *ntin = obja->GetNTupleInterface(adel);
|
|---|
| 116 |
|
|---|
| 117 | // Creation NTuple
|
|---|
| 118 | char* ntn[4] = {"expx","expy","expex","expey"};
|
|---|
| 119 | NTuple * ntint = NULL;
|
|---|
| 120 | ntint = new NTuple(4,ntn);
|
|---|
| 121 | // remplissage du ntuple
|
|---|
| 122 | string bidon = "0.";
|
|---|
| 123 | string nocut = "1.";
|
|---|
| 124 | if(tokens.size()>7) bidon = tokens[7];
|
|---|
| 125 | if(tokens.size()>5) nocut = tokens[5];
|
|---|
| 126 |
|
|---|
| 127 |
|
|---|
| 128 | srvo->ComputeExpressions(obja,tokens[1],tokens[2],tokens[3],tokens[4],nocut,bidon,ntint,NULL,NULL);
|
|---|
| 129 |
|
|---|
| 130 | if(ntint->NEntry()<=0){
|
|---|
| 131 | cerr << " FlowModExecutor::Execute plot2dvec <=0 evts selectionness "<<endl;
|
|---|
| 132 | return(0);
|
|---|
| 133 | }
|
|---|
| 134 |
|
|---|
| 135 | cout << " avant creation de p2dv "<<endl;
|
|---|
| 136 | p2dv = new PI2dVecDrawer(ntint,adel);
|
|---|
| 137 | p2dv->SelectXY(ntn[0],ntn[1]);
|
|---|
| 138 | p2dv->SelectVW(ntn[2],ntn[3]);
|
|---|
| 139 |
|
|---|
| 140 | if (tokens.size() > 6) dopt = tokens[6];
|
|---|
| 141 |
|
|---|
| 142 | string name = "ChampVec";
|
|---|
| 143 |
|
|---|
| 144 | int wrsid = omg.GetImgApp()->DispScDrawer(p2dv , name, dopt);
|
|---|
| 145 |
|
|---|
| 146 | }
|
|---|
| 147 |
|
|---|
| 148 |
|
|---|
| 149 | return(0);
|
|---|
| 150 |
|
|---|
| 151 | }
|
|---|
| 152 |
|
|---|
| 153 |
|
|---|
| 154 |
|
|---|