ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/FastOpenGlDisplayer/src/Frog_Analyzer.cc
Revision: 1.8
Committed: Mon May 5 08:49:58 2008 UTC (16 years, 11 months ago) by querten
Content type: text/plain
Branch: MAIN
Changes since 1.7: +2 -1 lines
Log Message:
Add Chi2Info to Tracks

File Contents

# User Rev Content
1 querten 1.1 // -*- C++ -*-
2     //
3     // Package: Frog_Analyzer
4     // Class: Frog_Analyzer
5     //
6     /**\class Frog_Analyzer Frog_Analyzer.cc Visualisation/Frog/src/Frog_Analyzer.cc
7    
8     Description: <one line class summary>
9    
10     Implementation:
11     <Notes on implementation>
12     */
13     //
14     // Original Author: Loic QUERTENMONT
15     // Created: Fri Oct 26 07:22:12 CEST 2007
16 querten 1.8 // $Id: Frog_Analyzer.cc,v 1.7 2008/05/04 06:46:30 querten Exp $
17 querten 1.1 //
18     //
19    
20    
21     // system include files
22     #include <memory>
23    
24     // user include files
25     #include "FWCore/Framework/interface/Frameworkfwd.h"
26     #include "FWCore/Framework/interface/EDAnalyzer.h"
27    
28     #include "FWCore/Framework/interface/Event.h"
29     #include "FWCore/Framework/interface/MakerMacros.h"
30    
31     #include "FWCore/ParameterSet/interface/ParameterSet.h"
32     #include "FWCore/ServiceRegistry/interface/Service.h"
33     #include "FWCore/Framework/interface/ESHandle.h"
34    
35     #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
36     #include "Geometry/CommonDetUnit/interface/GeomDetUnit.h"
37     #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
38     #include "Geometry/TrackerNumberingBuilder/interface/GeometricDet.h"
39     #include "Geometry/CommonTopologies/interface/PixelTopology.h"
40     #include "Geometry/CommonTopologies/interface/StripTopology.h"
41     #include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetType.h"
42     #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetType.h"
43     #include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h"
44     #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h"
45     #include "DataFormats/GeometrySurface/interface/BoundSurface.h"
46     #include "DataFormats/DetId/interface/DetId.h"
47    
48     #include "Geometry/CaloEventSetup/interface/CaloTopologyRecord.h"
49     #include "Geometry/Records/interface/IdealGeometryRecord.h"
50     #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
51     #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
52     #include "Geometry/EcalBarrelAlgo/interface/EcalBarrelGeometry.h"
53     #include "Geometry/EcalEndcapAlgo/interface/EcalEndcapGeometry.h"
54     #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
55     #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
56    
57     #include "Geometry/CommonDetUnit/interface/TrackingGeometry.h"
58     #include "Geometry/Records/interface/MuonGeometryRecord.h"
59     #include "Geometry/DTGeometry/interface/DTGeometry.h"
60     #include "Geometry/CSCGeometry/interface/CSCGeometry.h"
61     #include "Geometry/RPCGeometry/interface/RPCGeometry.h"
62    
63    
64     #include "DataFormats/CaloRecHit/interface/CaloRecHit.h"
65     #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
66     #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
67    
68     #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
69     #include "SimDataFormats/TrackingHit/interface/PSimHit.h"
70     #include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h"
71     #include "SimDataFormats/CrossingFrame/interface/MixCollection.h"
72     #include "SimDataFormats/CaloHit/interface/PCaloHit.h"
73     #include "SimDataFormats/Track/interface/SimTrack.h"
74     #include "SimDataFormats/Vertex/interface/SimVertex.h"
75    
76     #include "DataFormats/Provenance/interface/BranchDescription.h"
77     #include "DataFormats/Provenance/interface/Provenance.h"
78     #include "DataFormats/Candidate/interface/Candidate.h"
79     #include "DataFormats/HepMCCandidate/interface/GenParticleCandidate.h"
80     #include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h"
81     #include "DataFormats/TrackReco/interface/Track.h"
82 roberfro 1.5 #include "TrackingTools/PatternTools/interface/Trajectory.h"
83 querten 1.6 #include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h"
84    
85 querten 1.1
86 querten 1.2 #include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h"
87     #include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h"
88    
89     #include "DataFormats/DTRecHit/interface/DTRecHitCollection.h"
90     #include "DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h"
91     #include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h"
92    
93 querten 1.1 #include "DataFormats/Math/interface/Point3D.h"
94     #include "DataFormats/GeometrySurface/interface/TrapezoidalPlaneBounds.h"
95     #include "DataFormats/GeometrySurface/interface/RectangularPlaneBounds.h"
96    
97     #include "Visualisation/Frog/interface/SimEvent.h"
98     #include "Visualisation/Frog/interface/Geometry.h"
99    
100     using namespace edm;
101     using namespace std;
102    
103     //
104     // class decleration
105     //
106    
107     class Frog_Analyzer : public edm::EDAnalyzer {
108     public:
109     explicit Frog_Analyzer(const edm::ParameterSet&);
110     ~Frog_Analyzer();
111    
112    
113     private:
114     virtual void beginJob(const edm::EventSetup& iSetup);
115     virtual void analyze (const edm::Event&, const edm::EventSetup&);
116     virtual void endJob ();
117    
118    
119     MySimEvents* MyEvents;
120     Geometry* Geom_Tracker;
121     Geometry* Geom_ECAL;
122     Geometry* Geom_HCAL;
123     Geometry* Geom_Muon;
124 querten 1.7 Geometry* Geom_Fwd;
125 querten 1.1
126    
127     std::string OutputFile;
128    
129     std::vector<InputTag> SimTrackProducers;
130     std::vector<InputTag> SimVertexProducers;
131     std::vector<InputTag> SimHitProducers;
132    
133 roberfro 1.5 std::vector<InputTag> TrajectoryProducers;
134 querten 1.1 std::vector<InputTag> EcalRecHitProducers;
135     std::vector<InputTag> HcalHBHERecHitProducers;
136     std::vector<InputTag> HcalHORecHitProducers;
137     std::vector<InputTag> HcalHFRecHitProducers;
138 querten 1.2 std::vector<InputTag> DTSegmentProducers;
139     std::vector<InputTag> CSCSegmentProducers;
140    
141     std::vector<InputTag> RPCHitsProducers;
142 querten 1.1
143    
144    
145    
146     // ----------member data ---------------------------
147     };
148    
149     //
150     // constructors and destructor
151     //
152     Frog_Analyzer::Frog_Analyzer(const edm::ParameterSet& iConfig)
153     {
154     OutputFile = iConfig.getParameter<std::string >("OutputFile");
155    
156     SimTrackProducers = iConfig.getParameter<std::vector<InputTag> >("SimTrackProducers");
157     SimVertexProducers = iConfig.getParameter<std::vector<InputTag> >("SimVertexProducers");
158     SimHitProducers = iConfig.getParameter<std::vector<InputTag> >("SimHitProducers");
159    
160 roberfro 1.5 TrajectoryProducers = iConfig.getParameter<std::vector<InputTag> >("TrajectoryProducers");
161 querten 1.1 EcalRecHitProducers = iConfig.getParameter<std::vector<InputTag> >("EcalRecHitProducers");
162     HcalHBHERecHitProducers = iConfig.getParameter<std::vector<InputTag> >("HcalHBHERecHitProducers");
163     HcalHORecHitProducers = iConfig.getParameter<std::vector<InputTag> >("HcalHORecHitProducers");
164     HcalHFRecHitProducers = iConfig.getParameter<std::vector<InputTag> >("HcalHFRecHitProducers");
165    
166 querten 1.2 DTSegmentProducers = iConfig.getParameter<std::vector<InputTag> >("DTSegmentProducers");
167     CSCSegmentProducers = iConfig.getParameter<std::vector<InputTag> >("CSCSegmentProducers");
168    
169     RPCHitsProducers = iConfig.getParameter<std::vector<InputTag> >("RPCHitsProducers");
170    
171 querten 1.1 }
172    
173    
174     Frog_Analyzer::~Frog_Analyzer()
175     {
176     }
177    
178     // ------------ method called once each job just before starting event loop ------------
179     void
180     Frog_Analyzer::beginJob(const edm::EventSetup& iSetup)
181     {
182     DetId Detid;
183     int SubDet;
184    
185     MyEvents = new MySimEvents();
186     Geom_Tracker = new Geometry();
187     Geom_ECAL = new Geometry();
188     Geom_HCAL = new Geometry();
189     Geom_Muon = new Geometry();
190 querten 1.7 Geom_Fwd = new Geometry();
191    
192 querten 1.1
193    
194     // ### TRACKER GEOMETRY ###
195    
196     edm::ESHandle<TrackerGeometry> tkGeom;
197     iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom );
198     vector<GeomDet*> TrackerDets = tkGeom->dets();
199    
200     for(unsigned int i=0;i<TrackerDets.size();i++){
201     Detid = TrackerDets[i]->geographicalId();
202     // SubDet = Detid.subdetId();
203    
204     GeomDet* DetUnit = TrackerDets[i];
205     if(!DetUnit)continue;
206     const BoundPlane plane = DetUnit->surface();
207     const TrapezoidalPlaneBounds* trapezoidalBounds( dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
208     const RectangularPlaneBounds* rectangularBounds( dynamic_cast<const RectangularPlaneBounds*>(&(plane.bounds())));
209    
210     float width = 0;
211     float length = 0;
212     float thickness = 0;
213     float TrapezoidalParam = 0;
214    
215     if(trapezoidalBounds)
216     {
217     std::vector<float> const & parameters = (*trapezoidalBounds).parameters();
218     width = parameters[0]*2;
219     length = parameters[3]*2;
220     thickness = (*trapezoidalBounds).thickness();
221     TrapezoidalParam = parameters[1]/parameters[0];
222     }else if(rectangularBounds){
223     width = DetUnit->surface().bounds().width();
224     length = DetUnit->surface().bounds().length();
225     thickness = DetUnit->surface().bounds().thickness();
226     TrapezoidalParam = 1;
227     }
228    
229     Surface::GlobalPoint WidthVector = plane.toGlobal( LocalPoint(width/2, 0, 0) );
230     Surface::GlobalPoint LengthVector = plane.toGlobal( LocalPoint(0, length/2, 0) );
231     Surface::GlobalPoint ThickVector = plane.toGlobal( LocalPoint(0, 0, thickness/2) );
232    
233     GlobalVector Pos = GlobalVector(DetUnit->position().basicVector());
234    
235     Geom_Tracker->Add_TrackerDet(Detid.rawId(), TrapezoidalParam,
236     Pos.x(), Pos.y(), Pos.z(),
237     WidthVector.x() -Pos.x(), WidthVector.y() -Pos.y(), WidthVector.z() -Pos.z(),
238     LengthVector.x()-Pos.x(), LengthVector.y()-Pos.y(), LengthVector.z()-Pos.z(),
239     ThickVector.x() -Pos.x(), ThickVector.y() -Pos.y(), ThickVector.z() -Pos.z());
240    
241    
242     }
243    
244    
245     // ### CALO GEOMETRY ###
246    
247     edm::ESHandle<CaloGeometry> CaloGeom;
248     iSetup.get<IdealGeometryRecord>().get( CaloGeom );
249     const vector<DetId> CaloDets = CaloGeom->getValidDetIds();
250    
251     for(unsigned int i=0;i<CaloDets.size();i++)
252     {
253     Detid = CaloDets[i];
254     SubDet = Detid.subdetId();
255    
256     Geometry* Geom_temp = NULL;
257     if(Detid.det()==DetId::Ecal){
258     Geom_temp = Geom_ECAL;
259    
260     if(SubDet<1 || SubDet>3){
261     printf("Don't Save EcalTriggerTower or EcalLaserPnDiode\n");
262     continue;
263     }
264     }else if(Detid.det()==DetId::Hcal){
265     Geom_temp = Geom_HCAL;
266    
267     if(SubDet<1 || SubDet>4){
268     printf("Don't Save HcalEmpty, HcalTriggerTower, HcalOther\n");
269     continue;
270     }
271 querten 1.7 }else if(Detid.det() == DetId::Calo){
272     Geom_temp = NULL;
273    
274     // Calo Tower Geometry (SudDet=1)
275     // if(SubDet==1)
276     // //printf("Don't Save CaloTowers\n");
277     // continue;
278    
279     // Forward Calo Geometry --> Castor (SudDet=3) and ZDS (SubDet=2)
280     if(SubDet==HcalCastorDetId::SubdetectorId || SubDet==HcalZDCDetId::SubdetectorId)
281     Geom_temp = Geom_Fwd;
282     // printf("Save FWD CaloTowers\n");
283 querten 1.1 }
284    
285     const CaloCellGeometry* CellGeom = CaloGeom->getGeometry(Detid);
286     GlobalPoint CellPos = CellGeom->getPosition();
287     const CaloCellGeometry::CornersVec CellCorners = CellGeom->getCorners();
288    
289 querten 1.7 if(Geom_temp == Geom_ECAL || Geom_temp == Geom_HCAL){
290     float cX = (CellCorners[0].x() + CellCorners[2].x())/2;
291     float cY = (CellCorners[0].y() + CellCorners[2].y())/2;
292     float cZ = (CellCorners[0].z() + CellCorners[2].z())/2;
293    
294     float wX = (CellCorners[1].x() - CellCorners[0].x())/2;
295     float wY = (CellCorners[1].y() - CellCorners[0].y())/2;
296     float wZ = (CellCorners[1].z() - CellCorners[0].z())/2;
297    
298     float hX = (CellCorners[3].x() - CellCorners[0].x())/2;
299     float hY = (CellCorners[3].y() - CellCorners[0].y())/2;
300     float hZ = (CellCorners[3].z() - CellCorners[0].z())/2;
301    
302     float F = sqrt( pow(CellCorners[4].x()+CellCorners[6].x(),2) + pow(CellCorners[4].y()+CellCorners[6].y(),2) + pow(CellCorners[4].z()+CellCorners[6].z(),2) );
303     F /= sqrt( pow(CellCorners[0].x()+CellCorners[2].x(),2) + pow(CellCorners[0].y()+CellCorners[2].y(),2) + pow(CellCorners[0].z()+CellCorners[2].z(),2) );
304    
305     Geom_temp->Add_CaloDet(Detid.rawId(),
306     cX , cY , cZ ,
307     wX , wY , wZ ,
308     hX , hY , hZ , F );
309     }else if(Geom_temp == Geom_Fwd){
310     /*
311     Geom_temp->Add_FwdDet(Detid.rawId(),
312     CellCorners[0].x(), CellCorners[0].y(), CellCorners[0].z(),
313     CellCorners[1].x(), CellCorners[1].y(), CellCorners[1].z(),
314     CellCorners[2].x(), CellCorners[2].y(), CellCorners[2].z(),
315     CellCorners[3].x(), CellCorners[3].y(), CellCorners[3].z(),
316     CellCorners[4].x(), CellCorners[4].y(), CellCorners[4].z(),
317     CellCorners[5].x(), CellCorners[5].y(), CellCorners[5].z(),
318     CellCorners[6].x(), CellCorners[6].y(), CellCorners[6].z(),
319     CellCorners[7].x(), CellCorners[7].y(), CellCorners[7].z());
320     printf("SubDet = %i : (%6.2f,%6.2f,%6.2f) --> 7 (%6.2f,%6.2f,%6.2f) \n", SubDet,CellCorners[0].x(), CellCorners[0].y(), CellCorners[0].z(),CellCorners[6].x(), CellCorners[6].y(), CellCorners[6].z());
321     */
322     }
323 querten 1.1 }
324 querten 1.7
325 querten 1.1
326     // ### MUON GEOMETRY ###
327    
328     edm::ESHandle<DTGeometry> DtGeom;
329     iSetup.get<MuonGeometryRecord>().get( DtGeom );
330     const vector<GeomDet*> DtDets = DtGeom->dets();
331    
332     edm::ESHandle<CSCGeometry> CscGeom;
333     iSetup.get<MuonGeometryRecord>().get( CscGeom );
334     const vector<GeomDet*> CscDets = CscGeom->dets();
335    
336     edm::ESHandle<RPCGeometry> RpcGeom;
337     iSetup.get<MuonGeometryRecord>().get( RpcGeom );
338     const vector<GeomDet*> RpcDets = RpcGeom->dets();
339    
340     vector<GeomDet*> MuonDets;
341     for(unsigned int i=0;i<DtDets.size() ;i++){MuonDets.push_back(DtDets [i]);}
342     for(unsigned int i=0;i<CscDets.size();i++){MuonDets.push_back(CscDets[i]);}
343     for(unsigned int i=0;i<RpcDets.size();i++){MuonDets.push_back(RpcDets[i]);}
344    
345    
346     for(unsigned int i=0;i<MuonDets.size();i++)
347     {
348     Detid = DetId(MuonDets[i]->geographicalId());
349     SubDet = Detid.subdetId();
350    
351     GeomDet* DetUnit = MuonDets[i];
352     if(!DetUnit)continue;
353     const BoundPlane plane = DetUnit->surface();
354     const TrapezoidalPlaneBounds* trapezoidalBounds( dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
355     const RectangularPlaneBounds* rectangularBounds( dynamic_cast<const RectangularPlaneBounds*>(&(plane.bounds())));
356    
357     float width = 0;
358     float length = 0;
359     float thickness = 0;
360     float TrapezoidalParam = 0;
361    
362     if(trapezoidalBounds)
363     {
364     std::vector<float> const & parameters = (*trapezoidalBounds).parameters();
365     width = parameters[0]*2;
366     length = parameters[3]*2;
367     thickness = (*trapezoidalBounds).thickness();
368     TrapezoidalParam = parameters[1]/parameters[0];
369     }else if(rectangularBounds){
370     width = DetUnit->surface().bounds().width();
371     length = DetUnit->surface().bounds().length();
372     thickness = DetUnit->surface().bounds().thickness();
373     TrapezoidalParam = 1;
374     }
375    
376     Surface::GlobalPoint WidthVector = plane.toGlobal( LocalPoint(width/2, 0, 0) );
377     Surface::GlobalPoint LengthVector = plane.toGlobal( LocalPoint(0, length/2, 0) );
378     Surface::GlobalPoint ThickVector = plane.toGlobal( LocalPoint(0, 0, thickness/2) );
379    
380     GlobalVector Pos = GlobalVector(DetUnit->position().basicVector());
381    
382     Geom_Muon->Add_TrackerDet(Detid.rawId(), TrapezoidalParam,
383     Pos.x(), Pos.y(), Pos.z(),
384     WidthVector.x() -Pos.x(), WidthVector.y() -Pos.y(), WidthVector.z() -Pos.z(),
385     LengthVector.x()-Pos.x(), LengthVector.y()-Pos.y(), LengthVector.z()-Pos.z(),
386     ThickVector.x() -Pos.x(), ThickVector.y() -Pos.y(), ThickVector.z() -Pos.z());
387     }
388    
389 querten 1.7 // ### FORWARD GEOMETRY ###
390     // edm::ESHandle<CaloGeometry> ForwardGeom;
391     // iSetup.get<IdealGeometryRecord>().get( ForwardGeom );
392     // const vector<DetId> FwdDets = ForwardGeom->getValidDetIds(DetId::Calo, HcalCastorDetId::SubdetectorId);
393     // printf("FwdDetsSize = %i\n",FwdDets.size());
394 querten 1.1
395     // ### Save .geom ###
396    
397 querten 1.7 printf("FWD Size = %i\n", Geom_Fwd->Det_ECAL_ALL.size());
398     printf("FWD Size = %i\n", Geom_Fwd->Det_HCAL_ALL.size());
399     printf("FWD Size = %i\n", Geom_Fwd->Det_FWD_ALL.size());
400    
401    
402    
403 querten 1.1 Geom_Tracker->Save("Tracker.geom");
404     Geom_ECAL ->Save("Ecal.geom");
405     Geom_HCAL ->Save("Hcal.geom");
406     Geom_Muon ->Save("Muon.geom");
407 querten 1.7 // Geom_Fwd ->Save("Fwd.geom");
408    
409    
410 querten 1.1
411     }
412    
413     // ------------ method called once each job just after ending the event loop ------------
414     void
415     Frog_Analyzer::endJob() {
416    
417     MyEvents->Save((char*) OutputFile.c_str());
418     // MyEvents->Load((char*) OutputFile.c_str());
419     }
420    
421    
422    
423     //
424     // member functions
425     //
426    
427     // ------------ method called to for each event ------------
428     void
429     Frog_Analyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
430     {
431     MySimEvent* MyEvent = new MySimEvent;
432    
433 querten 1.2 // access the tracker
434     edm::ESHandle<TrackerGeometry> tkGeom;
435     iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom );
436 querten 1.1
437 querten 1.2 edm::ESHandle<DTGeometry> DtGeom;
438     iSetup.get<MuonGeometryRecord>().get( DtGeom );
439    
440     edm::ESHandle<CSCGeometry> CscGeom;
441     iSetup.get<MuonGeometryRecord>().get( CscGeom );
442 querten 1.1
443 querten 1.2 edm::ESHandle<RPCGeometry> RpcGeom;
444     iSetup.get<MuonGeometryRecord>().get( RpcGeom );
445 querten 1.1
446    
447     // Save Data
448 querten 1.2 // ### SIMTRACK ###
449 querten 1.1 for(unsigned int i=0;i<SimTrackProducers.size();i++){
450     edm::Handle<std::vector< SimTrack > > h_SimTracks;
451     iEvent.getByLabel(SimTrackProducers[i], h_SimTracks);
452     std::vector< SimTrack > SimTrackColl = *h_SimTracks.product();
453    
454     for ( unsigned int a = 0; a < SimTrackColl.size(); ++a ) {
455 querten 1.4 MySimTrack* MysimTrack = new MySimTrack;
456 querten 1.1 SimTrack simTrack =SimTrackColl[a];
457    
458 querten 1.4 MysimTrack->track_id =simTrack.trackId();
459     MysimTrack->Type =simTrack.type();
460     MysimTrack->parent_vertex=simTrack.vertIndex();
461     MysimTrack->Px =simTrack.momentum().x();
462     MysimTrack->Py =simTrack.momentum().y();
463     MysimTrack->Pz =simTrack.momentum().z();
464     MysimTrack->E =simTrack.momentum().e();
465     MysimTrack->charge =simTrack.charge();
466 querten 1.1
467     MyEvent->MySimTrackCollection.push_back(MysimTrack);
468     }
469     }
470    
471 querten 1.2 // ### SIMVERTEX ###
472 querten 1.1 for(unsigned int i=0;i<SimVertexProducers.size();i++){
473     edm::Handle<std::vector< SimVertex > > h_Vertex;
474     iEvent.getByLabel(SimVertexProducers[i], h_Vertex);
475     std::vector< SimVertex > VertexColl = *h_Vertex.product();
476    
477     for (unsigned int b = 0; b < VertexColl.size(); ++b ) {
478 querten 1.4 MySimVertex* MyVertex = new MySimVertex;
479 querten 1.1 SimVertex Vertex = VertexColl[b];
480    
481 querten 1.4 MyVertex->parentTrack_id=Vertex.parentIndex ();
482     MyVertex->x =Vertex.position().x();
483     MyVertex->y =Vertex.position().y();
484     MyVertex->z =Vertex.position().z();
485 querten 1.1
486     MyEvent->MySimVertexCollection.push_back(MyVertex);
487     }
488     }
489    
490 querten 1.2 // ### SIMHIT ###
491 querten 1.1 for(unsigned int i=0;i<SimHitProducers.size();i++){
492     edm::Handle<std::vector< PSimHit > > h_Hits;
493     iEvent.getByLabel(SimHitProducers[i], h_Hits);
494     std::vector< PSimHit > Hits = *h_Hits.product();
495    
496     for(unsigned int h=0; h<Hits.size(); h++)
497     {
498 querten 1.2 DetId theDetUnitId(Hits[h].detUnitId());
499     const GeomDet* theDet = tkGeom->idToDet(theDetUnitId);
500 querten 1.1
501 querten 1.4 MyPSimHit* Hit = new MyPSimHit;
502     Hit->x = theDet->surface().toGlobal(Hits[h].localPosition()).x();
503     Hit->y = theDet->surface().toGlobal(Hits[h].localPosition()).y();
504     Hit->z = theDet->surface().toGlobal(Hits[h].localPosition()).z();
505     Hit->ProcessType = Hits[h].processType();
506     Hit->dEdX = Hits[h].energyLoss();
507 querten 1.1
508     MyEvent->MyPSimHitCollection.push_back(Hit);
509     }
510     }
511    
512    
513 querten 1.2 // ### TRACKS ###
514 roberfro 1.5 for(unsigned int i=0;i<TrajectoryProducers.size();i++){
515 querten 1.6 Handle<TrajTrackAssociationCollection> trajTrackAssociationHandle;
516     iEvent.getByLabel(TrajectoryProducers[i], trajTrackAssociationHandle);
517     const TrajTrackAssociationCollection TrajToTrackMap = *trajTrackAssociationHandle.product();
518    
519     for(TrajTrackAssociationCollection::const_iterator it = TrajToTrackMap.begin(); it!=TrajToTrackMap.end(); ++it) {
520     Trajectory recoTraj = *it->key;
521     MyRecoTrack* MyrecoTrack = new MyRecoTrack;
522    
523     MyRecoTrackInfo* info = new MyRecoTrackInfo;
524     info->Coll = i;
525     info->P = it->val->p();
526     info->Pt = it->val->pt();
527 querten 1.8 info->chi2 = it->key->chiSquared();
528 querten 1.6 MyrecoTrack->Info = info;
529    
530 querten 1.1
531 roberfro 1.5 std::vector<TrajectoryMeasurement> measurements = recoTraj.measurements();
532     for(unsigned int h=0;h<measurements.size();h++){
533    
534     TrajectoryMeasurement::ConstRecHitPointer h_it = measurements[h].recHit();
535 querten 1.1 if(!h_it->isValid() )continue;
536     DetId detId = h_it->geographicalId();
537 querten 1.6 // const GeomDet * theDet = tkGeom->idToDet(detId);
538     // LocalPoint localPos = h_it->localPosition();
539 roberfro 1.5 GlobalPoint globalPos = measurements[h].updatedState().globalPosition();
540 querten 1.1
541 querten 1.4 MyRecoHit* hit = new MyRecoHit;
542 roberfro 1.5 /*
543 querten 1.4 hit->x = theDet->surface().toGlobal(localPos).x();
544     hit->y = theDet->surface().toGlobal(localPos).y();
545     hit->z = theDet->surface().toGlobal(localPos).z();
546 roberfro 1.5 */
547     hit->x = globalPos.x();
548     hit->y = globalPos.y();
549     hit->z = globalPos.z();
550 querten 1.4 hit->DetId = detId.rawId();
551     hit->Charge = -1;
552     MyrecoTrack->Hits.push_back(hit);
553 querten 1.1 }
554     MyEvent->MyRecoTrackCollection.push_back(MyrecoTrack);
555     }
556     }
557    
558    
559 querten 1.2 // ### ECALRecHits ###
560 querten 1.1 for(unsigned int i=0;i<EcalRecHitProducers.size();i++){
561     edm::Handle<EcalRecHitCollection > h_Ecal_RecHits;
562     iEvent.getByLabel(EcalRecHitProducers[i], h_Ecal_RecHits);
563     EcalRecHitCollection Ecal_RecHits = *h_Ecal_RecHits.product();
564    
565     for(unsigned int eh=0;eh<Ecal_RecHits.size();eh++){
566 querten 1.4 MyCaloHit* temp_EcalHit = new MyCaloHit;
567     temp_EcalHit->E = Ecal_RecHits[eh].energy();
568     temp_EcalHit->t = Ecal_RecHits[eh].time();
569     temp_EcalHit->DetId = (Ecal_RecHits[eh].detid()).rawId();
570 querten 1.1
571     MyEvent->MyEcalCaloHitCollection.push_back(temp_EcalHit);
572     }
573     }
574    
575    
576 querten 1.2 // ### HCALRecHits ###
577 querten 1.1 for(unsigned int i=0;i<HcalHBHERecHitProducers.size();i++){
578     edm::Handle<HBHERecHitCollection > h_HcalHBHE_RecHits;
579     iEvent.getByLabel(HcalHBHERecHitProducers[i], h_HcalHBHE_RecHits);
580     HBHERecHitCollection HcalHBHE_RecHits = *h_HcalHBHE_RecHits.product();
581    
582     for(unsigned int hh=0;hh<HcalHBHE_RecHits.size();hh++){
583 querten 1.4 MyCaloHit* temp_HcalHBHEHit = new MyCaloHit;
584     temp_HcalHBHEHit->E = HcalHBHE_RecHits[hh].energy();
585     temp_HcalHBHEHit->t = HcalHBHE_RecHits[hh].time();
586     temp_HcalHBHEHit->DetId = (HcalHBHE_RecHits[hh].detid()).rawId();
587 querten 1.1
588     MyEvent->MyHcalCaloHitCollection.push_back(temp_HcalHBHEHit);
589     }
590     }
591    
592    
593     for(unsigned int i=0;i<HcalHORecHitProducers.size();i++){
594     edm::Handle<HORecHitCollection > h_HcalHO_RecHits;
595     iEvent.getByLabel(HcalHORecHitProducers[i], h_HcalHO_RecHits);
596     HORecHitCollection HcalHO_RecHits = *h_HcalHO_RecHits.product();
597    
598     for(unsigned int hh=0;hh<HcalHO_RecHits.size();hh++){
599 querten 1.4 MyCaloHit* temp_HcalHOHit = new MyCaloHit;
600     temp_HcalHOHit->E = HcalHO_RecHits[hh].energy();
601     temp_HcalHOHit->t = HcalHO_RecHits[hh].time();
602     temp_HcalHOHit->DetId = (HcalHO_RecHits[hh].detid()).rawId();
603 querten 1.1
604     MyEvent->MyHcalCaloHitCollection.push_back(temp_HcalHOHit);
605     }
606     }
607    
608    
609     for(unsigned int i=0;i<HcalHFRecHitProducers.size();i++){
610     edm::Handle<HFRecHitCollection > h_HcalHF_RecHits;
611     iEvent.getByLabel(HcalHFRecHitProducers[i], h_HcalHF_RecHits);
612     HFRecHitCollection HcalHF_RecHits = *h_HcalHF_RecHits.product();
613    
614     for(unsigned int hh=0;hh<HcalHF_RecHits.size();hh++){
615 querten 1.4 MyCaloHit* temp_HcalHFHit = new MyCaloHit;
616     temp_HcalHFHit->E = HcalHF_RecHits[hh].energy();
617     temp_HcalHFHit->t = HcalHF_RecHits[hh].time();
618     temp_HcalHFHit->DetId = (HcalHF_RecHits[hh].detid()).rawId();
619 querten 1.1
620     MyEvent->MyHcalCaloHitCollection.push_back(temp_HcalHFHit);
621     }
622     }
623    
624 querten 1.2 // ### Muon Segments ###
625     for(unsigned int i=0;i<CSCSegmentProducers.size();i++){
626     edm::Handle<CSCSegmentCollection > h_CSC_Segments;
627     iEvent.getByLabel(CSCSegmentProducers[i], h_CSC_Segments);
628     CSCSegmentCollection CSC_Segments = *h_CSC_Segments.product();
629    
630     for(unsigned int s=0;s<CSC_Segments.size();s++){
631     DetId theDetUnitId = CSC_Segments[s].geographicalId();
632     const GeomDet* theDet = CscGeom->idToDet(theDetUnitId);
633    
634 querten 1.4 MyMuonSegment* temp_CscSeg = new MyMuonSegment;
635     temp_CscSeg->DetId = theDetUnitId.rawId();
636     temp_CscSeg->PosX = theDet->surface().toGlobal(CSC_Segments[s].localPosition()).x();
637     temp_CscSeg->PosY = theDet->surface().toGlobal(CSC_Segments[s].localPosition()).y();
638     temp_CscSeg->PosZ = theDet->surface().toGlobal(CSC_Segments[s].localPosition()).z();
639     temp_CscSeg->DirX = theDet->surface().toGlobal(CSC_Segments[s].localDirection()).x();
640     temp_CscSeg->DirY = theDet->surface().toGlobal(CSC_Segments[s].localDirection()).y();
641     temp_CscSeg->DirZ = theDet->surface().toGlobal(CSC_Segments[s].localDirection()).z();
642 querten 1.2
643     MyEvent->MyMuonSegmentCollection.push_back(temp_CscSeg);
644     }
645     }
646    
647     for(unsigned int i=0;i<DTSegmentProducers.size();i++){
648     edm::Handle<DTRecSegment4DCollection > h_DT_Segments;
649     iEvent.getByLabel(DTSegmentProducers[i], h_DT_Segments);
650     DTRecSegment4DCollection DT_Segments = *h_DT_Segments.product();
651    
652     for(unsigned int s=0;s<DT_Segments.size();s++){
653     DetId theDetUnitId = DT_Segments[s].geographicalId();
654     const GeomDet* theDet = DtGeom->idToDet(theDetUnitId);
655    
656 querten 1.4 MyMuonSegment* temp_DtSeg = new MyMuonSegment;
657     temp_DtSeg->DetId = theDetUnitId.rawId();
658     temp_DtSeg->PosX = theDet->surface().toGlobal(DT_Segments[s].localPosition()).x();
659     temp_DtSeg->PosY = theDet->surface().toGlobal(DT_Segments[s].localPosition()).y();
660     temp_DtSeg->PosZ = theDet->surface().toGlobal(DT_Segments[s].localPosition()).z();
661     temp_DtSeg->DirX = theDet->surface().toGlobal(DT_Segments[s].localDirection()).x();
662     temp_DtSeg->DirY = theDet->surface().toGlobal(DT_Segments[s].localDirection()).y();
663     temp_DtSeg->DirZ = theDet->surface().toGlobal(DT_Segments[s].localDirection()).z();
664 querten 1.2
665     MyEvent->MyMuonSegmentCollection.push_back(temp_DtSeg);
666     }
667     }
668    
669     // ### Muon Hits ###
670     for(unsigned int i=0;i<RPCHitsProducers.size();i++){
671     edm::Handle<RPCRecHitCollection > h_RPC_Hits;
672     iEvent.getByLabel(RPCHitsProducers[i], h_RPC_Hits);
673     RPCRecHitCollection RPC_Hits = *h_RPC_Hits.product();
674    
675     for(unsigned int h=0;h<RPC_Hits.size();h++){
676     DetId theDetUnitId = RPC_Hits[h].geographicalId();
677     const GeomDet* theDet = RpcGeom->idToDet(theDetUnitId);
678    
679 querten 1.4 MyMuonHit* temp_RpcHit = new MyMuonHit;
680     temp_RpcHit->DetId = theDetUnitId.rawId();
681     temp_RpcHit->x = theDet->surface().toGlobal(RPC_Hits[h].localPosition()).x();
682     temp_RpcHit->y = theDet->surface().toGlobal(RPC_Hits[h].localPosition()).y();
683     temp_RpcHit->z = theDet->surface().toGlobal(RPC_Hits[h].localPosition()).z();
684 querten 1.2
685     MyEvent->MyMuonHitCollection.push_back(temp_RpcHit);
686     }
687     }
688    
689 querten 1.1 MyEvents->Events.push_back(MyEvent);
690     }
691    
692    
693     //define this as a plug-in
694     DEFINE_FWK_MODULE(Frog_Analyzer);
695    
696