23 #include <sys/types.h>
40 #include <readline/readline.h>
41 #include <readline/history.h>
46 using namespace lcio ;
93 for( levelIt =
position.begin(); levelIt != levelItEnd ; levelIt++ ){
94 prompt += levelIt->second ;
130 cout <<
"interrupting.." << sig <<
endl;
135 cout <<
"leaving.. " << sig <<
endl;
153 file->
fd_temp = open(file->
filename, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR );
168 string lessCommand =
pager;
194 SimTrackerHit *trackerHit;
195 SimCalorimeterHit *calHit;
198 cout <<
"elements: " << (nElements = col->getNumberOfElements()) <<
endl;
199 if (colType == LCIO::SIMTRACKERHIT ) {
201 for (
int i=0; i<nElements; i++) {
202 trackerHit =
dynamic_cast<SimTrackerHit*
> ( col->getElementAt(i) );
203 cout <<
setw(4) << i <<
"\t" <<
setw(10) << trackerHit->getCellID() <<
endl;
205 }
else if (colType == LCIO::SIMCALORIMETERHIT ) {
206 cout <<
" Hit \tCell \tEnergy" <<
endl;
207 for (
int i=0; i<nElements; i++) {
208 calHit =
dynamic_cast<SimCalorimeterHit*
> ( col->getElementAt(i) );
209 cout <<
setw(4) << i <<
"\t" <<
setw(10) << calHit->getCellID0() <<
"\t" <<
setw(6) << calHit->getEnergy() <<
endl;
218 if( col->getTypeName() == LCIO::MCPARTICLE ){
219 LCTOOLS::printMCParticles( col ) ;
222 else if( col->getTypeName() == LCIO::SIMTRACKERHIT ){
224 LCTOOLS::printSimTrackerHits( col ) ;
227 else if( col->getTypeName() == LCIO::TPCHIT ){
229 LCTOOLS::printTPCHits( col ) ;
232 else if( col->getTypeName() == LCIO::TRACKERHIT ){
234 LCTOOLS::printTrackerHits( col ) ;
237 else if( col->getTypeName() == LCIO::SIMCALORIMETERHIT ){
239 LCTOOLS::printSimCalorimeterHits( col ) ;
242 else if( col->getTypeName() == LCIO::CALORIMETERHIT ){
244 LCTOOLS::printCalorimeterHits( col ) ;
247 else if( col->getTypeName() == LCIO::RAWCALORIMETERHIT ){
249 LCTOOLS::printRawCalorimeterHits( col ) ;
252 else if( col->getTypeName() == LCIO::LCFLOATVEC ){
254 LCTOOLS::printLCFloatVecs( col ) ;
257 else if( col->getTypeName() == LCIO::LCINTVEC ){
259 LCTOOLS::printLCIntVecs( col ) ;
262 else if( col->getTypeName() == LCIO::LCSTRVEC ){
264 LCTOOLS::printLCStrVecs( col ) ;
267 else if( col->getTypeName() == LCIO::TRACK ){
269 LCTOOLS::printTracks( col ) ;
272 else if( col->getTypeName() == LCIO::CLUSTER ){
274 LCTOOLS::printClusters( col ) ;
277 else if( col->getTypeName() == LCIO::RECONSTRUCTEDPARTICLE ){
279 LCTOOLS::printReconstructedParticles( col ) ;
282 else if( col->getTypeName() == LCIO::VERTEX ){
284 LCTOOLS::printVertices( col ) ;
287 else if( col->getTypeName() == LCIO::LCGENERICOBJECT ){
289 LCTOOLS::printLCGenericObjects( col ) ;
292 else if( col->getTypeName() == LCIO::LCRELATION ){
294 LCTOOLS::printRelation( col ) ;
296 else if( col->getTypeName() == LCIO::TRACKERRAWDATA ){
298 LCTOOLS::printTrackerRawData( col ) ;
300 else if( col->getTypeName() == LCIO::TRACKERDATA ){
302 LCTOOLS::printTrackerData( col ) ;
304 else if( col->getTypeName() == LCIO::TRACKERPULSE ){
306 LCTOOLS::printTrackerPulse( col ) ;
334 if (c < colVec->
size()) {
335 gCol =
event->getCollection((*colVec)[c]);
336 cout <<
"name: " << (*colVec)[c] <<
endl;
364 for( it =
mapRuns.begin() ; it != itEnd ; it++ ) {
368 string tempEvents = sstream.
str() ;
383 cout <<
"[" <<
setw(2) <<
event->getEventNumber() <<
"] " <<
setw(3) << (
event->getCollectionNames())->
size() <<
" Collections" <<
endl;
400 for( it = colVec->
begin(); it != itEnd ; it++ ){
401 gCol =
event->getCollection(*it);
406 cout <<
"this event does not exist" <<
endl;
448 if (str.
size() < 1) {
453 cstr =
new char [str.
size()+1];
483 if (n < colVec->
size()) {
486 cout <<
"No collection with number " << n <<
endl;
510 int run =
runHdr->getRunNumber();
513 LCTOOLS::dumpRunHeader(
runHdr);
523 LCTOOLS::dumpEventDetailed(
event);
542 for (
int i = 0; i < 4; i++ ) {
563 if (pFile==NULL)
perror (
"Error opening file");
566 fseek (pFile, 0, SEEK_END);
569 if (size > 50000000) {
570 cout <<
"Large file: not preparing map of events in runs!" <<
endl;
571 cout <<
"(Initialising will still take some time though." <<
endl;
572 cout <<
" You can skip it using [ctrl]-[c].)" <<
endl;
583 int run =
runHdr->getRunNumber();
606 cout <<
" cd | cl <number of OBJECT|..> change into OBJECT | leave object; multiple levels can be given at once" <<
endl;
607 cout <<
" e.g.: file.slcio/run1$ cd ../3/1" <<
endl;
608 cout <<
" ls list elements on next level | list content of active collection" <<
endl;
609 cout <<
" dump [-d] dump data of active level; -d triggers detailed dump of event" <<
endl;
610 cout <<
" print | cat [-s] <collection nr> print content of collection given; -s triggers short print-out" <<
endl;
612 cout <<
" open <filename> open new file" <<
endl;
613 cout <<
" exit | quit exit program" <<
endl;
614 cout <<
" help print this help text" <<
endl;
615 cout <<
" pager <command> use pager <command> when paging output" <<
endl;
618 cout <<
" If '|' or '>' is appended to the a command, the output will be redirected to a file and then"<<
endl;
619 cout <<
" displayed with the pager (see above)." <<
endl;
620 cout <<
" If a string is given after the redirect token, it is used as filename and the file is stored." <<
endl;
621 cout <<
" (existing files will get overwritten without prompt). If no filename is given, a temporary " <<
endl;
622 cout <<
" file will be used for paging." <<
endl;
623 cout <<
" e.g.: file.slcio/run1/evt1$ dump -d > event1.txt "<<
endl;
638 int main(
int argc,
char** argv ) {
649 cout <<
"usage: lsh <file name>|-h" <<
endl;
653 if (!
strcmp(argv[1],
"-h")) {
695 if( *line ==
'\0' ) {
701 if (!(line && *line)) {
710 while (sstream >> buf) {
720 int cvSize = commandVec.
size();
723 if ((commandVec[cvSize-1] ==
"|") || (commandVec[cvSize-1] ==
">")) {
730 if ((commandVec[cvSize-2] ==
"|") || (commandVec[cvSize-2] ==
">")) {
736 data.
filename = &commandVec[cvSize-1][0] ;
755 if ((commandVec[0] ==
"exit") || (commandVec[0] ==
"quit")) {
758 if (commandVec[0] ==
"ls") {
761 if ((commandVec[0] ==
"cl") || (commandVec[0] ==
"cd")) {
764 if ((commandVec[0] ==
"print") || (commandVec[0] ==
"cat")) {
766 if (commandVec.
size() == 2) {
768 it = ++(commandVec.
begin());
769 commandVec.
insert ( it ,
"-d" );
773 if ((commandVec[0] ==
"dump")) {
774 if (commandVec.
size() < 2) {
779 if ((commandVec[0] ==
"open") || (commandVec[0] ==
"file")) {
782 if ((commandVec[0] ==
egg)) {
785 if ((commandVec[0] ==
"help")) {
788 if ((commandVec[0] ==
"pager")) {
789 pager = commandVec[1];
798 outputSuccess =
true;
802 }
while (!outputSuccess);
804 cout <<
" paging failed - active pager: " <<
pager <<
" run: " << run <<
endl;
805 cout <<
" You can set another pager with: pager <command>" <<
endl;
map< int, string > mapRuns
void begin_paging(pagerInfo *file)
END SIGNAL HANDLERS.
void normalPrintCol(LCCollection *col)
void fun_dump(string arg)
void term_handler(int sig)
void simplePrintCol(LCCollection *col)
END PAGER HANDLING.
int main(int argc, char **argv)
Simple program that opens existing LCIO files and appends the records needed for direct access - if t...
bool end_paging(pagerInfo *file)
void fun_open(string filename)
void lsRuns()
END PRINT FUNCTIONS.
void fun_print(string colNr, string flag)
void int_handler(int sig)
END EXIT.
static const int directAccess
Configuration flags for the LCReader instance - to be used with LCFactory::createLCReader().
void leave(int ret)
END PROMPT.
void fun_ls()
END LS FUNCTIONS.
pair< int, string > level
void dumpEvent(EVENT::LCEvent *event)
map< int, int > mapEventsInRun
const char * print_prompt()
PROMPT.