ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillerStripHits.cc
Revision: 1.1
Committed: Wed Nov 25 23:41:07 2009 UTC (15 years, 5 months ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_013pre1, Mit_012i, Mit_012h, Mit_012g, Mit_012f, Mit_012e, Mit_012d, Mit_012c
Log Message:
Added simple StripHit Filler

File Contents

# User Rev Content
1 loizides 1.1 // $Id: FillerStripHits.cc,v 1.4 2009/11/19 14:35:23 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, const edm::EventSetup &es)
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     }