ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillerPixelHits.cc
Revision: 1.8
Committed: Sat Apr 23 19:13:14 2011 UTC (14 years ago) by bendavid
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_032, Mit_031, Mit_025c_branch2, Mit_025c_branch1, Mit_030, Mit_029c, Mit_029b, Mit_030_pre1, Mit_029a, Mit_029, Mit_029_pre1, Mit_028a, Mit_025c_branch0, Mit_028, Mit_027a, Mit_027, Mit_026, Mit_025e, Mit_025d, Mit_025c, Mit_025b, Mit_025a, Mit_025, Mit_025pre2, Mit_024b, Mit_025pre1, Mit_024a, Mit_024, Mit_023, Mit_022a, Mit_022, Mit_021, Mit_021pre2, Mit_021pre1, HEAD
Branch point for: Mit_025c_branch
Changes since 1.7: +2 -2 lines
Log Message:
minimal compilation fixes for 42x

File Contents

# User Rev Content
1 bendavid 1.8 // $Id: FillerPixelHits.cc,v 1.7 2010/03/18 20:21:01 bendavid 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 bendavid 1.8 #include "Geometry/TrackerGeometryBuilder/interface/RectangularPixelTopology.h"
12 loizides 1.3 #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 loizides 1.5 phits_(new mithep::PixelHitArr(1000))
29 loizides 1.1 {
30     // Constructor.
31     }
32    
33     //--------------------------------------------------------------------------------------------------
34     FillerPixelHits::~FillerPixelHits()
35     {
36     // Destructor.
37    
38     delete phits_;
39     }
40    
41     //--------------------------------------------------------------------------------------------------
42 bendavid 1.7 void FillerPixelHits::BookDataBlock(TreeWriter &tws)
43 loizides 1.1 {
44     // Add tracks branch to tree, publish and get tracker geometry.
45    
46     tws.AddBranch(mitName_,&phits_);
47     OS()->add<PixelHitArr>(phits_,mitName_);
48     }
49    
50     //--------------------------------------------------------------------------------------------------
51     void FillerPixelHits::FillDataBlock(const edm::Event &event,
52     const edm::EventSetup &setup)
53     {
54     // Fill pixel hits from edm collection into our collection.
55    
56     phits_->Delete();
57    
58     // initialize handle and get product
59     Handle<SiPixelRecHitCollection> hRecHits;
60     GetProduct(edmName_, hRecHits, event);
61    
62     const SiPixelRecHitCollection *hits = hRecHits.product();
63 loizides 1.4 if (!hits->size())
64     return;
65    
66     // get tracker geometry
67     edm::ESHandle<TrackerGeometry> trackerHandle;
68     setup.get<TrackerDigiGeometryRecord>().get(trackerHandle);
69 loizides 1.5 const TrackerGeometry *tgeo = trackerHandle.product();
70 loizides 1.4
71 loizides 1.1 for(SiPixelRecHitCollection::DataContainer::const_iterator hit = hits->data().begin(),
72     end = hits->data().end(); hit != end; ++hit) {
73    
74 loizides 1.2 if (!hit->isValid())
75     continue;
76    
77 loizides 1.1 DetId id(hit->geographicalId());
78    
79 edwenger 1.6 int type = 0; // PXB: 1,2,3 // PXF: +/- 11,12
80 loizides 1.1 if(id.subdetId() == int(PixelSubdetector::PixelBarrel)) {
81     PXBDetId pid(id);
82     type = pid.layer();
83     } else if (id.subdetId() == int(PixelSubdetector::PixelEndcap)) {
84     PXFDetId pid(id);
85 edwenger 1.6 type = (10 + pid.disk())*((pid.side()==1)?-1:1);
86 loizides 1.3 } else {
87     continue;
88     }
89    
90     bool isAnyPixelOnEdge = false;
91 loizides 1.5 const PixelGeomDetUnit *pgdu =
92     static_cast<const PixelGeomDetUnit*>(tgeo->idToDetUnit(id));
93 loizides 1.3 if (1) {
94     const RectangularPixelTopology *pixTopo =
95 loizides 1.4 static_cast<const RectangularPixelTopology*>(&pgdu->specificTopology());
96     const vector<SiPixelCluster::Pixel> pixels(hit->cluster()->pixels());
97 loizides 1.3 for(std::vector<SiPixelCluster::Pixel>::const_iterator pixel = pixels.begin();
98     pixel != pixels.end(); ++pixel) {
99     int pixelX = pixel->x;
100     int pixelY = pixel->y;
101     if(pixTopo->isItEdgePixelInX(pixelX) || pixTopo->isItEdgePixelInY(pixelY)) {
102     isAnyPixelOnEdge = true;
103     break;
104     }
105     }
106 loizides 1.1 }
107    
108 loizides 1.4 LocalPoint lpos = LocalPoint(hit->localPosition().x(),
109     hit->localPosition().y(),
110     hit->localPosition().z());
111     GlobalPoint gpos = pgdu->toGlobal(lpos);
112 loizides 1.1 mithep::PixelHit *newhit = phits_->Allocate();
113     new (newhit) mithep::PixelHit(gpos.x(),gpos.y(),gpos.z());
114     newhit->SetType(type);
115     newhit->SetQuality(hit->rawQualityWord());
116     newhit->SetCharge(static_cast<int>(hit->cluster()->charge()));
117 loizides 1.3 newhit->SetSizeX(hit->cluster()->sizeX());
118     newhit->SetSizeY(hit->cluster()->sizeY());
119     newhit->SetAnyPixelIsOnEdge(isAnyPixelOnEdge);
120 loizides 1.1 }
121     phits_->Trim();
122     }