ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillerStripHits.cc
Revision: 1.2
Committed: Thu Mar 18 20:21:01 2010 UTC (15 years, 1 month ago) by bendavid
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_025c_branch2, Mit_025c_branch1, Mit_025c_branch0, 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_020d, TMit_020d, Mit_020c, Mit_021, Mit_021pre2, Mit_021pre1, Mit_020b, Mit_020a, Mit_020, Mit_020pre1, Mit_018, Mit_017, Mit_017pre3, Mit_017pre2, Mit_017pre1, Mit_016, Mit_015b, Mit_015a, Mit_015, Mit_014e, Mit_014d, Mit_014c, Mit_014b, Mit_014a, Mit_014, Mit_014pre3, Mit_014pre2, Mit_014pre1, Mit_013d, Mit_013c, Mit_013b, Mit_013a, Mit_013
Branch point for: Mit_025c_branch
Changes since 1.1: +2 -2 lines
Log Message:
Fix beginrun,beginjob mess

File Contents

# Content
1 // $Id: FillerStripHits.cc,v 1.1 2009/11/25 23:41:07 loizides Exp $
2
3 #include "MitProd/TreeFiller/interface/FillerStripHits.h"
4 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
5 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
6 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
7 #include "DataFormats/SiStripDetId/interface/TECDetId.h"
8 #include "DataFormats/SiStripDetId/interface/TIBDetId.h"
9 #include "DataFormats/SiStripDetId/interface/TIDDetId.h"
10 #include "DataFormats/SiStripDetId/interface/TOBDetId.h"
11 #include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2DCollection.h"
12 #include "FWCore/Framework/interface/ESHandle.h"
13 #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h"
14 #include "Geometry/CommonTopologies/interface/StripTopology.h"
15 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
16 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
17 #include "MitAna/DataTree/interface/Names.h"
18 #include "MitAna/DataTree/interface/StripHitCol.h"
19 #include "MitProd/ObjectService/interface/ObjectService.h"
20
21 using namespace std;
22 using namespace edm;
23 using namespace mithep;
24
25 //--------------------------------------------------------------------------------------------------
26 FillerStripHits::FillerStripHits(const ParameterSet &cfg, const char *name, bool active) :
27 BaseFiller(cfg,name,active),
28 edmName_(Conf().getUntrackedParameter<string>("edmName","siStripMatchedRecHits:stereoRecHit")),
29 mitName_(Conf().getUntrackedParameter<string>("mitName",Names::gkStripHitBrn)),
30 shits_(new mithep::StripHitArr(1000))
31 {
32 // Constructor.
33 }
34
35 //--------------------------------------------------------------------------------------------------
36 FillerStripHits::~FillerStripHits()
37 {
38 // Destructor.
39
40 delete shits_;
41 }
42
43 //--------------------------------------------------------------------------------------------------
44 void FillerStripHits::BookDataBlock(TreeWriter &tws)
45 {
46
47 // Add tracks branch to tree, publish and get tracker geometry.
48
49 tws.AddBranch(mitName_,&shits_);
50 OS()->add<StripHitArr>(shits_,mitName_);
51 }
52
53 //--------------------------------------------------------------------------------------------------
54 void FillerStripHits::FillDataBlock(const edm::Event &event,
55 const edm::EventSetup &setup)
56 {
57 // Fill pixel hits from edm collection into our collection.
58
59 shits_->Delete();
60
61 // initialize handle and get product
62 Handle<SiStripMatchedRecHit2DCollection> hRecHits;
63 GetProduct(edmName_, hRecHits, event);
64
65 const SiStripMatchedRecHit2DCollection *hits = hRecHits.product();
66 if (!hits->size())
67 return;
68
69 // get tracker geometry
70 edm::ESHandle<TrackerGeometry> trackerHandle;
71 setup.get<TrackerDigiGeometryRecord>().get(trackerHandle);
72 const TrackerGeometry *tgeo = trackerHandle.product();
73
74 for(SiStripMatchedRecHit2DCollection::DataContainer::const_iterator hit = hits->data().begin(),
75 end = hits->data().end(); hit != end; ++hit) {
76
77 const SiStripRecHit2D *shit = hit->stereoHit();
78 if (!shit)
79 continue;
80
81 if (!shit->isValid())
82 continue;
83
84 int type = 0;
85 int gtyp = 0;
86 DetId id(shit->geographicalId());
87 if(id.subdetId() == int(StripSubdetector::TIB)) {
88 type = 1;
89 } else if (id.subdetId() == int(StripSubdetector::TID)) {
90 type = 2;
91 } else if (id.subdetId() == int(StripSubdetector::TOB)) {
92 type = 3;
93 TOBDetId pid(id);
94 gtyp = pid.layerNumber();
95 if (pid.isZMinusSide())
96 gtyp = -gtyp;
97 } else if (id.subdetId() == int(StripSubdetector::TEC)) {
98 type = 4;
99 } else {
100 continue;
101 }
102
103 const StripGeomDetUnit *tgdu =
104 static_cast<const StripGeomDetUnit*>(tgeo->idToDetUnit(id));
105
106 LocalPoint lpos = LocalPoint(shit->localPosition().x(),
107 shit->localPosition().y(),
108 shit->localPosition().z());
109 GlobalPoint gpos = tgdu->toGlobal(lpos);
110 mithep::StripHit *newhit = shits_->Allocate();
111 new (newhit) mithep::StripHit(gpos.x(),gpos.y(),gpos.z());
112 newhit->SetType(type);
113 newhit->SetGeoType(gtyp);
114 }
115 shits_->Trim();
116 }