00001 #include "CPPFORT/lcclu.h"
00002
00003 #include "lcio.h"
00004 #include "IMPL/ClusterImpl.h"
00005
00006 using namespace lcio ;
00007
00008 #include <iostream>
00009
00010
00011
00012 PTRTYPE lcclucreate(){
00013 ClusterImpl* clu = new ClusterImpl ;
00014 return C2F_POINTER( LCObject*, clu ) ;
00015 }
00016 int lccludelete( PTRTYPE cluster ){
00017 ClusterImpl* clu = f2c_pointer<ClusterImpl,LCObject>( cluster ) ;
00018 delete clu ;
00019 return LCIO::SUCCESS ;
00020 }
00021
00022
00023
00024
00025 int lccluid( PTRTYPE cluster ) {
00026 ClusterImpl* clu = f2c_pointer<ClusterImpl,LCObject>( cluster ) ;
00027 return clu->id() ;
00028 }
00029
00030 int lcclugettype( PTRTYPE cluster ) {
00031 ClusterImpl* clu = f2c_pointer<ClusterImpl,LCObject>( cluster ) ;
00032 return clu->getType() ;
00033 }
00034
00035
00036
00037
00038
00039
00040 float lcclugetenergy( PTRTYPE cluster ) {
00041 ClusterImpl* clu = f2c_pointer<ClusterImpl,LCObject>( cluster ) ;
00042 return clu->getEnergy() ;
00043 }
00044
00045 int lcclugetposition( PTRTYPE cluster, float* pos ) {
00046 ClusterImpl* clu = f2c_pointer<ClusterImpl,LCObject>( cluster ) ;
00047 for( int i=0 ; i<3 ; *pos++ = clu->getPosition()[i++] ) ;
00048 return LCIO::SUCCESS ;
00049 }
00050
00051 int lcclugetpositionerror( PTRTYPE cluster, float poserr[6] ) {
00052 ClusterImpl* clu = f2c_pointer<ClusterImpl,LCObject>( cluster ) ;
00053 for( int i=0 ; i<6 ; *poserr++ = clu->getPositionError()[i++] ) ;
00054 return LCIO::SUCCESS ;
00055 }
00056
00057 float lcclugetitheta( PTRTYPE cluster ) {
00058 ClusterImpl* clu = f2c_pointer<ClusterImpl,LCObject>( cluster ) ;
00059 return clu->getITheta() ;
00060 }
00061
00062 float lcclugetiphi( PTRTYPE cluster ) {
00063 ClusterImpl* clu = f2c_pointer<ClusterImpl,LCObject>( cluster ) ;
00064 return clu->getIPhi() ;
00065 }
00066
00067 int lcclugetdirectionerror( PTRTYPE cluster, float direrr[3] ) {
00068 ClusterImpl* clu = f2c_pointer<ClusterImpl,LCObject>( cluster ) ;
00069 for( int i=0 ; i<3 ; *direrr++ = clu->getDirectionError()[i++] ) ;
00070 return LCIO::SUCCESS ;
00071 }
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085 PTRTYPE lcclugetshape( PTRTYPE cluster ) {
00086 ClusterImpl* clu = f2c_pointer<ClusterImpl,LCObject>( cluster ) ;
00087 const FloatVec& shape = clu->getShape();
00088 return reinterpret_cast<PTRTYPE>( &shape );
00089 }
00090
00091 PTRTYPE lcclugetparticleids( PTRTYPE cluster ) {
00092 ClusterImpl* clu = f2c_pointer<ClusterImpl,LCObject>( cluster ) ;
00093 const ParticleIDVec& idvect = clu->getParticleIDs();
00094 return reinterpret_cast<PTRTYPE>( &idvect );
00095 }
00096
00097 PTRTYPE lcclugetclusters( PTRTYPE cluster ) {
00098 ClusterImpl* clu = f2c_pointer<ClusterImpl,LCObject>( cluster ) ;
00099 const ClusterVec& idvect = clu->getClusters();
00100 return reinterpret_cast<PTRTYPE>( &idvect );
00101 }
00102
00103 PTRTYPE lcclugetcalorimeterhits( PTRTYPE cluster ) {
00104 ClusterImpl* clu = f2c_pointer<ClusterImpl,LCObject>( cluster ) ;
00105 const CalorimeterHitVec& idvect = clu->getCalorimeterHits();
00106 return reinterpret_cast<PTRTYPE>( &idvect );
00107 }
00108
00109 PTRTYPE lcclugetsubdetectorenergies( PTRTYPE cluster ) {
00110 ClusterImpl* clu = f2c_pointer<ClusterImpl,LCObject>( cluster ) ;
00111 const FloatVec& idvect = clu->getSubdetectorEnergies();
00112 return reinterpret_cast<PTRTYPE>( &idvect );
00113 }
00114
00115 int lcclugethitcontributions( PTRTYPE cluster, float* weights, int* nweights ) {
00116 ClusterImpl* clu = f2c_pointer<ClusterImpl,LCObject>( cluster ) ;
00117 int ntot = *nweights -1 ;
00118 for(unsigned int l=0;l<clu->getCalorimeterHits().size();l++){
00119 if ( l > (unsigned)ntot ) {
00120 std::cout << "LCCluster: in getHitContributions more than " << ntot << "weights to store" << std::endl ;
00121 return LCIO::ERROR ;
00122 }
00123 *weights++ = clu->getHitContributions()[l] ;
00124 }
00125 *nweights = (int)(clu->getCalorimeterHits().size() + 1);
00126 return LCIO::SUCCESS ;
00127 }
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137 int lcclusettypebit( PTRTYPE cluster, int bit , int val) {
00138 ClusterImpl* clu = f2c_pointer<ClusterImpl,LCObject>( cluster ) ;
00139 clu->setTypeBit( bit , val ) ;
00140 return LCIO::SUCCESS ;
00141 }
00142
00143 int lcclusetenergy( PTRTYPE cluster, float energy ) {
00144 ClusterImpl* clu = f2c_pointer<ClusterImpl,LCObject>( cluster ) ;
00145 clu->setEnergy( energy ) ;
00146 return LCIO::SUCCESS ;
00147 }
00148
00149 int lcclusetposition( PTRTYPE cluster, float pos[3] ) {
00150 ClusterImpl* clu = f2c_pointer<ClusterImpl,LCObject>( cluster ) ;
00151 clu->setPosition( pos ) ;
00152 return LCIO::SUCCESS ;
00153 }
00154
00155
00156 int lcclusetpositionerror( PTRTYPE cluster, float errpos[3] ) {
00157 ClusterImpl* clu = f2c_pointer<ClusterImpl,LCObject>( cluster ) ;
00158 clu->setPositionError( errpos ) ;
00159 return LCIO::SUCCESS ;
00160 }
00161
00162 int lcclusetitheta( PTRTYPE cluster, float theta) {
00163 ClusterImpl* clu = f2c_pointer<ClusterImpl,LCObject>( cluster ) ;
00164 clu->setITheta( theta ) ;
00165 return LCIO::SUCCESS ;
00166 }
00167
00168 int lcclusetiphi( PTRTYPE cluster, float phi ) {
00169 ClusterImpl* clu = f2c_pointer<ClusterImpl,LCObject>( cluster ) ;
00170 clu->setIPhi( phi ) ;
00171 return LCIO::SUCCESS ;
00172 }
00173
00174 int lcclusetdirectionerror( PTRTYPE cluster, float errdir[3] ) {
00175 ClusterImpl* clu = f2c_pointer<ClusterImpl,LCObject>( cluster ) ;
00176 clu->setDirectionError( errdir ) ;
00177 return LCIO::SUCCESS ;
00178 }
00179
00180 int lcclusetshape( PTRTYPE cluster, PTRTYPE vector ) {
00181 ClusterImpl* clu = f2c_pointer<ClusterImpl,LCObject>( cluster ) ;
00182 FloatVec* shape = reinterpret_cast<FloatVec*>(vector) ;
00183 clu->setShape( *shape ) ;
00184 return LCIO::SUCCESS ;
00185 }
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206 int lccluaddparticleid( PTRTYPE cluster, PTRTYPE pid) {
00207 ClusterImpl* clu = f2c_pointer<ClusterImpl,LCObject>( cluster ) ;
00208 ParticleID* cpid = f2c_pointer<ParticleID,LCObject>( pid ) ;
00209 clu->addParticleID( cpid ) ;
00210 return LCIO::SUCCESS ;
00211 }
00212
00213 int lccluaddcluster( PTRTYPE cluster, PTRTYPE clus) {
00214 ClusterImpl* clu = f2c_pointer<ClusterImpl,LCObject>( cluster ) ;
00215 Cluster* cclus = f2c_pointer<Cluster,LCObject>( clus ) ;
00216 clu->addCluster( cclus ) ;
00217 return LCIO::SUCCESS ;
00218 }
00219
00220 int lccluaddhit( PTRTYPE cluster, PTRTYPE calohit, float weight ) {
00221 ClusterImpl* clu = f2c_pointer<ClusterImpl,LCObject>( cluster ) ;
00222 CalorimeterHit* ccalh = f2c_pointer<CalorimeterHit,LCObject>( calohit ) ;
00223 clu->addHit( ccalh, weight ) ;
00224 return LCIO::SUCCESS ;
00225 }
00226
00227 int lcclusetsubdetectorenergies( PTRTYPE cluster, float* floatv, const int nfloatv ) {
00228 ClusterImpl* clu = f2c_pointer<ClusterImpl,LCObject>( cluster ) ;
00229 FloatVec& floatvec = clu->subdetectorEnergies() ;
00230 floatvec.resize( nfloatv ) ;
00231 for(int j=0;j<nfloatv;j++) {
00232 floatvec[j] = floatv[j] ;
00233 }
00234 return LCIO::SUCCESS ;
00235
00236 }
00237
00238