00001 #include <iostream>
00002 #include <stdexcept>
00003 #include <cmath>
00004 #include <stdio.h>
00005 #include <stdlib.h>
00006 #include "StEvent.h"
00007 #include "StMcEvent/StMcEvent.hh"
00008 #include "StEventTypes.h"
00009 #include "StDbUtilities/StGlobalCoordinate.hh"
00010 #include "Sti/Base/Factory.h"
00011 #include "Sti/StiHit.h"
00012 #include "Sti/StiHitContainer.h"
00013 #include "Sti/StiDetector.h"
00014 #include "Sti/StiDetectorBuilder.h"
00015
00016 #include "Sti/StiTrackContainer.h"
00017 #include "StiIstHitLoader.h"
00018 #include "StMcEvent/StMcTrack.hh"
00019 #include "StMcEvent/StMcIstHit.hh"
00020 #include "StMcEvent/StMcIstHitCollection.hh"
00021 #include "StMcEvent/StMcIstLayerHitCollection.hh"
00022 #include "StBFChain.h"
00023 #include "StChain.h"
00024 #include "StMaker.h"
00025 #include "StPixelFastSimMaker/StPixelFastSimMaker.h"
00026
00027 StiIstHitLoader::StiIstHitLoader()
00028 : StiHitLoader<StEvent,StiDetectorBuilder>("IstHitLoader")
00029 {}
00030
00031 StiIstHitLoader::StiIstHitLoader(StiHitContainer* hitContainer,
00032 Factory<StiHit>*hitFactory,
00033 StiDetectorBuilder * detector)
00034 : StiHitLoader<StEvent,StiDetectorBuilder>("IstHitLoader",hitContainer,hitFactory,detector)
00035 {evNum=0;}
00036
00037 StiIstHitLoader::~StiIstHitLoader()
00038 {}
00039
00040 void StiIstHitLoader::loadHits(StEvent* source,
00041 Filter<StiTrack> * trackFilter,
00042 Filter<StiHit> * hitFilter)
00043 {
00044 n=0;
00045
00046 LOG_INFO << "StiIstHitLoader::loadHits(StEvent*) -I- Started" << endm;
00047 if (!_detector)
00048 throw runtime_error("StiIstHitLoader::loadHits(StEvent*) - FATAL - _detector==0");
00049 if(!_hitContainer)
00050 throw runtime_error("StiIstHitLoader::loadHits(StEvent*) - FATAL - _hitContainer==0");
00051
00052
00053 StRnDHitCollection *col = source->rndHitCollection();
00054 if (!col) {
00055 LOG_INFO <<"StiIstHitLoader::loadHits\tERROR:\tcol==0"<<endm;
00056 LOG_INFO <<"You must not have pixelFastSim in your chain"<<endm;
00057 LOG_INFO <<"will return with no action taken"<<endm;
00058 return;
00059 }
00060 StSPtrVecRnDHit& vec = col->hits();
00061
00062 LOG_DEBUG <<"StiIstHitLoader: RnD Hits: "<<vec.size()<<endm;
00063
00064 for(unsigned int j=0; j<vec.size(); j++) {
00065
00066
00067 StRnDHit* hit = vec[j];
00068 assert(hit);
00069
00070 if (hit->detector()!=kIstId) continue;
00071
00072
00073
00074
00075 int layer=hit->layer();
00076 int ladder=hit->ladder();
00077 int wafer=hit->wafer();
00078 LOG_DEBUG<<"StiIstHitLoader: hit has ladder: "<<ladder<<"; wafer: "<<wafer<<endm;
00079 LOG_DEBUG<<"StiIstHitLoader: hit volume id: "<<hit->volumeId()<<endm;
00080 StiDetector* detector=0;
00081
00082
00083 detector=_detector->getDetector(layer,ladder);
00084 if (!detector) cout <<"no detector found for hit:\t"<<*hit<<endl;
00085 assert(detector);
00086 cout <<"StiIstHitLoader: add hit to detector:\t"<<detector->getName()<<endl;
00087
00088 StiHit * stiHit = _hitFactory->getInstance();
00089 if(!stiHit) throw runtime_error("StiIstHitLoader::loadHits(StEvent*) -E- stiHit==0");
00090 stiHit->reset();
00091 LOG_DEBUG<<"StiIstHitLoader: hit has position ("<<hit->position().x()<<","<<hit->position().y()<<","<<hit->position().z()<<")"<<endm;
00092 stiHit->setGlobal(detector, hit, hit->position().x(),hit->position().y(),hit->position().z(),hit->charge());
00093 _hitContainer->add( stiHit );
00094
00095 }
00096
00097 LOG_INFO << "StiIstHitLoader::loadHits(StEvent*) -I- Done" << endm;
00098 }
00099
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157