1 |
loizides |
1.2 |
// $Id: FillerPixelHits.cc,v 1.1 2009/09/25 08:42:27 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 |
|
|
#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 |
loizides |
1.2 |
if (!hit->isValid())
|
71 |
|
|
continue;
|
72 |
|
|
|
73 |
loizides |
1.1 |
DetId id(hit->geographicalId());
|
74 |
|
|
LocalPoint lpos = LocalPoint(hit->localPosition().x(),
|
75 |
|
|
hit->localPosition().y(),
|
76 |
|
|
hit->localPosition().z());
|
77 |
|
|
GlobalPoint gpos = tgeo_->idToDet(id)->toGlobal(lpos);
|
78 |
|
|
|
79 |
|
|
Char_t type = 0;
|
80 |
|
|
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 |
|
|
if (pid.disk()==0)
|
86 |
|
|
type = 11;
|
87 |
|
|
else
|
88 |
|
|
type = 12;
|
89 |
|
|
if (pid.side()!=0)
|
90 |
|
|
type = -type;
|
91 |
|
|
}
|
92 |
|
|
|
93 |
|
|
mithep::PixelHit *newhit = phits_->Allocate();
|
94 |
|
|
new (newhit) mithep::PixelHit(gpos.x(),gpos.y(),gpos.z());
|
95 |
|
|
newhit->SetType(type);
|
96 |
|
|
newhit->SetQuality(hit->rawQualityWord());
|
97 |
|
|
newhit->SetCharge(static_cast<int>(hit->cluster()->charge()));
|
98 |
|
|
newhit->SetSize(hit->cluster()->size());
|
99 |
|
|
}
|
100 |
|
|
|
101 |
|
|
phits_->Trim();
|
102 |
|
|
}
|