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