00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include <iostream>
00039 #include <stdexcept>
00040 #include <cmath>
00041 #include <stdio.h>
00042 #include <stdlib.h>
00043 #include "StEvent.h"
00044 #include "StEventTypes.h"
00045 #include "StDbUtilities/StGlobalCoordinate.hh"
00046 #include "Sti/Base/Factory.h"
00047 #include "Sti/StiHit.h"
00048 #include "StRnDHit.h"
00049 #include "StRnDHitCollection.h"
00050 #include "Sti/StiHitContainer.h"
00051 #include "Sti/StiDetector.h"
00052 #include "Sti/StiDetectorBuilder.h"
00053 #include "Sti/StiTrackContainer.h"
00054 #include "StiPixelHitLoader.h"
00055
00056 StiPixelHitLoader::StiPixelHitLoader()
00057 : StiHitLoader<StEvent,StiDetectorBuilder>("PixelHitLoader")
00058 {}
00059
00060 StiPixelHitLoader::StiPixelHitLoader(StiHitContainer* hitContainer,
00061 Factory<StiHit>*hitFactory,
00062 StiDetectorBuilder * detector)
00063 : StiHitLoader<StEvent,StiDetectorBuilder>("PixelHitLoader",hitContainer,hitFactory,detector)
00064 {}
00065
00066 StiPixelHitLoader::~StiPixelHitLoader()
00067 {}
00068
00069 void StiPixelHitLoader::loadHits(StEvent* source,
00070 Filter<StiTrack> * trackFilter,
00071 Filter<StiHit> * hitFilter)
00072 {
00073
00074 LOG_INFO << " -I- Started" << endl;
00075 if (!_detector)
00076 throw runtime_error("StiPixelHitLoader::loadHits(StEvent*) - FATAL - _detector==0");
00077 if(!_hitContainer)
00078 throw runtime_error("StiPixelHitLoader::loadHits(StEvent*) - FATAL - _hitContainer==0");
00079
00080 StRnDHitCollection *col = source->rndHitCollection();
00081 if (!col) {
00082 LOG_ERROR <<"StiPixelHitLoader::loadHits\tERROR:\tcol==0"
00083 <<"You must not have pixelFastSim in your chain"
00084 <<"will return with no action taken"<<endm;
00085 return;
00086 }
00087 StSPtrVecRnDHit& vec = col->hits();
00088
00089 StiDetector *detector=0;
00090 int nHit=0;
00091 for(unsigned int j=0; j<vec.size(); j++) {
00092 StRnDHit *pxlH = vec[j];
00093 if(!pxlH)
00094 throw runtime_error("StiPixelHitLoader::loadHits(StEvent*) -E- NULL hit in container");
00095
00096 if (pxlH->detector()!=kPxlId) continue;
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111 LOG_DEBUG <<Form("hit layer: %i ladder: %i\n",pxlH->layer(), pxlH->ladder()) << endm;
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122 detector= _detector->getDetector(pxlH->layer(), pxlH->ladder());
00123
00124 if(!detector)
00125 throw runtime_error("StiPixelHitLoader::loadHits(StEvent*) -E- NULL detector pointer");
00126 LOG_DEBUG <<"add hit to detector:\t"<<detector->getName()<<endm;
00127
00128
00129
00130
00131 double angle = detector->getPlacement()->getNormalRefAngle();
00132 double radius = detector->getPlacement()->getNormalRadius();
00133 double zcenter = detector->getPlacement()->getZcenter();
00134 double halfDepth = detector->getShape()->getHalfDepth();
00135 double halfWidth = detector->getShape()->getHalfWidth();
00136 double thick = detector->getShape()->getThickness();
00137 LOG_DEBUG << " detector info " << *detector << endm;
00138 LOG_DEBUG << " radius = "<< radius << " angle = " << angle << " zCenter = " << zcenter << endm;
00139 LOG_DEBUG << " depth = " << halfDepth << " Width = " << halfWidth << " thickness= " << thick << endm;
00140 LOG_DEBUG << " key 1 : " << detector->getKey(1) <<" key 2 : " << detector->getKey(2) << endm;
00141
00142 StiHit *stiHit=_hitFactory->getInstance();
00143 if(!stiHit) throw runtime_error("StiPixelHitLoader::loadHits(StEvent*) -E- stiHit==0");
00144 stiHit->reset();
00145
00146
00147
00148 stiHit->setGlobal(detector, pxlH,
00149 pxlH->position().x(), pxlH->position().y(),
00150 pxlH->position().z(), pxlH->charge());
00151
00152 _hitContainer->add(stiHit);
00153 LOG_DEBUG <<" nHit = "<<nHit<<" Layer = "<<pxlH->layer()<<" Ladder = "<<pxlH->ladder()<<" x = "<<pxlH->position().x()<<" y = "<<pxlH->position().y()<<" z = "<<pxlH->position().z()<<endm;
00154
00155
00156 nHit++;
00157 }
00158
00159 LOG_INFO <<"StiPixelHitLoader:loadHits -I- Loaded "<<nHit<<" pixel hits."<<endm;
00160
00161
00162 }
00163