26 using namespace lcio ;
28 using namespace HEPEVTIMPL ;
44 int elemlen = nchfilename +1 ;
46 for (
int j=0;j < nfiles;j++)
48 char* filename =
reinterpret_cast<char*
>( stringpos ) ;
50 stringpos = stringpos + elemlen ;
52 LCReader*
lcReader =
reinterpret_cast<LCReader*
>( (reader) ) ;
54 return LCIO::SUCCESS ;
55 }
catch( Exception& e1) {
62 const char* description ,
void* sdnamevec ,
const int nsubd,
66 LCWriter* lcWriter =
reinterpret_cast<LCWriter*
>( (writer) ) ;
67 LCRunHeaderImpl*
runHdr =
new LCRunHeaderImpl ;
68 runHdr->setRunNumber( irun ) ;
69 runHdr->setDetectorName( detname ) ;
70 runHdr->setDescription( description ) ;
72 int elemlen = nchsd + 1 ;
74 for (
int j=0;j < nsubd;j++)
76 char* subdetectorname =
reinterpret_cast<char*
>( stringpos ) ;
77 runHdr->addActiveSubdetector( subdetectorname ) ;
78 stringpos = stringpos + elemlen ;
80 lcWriter->writeRunHeader( runHdr ) ;
82 return LCIO::SUCCESS ;
83 }
catch( Exception& e1) {
90 void* sdnamevec ,
int* nsubd ,
const int nchsubd){
92 LCReader*
lcReader =
reinterpret_cast<LCReader*
>( (reader) ) ;
94 LCRunHeader*
runHdr = lcReader->readNextRunHeader() ;
95 *irun = runHdr->getRunNumber() ;
98 stringpos =
reinterpret_cast<PTRTYPE>( detname ) ;
99 char* detnam =
reinterpret_cast<char*
>( stringpos ) ;
100 const char* detectorname = runHdr->getDetectorName().c_str() ;
101 strcpy(detnam,detectorname) ;
102 stringpos =
reinterpret_cast<PTRTYPE>( description ) ;
103 char* descr =
reinterpret_cast<char*
>( stringpos ) ;
104 const char* rundescription = runHdr->getDescription().c_str() ;
105 strcpy(descr,rundescription) ;
109 int elemlen = nchsubd + 1;
110 *nsubd = strVec->
size() ;
111 stringpos =
reinterpret_cast<PTRTYPE>( sdnamevec ) ;
114 char* tmpname =
reinterpret_cast<char*
>( stringpos ) ;
115 const char* subdname =
const_cast<char*
>( out.
c_str() ) ;
116 strcpy(tmpname,subdname) ;
117 stringpos = stringpos + elemlen ;
121 }
catch( Exception& e1) {
130 LCEventImpl* lcEventImpl =
reinterpret_cast<LCEventImpl*
>( (
event) ) ;
131 lcEventImpl->setRunNumber( irun ) ;
132 lcEventImpl->setEventNumber( ievent ) ;
133 lcEventImpl->setTimeStamp( timestamp ) ;
134 lcEventImpl->setDetectorName( detname ) ;
135 return LCIO::SUCCESS ;
139 LCEventImpl* lcEvent =
reinterpret_cast<LCEventImpl*
>( (
event) ) ;
140 *irun = lcEvent->getRunNumber() ;
141 *ievent = lcEvent->getEventNumber() ;
142 *timestamp = lcEvent->getTimeStamp() ;
144 char* detnam =
reinterpret_cast<char*
>( stringpos ) ;
145 const char* detectorname = lcEvent->getDetectorName().c_str() ;
146 strcpy(detnam,detectorname) ;
147 return LCIO::SUCCESS ;
150 LCRunHeader* runhdr =
reinterpret_cast<LCRunHeader*
>( (runheader) ) ;
151 LCTOOLS::dumpRunHeader( runhdr ) ;
152 return LCIO::SUCCESS ;
156 LCEventImpl* lcEvent =
reinterpret_cast<LCEventImpl*
>( (
event) ) ;
158 return LCIO::SUCCESS ;
162 LCEventImpl* lcEvent =
reinterpret_cast<LCEventImpl*
>( (
event) ) ;
163 LCTOOLS::dumpEventDetailed( lcEvent ) ;
164 return LCIO::SUCCESS ;
169 ,
double* prodvtx,
float* momentum,
float* mass,
float* charge,
172 MCParticle* lcMCParticle = f2c_pointer<MCParticle,LCObject>( mcparticle ) ;
174 *pdg = lcMCParticle->getPDG() ;
175 *genstatus = lcMCParticle->getGeneratorStatus() ;
176 *simstatus = lcMCParticle->getSimulatorStatus() ;
177 const double* dtmp = lcMCParticle->getVertex() ;
178 for(
int k=0;k<3;k++) *prodvtx++ = dtmp[k] ;
181 const double* tmp = lcMCParticle->getMomentum() ;
183 for(
int k=0;k<3;k++) *momentum++ = (
float) tmp[k] ;
184 *mass = lcMCParticle->getMass() ;
185 *charge = lcMCParticle->getCharge() ;
186 *ndaughters = lcMCParticle->getDaughters().size() ;
187 return LCIO::SUCCESS ;
194 LCCollectionVec* lcCollectionVec =
reinterpret_cast<LCCollectionVec*
>( (collectionvec) ) ;
195 SimTrackerHitImpl* hit =
new SimTrackerHitImpl ;
196 MCParticle* mmcp = f2c_pointer<MCParticle,LCObject>( mcp ) ;
198 hit->setCellID0( cellID0 ) ;
199 hit->setPosition( pos ) ;
200 hit->setEDep( dEdx ) ;
201 hit->setTime( time ) ;
202 hit->setMCParticle( mmcp ) ;
204 lcCollectionVec->push_back( hit ) ;
205 return LCIO::SUCCESS ;
209 LCCollectionVec* lcCollection =
reinterpret_cast<LCCollectionVec*
>( (collection) ) ;
210 SimTrackerHit* hit =
dynamic_cast<SimTrackerHit*
>( lcCollection->getElementAt( i-1 ) ) ;
212 *cellID = hit->getCellID() ;
213 const double* tmp = hit->getPosition() ;
214 for(
int k=0;k<3;k++) *pos++ = tmp[k] ;
215 *dEdx = hit->getdEdx() ;
216 *time = hit->getTime() ;
217 *mcp =
reinterpret_cast<PTRTYPE>( hit->getMCParticle() ) ;
218 return LCIO::SUCCESS ;
223 LCCollectionVec* lcCollection =
reinterpret_cast<LCCollectionVec*
>( col ) ;
224 SimCalorimeterHitImpl* lcHit =
new SimCalorimeterHitImpl ;
225 lcHit->setCellID0( cellID0 ) ;
226 lcHit->setCellID1( cellID1 ) ;
227 lcHit->setEnergy( energy ) ;
228 lcHit->setPosition( pos ) ;
229 lcCollection->addElement( lcHit ) ;
235 float* energy,
float* pos ) {
237 LCCollectionVec* lcCollection =
reinterpret_cast<LCCollectionVec*
>( collection ) ;
240 const int Nelements = lcCollection->getNumberOfElements() ;
241 if (i < 0 && i > Nelements-1) {
242 std::cerr <<
"Exception in LCGetSimCaloHit: index " << i <<
" out of range" <<
std::endl ;
246 SimCalorimeterHit* lcHit =
dynamic_cast<SimCalorimeterHit*
>( lcCollection->getElementAt( i-1 ) ) ;
247 *cellID0 = lcHit->getCellID0() ;
248 *cellID1 = lcHit->getCellID1() ;
249 *energy = lcHit->getEnergy() ;
250 const float* tmp = lcHit->getPosition() ;
251 for(
int k=0;k<3;k++) *pos++ = tmp[k] ;
258 SimCalorimeterHitImpl* lcHit = f2c_pointer<SimCalorimeterHitImpl,LCObject>( hit ) ;
260 const int Nelements = lcHit->getNMCContributions() ;
261 if (i < 0 && i > Nelements-1) {
262 std::cerr <<
"Exception in lcgetsimcalohitmccont: index " << i <<
" out of range" <<
std::endl ;
266 *mcp =
C2F_POINTER( LCObject*, lcHit->getParticleCont(i-1) ) ;
267 *energy = lcHit->getEnergyCont( i-1 ) ;
268 *time = lcHit->getTimeCont( i-1 ) ;
269 *pdg = lcHit->getPDGCont( i-1 ) ;
270 return LCIO::SUCCESS ;
274 LCEventImpl* lcEvent =
reinterpret_cast<LCEventImpl*
>( evtout ) ;
276 HEPEVT::fromHepEvt( lcEvent ) ;
277 return LCIO::SUCCESS ;
278 }
catch( Exception& e1) {
286 LCEvent* lcEvent =
reinterpret_cast<LCEventImpl*
>(
event ) ;
288 HEPEVT::toHepEvt( lcEvent ) ;
289 return LCIO::SUCCESS ;
290 }
catch( Exception& e1) {
299 for(
int j=0;j<nobjv;j++) {
300 LCObject* obj = f2c_pointer<LCObject,LCObject>( objectv[j] ) ;
303 return reinterpret_cast<PTRTYPE>( objVec ) ;
307 LCIntVec* intVec =
new LCIntVec ;
308 for(
int j=0;j<nintv;j++) intVec->push_back( intv[j] ) ;
309 return reinterpret_cast<PTRTYPE>( intVec ) ;
313 LCFloatVec* floatVec =
new LCFloatVec ;
314 for(
int j=0;j<nfloatv;j++) floatVec->push_back( floatv[j] ) ;
315 return reinterpret_cast<PTRTYPE>( floatVec ) ;
320 int elemlen = nchstringv + 1;
322 stringpos =
reinterpret_cast<PTRTYPE>( stringv ) ;
323 for(
int j=0;j<nstringv;j++){
324 const std::string& mystring =
reinterpret_cast<char*
>( stringpos ) ;
326 stringpos = stringpos + elemlen ;
328 return reinterpret_cast<PTRTYPE>( stringVec ) ;
332 LCIntVec* intVec = f2c_pointer<LCIntVec,LCObject>(vector) ;
333 int intVecLength = 0;
334 intVecLength = intVec->size() ;
335 if (intVecLength > *nintv) {
336 std::cerr <<
"Warning in lcgetintvector: vector size " << intVecLength
337 <<
" larger then target array size " << *nintv <<
std::endl ;
338 intVecLength = *nintv ;
341 *nintv = intVecLength ;
343 for (
int j=0;j < intVecLength;j++) *intv++ = (*intVec)[j] ;
344 return LCIO::SUCCESS ;
348 LCFloatVec* floatVec = f2c_pointer<LCFloatVec,LCObject>(vector) ;
349 int floatVecLength = 0 ;
350 floatVecLength = floatVec->size() ;
351 if (floatVecLength > *nfloatv) {
352 std::cerr <<
"Warning in lcgetfloatvector: vector size " << floatVecLength
353 <<
" larger then target array size " << *nfloatv <<
std::endl ;
354 floatVecLength = *nfloatv ;
357 *nfloatv = floatVecLength ;
359 for (
int j=0;j < floatVecLength;j++) *floatv++ = (*floatVec)[j] ;
360 return LCIO::SUCCESS ;
366 int stringVecLength = 0 ;
367 stringVecLength = stringVec->
size() ;
368 if (stringVecLength > *nstringv) {
369 std::cerr <<
"Warning in lcgetstringvector: vector size " << stringVecLength
370 <<
" larger then target array size " << *nstringv <<
std::endl ;
371 stringVecLength = *nstringv ;
374 *nstringv = stringVecLength ;
376 int elemlen = nchstringv + 1;
378 stringpos =
reinterpret_cast<PTRTYPE>( stringv ) ;
379 for (
int j=0;j < stringVecLength;j++) {
380 char* outstring =
const_cast<char*
>( (*stringVec)[j].c_str() );
381 char* tmpstring =
reinterpret_cast<char*
>( stringpos ) ;
382 strcpy(tmpstring,outstring) ;
383 stringpos = stringpos + elemlen ;
385 return LCIO::SUCCESS ;
391 for(
int j=0;j<nintv;j++) intVec->
push_back( intv[j] ) ;
392 return reinterpret_cast<PTRTYPE>( intVec ) ;
398 return LCIO::SUCCESS ;
403 for(
int j=0;j<nfloatv;j++) floatVec->
push_back( floatv[j] ) ;
404 return reinterpret_cast<PTRTYPE>( floatVec ) ;
410 return LCIO::SUCCESS ;
415 int elemlen = nchstringv + 1;
417 stringpos =
reinterpret_cast<PTRTYPE>( stringv ) ;
418 for(
int j=0;j<nstringv;j++){
419 const std::string& mystring =
reinterpret_cast<char*
>( stringpos ) ;
421 stringpos = stringpos + elemlen ;
423 return reinterpret_cast<PTRTYPE>( stringVec ) ;
429 return LCIO::SUCCESS ;
434 for(
int j=0;j<npointerv;j++) pointerVec->
push_back( pointerv[j] ) ;
435 return reinterpret_cast<PTRTYPE>( pointerVec ) ;
441 return LCIO::SUCCESS ;
447 int intVecLength = 0;
448 intVecLength = intVec->
size() ;
449 if (intVecLength > *nintv) {
450 std::cerr <<
"Warning in getintvector: vector size " << intVecLength
451 <<
" larger then target array size " << *nintv <<
std::endl ;
452 intVecLength = *nintv ;
455 *nintv = intVecLength ;
457 for (
int j=0;j < intVecLength;j++) *intv++ = (*intVec)[j] ;
458 return LCIO::SUCCESS ;
463 int floatVecLength = 0 ;
464 floatVecLength = floatVec->
size() ;
465 if (floatVecLength > *nfloatv) {
466 std::cerr <<
"Warning in getfloatvector: vector size " << floatVecLength
467 <<
" larger then target array size " << *nfloatv <<
std::endl ;
468 floatVecLength = *nfloatv ;
471 *nfloatv = floatVecLength ;
473 for (
int j=0;j < floatVecLength;j++) *floatv++ = (*floatVec)[j] ;
474 return LCIO::SUCCESS ;
480 int stringVecLength = 0 ;
481 stringVecLength = stringVec->
size() ;
482 if (stringVecLength > *nstringv) {
483 std::cerr <<
"Warning in getstringvector: vector size " << stringVecLength
484 <<
" larger then target array size " << *nstringv <<
std::endl ;
485 stringVecLength = *nstringv ;
488 *nstringv = stringVecLength ;
490 int elemlen = nchstringv + 1;
492 stringpos =
reinterpret_cast<PTRTYPE>( stringv ) ;
493 for (
int j=0;j < stringVecLength;j++) {
494 char* outstring =
const_cast<char*
>( (*stringVec)[j].c_str() );
495 char* tmpstring =
reinterpret_cast<char*
>( stringpos ) ;
496 strcpy(tmpstring,outstring) ;
497 stringpos = stringpos + elemlen ;
499 return LCIO::SUCCESS ;
504 int pointerVecLength = 0;
505 pointerVecLength = pointerVec->
size() ;
506 if (pointerVecLength > *npointerv) {
507 std::cerr <<
"Warning in getpointervector: vector size " << pointerVecLength
508 <<
" larger then target array size " << *npointerv <<
std::endl ;
509 pointerVecLength = *npointerv ;
512 *npointerv = pointerVecLength ;
514 for (
int j=0;j < pointerVecLength;j++) *pointerv++ = (*pointerVec)[j] ;
515 return LCIO::SUCCESS ;
522 if (classname == LCIO::LCRUNHEADER) {
523 LCRunHeaderImpl* rhd =
reinterpret_cast<LCRunHeaderImpl*
>(classp) ;
524 return do_set_method (rhd->parameters(), method, key, vecp) ;
526 else if (classname == LCIO::LCEVENT) {
527 LCEventImpl* evt =
reinterpret_cast<LCEventImpl*
>(classp) ;
528 return do_set_method (evt->parameters(), method, key, vecp) ;
530 else if (classname == LCIO::LCCOLLECTION) {
531 LCCollectionVec* col =
reinterpret_cast<LCCollectionVec*
>(classp) ;
532 return do_set_method (col->parameters(), method, key, vecp) ;
535 std::cerr <<
"Warning in lcsetparameters: unknown class name " << classname <<
std::endl ;
542 if (classname == LCIO::LCRUNHEADER) {
543 LCRunHeaderImpl* rhd =
reinterpret_cast<LCRunHeaderImpl*
>(classp) ;
544 return do_get_method (rhd->getParameters(), method, key, vecp) ;
546 else if (classname == LCIO::LCEVENT) {
547 LCEventImpl* evt =
reinterpret_cast<LCEventImpl*
>(classp) ;
548 return do_get_method (evt->getParameters(), method, key, vecp) ;
550 else if (classname == LCIO::LCCOLLECTION) {
551 LCCollectionVec* col =
reinterpret_cast<LCCollectionVec*
>(classp) ;
552 return do_get_method (col->getParameters(), method, key, vecp) ;
555 std::cerr <<
"Warning in lcgetparameters: unknown class name " << classname <<
std::endl ;
563 if (method ==
string(
"setIntValues")) {
565 params.setValues(key, *intVec) ;
566 return LCIO::SUCCESS ;
568 else if (method ==
string(
"setFloatValues")) {
570 params.setValues(key, *floatVec) ;
571 return LCIO::SUCCESS ;
573 else if (method ==
string(
"setStringValues")) {
575 params.setValues(key, *stringVec) ;
576 return LCIO::SUCCESS ;
579 std::cerr <<
"Warning in lcsetparameters: unknown method name " << method <<
std::endl ;
586 if (method ==
string(
"getIntValues")) {
587 IntVec* intVec = f2c_pointer<IntVec,LCObject>(vector) ;
588 params.getIntVals(key, *intVec) ;
589 return LCIO::SUCCESS ;
591 else if (method ==
string(
"getFloatValues")) {
592 FloatVec* floatVec = f2c_pointer<FloatVec,LCObject>(vector) ;
593 params.getFloatVals(key, *floatVec) ;
594 return LCIO::SUCCESS ;
596 else if (method ==
string(
"getStringValues")) {
597 StringVec* stringVec = f2c_pointer<StringVec,LCObject>(vector) ;
598 params.getStringVals(key, *stringVec) ;
599 return LCIO::SUCCESS ;
601 else if (method ==
string(
"getIntKeys")) {
602 StringVec* stringVec = f2c_pointer<StringVec,LCObject>(vector) ;
603 params.getIntKeys(*stringVec) ;
604 return LCIO::SUCCESS ;
606 else if (method ==
string(
"getFloatKeys")) {
607 StringVec* stringVec = f2c_pointer<StringVec,LCObject>(vector) ;
608 params.getFloatKeys(*stringVec) ;
609 return LCIO::SUCCESS ;
611 else if (method ==
string(
"getStringtKeys")) {
612 StringVec* stringVec = f2c_pointer<StringVec,LCObject>(vector) ;
613 params.getStringKeys(*stringVec) ;
614 return LCIO::SUCCESS ;
617 std::cerr <<
"Warning in lcgetparameters: unknown method name " << method <<
std::endl ;
LCIO_DEPRECATED_CAPI int lcio2hepevt(PTRTYPE event)
Fill the hepevt common block with the MCParicle data in the LCIO event.
LCIO_DEPRECATED_CAPI PTRTYPE intvectorcreate(int *intv, const int nintv)
Create/Delete an int vector.
std::vector< std::string > StringVec
Vector of strings.
LCIO_DEPRECATED_CAPI int lcsetparameters(const char *classname, PTRTYPE classp, const char *method, const char *key, PTRTYPE vecp)
For the set methods:
LCIO_DEPRECATED_CAPI int getintvector(PTRTYPE vector, int *intv, int *nintv)
Return the content of an int vector.
INTV CFORTRANPNTRV lcgetsimcalohit
LCIO_DEPRECATED_CAPI int lcdumpeventdetailed(PTRTYPE event)
Detailed dump of all the data in the event to stdout.
LCIO_DEPRECATED_CAPI int lcgetfloatvector(PTRTYPE vector, float *floatv, int *nfloatv)
Return the content of a LC float vector.
std::vector< LCObject * > LCObjectVec
Vector of (pointers to) LCObjects.
INTV INT CFORTRANPNTR floatvectordelete
CFORTRANPNTR CFORTRANPNTR getfloatvector
std::vector< float > FloatVec
Vector of floats.
static std::vector< std::string > filenamelist
LCIO_DEPRECATED_CAPI int getstringvector(PTRTYPE vector, void *stringv, int *nstringv, const int nchstringv)
Return the content of a string vector.
LCIO_DEPRECATED_CAPI PTRTYPE lcaddsimcalohit(PTRTYPE col, int cellID0, int cellID1, float energy, float *pos)
Add a new SimCalorimeterHit with the given data to the collection.
std::vector< std::string > LCStrVec
Header file for the f77-wrapper functions for stl vectors.
LCIO_DEPRECATED_CAPI int hepevt2lcio(PTRTYPE event)
Create an MCParticle collection from the hepevt common block and add it to the event.
INTV CFORTRANPNTRV FLOATV INT lcfloatvectorcreate
LCIO_DEPRECATED_CAPI PTRTYPE lcreadnextrunheader(PTRTYPE reader, int *irun, void *detname, void *descr, void *sdnamevec, int *nsubd, const int nchsubd)
Read the next run header and fills the return arguments with the data.
LCIO_DEPRECATED_CAPI int lcrdropenchain(PTRTYPE reader, void *filenamesv, const int nfiles, const int nchfilename)
Header file for additional f77-wrapper functions.
CFORTRANPNTR pointervectordelete
long PTRTYPE
Fortran interface - define the length of pointers this has to made machine independent ...
LCIO_DEPRECATED_CAPI int lcgeteventheader(PTRTYPE event, int *irun, int *ievent, int *timestamp, void *detname)
Read the complete event header data from the event.
LCIO_DEPRECATED_CAPI PTRTYPE floatvectorcreate(float *floatv, const int nfloatv)
Create/Delete a float vector.
INTV CFORTRANPNTRV FLOATV lcobjectvectorcreate
LCIO_DEPRECATED_CAPI int lcgetsimcalohitmccont(PTRTYPE hit, int i, PTRTYPE *mcp, float *energy, float *time, int *pdg)
Return the specified contribution of a MCParticle to the hit in the arguments.
LCIO_DEPRECATED_CAPI int lcaddsimtrackerhit(PTRTYPE col, int cellID, double *pos, float dEdx, float time, PTRTYPE mcp)
Add a new SimTrackerHit with the given data to the collection.
std::vector< int > IntVec
Vector of ints.
int do_get_method(const LCParameters ¶ms, const char *method, const char *key, PTRTYPE vector)
LCIO_DEPRECATED_CAPI PTRTYPE pointervectorcreate(PTRTYPE *pointerv, const int npointerv)
Create/Delete a pointer vector.
std::vector< PTRTYPE > PointerVec
LCIO_DEPRECATED_CAPI int lcdumprunheader(PTRTYPE runheader)
Dump the run header to the stdout.
LCIO_DEPRECATED_CAPI PTRTYPE lcstringvectorcreate(void *stringv, const int nstringv, const int nchstringv)
Create a LC string vector.
int do_set_method(LCParameters ¶ms, const char *method, const char *key, PTRTYPE vector)
LCIO_DEPRECATED_CAPI PTRTYPE lcintvectorcreate(int *intv, const int nintv)
Create an LC int vector.
void dumpEvent(EVENT::LCEvent *event)
LCIO_DEPRECATED_CAPI int lcdumpevent(PTRTYPE event)
Dump the event to the stdout - one line per collection.
#define C2F_POINTER(T, ptr)
LCIO_DEPRECATED_CAPI PTRTYPE stringvectorcreate(void *stringv, const int nstringv, const int nchstringv)
Create/Delete a string vector.