8 #include <EVENT/LCCollection.h>
10 #include <EVENT/SimTrackerHit.h>
17 #include <gear/GEAR.h>
18 #include <marlin/Global.h>
19 #ifdef MARLIN_USE_AIDA
20 #include <marlin/AIDAProcessor.h>
26 using namespace lcio ;
27 using namespace marlin ;
36 _description =
"VTXBgClusters should create VTX TrackerHits from SimTrackerHits" ;
41 registerProcessorParameter(
"RemoveDrays" ,
46 registerProcessorParameter(
"MomentumCutForDRays" ,
47 "Momentum Cut For D Rays (MeV)",
51 registerProcessorParameter(
"Debug",
56 registerProcessorParameter(
"Modif",
57 "sensor modification option",
62 registerInputCollection( LCIO::SIMTRACKERHIT,
64 "Name of the VTX SimTrackerHit collection" ,
66 std::string(
"VXDCollection") ) ;
95 for(
int i=0; i<6; i++) {
101 std::cout <<
"------------STANDARD mode for sensor--------------- " << std::endl;
105 for(
int i=0; i<6; i++) {
113 std::cout <<
"------------MODIFIED mode for sensor--------------- " << std::endl;
123 LCCollection* STHcol = 0 ;
127 catch(DataNotAvailableException &
e){
128 streamlog_out( DEBUG ) <<
"Collection " <<
_colNameVTX.c_str() <<
" is unavailable in event "
129 <<
_nEvt << std::endl;
138 int nSimHits = STHcol->getNumberOfElements() ;
140 for(
int i=0; i< nSimHits; i++){
142 SimTrackerHit* SimTHit =
dynamic_cast<SimTrackerHit*
>( STHcol->getElementAt( i ) ) ;
146 float totMomentum = 0;
148 for (
int i=0;i<3;++i)
149 totMomentum+=SimTHit->getMomentum()[i]*SimTHit->getMomentum()[i];
150 totMomentum = sqrt(totMomentum);
164 const int cellId = SimTHit->getCellID0() ;
166 const int layerId = ( cellId & 0xff ) - 1 ;
169 double effpl = SimTHit->getPathLength()*
_epi;
174 else sma=4*
_pitch[layerId];
176 double SMA = ((int)(effpl*1000/
_pitch[layerId] -1/4) +4)*
_pitch[layerId];
182 gear::Vector3D pos(SimTHit->getPosition()[0],SimTHit->getPosition()[1],SimTHit->getPosition()[2]) ;
185 streamlog_out( DEBUG ) <<
" eff. path length : " << effpl
188 <<
" layerId : " << layerId
189 <<
" ladderId : " << ladderId
194 gear::Vector3D mom(SimTHit->getMomentum()[0],SimTHit->getMomentum()[1],SimTHit->getMomentum()[2]);
196 double modladdermom = sqrt(laddermom[1]*laddermom[1]+laddermom[2]*laddermom[2]);
199 gear::Vector3D dSMAladder(0,SMA*laddermom[1]/modladdermom,SMA*laddermom[2]/modladdermom);
202 gear::Vector3D dsmaladder(0,sma*laddermom[2]/modladdermom,sma*laddermom[1]/modladdermom);
214 dSMAladder, dsmaladder,
231 #ifdef MARLIN_USE_AIDA
244 if( isFirstEvent() ) {
246 _hist1DVec.resize( H1D::size ) ;
248 float hitMax = 1000. ;
249 _hist1DVec[ H1D::hitsLayer1 ] = AIDAProcessor::histogramFactory(
this)->createHistogram1D(
"hitsLayer1",
252 _hist1DVec[ H1D::hitsLayer2 ] = AIDAProcessor::histogramFactory(
this)->createHistogram1D(
"hitsLayer2",
255 _hist1DVec[ H1D::hitsLayer3 ] = AIDAProcessor::histogramFactory(
this)->createHistogram1D(
"hitsLayer3",
258 _hist1DVec[ H1D::hitsLayer4 ] = AIDAProcessor::histogramFactory(
this)->createHistogram1D(
"hitsLayer4",
261 _hist1DVec[ H1D::hitsLayer5 ] = AIDAProcessor::histogramFactory(
this)->createHistogram1D(
"hitsLayer5",
264 _hist1DVec[ H1D::hitsLayer6 ] = AIDAProcessor::histogramFactory(
this)->createHistogram1D(
"hitsLayer6",
269 _hist2DVec.resize( H1D::size ) ;
271 for(
int i=0 ; i < H1D::size ; ++i ){
273 std::stringstream name ;
274 name <<
"clusSizLayer" << i ;
276 std::stringstream comment ;
277 comment <<
"cluster sizes in layer " << i ;
289 _hist2DVec[i] = AIDAProcessor::histogramFactory(
this)
290 ->createHistogram2D( name.str() ,
304 LCCollection* vxdCol = 0 ;
318 int nH = vxdCol->getNumberOfElements() ;
321 for(
int i=0; i<nH ; ++i){
323 SimTrackerHit* sth =
dynamic_cast<SimTrackerHit*
>( vxdCol->getElementAt(i) ) ;
325 int layer = ( sth->getCellID0() & 0xff ) - 1 ;
340 double za = std::abs( axisAlad.z() ) ;
341 double zb = std::abs( axisBlad.z() ) ;
342 double ya = std::abs( axisAlad.y() ) ;
343 double yb = std::abs( axisBlad.y() ) ;
345 double zPro = ( za > zb ? za : zb ) ;
346 double yPro = ( ya > yb ? ya : yb ) ;
348 #ifdef MARLIN_USE_AIDA
349 _hist2DVec[ layer ]->fill( zPro , yPro ) ;
401 }
catch( DataNotAvailableException&
e) {}
403 #ifdef MARLIN_USE_AIDA
404 _hist1DVec[ H1D::hitsLayer1 ]->fill( nHitL1 ) ;
405 _hist1DVec[ H1D::hitsLayer2 ]->fill( nHitL2 ) ;
406 _hist1DVec[ H1D::hitsLayer3 ]->fill( nHitL3 ) ;
407 _hist1DVec[ H1D::hitsLayer4 ]->fill( nHitL4 ) ;
408 _hist1DVec[ H1D::hitsLayer5 ]->fill( nHitL5 ) ;
409 _hist1DVec[ H1D::hitsLayer6 ]->fill( nHitL6 ) ;
416 streamlog_out( DEBUG4 ) <<
"VTXBgClusters::end() " << name()
417 <<
" processed " <<
_nEvt <<
" events in " <<
_nRun <<
" runs "
VTXBgClusters aVTXBgClusters
virtual void check(LCEvent *evt)
CLHEP::Hep3Vector Vector3D
Allows to use VXDClusterParameters as runtime extension object.
======= VXDGeometry ========== Helper class for VXD geomtry transformations: from lab frame to ladd...
gear::Vector3D getClusterAxisA()
gear::Vector3D lab2LadderDir(gear::Vector3D labPos, int layerID, int ladderID)
Convert a direction in the lab frame to local ladder coordinates (x_ladder==0 is the middle of the se...
virtual void processEvent(LCEvent *evt)
Called for every event - the working horse.
virtual void processRunHeader(LCRunHeader *run)
Called for every run.
virtual void end()
Called after data processing for clean up.
gear::Vector3D lab2LadderPos(gear::Vector3D labPos, int layerID, int ladderID)
Convert a position in the lab frame to local ladder coordinates (x_ladder==0 is the middle of the sen...
std::pair< int, int > getLadderID(gear::Vector3D labPos, int layerID=-1)
Return the pair (layerID, ladderID) for the given position, (-1,-1) if not in sensitive volume (in th...
gear::Vector3D getClusterAxisB()
virtual void init()
Called at the begin of the job before anything is read.