70 {
71
72
73 MsgStream log(
msgSvc(), name() );
74 log << MSG::INFO << " BesVisAlg initialize()" << endmsg;
75 StatusCode status = StatusCode::SUCCESS;
76
77
78
79 IService* isvc = 0;
80 status = service( "RootCnvSvc", m_cnvSvc, false );
81 if ( !status.isSuccess() ) status = service( "EventCnvSvc", m_cnvSvc, true );
82 status = hasWrite();
83 if ( status.isSuccess() ) { log << MSG::INFO << "share file writed -- success" << endmsg; }
84 else { log << MSG::ERROR << "share file writed -- ERROR!!!!!" << endmsg; }
85
86
87
88 log << MSG::INFO << " OutputFile = " << f_rootOutputFile << endmsg;
89
90 for ( unsigned int i = 0; i < testVec.size(); i++ )
91 { log << MSG::INFO << " MyStringVec[" << i << "] = " << testVec[i] << endmsg; }
92
93
94 m_pid = getpid();
95 log << MSG::ERROR << "BesVisAlg process PID: [" << m_pid << "]" << endmsg;
96
97 log << MSG::ERROR << "Create and initialize semaphore" << endmsg;
98 if ( ( semid = semget( (int)m_pid, 2, IPC_CREAT | IPC_EXCL | 0666 ) ) != -1 )
99 {
100 arg.array = start_val;
101 log << MSG::ERROR << "Semaphore ID:" << semid << endmsg;
102
103 if ( semctl( semid, 0, SETALL, arg ) == -1 )
104 {
105 log << MSG::ERROR << "semctl -- parent -- initialization" << endmsg;
106 exit( 1 );
107 }
108
109 if ( ( sem_value_F = semctl( semid,
FREE_SPACE, GETVAL, 0 ) ) == -1 )
110 {
111 log << MSG::ERROR << "semctl -- GETVAL" << endmsg;
112 exit( 1 );
113 }
114
115 if ( ( sem_value_O = semctl( semid,
OUTPUT_STORE, GETVAL, 0 ) ) == -1 )
116 {
117 log << MSG::ERROR << "semctl -- GETVAL" << endmsg;
118 exit( 1 );
119 }
120 }
121 else
122 {
123 log << MSG::INFO << "semget -- parent -- creation" << endmsg;
124 exit( 2 );
125 }
126
127
128
129
130
131
132
133
134 if ( ( c_pid = fork() ) == -1 )
135 {
136 log << MSG::ERROR << "fork -- consumer" << endmsg;
137 exit( 5 );
138 }
139 else if ( c_pid == 0 )
140 {
141
142 log << MSG::INFO << "Parent fork consumer: ppid = " << getppid() << "; pid = " << getpid()
143 << endmsg;
144
145
146 char msg_pid[25];
147 sprintf( msg_pid,
"%d", m_pid );
148
149 const char* msg_sleep = testVec[1].c_str();
150
151 log << MSG::INFO << "msg_pid: " << msg_pid << endmsg;
152 log << MSG::INFO << "Consumer sleep time: " << msg_sleep << " seconds." << endmsg;
153
154
155 execlp( "besvis.exe", "besvis.exe", "-B", msg_pid, "-e", f_rootOutputFile.c_str(), "-g",
156 f_geoInputFile.c_str(), (char*)NULL );
157
158
159 log << MSG::ERROR << "exec -- consumer" << endmsg;
160 exit( 6 );
161 }
162
163 return StatusCode::SUCCESS;
164}
sprintf(cut, "kal_costheta0_em>-0.93&&kal_costheta0_em<0.93&&kal_pxy0_em>=0.05+%d*0.1&&kal_" "pxy0_em<0.15+%d*0.1&&NGch>=2", j, j)