Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef STACKED_TRACKER_L1TK_STUB_FORMAT_H
00016 #define STACKED_TRACKER_L1TK_STUB_FORMAT_H
00017
00018 #include "DataFormats/SiPixelDetId/interface/StackedTrackerDetId.h"
00019 #include "CLHEP/Units/PhysicalConstants.h"
00020
00021 #include "DataFormats/DetId/interface/DetId.h"
00022 #include "DataFormats/Common/interface/Ref.h"
00023 #include "DataFormats/GeometryCommonDetAlgo/interface/MeasurementPoint.h"
00024 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00025 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
00026 #include "DataFormats/Common/interface/DetSetVector.h"
00027 #include "SimDataFormats/TrackerDigiSimLink/interface/PixelDigiSimLink.h"
00028 #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
00029 #include "SimDataFormats/SLHC/interface/L1TkCluster.h"
00030
00037 template< typename T >
00038 class L1TkStub
00039 {
00040 public:
00042 L1TkStub();
00043 L1TkStub( DetId aDetId );
00044
00046 ~L1TkStub();
00047
00050
00052 std::vector< edm::Ptr< L1TkCluster< T > > > getClusterPtrs() const;
00053 const edm::Ptr< L1TkCluster< T > >& getClusterPtr( unsigned int hitIdentifier ) const;
00054 void addClusterPtr( edm::Ptr< L1TkCluster< T > > aL1TkCluster );
00055
00059
00061 DetId getDetId() const;
00062 void setDetId( DetId aDetId );
00063
00065 double getTriggerDisplacement() const;
00066 void setTriggerDisplacement( int aDisplacement );
00067 double getTriggerOffset() const;
00068 void setTriggerOffset( int anOffset );
00069
00071 edm::Ptr< SimTrack > getSimTrackPtr() const;
00072 bool isGenuine() const;
00073 bool isCombinatoric() const;
00074 bool isUnknown() const;
00075 int findType() const;
00076 unsigned int findSimTrackId() const;
00077
00079 void checkSimTrack();
00080
00082 std::string print( unsigned int i=0 ) const;
00083
00084 private:
00086 DetId theDetId;
00087 std::vector< edm::Ptr< L1TkCluster< T > > > theClusters;
00088 edm::Ptr< SimTrack > theSimTrack;
00089 int theDisplacement;
00090 int theOffset;
00091
00092 };
00093
00100
00101 template< typename T >
00102 L1TkStub< T >::L1TkStub()
00103 {
00105 theDetId = 0;
00106 theClusters.clear();
00107 theDisplacement = 999999;
00108 theOffset = 0;
00109 }
00110
00112 template< typename T >
00113 L1TkStub< T >::L1TkStub( DetId aDetId )
00114 {
00116 theDetId = aDetId;
00117 theClusters.clear();
00118 theDisplacement = 999999;
00119 theOffset = 0;
00120 }
00121
00123 template< typename T >
00124 L1TkStub< T >::~L1TkStub(){}
00125
00127 template< typename T >
00128 std::vector< edm::Ptr< L1TkCluster< T > > > L1TkStub< T >::getClusterPtrs() const { return theClusters; }
00129
00131 template< typename T >
00132 const edm::Ptr< L1TkCluster< T > >& L1TkStub< T >::getClusterPtr( unsigned int hitIdentifier ) const
00133 {
00134 typename std::vector< edm::Ptr< L1TkCluster< T > > >::const_iterator clusIter;
00135 for ( clusIter = theClusters.begin();
00136 clusIter != theClusters.end();
00137 ++clusIter )
00138 {
00139 if ( (*clusIter)->getStackMember() == hitIdentifier )
00140 return *clusIter;
00141 }
00142
00143
00144 edm::Ptr< L1TkCluster< T > >* tmpCluPtr = new edm::Ptr< L1TkCluster< T > >();
00145 return *tmpCluPtr;
00146
00147 }
00148
00150 template< typename T >
00151 void L1TkStub< T >::addClusterPtr( edm::Ptr< L1TkCluster< T > > aL1TkCluster )
00152 {
00156 theClusters.push_back( aL1TkCluster );
00157 }
00158
00160 template< typename T >
00161 DetId L1TkStub< T >::getDetId() const { return theDetId; }
00162
00163 template< typename T >
00164 void L1TkStub< T >::setDetId( DetId aDetId ) { theDetId = aDetId; }
00165
00167 template< typename T >
00168 double L1TkStub< T >::getTriggerDisplacement() const { return 0.5*theDisplacement; }
00169
00170 template< typename T >
00171 void L1TkStub< T >::setTriggerDisplacement( int aDisplacement ) { theDisplacement = aDisplacement; }
00172
00173 template< typename T >
00174 double L1TkStub< T >::getTriggerOffset() const { return 0.5*theOffset; }
00175
00176 template< typename T >
00177 void L1TkStub< T >::setTriggerOffset( int anOffset ) { theOffset = anOffset; }
00178
00180 template< typename T >
00181 edm::Ptr< SimTrack > L1TkStub< T >::getSimTrackPtr() const { return theSimTrack; }
00182
00183 template< typename T >
00184 bool L1TkStub< T >::isGenuine() const
00185 {
00186
00190
00193
00194
00195
00196
00200
00201
00202
00204
00205
00206
00207
00208
00209
00211
00212
00213
00214
00215
00217
00218
00219
00220
00222
00223
00224
00225
00226
00228
00229
00230
00231
00234
00235
00236
00237
00238
00240
00241
00246
00247
00248
00251
00252
00253
00254
00255 if ( theSimTrack.isNull() )
00256 return false;
00257
00258 return true;
00259 }
00260
00261 template< typename T >
00262 bool L1TkStub< T >::isCombinatoric() const
00263 {
00264 if ( this->isGenuine() )
00265 return false;
00266
00270 if ( theClusters.at(0)->isUnknown() && theClusters.at(1)->isUnknown() )
00272 return false;
00273
00274 else if ( theClusters.at(0)->isUnknown() || theClusters.at(1)->isUnknown() )
00277 return true;
00278
00279 else
00280 {
00284 if ( theClusters.at(0)->isGenuine() && theClusters.at(1)->isGenuine() )
00285 {
00286 if ( theClusters.at(0)->findSimTrackId() == theClusters.at(1)->findSimTrackId() )
00288 return false;
00289 else
00290 return true;
00291 }
00292 else
00293 {
00295 int prevTrack = -99999;
00296 std::vector< edm::Ptr< SimTrack > > innerSimTracks = theClusters.at(0)->getSimTrackPtrs();
00297 std::vector< edm::Ptr< SimTrack > > outerSimTracks = theClusters.at(1)->getSimTrackPtrs();
00298 for ( unsigned int i = 0; i < innerSimTracks.size(); i++ )
00299 {
00301 if ( innerSimTracks.at(i).isNull() );
00302 continue;
00303 for ( unsigned int j = 0; j < outerSimTracks.size(); j++ )
00304 {
00306 if ( outerSimTracks.at(j).isNull() );
00307 continue;
00308
00309 if ( innerSimTracks.at(i)->trackId() == outerSimTracks.at(j)->trackId() )
00310 {
00312 if ( prevTrack < 0 )
00313 prevTrack = outerSimTracks.at(j)->trackId();
00314
00315 if ( prevTrack != (int)outerSimTracks.at(j)->trackId() )
00318 return true;
00319 }
00320 }
00321 }
00322 if ( prevTrack < 0 )
00324 return true;
00325 else
00330 return false;
00331 }
00332 }
00335 std::cerr << "W A R N I N G! L1TkStub::isCombinatoric() \t we should never get here" << std::endl;
00336 return false;
00337 }
00338
00339 template< typename T >
00340 bool L1TkStub< T >::isUnknown() const
00341 {
00343 return ( theClusters.at(0)->isUnknown() && theClusters.at(1)->isUnknown() );
00344 }
00345
00346 template< typename T >
00347 int L1TkStub< T >::findType() const
00348 {
00349 if ( theSimTrack.isNull() )
00350 return 999999999;
00351 return theSimTrack->type();
00352 }
00353
00354 template< typename T >
00355 unsigned int L1TkStub< T >::findSimTrackId() const
00356 {
00357 if ( theSimTrack.isNull() )
00358 return 0;
00359 return theSimTrack->trackId();
00360 }
00361
00363 template< typename T >
00364 void L1TkStub< T >::checkSimTrack()
00365 {
00368
00372 if ( theClusters.at(0)->isUnknown() || theClusters.at(1)->isUnknown() )
00376 return;
00377
00378 else
00379 {
00383 if ( theClusters.at(0)->isGenuine() && theClusters.at(1)->isGenuine() )
00384 {
00385 if ( theClusters.at(0)->findSimTrackId() == theClusters.at(1)->findSimTrackId() )
00386 {
00388 std::vector< edm::Ptr< SimTrack > > curSimTracks = theClusters.at(0)->getSimTrackPtrs();
00389 for ( unsigned int k = 0; k < curSimTracks.size(); k++ )
00390 {
00391 if ( curSimTracks.at(k).isNull() == false )
00392 {
00393 theSimTrack = curSimTracks.at(k);
00394 return;
00395 }
00396 }
00397 }
00398 else
00399 return;
00400 }
00401 else
00402 {
00404 int prevTrack = -99999;
00405 unsigned int whichSimTrack = 0;
00406 std::vector< edm::Ptr< SimTrack > > innerSimTracks = theClusters.at(0)->getSimTrackPtrs();
00407 std::vector< edm::Ptr< SimTrack > > outerSimTracks = theClusters.at(1)->getSimTrackPtrs();
00408 for ( unsigned int i = 0; i < innerSimTracks.size(); i++ )
00409 {
00411 if ( innerSimTracks.at(i).isNull() );
00412 continue;
00413 for ( unsigned int j = 0; j < outerSimTracks.size(); j++ )
00414 {
00416 if ( outerSimTracks.at(j).isNull() );
00417 continue;
00418
00419 if ( innerSimTracks.at(i)->trackId() == outerSimTracks.at(j)->trackId() )
00420 {
00422 if ( prevTrack < 0 )
00423 {
00424 prevTrack = outerSimTracks.at(j)->trackId();
00425 whichSimTrack = j;
00426 }
00427
00428 if ( prevTrack != (int)outerSimTracks.at(j)->trackId() )
00431 return;
00432 }
00433 }
00434 }
00435 if ( prevTrack < 0 )
00437 return;
00438 else
00443 theSimTrack = outerSimTracks.at(whichSimTrack);
00444 }
00445 }
00446 }
00447
00448
00450 template< typename T >
00451 std::string L1TkStub< T >::print( unsigned int i ) const
00452 {
00453 std::string padding("");
00454 for ( unsigned int j=0; j!=i; ++j )
00455 padding+="\t";
00456 std::stringstream output;
00457 output<<padding<<"L1TkStub:\n";
00458 padding+='\t';
00459 output << padding << "DetId: " << theDetId.rawId() << '\n';
00460 unsigned int iClu = 0;
00461 typename std::vector< edm::Ptr< L1TkCluster< T > > >::const_iterator clusIter;
00462 for ( clusIter = theClusters.begin(); clusIter!= theClusters.end(); ++clusIter )
00463 output << padding << "cluster: " << iClu++ << ", member: " << (*clusIter)->getStackMember() << ", cluster size: " << (*clusIter)->getHits().size() << '\n';
00464 return output.str();
00465 }
00466
00467 template< typename T >
00468 std::ostream& operator << (std::ostream& os, const L1TkStub< T >& aL1TkStub) { return ( os<<aL1TkStub.print() ); }
00469
00470
00471
00472 #endif
00473