ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillerStripHits.cc
Revision: 1.3
Committed: Fri Mar 30 01:08:41 2012 UTC (13 years, 1 month ago) by paus
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_032, Mit_031, Mit_030, Mit_029c, Mit_029b, Mit_030_pre1, Mit_029a, Mit_029, Mit_029_pre1, Mit_028a, Mit_028, Mit_027a, Mit_027, Mit_026, HEAD
Changes since 1.2: +7 -9 lines
Log Message:
Initial 5 version.

File Contents

# User Rev Content
1 paus 1.3 // $Id: FillerStripHits.cc,v 1.2 2010/03/18 20:21:01 bendavid Exp $
2 loizides 1.1
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 bendavid 1.2 void FillerStripHits::BookDataBlock(TreeWriter &tws)
45 loizides 1.1 {
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 paus 1.3 const SiStripRecHit2D &shit = hit->stereoHit();
78 loizides 1.1
79 paus 1.3 if (!shit.isValid())
80 loizides 1.1 continue;
81    
82     int type = 0;
83     int gtyp = 0;
84 paus 1.3 DetId id(shit.geographicalId());
85 loizides 1.1 if(id.subdetId() == int(StripSubdetector::TIB)) {
86     type = 1;
87     } else if (id.subdetId() == int(StripSubdetector::TID)) {
88     type = 2;
89     } else if (id.subdetId() == int(StripSubdetector::TOB)) {
90     type = 3;
91     TOBDetId pid(id);
92     gtyp = pid.layerNumber();
93     if (pid.isZMinusSide())
94     gtyp = -gtyp;
95     } else if (id.subdetId() == int(StripSubdetector::TEC)) {
96     type = 4;
97     } else {
98     continue;
99     }
100    
101     const StripGeomDetUnit *tgdu =
102     static_cast<const StripGeomDetUnit*>(tgeo->idToDetUnit(id));
103    
104 paus 1.3 LocalPoint lpos = LocalPoint(shit.localPosition().x(),
105     shit.localPosition().y(),
106     shit.localPosition().z());
107 loizides 1.1 GlobalPoint gpos = tgdu->toGlobal(lpos);
108     mithep::StripHit *newhit = shits_->Allocate();
109     new (newhit) mithep::StripHit(gpos.x(),gpos.y(),gpos.z());
110     newhit->SetType(type);
111     newhit->SetGeoType(gtyp);
112     }
113     shits_->Trim();
114     }