File indexing completed on 2023-03-17 10:59:32
0001 #include <unistd.h> // usleep
0002 #include <iostream> // cout
0003 #include <math.h> // exp
0004 #include <stdio.h> // printf
0005 #include <errno.h> // errno
0006 #include <sys/wait.h> // waitpid
0007
0008
0009
0010
0011
0012 #include <sys/select.h>
0013 int kbhit(void){
0014 struct timeval wait;
0015 int ret;
0016 fd_set readfd;
0017 FD_ZERO(&readfd);
0018 FD_SET(0, &readfd);
0019 wait.tv_sec = 0;
0020 wait.tv_usec = 0;
0021 ret = select(1, &readfd, NULL, NULL, &wait);
0022 return(ret);
0023 }
0024 #include <termios.h>
0025 struct termios stored_settings;
0026 void set_keypress(void) {
0027 struct termios new_settings;
0028 tcgetattr(0,&stored_settings);
0029 new_settings = stored_settings;
0030 new_settings.c_lflag &= (~ICANON);
0031 new_settings.c_cc[VTIME] = 0;
0032 tcgetattr(0,&stored_settings);
0033 new_settings.c_cc[VMIN] = 1;
0034 tcsetattr(0,TCSANOW,&new_settings);
0035 }
0036 void reset_keypress(void) {
0037 tcsetattr(0,TCSANOW,&stored_settings);
0038 }
0039 int tty_echo(bool echo){
0040 struct termios tattr; int fd = 0;
0041 if(isatty(fd)){
0042 int rc = tcgetattr(fd, &tattr);
0043 if (rc != 0) return rc;
0044 if(!echo)
0045 tattr.c_lflag &= ~(ICANON|ECHO);
0046 else
0047 tattr.c_lflag &= (ICANON|ECHO);
0048 rc = tcsetattr(fd, TCSANOW, &tattr);
0049 }
0050 return 0;
0051 }
0052
0053 __pid_t pid = 0;
0054 int pipedescr[2] = { 3, 4 };
0055
0056 #define SIGNAL(s, handler) { \
0057 sa.sa_handler = handler; \
0058 if (sigaction(s, &sa, NULL) < 0) { \
0059 fprintf(stderr, "Couldn't establish signal handler (%d): %m", s); \
0060 exit(1); \
0061 } \
0062 }
0063 static void term(int qwe){
0064 printf("Terminating\n");
0065 int stat_loc;
0066 if( write(pipedescr[1],".q\n",4) != 4 ){ printf("Can't write to pipe errno=%d\n",errno); exit(1); }
0067 waitpid(pid,&stat_loc,WCONTINUED);
0068 tty_echo(true);
0069 reset_keypress();
0070 system("cp ~/.root_hist.save ~/.root_hist");
0071 exit(0);
0072 }
0073 static void chld(int qwe){
0074 printf("root.exe terminated\n");
0075 tty_echo(true);
0076 reset_keypress();
0077 system("cp ~/.root_hist.save ~/.root_hist");
0078 exit(0);
0079 }
0080 static void hup (int qwe){
0081 printf("Hanging up\n");
0082 int stat_loc;
0083 if( write(pipedescr[1],".q\n",4) != 4 ){ printf("Can't write to pipe errno=%d\n",errno); exit(1); }
0084 waitpid(pid,&stat_loc,WCONTINUED);
0085 tty_echo(true);
0086 reset_keypress();
0087 system("cp ~/.root_hist.save ~/.root_hist");
0088 exit(0);
0089 }
0090 static void bad_signal(int qwe){
0091 printf("Some signal %d\n",qwe);
0092 int stat_loc;
0093 if( write(pipedescr[1],".q\n",4) != 4 ){ printf("Can't write to pipe errno=%d\n",errno); exit(1); }
0094 waitpid(pid,&stat_loc,WCONTINUED);
0095 tty_echo(true);
0096 reset_keypress();
0097 system("cp ~/.root_hist.save ~/.root_hist");
0098 exit(0);
0099 }
0100
0101
0102 #include "EventFilter/CSCTFRawToDigi/src/CSCTFEvent.cc"
0103 #include "EventFilter/CSCTFRawToDigi/src/CSCSPEvent.cc"
0104 #include "EventFilter/CSCTFRawToDigi/src/CSCSPRecord.cc"
0105 #include "IORawData/CSCCommissioning/src/FileReaderDDU.cc"
0106
0107
0108 #include <iterator>
0109 int main(int argc, char *argv[]){
0110
0111 if( argc<2 ){
0112 printf("Usage: ./show csc_00*RUI00*.raw\n"); exit(1);
0113 }
0114
0115
0116 set_keypress();
0117
0118
0119 FileReaderDDU reader;
0120 try {
0121 reader.open(argv[1]);
0122 } catch (...){
0123 printf("Can't open file %s , errno=%d\n",argv[1],errno); exit(1);
0124 }
0125
0126
0127
0128
0129 if( pipe(pipedescr) ) { printf("Can't open pipe errno=%d\n",errno); exit(1); }
0130 if( ( pid = fork() ) == -1 ) { printf("Can't create process errno=%d\n",errno); exit(1); }
0131 if( pid == 0 ){
0132 close(0);
0133 dup(pipedescr[0]);
0134 close(pipedescr[0]);
0135 execl("/bin/sh", "sh", "-c", "root.exe", (char *)0);
0136 }
0137
0138
0139 system("cp ~/.root_hist ~/.root_hist.save");
0140
0141
0142 struct sigaction sa;
0143 sigset_t mask;
0144
0145 sigemptyset(&mask);
0146 sigaddset(&mask, SIGHUP);
0147 sigaddset(&mask, SIGINT);
0148 sigaddset(&mask, SIGTERM);
0149 sigaddset(&mask, SIGCHLD);
0150
0151 sa.sa_mask = mask;
0152 sa.sa_flags = 0;
0153 SIGNAL(SIGHUP, hup);
0154 SIGNAL(SIGINT, term);
0155 SIGNAL(SIGTERM, term);
0156 SIGNAL(SIGCHLD, chld);
0157
0158 SIGNAL(SIGUSR1, bad_signal);
0159 SIGNAL(SIGUSR2, bad_signal);
0160
0161 SIGNAL(SIGABRT, bad_signal);
0162 SIGNAL(SIGALRM, bad_signal);
0163 SIGNAL(SIGFPE, bad_signal);
0164 SIGNAL(SIGILL, bad_signal);
0165 SIGNAL(SIGPIPE, bad_signal);
0166 SIGNAL(SIGQUIT, bad_signal);
0167 SIGNAL(SIGSEGV, bad_signal);
0168
0169 #ifdef SIGBUS
0170 SIGNAL(SIGBUS, bad_signal);
0171 #endif
0172 #ifdef SIGEMT
0173 SIGNAL(SIGEMT, bad_signal);
0174 #endif
0175 #ifdef SIGPOLL
0176 SIGNAL(SIGPOLL, bad_signal);
0177 #endif
0178 #ifdef SIGPROF
0179 SIGNAL(SIGPROF, bad_signal);
0180 #endif
0181 #ifdef SIGSYS
0182 SIGNAL(SIGSYS, bad_signal);
0183 #endif
0184 #ifdef SIGTRAP
0185 SIGNAL(SIGTRAP, bad_signal);
0186 #endif
0187 #ifdef SIGVTALRM
0188 SIGNAL(SIGVTALRM, bad_signal);
0189 #endif
0190 #ifdef SIGXCPU
0191 SIGNAL(SIGXCPU, bad_signal);
0192 #endif
0193 #ifdef SIGXFSZ
0194 SIGNAL(SIGXFSZ, bad_signal);
0195 #endif
0196
0197
0198 char command[1024];
0199 sprintf(command,"TCanvas p(\"p\",\"Positive endcap\",0,0,600,600);\n");
0200 if( write(pipedescr[1],command,strlen(command)) != strlen(command) ){ printf("Can't write to pipe errno=%d\n",errno); exit(1); }
0201 sprintf(command,"TCanvas n(\"n\",\"Negative endcap\",650,0,600,600);\n");
0202 if( write(pipedescr[1],command,strlen(command)) != strlen(command) ){ printf("Can't write to pipe errno=%d\n",errno); exit(1); }
0203
0204 using namespace std;
0205
0206
0207 size_t size, nevents=0;
0208 const unsigned short *buf=0;
0209
0210
0211 tty_echo(false);
0212
0213
0214 while( (size = reader.read(buf)) ){
0215 unsigned short event[size];
0216
0217
0218 unsigned int index1=12, index2=12;
0219 memcpy(event,buf,12*sizeof(unsigned short));
0220 while( index1 < size ){
0221 if( (buf[index1]&0xF000)!=0xC000 ){
0222 event[index2] = buf[index1];
0223 index1++;
0224 index2++;
0225 } else {
0226 index1++;
0227 }
0228 }
0229
0230
0231 CSCTFEvent tfEvent;
0232 if(nevents%1000==0) cout<<"Event: "<<nevents<<endl;
0233
0234 tfEvent.unpack(event,index2);
0235
0236
0237
0238 bool empty = true;
0239 vector<CSCSPEvent> SPs = tfEvent.SPs();
0240 for(vector<CSCSPEvent>::const_iterator spPtr=SPs.begin(); spPtr!=SPs.end(); spPtr++)
0241 for(unsigned int tbin=0; tbin<spPtr->header().nTBINs(); tbin++)
0242 if( spPtr->record(tbin).LCTs().size() ){ empty = false; break; }
0243 if( empty ) continue;
0244
0245
0246 sprintf(command,"p.cd();\n");
0247 if( write(pipedescr[1],command,strlen(command)) != strlen(command) ){ printf("Can't write to pipe errno=%d\n",errno); exit(1); }
0248 sprintf(command,"TGraph g(2); g.SetPoint(0,-12,-12); g.SetPoint(1,12,12); g.Draw(\"AP\"); g.SetMarkerColor(0); \n");
0249 if( write(pipedescr[1],command,strlen(command)) != strlen(command) ){ printf("Can't write to pipe errno=%d\n",errno); exit(1); }
0250 sprintf(command,"n.cd();\n");
0251 if( write(pipedescr[1],command,strlen(command)) != strlen(command) ){ printf("Can't write to pipe errno=%d\n",errno); exit(1); }
0252 sprintf(command,"g.Draw(\"AP\"); \n");
0253 if( write(pipedescr[1],command,strlen(command)) != strlen(command) ){ printf("Can't write to pipe errno=%d\n",errno); exit(1); }
0254 sprintf(command,"TLegend leg(0.7,0.7,0.99,0.99); \n");
0255 if( write(pipedescr[1],command,strlen(command)) != strlen(command) ){ printf("Can't write to pipe errno=%d\n",errno); exit(1); }
0256 sprintf(command,"TGraph _m6(1); _m6.SetMarkerStyle(22); _m6.SetMarkerColor(3); leg.AddEntry(&_m6,\"CSCTF track mode=6\",\"p\"); \n");
0257 if( write(pipedescr[1],command,strlen(command)) != strlen(command) ){ printf("Can't write to pipe errno=%d\n",errno); exit(1); }
0258 sprintf(command,"TGraph _m8(1); _m8.SetMarkerStyle(22); _m8.SetMarkerColor(4); leg.AddEntry(&_m8,\"CSCTF track mode=8\",\"p\"); \n");
0259 if( write(pipedescr[1],command,strlen(command)) != strlen(command) ){ printf("Can't write to pipe errno=%d\n",errno); exit(1); }
0260 sprintf(command,"TGraph _m11(1); _m11.SetMarkerStyle(22); _m11.SetMarkerColor(7); leg.AddEntry(&_m11,\"CSCTF track mode=11\",\"p\"); \n");
0261 if( write(pipedescr[1],command,strlen(command)) != strlen(command) ){ printf("Can't write to pipe errno=%d\n",errno); exit(1); }
0262 sprintf(command,"TGraph _m15(1); _m15.SetMarkerStyle(22); _m15.SetMarkerColor(6); leg.AddEntry(&_m15,\"CSCTF track mode=15\",\"p\"); \n");
0263 if( write(pipedescr[1],command,strlen(command)) != strlen(command) ){ printf("Can't write to pipe errno=%d\n",errno); exit(1); }
0264 sprintf(command,"TGraph _csc12(1); _csc12.SetMarkerStyle(4); _csc12.SetMarkerColor(3); leg.AddEntry(&_csc12,\"ME1 LCT\",\"p\"); \n");
0265 if( write(pipedescr[1],command,strlen(command)) != strlen(command) ){ printf("Can't write to pipe errno=%d\n",errno); exit(1); }
0266 sprintf(command,"TGraph _csc2(1); _csc2.SetMarkerStyle(4); _csc2.SetMarkerColor(4); leg.AddEntry(&_csc2,\"ME2 LCT\",\"p\"); \n");
0267 if( write(pipedescr[1],command,strlen(command)) != strlen(command) ){ printf("Can't write to pipe errno=%d\n",errno); exit(1); }
0268 sprintf(command,"TGraph _csc3(1); _csc3.SetMarkerStyle(4); _csc3.SetMarkerColor(7); leg.AddEntry(&_csc3,\"ME3 LCT\",\"p\"); \n");
0269 if( write(pipedescr[1],command,strlen(command)) != strlen(command) ){ printf("Can't write to pipe errno=%d\n",errno); exit(1); }
0270 sprintf(command,"TGraph _csc4(1); _csc4.SetMarkerStyle(4); _csc4.SetMarkerColor(6); leg.AddEntry(&_csc4,\"ME2 LCT\",\"p\"); \n");
0271 if( write(pipedescr[1],command,strlen(command)) != strlen(command) ){ printf("Can't write to pipe errno=%d\n",errno); exit(1); }
0272 sprintf(command,"leg.Draw(); \n");
0273 if( write(pipedescr[1],command,strlen(command)) != strlen(command) ){ printf("Can't write to pipe errno=%d\n",errno); exit(1); }
0274
0275 for(vector<CSCSPEvent>::const_iterator spPtr=SPs.begin(); spPtr!=SPs.end(); spPtr++){
0276
0277 if( !spPtr->header().endcap() ){
0278 sprintf(command,"p.cd();\n");
0279 if( write(pipedescr[1],command,strlen(command)) != strlen(command) ){ printf("Can't write to pipe errno=%d\n",errno); exit(1); }
0280 } else {
0281 sprintf(command,"n.cd();\n");
0282 if( write(pipedescr[1],command,strlen(command)) != strlen(command) ){ printf("Can't write to pipe errno=%d\n",errno); exit(1); }
0283 }
0284
0285 for(unsigned int tbin=0; tbin<spPtr->header().nTBINs(); tbin++){
0286 int sector = spPtr->header().sector() + spPtr->header().endcap()*6;
0287 vector<CSCSP_MEblock> LCTs = spPtr->record(tbin).LCTs();
0288 if( LCTs.size() ){
0289 cout<<"Event: "<<nevents<<" Sector="<<spPtr->header().sector()<<" L1A="<<spPtr->header().L1A()<<endl;
0290 cout<<" Endcap: "<<(spPtr->header().endcap()?2:1)<<" sector: "<<spPtr->header().sector();
0291 cout<<" tbin: "<<tbin<<" nLCTs: "<<LCTs.size()<<" (";
0292 }
0293 for(std::vector<CSCSP_MEblock>::const_iterator lct=LCTs.begin(); lct!=LCTs.end(); lct++){
0294 cout<<" F"<<((lct->spInput()-1)/3+1)<<"/CSC"<<lct->csc()<<":{w="<<lct->wireGroup()<<",s="<<lct->strip()<<"} ";
0295 unsigned short mpc =(lct->spInput()-1)/3+1;
0296 unsigned short csc = lct->csc();
0297
0298
0299 const double offsetEta[6][10] = {
0300 {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
0301 {-1, 2.4, 2.4, 2.4, 1.67, 1.67, 1.67, 1.13, 1.13, 1.13},
0302 {-1, 2.4, 2.4, 2.4, 1.67, 1.67, 1.67, 1.13, 1.13, 1.13},
0303 {-1, 2.48, 2.48, 2.48, 1.57, 1.57, 1.57, 1.57, 1.57, 1.57},
0304 {-1, 2.47, 2.47, 2.47, 1.70, 1.70, 1.70, 1.70, 1.70, 1.70},
0305 {-1, 2.46, 2.46, 2.46, 1.78, 1.78, 1.78, 1.78, 1.78, 1.78}
0306 };
0307 const double scaleEta[6][10] = {
0308 {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
0309 {-1, 0.75, 0.75, 0.75, 0.47, 0.47, 0.47, 0.24, 0.24, 0.24},
0310 {-1, 0.75, 0.75, 0.75, 0.47, 0.47, 0.47, 0.24, 0.24, 0.24},
0311 {-1, 0.88, 0.88, 0.88, 0.57, 0.57, 0.57, 0.57, 0.57, 0.57},
0312 {-1, 0.74, 0.74, 0.74, 0.56, 0.56, 0.56, 0.56, 0.56, 0.56},
0313 {-1, .645, .645, .645, .595, .595, .595, .595, .595, .595}
0314 };
0315 const double normEta[6][10] = {
0316 {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
0317 {-1, 48., 48., 48., 64., 64., 64., 32., 32., 32.},
0318 {-1, 48., 48., 48., 64., 64., 64., 32., 32., 32.},
0319 {-1,112.,112.,112., 64., 64., 64., 64., 64., 64.},
0320 {-1, 96., 96., 96., 64., 64., 64., 64., 64., 64.},
0321 {-1, 96., 96., 96., 64., 64., 64., 64., 64., 64.}
0322 };
0323 const double offsetPhi[6][10] = {
0324 {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
0325 {-1, 0, 1/6., 2/6., 0, 1/6., 2/6., 0, 1/6., 2/6.},
0326 {-1, 3/6., 4/6., 5/6., 3/6., 4/6., 5/6., 3/6., 4/6., 5/6.},
0327 {-1, 0, 1/3., 2/3., 0, 1/6., 2/6., 3/6., 4/6., 5/6.},
0328 {-1, 0, 1/3., 2/3., 0, 1/6., 2/6., 3/6., 4/6., 5/6.},
0329 {-1, 0, 1/3., 2/3., 0, 1/6., 2/6., 3/6., 4/6., 5/6.}
0330 };
0331 const double normPhi[6][10] = {
0332 {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
0333 {-1, 158, 158, 158, 158, 158, 158, 126, 126, 126},
0334 {-1, 158, 158, 158, 158, 158, 158, 126, 126, 126},
0335 {-1, 158, 158, 158, 158, 158, 158, 158, 158, 158},
0336 {-1, 158, 158, 158, 158, 158, 158, 158, 158, 158},
0337 {-1, 158, 158, 158, 158, 158, 158, 158, 158, 158}
0338 };
0339 const double scalePhi[6][10] = {
0340 {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
0341 {-1, 1./6., 1./6., 1./6., 1./6., 1./6., 1./6., 1./6., 1./6., 1./6.},
0342 {-1, 1./6., 1./6., 1./6., 1./6., 1./6., 1./6., 1./6., 1./6., 1./6.},
0343 {-1, 1./3., 1./3., 1./3., 1./6., 1./6., 1./6., 1./6., 1./6., 1./6.},
0344 {-1, 1./3., 1./3., 1./3., 1./6., 1./6., 1./6., 1./6., 1./6., 1./6.},
0345 {-1, 1./3., 1./3., 1./3., 1./6., 1./6., 1./6., 1./6., 1./6., 1./6.}
0346 };
0347 const double emuZ[6][10] = {
0348 {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
0349 {-1, 6, 6, 6, 7.03, 7.03, 7.03, 7.03, 7.03, 7.03},
0350 {-1, 6, 6, 6, 7.03, 7.03, 7.03, 7.03, 7.03, 7.03},
0351 {-1, 8.2, 8.2, 8.2, 8.2, 8.2, 8.2, 8.2, 8.2, 8.2},
0352 {-1, 9.41, 9.41, 9.41, 9.41, 9.41, 9.41, 9.41, 9.41, 9.41},
0353 {-1,10.31,10.31,10.31,10.31,10.31,10.31,10.31,10.31,10.31}
0354 };
0355
0356 if( mpc<6 && csc<10){
0357 double eta, phi;
0358 if( mpc<3 && csc<=3 && lct->strip()>=128 ){
0359 eta = 2.4 - lct->wireGroup()/48.* 0.3;
0360 phi = (lct->strip()-128)/32./6. + 1./6. + (mpc-1)*1./2.;
0361 phi = fmod((phi + spPtr->header().sector()-1.)/6.*2*3.1415927 + 3.1415927/12.,2*3.1415927);
0362 } else {
0363 eta = offsetEta[mpc][csc] - scaleEta[mpc][csc] * lct->wireGroup() / normEta[mpc][csc];
0364 phi = lct->strip() / normPhi[mpc][csc];
0365 if( (!spPtr->header().endcap() && mpc<4) || (spPtr->header().endcap() && mpc>=4) ) phi = 1. - phi;
0366 phi = fmod((phi*scalePhi[mpc][csc]+offsetPhi[mpc][csc] + spPtr->header().sector()-1.)/6.*2*3.1415927 + 3.1415927/12.,2*3.1415927);
0367 }
0368
0369 double rho = 2.*emuZ[mpc][csc]/fabs(exp(eta)-exp(-eta));
0370 double x = rho * cos(phi);
0371 double y = rho * sin(phi);
0372
0373 const int color[6] = { -1, 3, 3, 4, 7, 6 };
0374 sprintf(command,"TGraph lct_%d_%d_%d(1); lct_%d_%d_%d.SetPoint(0,%f,%f); lct_%d_%d_%d.SetMarkerStyle(4); lct_%d_%d_%d.SetMarkerColor(%d); lct_%d_%d_%d.Draw(\"P\"); \n",mpc,csc,sector,mpc,csc,sector,x,y,mpc,csc,sector,mpc,csc,sector,color[mpc],mpc,csc,sector);
0375 if( write(pipedescr[1],command,strlen(command)) != strlen(command) ){ printf("Can't write to pipe errno=%d\n",errno); exit(1); }
0376 }
0377 }
0378 if( LCTs.size() ) cout<<" )"<<endl;
0379
0380 std::vector<CSCSP_SPblock> trks = spPtr->record(tbin).tracks();
0381 if( trks.size() ){ cout<<" Track(s) at BX="<<spPtr->header().BXN()<<" :"; }
0382 for(std::vector<CSCSP_SPblock>::const_iterator trk=trks.begin(); trk!=trks.end(); trk++){
0383 cout<<" mode="<<trk->mode()<<" (eta="<<trk->eta()<<",phi="<<trk->phi()<<")";
0384 double eta = (2.5-0.9)*trk->eta()/32.+0.9;
0385 double phi = trk->phi() + ((spPtr->header().sector() - 1)*24) + 6;
0386 if(phi > 143) phi -= 143;
0387 phi /= 144./2./3.1415927;
0388 double rho2= 2.*8.2/fabs(exp(eta)-exp(-eta));
0389 double x2 = rho2 * cos(phi);
0390 double y2 = rho2 * sin(phi);
0391 const int color[16] = { -1, 1, 1, 1, 1, 1, 3, 1, 4, 1, 1, 7, 1, 1, 1, 6 };
0392 int i = distance(vector<CSCSP_SPblock>::const_iterator(trks.begin()),trk);
0393 sprintf(command,"TGraph trk_%d_%d(1); trk_%d_%d.SetPoint(0,%f,%f); trk_%d_%d.SetMarkerStyle(22); trk_%d_%d.SetMarkerColor(%d); trk_%d_%d.Draw(\"P\"); \n",i,sector,i,sector,x2,y2,i,sector,i,sector,color[trk->mode()],i,sector);
0394 if( write(pipedescr[1],command,strlen(command)) != strlen(command) ){ printf("Can't write to pipe errno=%d\n",errno); exit(1); }
0395 }
0396 if( trks.size() ){ cout<<endl; }
0397
0398 }
0399 }
0400
0401
0402 while( !kbhit() ){
0403 int key1=0, key2=0, key3=0;
0404 if((key1=getchar())==27 && (key2=getchar())==91 && (key3=getchar())==68 ){
0405 std::cout<<"Pressed: "<<key1<<" "<<key2<<" "<<key3<<std::endl;
0406
0407 break;
0408 }
0409 if( key3==67 ){
0410
0411 break;
0412 }
0413 if( key3==65 ){
0414
0415 break;
0416 }
0417 if( key3==66 ){
0418
0419 break;
0420 }
0421 if( key1==32 ){
0422
0423
0424
0425
0426
0427
0428
0429
0430 break;
0431 }
0432 if( key1==113 ) { size = 0; break; }
0433 usleep(100);
0434 }
0435 sprintf(command,"p.Clear();\n");
0436 if( write(pipedescr[1],command,strlen(command)) != strlen(command) ){ printf("Can't write to pipe errno=%d\n",errno); exit(1); }
0437 sprintf(command,"n.Clear();\n");
0438 if( write(pipedescr[1],command,strlen(command)) != strlen(command) ){ printf("Can't write to pipe errno=%d\n",errno); exit(1); }
0439 nevents++;
0440 if( size==0 ) break;
0441 }
0442 if( write(pipedescr[1],".q\n",4) != 4 ){ printf("Can't write to pipe errno=%d\n",errno); exit(1); }
0443 int stat_loc;
0444 waitpid(pid,&stat_loc,WCONTINUED);
0445 tty_echo(true);
0446 reset_keypress();
0447 system("mv ~/.root_hist.save ~/.root_hist");
0448 return 0;
0449 }