ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillerPixelHits.cc
Revision: 1.1
Committed: Fri Sep 25 08:42:27 2009 UTC (15 years, 7 months ago) by loizides
Content type: text/plain
Branch: MAIN
Log Message:
Added pixel hit filler

File Contents

# User Rev Content
1 loizides 1.1 // $Id: FillerTracks.cc,v 1.33 2009/07/14 13:44:35 bendavid Exp $
2    
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     #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
12     #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
13     #include "MitAna/DataTree/interface/Names.h"
14     #include "MitAna/DataTree/interface/PixelHitCol.h"
15     #include "MitProd/ObjectService/interface/ObjectService.h"
16    
17     using namespace std;
18     using namespace edm;
19     using namespace mithep;
20    
21     //--------------------------------------------------------------------------------------------------
22     FillerPixelHits::FillerPixelHits(const ParameterSet &cfg, const char *name, bool active) :
23     BaseFiller(cfg,name,active),
24     edmName_(Conf().getUntrackedParameter<string>("edmName","siPixelRecHits")),
25     mitName_(Conf().getUntrackedParameter<string>("mitName",Names::gkPixelHitBrn)),
26     phits_(new mithep::PixelHitArr(1000)),
27     tgeo_(0)
28     {
29     // Constructor.
30     }
31    
32     //--------------------------------------------------------------------------------------------------
33     FillerPixelHits::~FillerPixelHits()
34     {
35     // Destructor.
36    
37     delete phits_;
38     }
39    
40     //--------------------------------------------------------------------------------------------------
41     void FillerPixelHits::BookDataBlock(TreeWriter &tws, const edm::EventSetup &es)
42     {
43     // Add tracks branch to tree, publish and get tracker geometry.
44    
45     tws.AddBranch(mitName_,&phits_);
46     OS()->add<PixelHitArr>(phits_,mitName_);
47    
48     // get tracker geometry
49     edm::ESHandle<TrackerGeometry> trackerHandle;
50     es.get<TrackerDigiGeometryRecord>().get(trackerHandle);
51     tgeo_ = trackerHandle.product();
52     }
53    
54     //--------------------------------------------------------------------------------------------------
55     void FillerPixelHits::FillDataBlock(const edm::Event &event,
56     const edm::EventSetup &setup)
57     {
58     // Fill pixel hits from edm collection into our collection.
59    
60     phits_->Delete();
61    
62     // initialize handle and get product
63     Handle<SiPixelRecHitCollection> hRecHits;
64     GetProduct(edmName_, hRecHits, event);
65    
66     const SiPixelRecHitCollection *hits = hRecHits.product();
67     for(SiPixelRecHitCollection::DataContainer::const_iterator hit = hits->data().begin(),
68     end = hits->data().end(); hit != end; ++hit) {
69    
70     DetId id(hit->geographicalId());
71     LocalPoint lpos = LocalPoint(hit->localPosition().x(),
72     hit->localPosition().y(),
73     hit->localPosition().z());
74     GlobalPoint gpos = tgeo_->idToDet(id)->toGlobal(lpos);
75    
76     Char_t type = 0;
77     if(id.subdetId() == int(PixelSubdetector::PixelBarrel)) {
78     PXBDetId pid(id);
79     type = pid.layer();
80     } else if (id.subdetId() == int(PixelSubdetector::PixelEndcap)) {
81     PXFDetId pid(id);
82     if (pid.disk()==0)
83     type = 11;
84     else
85     type = 12;
86     if (pid.side()!=0)
87     type = -type;
88     }
89    
90     mithep::PixelHit *newhit = phits_->Allocate();
91     new (newhit) mithep::PixelHit(gpos.x(),gpos.y(),gpos.z());
92     newhit->SetType(type);
93     newhit->SetQuality(hit->rawQualityWord());
94     newhit->SetCharge(static_cast<int>(hit->cluster()->charge()));
95     newhit->SetSize(hit->cluster()->size());
96     }
97    
98     phits_->Trim();
99     }