ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillerPixelHits.cc
Revision: 1.3
Committed: Tue Nov 17 21:16:31 2009 UTC (15 years, 5 months ago) by loizides
Content type: text/plain
Branch: MAIN
Changes since 1.2: +26 -2 lines
Log Message:
Check for pixel on edges

File Contents

# User Rev Content
1 loizides 1.3 // $Id: FillerPixelHits.cc,v 1.2 2009/09/28 14:33:21 loizides Exp $
2 loizides 1.1
3     #include "MitProd/TreeFiller/interface/FillerPixelHits.h"
4     #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
5     #include "DataFormats/GeometryVector/interface/LocalPoint.h"
6     #include "DataFormats/SiPixelDetId/interface/PXBDetId.h"
7     #include "DataFormats/SiPixelDetId/interface/PXFDetId.h"
8     #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHitCollection.h"
9     #include "FWCore/Framework/interface/ESHandle.h"
10     #include "Geometry/CommonDetUnit/interface/GeomDet.h"
11 loizides 1.3 #include "Geometry/TrackerTopology/interface/RectangularPixelTopology.h"
12     #include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h"
13 loizides 1.1 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
14     #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
15     #include "MitAna/DataTree/interface/Names.h"
16     #include "MitAna/DataTree/interface/PixelHitCol.h"
17     #include "MitProd/ObjectService/interface/ObjectService.h"
18    
19     using namespace std;
20     using namespace edm;
21     using namespace mithep;
22    
23     //--------------------------------------------------------------------------------------------------
24     FillerPixelHits::FillerPixelHits(const ParameterSet &cfg, const char *name, bool active) :
25     BaseFiller(cfg,name,active),
26     edmName_(Conf().getUntrackedParameter<string>("edmName","siPixelRecHits")),
27     mitName_(Conf().getUntrackedParameter<string>("mitName",Names::gkPixelHitBrn)),
28     phits_(new mithep::PixelHitArr(1000)),
29     tgeo_(0)
30     {
31     // Constructor.
32     }
33    
34     //--------------------------------------------------------------------------------------------------
35     FillerPixelHits::~FillerPixelHits()
36     {
37     // Destructor.
38    
39     delete phits_;
40     }
41    
42     //--------------------------------------------------------------------------------------------------
43     void FillerPixelHits::BookDataBlock(TreeWriter &tws, const edm::EventSetup &es)
44     {
45     // Add tracks branch to tree, publish and get tracker geometry.
46    
47     tws.AddBranch(mitName_,&phits_);
48     OS()->add<PixelHitArr>(phits_,mitName_);
49    
50     // get tracker geometry
51     edm::ESHandle<TrackerGeometry> trackerHandle;
52     es.get<TrackerDigiGeometryRecord>().get(trackerHandle);
53     tgeo_ = trackerHandle.product();
54     }
55    
56     //--------------------------------------------------------------------------------------------------
57     void FillerPixelHits::FillDataBlock(const edm::Event &event,
58     const edm::EventSetup &setup)
59     {
60     // Fill pixel hits from edm collection into our collection.
61    
62     phits_->Delete();
63    
64     // initialize handle and get product
65     Handle<SiPixelRecHitCollection> hRecHits;
66     GetProduct(edmName_, hRecHits, event);
67    
68     const SiPixelRecHitCollection *hits = hRecHits.product();
69     for(SiPixelRecHitCollection::DataContainer::const_iterator hit = hits->data().begin(),
70     end = hits->data().end(); hit != end; ++hit) {
71    
72 loizides 1.2 if (!hit->isValid())
73     continue;
74    
75 loizides 1.1 DetId id(hit->geographicalId());
76     LocalPoint lpos = LocalPoint(hit->localPosition().x(),
77     hit->localPosition().y(),
78     hit->localPosition().z());
79     GlobalPoint gpos = tgeo_->idToDet(id)->toGlobal(lpos);
80    
81     Char_t type = 0;
82     if(id.subdetId() == int(PixelSubdetector::PixelBarrel)) {
83     PXBDetId pid(id);
84     type = pid.layer();
85     } else if (id.subdetId() == int(PixelSubdetector::PixelEndcap)) {
86     PXFDetId pid(id);
87     if (pid.disk()==0)
88     type = 11;
89     else
90     type = 12;
91     if (pid.side()!=0)
92     type = -type;
93 loizides 1.3 } else {
94     continue;
95     }
96    
97     bool isAnyPixelOnEdge = false;
98     if (1) {
99     const PixelGeomDetUnit *pgdu = static_cast<const PixelGeomDetUnit*>(tgeo_->idToDet(id));
100     const RectangularPixelTopology *pixTopo =
101     static_cast<const RectangularPixelTopology*>(&(pgdu->specificTopology()));
102     vector<SiPixelCluster::Pixel> pixels(hit->cluster()->pixels());
103    
104     for(std::vector<SiPixelCluster::Pixel>::const_iterator pixel = pixels.begin();
105     pixel != pixels.end(); ++pixel) {
106     int pixelX = pixel->x;
107     int pixelY = pixel->y;
108     if(pixTopo->isItEdgePixelInX(pixelX) || pixTopo->isItEdgePixelInY(pixelY)) {
109     isAnyPixelOnEdge = true;
110     break;
111     }
112     }
113 loizides 1.1 }
114    
115     mithep::PixelHit *newhit = phits_->Allocate();
116     new (newhit) mithep::PixelHit(gpos.x(),gpos.y(),gpos.z());
117     newhit->SetType(type);
118     newhit->SetQuality(hit->rawQualityWord());
119     newhit->SetCharge(static_cast<int>(hit->cluster()->charge()));
120 loizides 1.3 newhit->SetSizeX(hit->cluster()->sizeX());
121     newhit->SetSizeY(hit->cluster()->sizeY());
122     newhit->SetAnyPixelIsOnEdge(isAnyPixelOnEdge);
123 loizides 1.1 }
124    
125     phits_->Trim();
126     }