ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/FastOpenGlDisplayer/src/Frog_Analyzer.cc
(Generate patch)

Comparing UserCode/FastOpenGlDisplayer/src/Frog_Analyzer.cc (file contents):
Revision 1.1 by querten, Sat Apr 19 06:16:28 2008 UTC vs.
Revision 1.29 by roberfro, Thu Aug 21 15:08:52 2008 UTC

# Line 49 | Line 49
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"
52 > //#include "Geometry/EcalBarrelAlgo/interface/EcalBarrelGeometry.h"
53 > //#include "Geometry/EcalEndcapAlgo/interface/EcalEndcapGeometry.h"
54 > #include "Geometry/Records/interface/CaloGeometryRecord.h"
55 > #include "Geometry/EcalAlgo/interface/EcalBarrelGeometry.h"
56 > #include "Geometry/EcalAlgo/interface/EcalEndcapGeometry.h"
57   #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
58   #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
59  
# Line 61 | Line 64
64   #include "Geometry/RPCGeometry/interface/RPCGeometry.h"
65  
66  
64
67   #include "DataFormats/CaloRecHit/interface/CaloRecHit.h"
68   #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
69   #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
# Line 80 | Line 82
82   #include "DataFormats/HepMCCandidate/interface/GenParticleCandidate.h"
83   #include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h"
84   #include "DataFormats/TrackReco/interface/Track.h"
85 + #include "TrackingTools/PatternTools/interface/Trajectory.h"
86 + #include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h"
87 +
88 +
89 + #include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h"
90 + #include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h"
91 +
92 + #include "DataFormats/DTRecHit/interface/DTRecHitCollection.h"
93 + #include "DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h"
94 + #include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h"
95  
96   #include "DataFormats/Math/interface/Point3D.h"
97   #include "DataFormats/GeometrySurface/interface/TrapezoidalPlaneBounds.h"
98   #include "DataFormats/GeometrySurface/interface/RectangularPlaneBounds.h"
99  
100 < #include "Visualisation/Frog/interface/SimEvent.h"
101 < #include "Visualisation/Frog/interface/Geometry.h"
100 > #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
101 > #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
102 > #include "DataFormats/SiPixelDetId/interface/PXBDetId.h"
103 > #include "DataFormats/SiPixelDetId/interface/PXFDetId.h"
104 > #include "DataFormats/SiStripDetId/interface/TIBDetId.h"
105 > #include "DataFormats/SiStripDetId/interface/TIDDetId.h"
106 > #include "DataFormats/SiStripDetId/interface/TOBDetId.h"
107 > #include "DataFormats/SiStripDetId/interface/TECDetId.h"
108 >
109 > #include "DataFormats/MuonDetId/interface/DTChamberId.h"
110 > #include "DataFormats/MuonDetId/interface/CSCDetId.h"
111 > #include "DataFormats/MuonDetId/interface/RPCDetId.h"
112 >
113 > #include "DataFormats/EcalDetId/interface/EBDetId.h"
114 > #include "DataFormats/EcalDetId/interface/EEDetId.h"
115 > #include "DataFormats/EcalDetId/interface/ESDetId.h"
116 > #include "DataFormats/HcalDetId/interface/HcalDetId.h"
117 >
118 > #include "DataFormats/VertexReco/interface/NuclearInteraction.h"
119 >
120 > #include "DataFormats/JetReco/interface/Jet.h"
121 > #include "DataFormats/JetReco/interface/BasicJetCollection.h"
122 > #include "DataFormats/JetReco/interface/GenJetCollection.h"
123 > #include "DataFormats/JetReco/interface/CaloJetCollection.h"
124 > #include "DataFormats/JetReco/interface/PFJetCollection.h"
125 >
126 > #include "Visualisation/Frog/soft/Includes/FROG/FROG_Element_Base_With_DetId.h"
127 > #include "Visualisation/Frog/soft/Includes/FROG/FROG_Element_Tools.h"
128 > #include "Visualisation/Frog/soft/Includes/FROG/FROG_Element_Tools.cpp"
129 > #include "Visualisation/Frog/soft/Includes/FROG/FROG_Element_Event_Track.h"
130 >
131 > #include "Visualisation/Frog/soft/Includes/FROG/FROG_Events.h"
132 > #include "Visualisation/Frog/soft/Includes/FROG/FROG_Events.cpp"
133 >
134 > #include "Visualisation/Frog/soft/Includes/FROG/FROG_Geometry.h"
135 > #include "Visualisation/Frog/soft/Includes/FROG/FROG_Geometry.cpp"
136 >
137 > #include "Visualisation/Frog/soft/Includes/FROG/FROG_DetId.h"
138 > #include "Visualisation/Frog/soft/Includes/FROG/FROG_ReadCards.cpp"
139 > #include "Visualisation/Frog/soft/Includes/FROG/FROG_Element_Event_NuclInt.h"
140 >
141 >
142  
143   using namespace edm;
144   using namespace std;
145 + using namespace reco;
146  
147   //
148   // class decleration
# Line 106 | Line 159 | class Frog_Analyzer : public edm::EDAnal
159        virtual void analyze (const edm::Event&, const edm::EventSetup&);
160        virtual void endJob  ();
161  
162 +      FROG_Element_Base*    events_prim;
163  
164 <      MySimEvents* MyEvents;
111 <      Geometry*    Geom_Tracker;
112 <      Geometry*    Geom_ECAL;
113 <      Geometry*    Geom_HCAL;
114 <      Geometry*    Geom_Muon;
115 <
116 <
117 <      std::string              OutputFile;
164 >      std::string           OutputFile;
165  
166        std::vector<InputTag> SimTrackProducers;
167        std::vector<InputTag> SimVertexProducers;
168        std::vector<InputTag> SimHitProducers;
169 +      std::vector<InputTag> SimCaloHitProducers;
170 +
171 +      std::vector<InputTag> NIProducers;
172  
173        std::vector<InputTag> TrackProducers;
174 +      std::vector<InputTag> TrajectoryProducers;
175        std::vector<InputTag> EcalRecHitProducers;
176        std::vector<InputTag> HcalHBHERecHitProducers;
177        std::vector<InputTag> HcalHORecHitProducers;
178        std::vector<InputTag> HcalHFRecHitProducers;
179 +      std::vector<InputTag> DTSegmentProducers;
180 +      std::vector<InputTag> CSCSegmentProducers;
181  
182 +      std::vector<InputTag> RPCHitsProducers;
183  
184 <
184 >      std::vector<InputTag> CaloJetsProducers;
185  
186        // ----------member data ---------------------------
187 +
188 +      bool                  ProduceGeom;
189 +      int                   NEventsInVisFile;
190 +      int                   NEvents;
191 +
192 +      unsigned int          SRun;
193 +      unsigned int          SEvent;
194   };
195  
196   //
# Line 142 | Line 203 | Frog_Analyzer::Frog_Analyzer(const edm::
203      SimTrackProducers       = iConfig.getParameter<std::vector<InputTag> >("SimTrackProducers");
204      SimVertexProducers      = iConfig.getParameter<std::vector<InputTag> >("SimVertexProducers");
205      SimHitProducers         = iConfig.getParameter<std::vector<InputTag> >("SimHitProducers");
206 +    SimCaloHitProducers     = iConfig.getParameter<std::vector<InputTag> >("SimCaloHitProducers");
207 +
208  
209      TrackProducers          = iConfig.getParameter<std::vector<InputTag> >("TrackProducers");
210 +    TrajectoryProducers     = iConfig.getParameter<std::vector<InputTag> >("TrajectoryProducers");
211      EcalRecHitProducers     = iConfig.getParameter<std::vector<InputTag> >("EcalRecHitProducers");
212      HcalHBHERecHitProducers = iConfig.getParameter<std::vector<InputTag> >("HcalHBHERecHitProducers");
213      HcalHORecHitProducers   = iConfig.getParameter<std::vector<InputTag> >("HcalHORecHitProducers");
214      HcalHFRecHitProducers   = iConfig.getParameter<std::vector<InputTag> >("HcalHFRecHitProducers");
215  
216 +    NIProducers             = iConfig.getParameter<std::vector<InputTag> >("NIProducers");
217 +
218 +    DTSegmentProducers      = iConfig.getParameter<std::vector<InputTag> >("DTSegmentProducers");
219 +    CSCSegmentProducers     = iConfig.getParameter<std::vector<InputTag> >("CSCSegmentProducers");
220 +
221 +    RPCHitsProducers        = iConfig.getParameter<std::vector<InputTag> >("RPCHitsProducers");
222 +
223 +    CaloJetsProducers       = iConfig.getParameter<std::vector<InputTag> >("CaloJetsProducers");
224 +
225 +    ProduceGeom             = iConfig.getParameter<bool  >("ProduceGeom"       );
226 +    NEventsInVisFile        = iConfig.getParameter<int   >("NEventsInVisFile"  );
227 +
228 +    NEvents = 0;
229   }
230  
231  
# Line 160 | Line 237 | Frog_Analyzer::~Frog_Analyzer()
237   void
238   Frog_Analyzer::beginJob(const edm::EventSetup& iSetup)
239   {
240 <   DetId  Detid;
241 <   int    SubDet;
242 <
243 <   MyEvents     = new MySimEvents();
244 <   Geom_Tracker = new Geometry();
245 <   Geom_ECAL    = new Geometry();
246 <   Geom_HCAL    = new Geometry();
247 <   Geom_Muon    = new Geometry();
248 <
240 >   if(ProduceGeom){
241 >      DetId  Detid;
242 >      unsigned int    SubDet;
243 >
244 >      unsigned int Frog_DetId;
245 >      FROG_Element_Base*            FEB      = NULL;
246 >      FROG_Element_Base_With_DetId* FEB_Temp = NULL;
247 >
248 >      FROG_Element_Base* prim               = new FROG_Element_Base(C_PRIMARY);
249 >      FROG_Element_Base* geom               = new FROG_Element_Base(C_GEOMETRY);                          prim->addDaughter(geom);
250 >      FROG_Element_Base_With_DetId* tracker = new FROG_Element_Base_With_DetId(C_FEB_DETID, DETID_TRK);   geom->addDaughter(tracker);
251 >      FROG_Element_Base_With_DetId* muon    = new FROG_Element_Base_With_DetId(C_FEB_DETID, DETID_MUON);  geom->addDaughter(muon);
252 >      FROG_Element_Base_With_DetId* ecal    = new FROG_Element_Base_With_DetId(C_FEB_DETID, DETID_ECAL);  geom->addDaughter(ecal);
253 >      FROG_Element_Base_With_DetId* hcal    = new FROG_Element_Base_With_DetId(C_FEB_DETID, DETID_HCAL);  geom->addDaughter(hcal);
254 >
255 >
256 >      // ### TRACKER GEOMETRY ###
257 >
258 >      edm::ESHandle<TrackerGeometry> tkGeom;
259 >      iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom );
260 >      vector<GeomDet*> TrackerDets = tkGeom->dets();
261 >
262 >      for(unsigned int i=0;i<TrackerDets.size();i++){
263 >         Detid  = TrackerDets[i]->geographicalId();
264 >         SubDet = Detid.subdetId();
265 >         if(SubDet<1 || SubDet>6) continue;
266  
173   // ### TRACKER GEOMETRY ###
174
175   edm::ESHandle<TrackerGeometry> tkGeom;
176   iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom );
177   vector<GeomDet*> TrackerDets = tkGeom->dets();
178
179   for(unsigned int i=0;i<TrackerDets.size();i++){
180      Detid  = TrackerDets[i]->geographicalId();
181 //    SubDet = Detid.subdetId();
267    
268 <      GeomDet* DetUnit = TrackerDets[i];
269 <      if(!DetUnit)continue;
270 <      const BoundPlane plane = DetUnit->surface();
271 <      const TrapezoidalPlaneBounds* trapezoidalBounds( dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
272 <      const RectangularPlaneBounds* rectangularBounds( dynamic_cast<const RectangularPlaneBounds*>(&(plane.bounds())));  
273 <
274 <      float width            = 0;
275 <      float length           = 0;
276 <      float thickness        = 0;
277 <      float TrapezoidalParam = 0;
268 >         GeomDet* DetUnit = TrackerDets[i];
269 >         if(!DetUnit)continue;
270 >         const BoundPlane plane = DetUnit->surface();
271 >         const TrapezoidalPlaneBounds* trapezoidalBounds( dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
272 >         const RectangularPlaneBounds* rectangularBounds( dynamic_cast<const RectangularPlaneBounds*>(&(plane.bounds())));  
273 >
274 >         float width            = 0;
275 >         float length           = 0;
276 >         float thickness        = 0;
277 >         float TrapezoidalParam = 0;
278 >
279 >         if(trapezoidalBounds){
280 >            std::vector<float> const & parameters = (*trapezoidalBounds).parameters();      
281 >            width            = parameters[0]*2;
282 >            length           = parameters[3]*2;  
283 >            thickness        = (*trapezoidalBounds).thickness();
284 >            TrapezoidalParam = parameters[1]/parameters[0];
285 >         }else if(rectangularBounds){
286 >            width            = DetUnit->surface().bounds().width();
287 >            length           = DetUnit->surface().bounds().length();
288 >            thickness        = DetUnit->surface().bounds().thickness();
289 >            TrapezoidalParam = 1;
290 >         }
291 >
292 >         Surface::GlobalPoint WidthVector  = plane.toGlobal( LocalPoint(width/2, 0, 0) );
293 >         Surface::GlobalPoint LengthVector = plane.toGlobal( LocalPoint(0, length/2, 0) );
294 >         Surface::GlobalPoint ThickVector  = plane.toGlobal( LocalPoint(0, 0, thickness/2) );
295 >
296 >         GlobalVector Pos =  GlobalVector(DetUnit->position().basicVector());
297 >
298 >         FROG_Element_Geom_TrackerMod* mod = new FROG_Element_Geom_TrackerMod(
299 >              Detid.rawId(),           TrapezoidalParam,
300 >              Pos.x(),                  Pos.y(),                  Pos.z(),
301 >              WidthVector.x() -Pos.x(), WidthVector.y() -Pos.y(), WidthVector.z() -Pos.z(),
302 >              LengthVector.x()-Pos.x(), LengthVector.y()-Pos.y(), LengthVector.z()-Pos.z(),
303 >              ThickVector.x() -Pos.x(), ThickVector.y() -Pos.y(), ThickVector.z() -Pos.z());
304  
305 <      if(trapezoidalBounds)
306 <      {
307 <         std::vector<float> const & parameters = (*trapezoidalBounds).parameters();      
308 <         width            = parameters[0]*2;
309 <         length           = parameters[3]*2;  
310 <         thickness        =  (*trapezoidalBounds).thickness();
311 <         TrapezoidalParam = parameters[1]/parameters[0];
312 <      }else if(rectangularBounds){
313 <         width            = DetUnit->surface().bounds().width();
314 <         length           = DetUnit->surface().bounds().length();
315 <         thickness        = DetUnit->surface().bounds().thickness();
316 <         TrapezoidalParam = 1;
305 >
306 >         Frog_DetId = DETID_TRK;
307 >         FEB        = tracker;
308 >
309 >         Frog_DetId += SubDet*100000;
310 >         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
311 >         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
312 >         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
313 >
314 >         if(SubDet==PixelSubdetector::PixelBarrel){
315 >            PXBDetId detid = PXBDetId(Detid);
316 >
317 >            Frog_DetId += detid.layer()*10000;
318 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
319 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
320 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
321 >
322 >            Frog_DetId += detid.ladder()*100;
323 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
324 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
325 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
326 >         }else if(SubDet==PixelSubdetector::PixelEndcap){
327 >            PXFDetId detid = PXFDetId(Detid);
328 >
329 >            Frog_DetId += detid.side()*10000;
330 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
331 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
332 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
333 >
334 >            Frog_DetId += detid.disk()*1000;
335 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
336 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
337 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
338 >
339 >            Frog_DetId += detid.blade()*10;
340 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
341 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
342 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
343 >
344 >            Frog_DetId += detid.panel()*1;
345 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
346 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
347 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
348 >         }else if(SubDet==StripSubdetector::TIB){
349 >            TIBDetId detid = TIBDetId(Detid);
350 >
351 >            Frog_DetId += detid.layer()*10000;
352 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
353 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
354 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
355 >
356 >            Frog_DetId += detid.stringNumber()*100;
357 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
358 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
359 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
360 >         }else if(SubDet==StripSubdetector::TID){
361 >            TIDDetId detid = TIDDetId(Detid);
362 >
363 >            Frog_DetId += detid.side()*10000;
364 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
365 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
366 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
367 >
368 >            Frog_DetId += detid.wheel()*1000;
369 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
370 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
371 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
372 >
373 >            Frog_DetId += detid.ring()*10;
374 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
375 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
376 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
377 >         }else if(SubDet==StripSubdetector::TOB){
378 >            TOBDetId detid = TOBDetId(Detid);
379 >
380 >            Frog_DetId += detid.layer()*10000;
381 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
382 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
383 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
384 >
385 >            Frog_DetId += detid.rodNumber()*100;
386 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
387 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
388 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
389 >         }else if(SubDet==StripSubdetector::TEC){
390 >            TECDetId detid = TECDetId(Detid);
391 >
392 >            Frog_DetId += detid.side()*10000;
393 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
394 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
395 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
396 >
397 >            Frog_DetId += detid.wheel()*1000;
398 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
399 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
400 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
401 >
402 >            Frog_DetId += detid.ring()*10;
403 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
404 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
405 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
406 >
407 >            Frog_DetId += detid.petalNumber();
408 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
409 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
410 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
411 >         }else{
412 >            if(mod)delete mod;
413 >            continue;
414 >         }
415 >         FEB->addDaughter(mod);
416        }
417  
208      Surface::GlobalPoint WidthVector  = plane.toGlobal( LocalPoint(width/2, 0, 0) );
209      Surface::GlobalPoint LengthVector = plane.toGlobal( LocalPoint(0, length/2, 0) );
210      Surface::GlobalPoint ThickVector  = plane.toGlobal( LocalPoint(0, 0, thickness/2) );
211
212      GlobalVector Pos =  GlobalVector(DetUnit->position().basicVector());
213
214      Geom_Tracker->Add_TrackerDet(Detid.rawId(), TrapezoidalParam,
215           Pos.x(),                  Pos.y(),                  Pos.z(),
216           WidthVector.x() -Pos.x(), WidthVector.y() -Pos.y(), WidthVector.z() -Pos.z(),
217           LengthVector.x()-Pos.x(), LengthVector.y()-Pos.y(), LengthVector.z()-Pos.z(),
218           ThickVector.x() -Pos.x(), ThickVector.y() -Pos.y(), ThickVector.z() -Pos.z());
219      
418  
419 <   }
419 >      // ### MUON GEOMETRY ###
420  
421 +      edm::ESHandle<DTGeometry> DtGeom;
422 +      iSetup.get<MuonGeometryRecord>().get( DtGeom );
423 +      const vector<GeomDet*> DtDets = DtGeom->dets();
424 +
425 +      edm::ESHandle<CSCGeometry> CscGeom;
426 +      iSetup.get<MuonGeometryRecord>().get( CscGeom );
427 +      const vector<GeomDet*> CscDets = CscGeom->dets();
428 +
429 +      edm::ESHandle<RPCGeometry> RpcGeom;
430 +      iSetup.get<MuonGeometryRecord>().get( RpcGeom );
431 +      const vector<GeomDet*> RpcDets = RpcGeom->dets();
432 +
433 +      vector<GeomDet*> MuonDets;
434 +      for(unsigned int i=0;i<DtDets.size() ;i++){MuonDets.push_back(DtDets [i]);}
435 +      for(unsigned int i=0;i<CscDets.size();i++){MuonDets.push_back(CscDets[i]);}
436 +      for(unsigned int i=0;i<RpcDets.size();i++){MuonDets.push_back(RpcDets[i]);}
437  
438 <   // ### CALO GEOMETRY ###
438 >      for(unsigned int i=0;i<MuonDets.size();i++)
439 >      {
440 >         Detid  = DetId(MuonDets[i]->geographicalId());
441 >         SubDet = Detid.subdetId();
442  
443 <   edm::ESHandle<CaloGeometry> CaloGeom;
444 <   iSetup.get<IdealGeometryRecord>().get( CaloGeom );
445 <   const vector<DetId> CaloDets = CaloGeom->getValidDetIds();
446 <
447 <   for(unsigned int i=0;i<CaloDets.size();i++)
448 <   {
449 <      Detid  = CaloDets[i];
450 <      SubDet = Detid.subdetId();
451 <
452 <      Geometry* Geom_temp = NULL;
453 <      if(Detid.det()==DetId::Ecal){
454 <        Geom_temp = Geom_ECAL;
455 <
456 <        if(SubDet<1 || SubDet>3){
457 <                printf("Don't Save EcalTriggerTower or EcalLaserPnDiode\n");
458 <                continue;
459 <        }
460 <      }else if(Detid.det()==DetId::Hcal){
461 <        Geom_temp = Geom_HCAL;
462 <
463 <        if(SubDet<1 || SubDet>4){
464 <                printf("Don't Save HcalEmpty, HcalTriggerTower, HcalOther\n");
465 <                continue;
466 <        }
467 <      }else{
468 <        continue;
443 >         GeomDet* DetUnit = MuonDets[i];
444 >         if(!DetUnit)continue;
445 >         const BoundPlane plane = DetUnit->surface();
446 >         const TrapezoidalPlaneBounds* trapezoidalBounds( dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
447 >         const RectangularPlaneBounds* rectangularBounds( dynamic_cast<const RectangularPlaneBounds*>(&(plane.bounds())));
448 >
449 >         float width            = 0;
450 >         float length           = 0;
451 >         float thickness        = 0;
452 >         float TrapezoidalParam = 0;
453 >
454 >         if(trapezoidalBounds)
455 >         {
456 >            std::vector<float> const & parameters = (*trapezoidalBounds).parameters();
457 >            width            = parameters[0]*2;
458 >            length           = parameters[3]*2;
459 >            thickness        =  (*trapezoidalBounds).thickness();
460 >            TrapezoidalParam = parameters[1]/parameters[0];
461 >         }else if(rectangularBounds){
462 >            width            = DetUnit->surface().bounds().width();
463 >            length           = DetUnit->surface().bounds().length();
464 >            thickness        = DetUnit->surface().bounds().thickness();
465 >            TrapezoidalParam = 1;
466 >         }
467 >
468 >         Surface::GlobalPoint WidthVector  = plane.toGlobal( LocalPoint(width/2, 0, 0) );
469 >         Surface::GlobalPoint LengthVector = plane.toGlobal( LocalPoint(0, length/2, 0) );
470 >         Surface::GlobalPoint ThickVector  = plane.toGlobal( LocalPoint(0, 0, thickness/2) );
471 >
472 >         GlobalVector Pos =  GlobalVector(DetUnit->position().basicVector());
473 >
474 >         FROG_Element_Geom_TrackerMod* mod = new FROG_Element_Geom_TrackerMod(
475 >              Detid.rawId(),           TrapezoidalParam,
476 >              Pos.x(),                  Pos.y(),                  Pos.z(),
477 >              WidthVector.x() -Pos.x(), WidthVector.y() -Pos.y(), WidthVector.z() -Pos.z(),
478 >              LengthVector.x()-Pos.x(), LengthVector.y()-Pos.y(), LengthVector.z()-Pos.z(),
479 >              ThickVector.x() -Pos.x(), ThickVector.y() -Pos.y(), ThickVector.z() -Pos.z());
480 >
481 >         Frog_DetId = DETID_MUON;
482 >         FEB        = muon;
483 >
484 >         Frog_DetId += SubDet*100000;
485 >         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
486 >         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
487 >         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
488 >
489 >         if(SubDet==1){
490 >                DTChamberId detid = DTChamberId(Detid);
491 >
492 >            Frog_DetId += (detid.wheel()+3)*10000;
493 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
494 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
495 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
496 >
497 >            Frog_DetId += detid.station()*100;
498 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
499 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
500 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
501 >
502 >            Frog_DetId += detid.sector()*1;
503 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
504 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
505 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
506 >         }else if(SubDet==2){
507 >            CSCDetId detid = CSCDetId(Detid);
508 >  
509 >            Frog_DetId += detid.endcap()*10000;
510 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
511 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
512 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
513 >  
514 >            Frog_DetId += detid.station()*1000;
515 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
516 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
517 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
518 >  
519 >            Frog_DetId += detid.ring()*100;
520 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
521 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
522 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
523 >
524 >            Frog_DetId += detid.chamber()*1;
525 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
526 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
527 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
528 >         }else if(SubDet==3){
529 >            RPCDetId detid = RPCDetId(Detid);
530 >
531 >            Frog_DetId += (detid.region()+2)*10000;
532 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
533 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
534 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
535 >
536 >            // Barrel
537 >            if(detid.region()==0){
538 >               Frog_DetId += (detid.ring()+3)*1000;
539 >               FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
540 >               FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
541 >               if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
542 >            // Endcap
543 >            }else{
544 >               Frog_DetId += detid.ring()*1000;
545 >               FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
546 >               FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
547 >               if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
548 >            }
549 >
550 >            Frog_DetId += detid.station()*100;
551 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
552 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
553 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
554 >
555 >            Frog_DetId += detid.sector()*1;
556 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
557 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
558 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
559 >         }
560 >
561 >         FEB->addDaughter(mod);
562        }
563  
254      const CaloCellGeometry* CellGeom = CaloGeom->getGeometry(Detid);
255      GlobalPoint CellPos =  CellGeom->getPosition();
256      const CaloCellGeometry::CornersVec CellCorners =  CellGeom->getCorners();
257
258      Geom_temp->Add_CaloDet(Detid.rawId(),
259                        CellPos.x()         ,   CellPos.y()         ,   CellPos.z(),
260                        CellCorners[0].x()  ,   CellCorners[0].y()  ,   CellCorners[0].z()  ,
261                        CellCorners[1].x()  ,   CellCorners[1].y()  ,   CellCorners[1].z()  ,
262                        CellCorners[2].x()  ,   CellCorners[2].y()  ,   CellCorners[2].z()  ,
263                        CellCorners[3].x()  ,   CellCorners[3].y()  ,   CellCorners[3].z()  ,
264                        CellCorners[4].x()  ,   CellCorners[4].y()  ,   CellCorners[4].z()  ,
265                        CellCorners[5].x()  ,   CellCorners[5].y()  ,   CellCorners[5].z()  ,
266                        CellCorners[6].x()  ,   CellCorners[6].y()  ,   CellCorners[6].z()  ,
267                        CellCorners[7].x()  ,   CellCorners[7].y()  ,   CellCorners[7].z()  );
268   }
564  
565 <   // ### MUON GEOMETRY ###
565 >      
566 >      // ### CALO GEOMETRY ###
567  
568 <   edm::ESHandle<DTGeometry> DtGeom;
569 <   iSetup.get<MuonGeometryRecord>().get( DtGeom );
570 <   const vector<GeomDet*> DtDets = DtGeom->dets();
275 <
276 <   edm::ESHandle<CSCGeometry> CscGeom;
277 <   iSetup.get<MuonGeometryRecord>().get( CscGeom );
278 <   const vector<GeomDet*> CscDets = CscGeom->dets();
279 <
280 <   edm::ESHandle<RPCGeometry> RpcGeom;
281 <   iSetup.get<MuonGeometryRecord>().get( RpcGeom );
282 <   const vector<GeomDet*> RpcDets = RpcGeom->dets();
283 <
284 <   vector<GeomDet*> MuonDets;
285 <   for(unsigned int i=0;i<DtDets.size() ;i++){MuonDets.push_back(DtDets [i]);}
286 <   for(unsigned int i=0;i<CscDets.size();i++){MuonDets.push_back(CscDets[i]);}
287 <   for(unsigned int i=0;i<RpcDets.size();i++){MuonDets.push_back(RpcDets[i]);}
288 <
289 <
290 <   for(unsigned int i=0;i<MuonDets.size();i++)
291 <   {
292 <      Detid  = DetId(MuonDets[i]->geographicalId());
293 <      SubDet = Detid.subdetId();
294 <
295 <      GeomDet* DetUnit = MuonDets[i];
296 <      if(!DetUnit)continue;
297 <      const BoundPlane plane = DetUnit->surface();
298 <      const TrapezoidalPlaneBounds* trapezoidalBounds( dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
299 <      const RectangularPlaneBounds* rectangularBounds( dynamic_cast<const RectangularPlaneBounds*>(&(plane.bounds())));
300 <
301 <      float width            = 0;
302 <      float length           = 0;
303 <      float thickness        = 0;
304 <      float TrapezoidalParam = 0;
568 >      edm::ESHandle<CaloGeometry> CaloGeom;
569 >      iSetup.get<CaloGeometryRecord>().get( CaloGeom );
570 >      const vector<DetId> CaloDets = CaloGeom->getValidDetIds();
571  
572 <      if(trapezoidalBounds)
572 >      for(unsigned int i=0;i<CaloDets.size();i++)
573        {
574 <         std::vector<float> const & parameters = (*trapezoidalBounds).parameters();
575 <         width            = parameters[0]*2;
310 <         length           = parameters[3]*2;
311 <         thickness        =  (*trapezoidalBounds).thickness();
312 <         TrapezoidalParam = parameters[1]/parameters[0];
313 <      }else if(rectangularBounds){
314 <         width            = DetUnit->surface().bounds().width();
315 <         length           = DetUnit->surface().bounds().length();
316 <         thickness        = DetUnit->surface().bounds().thickness();
317 <         TrapezoidalParam = 1;
318 <      }
574 >         Detid  = CaloDets[i];
575 >         SubDet = Detid.subdetId();
576  
577 <      Surface::GlobalPoint WidthVector  = plane.toGlobal( LocalPoint(width/2, 0, 0) );
578 <      Surface::GlobalPoint LengthVector = plane.toGlobal( LocalPoint(0, length/2, 0) );
322 <      Surface::GlobalPoint ThickVector  = plane.toGlobal( LocalPoint(0, 0, thickness/2) );
323 <
324 <      GlobalVector Pos =  GlobalVector(DetUnit->position().basicVector());
325 <
326 <      Geom_Muon->Add_TrackerDet(Detid.rawId(), TrapezoidalParam,
327 <           Pos.x(),                  Pos.y(),                  Pos.z(),
328 <           WidthVector.x() -Pos.x(), WidthVector.y() -Pos.y(), WidthVector.z() -Pos.z(),
329 <           LengthVector.x()-Pos.x(), LengthVector.y()-Pos.y(), LengthVector.z()-Pos.z(),
330 <           ThickVector.x() -Pos.x(), ThickVector.y() -Pos.y(), ThickVector.z() -Pos.z());
331 <   }
577 >         if(Detid.det()==DetId::Ecal){
578 >             if(SubDet<1 || SubDet>3) continue;
579  
580 +            Frog_DetId = DETID_ECAL;
581 +            FEB        = ecal;
582  
583 <   // ### Save .geom ###
583 >            Frog_DetId += SubDet*100000;
584 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
585 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
586 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
587 >
588 >            if(SubDet==1){
589 >               EBDetId detid = EBDetId(Detid);
590 >
591 >               Frog_DetId += ((detid.zside()==1)+1)*10000;
592 >               FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
593 >               FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
594 >               if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
595 >
596 >               Frog_DetId += (detid.tower_ieta()*detid.zside())*100;
597 >               FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
598 >               FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
599 >               if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
600 >
601 >               Frog_DetId += detid.tower_iphi()*1;
602 >               FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
603 >               FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
604 >               if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
605 >            }else if(SubDet==2){
606 >               EEDetId detid = EEDetId(Detid);
607 >
608 >               Frog_DetId += ((detid.zside()==1)+1)*10000;
609 >               FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
610 >               FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
611 >               if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
612 >
613 >               Frog_DetId += detid.iquadrant()*1000;
614 >               FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
615 >               FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
616 >               if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
617 >
618 >               Frog_DetId += detid.isc();
619 >               FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
620 >               FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
621 >               if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
622 >            }else if(SubDet==3){
623 >               ESDetId detid = ESDetId(Detid);
624 >
625 >               Frog_DetId += ((detid.zside()==1)+1)*10000;
626 >               FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
627 >               FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
628 >               if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
629 >
630 >               Frog_DetId += detid.plane()*1000;
631 >               FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
632 >               FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
633 >               if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
634 >
635 >               Frog_DetId += detid.six()*50;
636 >               FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
637 >               FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
638 >               if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
639 >
640 >               Frog_DetId += detid.siy();
641 >               FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
642 >               FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
643 >               if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
644 >             }
645 >         }else if(Detid.det()==DetId::Hcal){
646 >            if(SubDet<1 || SubDet>4) continue;
647 >
648 >            Frog_DetId = DETID_HCAL;
649 >            FEB        = hcal;
650 >
651 >            Frog_DetId += SubDet*100000;
652 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
653 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
654 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
655 >
656 >            if(true){
657 >               HcalDetId detid = HcalDetId(Detid);
658 >
659 >               Frog_DetId += ((detid.zside()==1)+1)*10000;
660 >               FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
661 >               FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
662 >               if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
663 >
664 >               Frog_DetId += detid.ietaAbs()*100;
665 >               FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
666 >               FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
667 >               if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
668 >
669 >               Frog_DetId += detid.iphi()*1;
670 >               FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
671 >               FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
672 >               if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
673 >            }
674 >
675 >         }else if(Detid.det() == DetId::Calo){
676 >         continue;
677 >         /*
678 >            Frog_DetId = DETID_CALO + 1000000;
679 >            FEB        = hcal;
680 >
681 >            Frog_DetId += SubDet*100000;
682 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
683 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
684 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
685 >         */
686 >         }
687 >
688 >         const CaloCellGeometry* CellGeom = CaloGeom->getGeometry(Detid);
689 >         GlobalPoint CellPos =  CellGeom->getPosition();
690 >         const CaloCellGeometry::CornersVec CellCorners =  CellGeom->getCorners();
691 >
692 >         float cX = (CellCorners[0].x() + CellCorners[2].x())/2;
693 >         float cY = (CellCorners[0].y() + CellCorners[2].y())/2;
694 >         float cZ = (CellCorners[0].z() + CellCorners[2].z())/2;
695 >
696 >         float wX = (CellCorners[1].x() - CellCorners[0].x())/2;
697 >         float wY = (CellCorners[1].y() - CellCorners[0].y())/2;
698 >         float wZ = (CellCorners[1].z() - CellCorners[0].z())/2;
699 >        
700 >         float hX = (CellCorners[3].x() - CellCorners[0].x())/2;
701 >         float hY = (CellCorners[3].y() - CellCorners[0].y())/2;
702 >         float hZ = (CellCorners[3].z() - CellCorners[0].z())/2;
703 >
704 >         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) );
705 >               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) );
706 >
707 >         FROG_Element_Geom_CaloMod* mod = new FROG_Element_Geom_CaloMod(
708 >            Detid.rawId(), F,
709 >            cX  ,   cY  , cZ ,
710 >            wX  ,   wY  , wZ ,
711 >            hX  ,   hY  , hZ );
712  
713 <   Geom_Tracker->Save("Tracker.geom");    
714 <   Geom_ECAL   ->Save("Ecal.geom");
338 <   Geom_HCAL   ->Save("Hcal.geom");
713 >         FEB->addDaughter(mod);
714 >      }
715  
716 <   printf("RPC = %i\n",Geom_Muon   ->Det_Muon_RPC.size());
716 >      // ### Save .geom ###
717  
718 <   Geom_Muon   ->Save("Muon.geom");
719 <
718 >      FROG_Geometry* CMS_Geom = new FROG_Geometry(prim);
719 >      CMS_Geom->Save("CMS.geom");  
720 >   }
721 >
722 >   events_prim = new FROG_Element_Base(C_PRIMARY);  
723   }
724  
725   // ------------ method called once each job just after ending the event loop  ------------
726   void
727 < Frog_Analyzer::endJob() {
728 <  
729 <   MyEvents->Save((char*) OutputFile.c_str());
730 < //   MyEvents->Load((char*) OutputFile.c_str());
727 > Frog_Analyzer::endJob()
728 > {
729 >   if(NEvents>0){
730 >      char OutputFileName[1024];
731 >      sprintf(OutputFileName,"%s",OutputFile.substr(0,OutputFile.size()-4).c_str());
732 >      if(NEventsInVisFile>=0)sprintf(OutputFileName,"%s_R%i_E%i.vis",OutputFileName,SRun,SEvent);
733 >      sprintf(OutputFileName,"%s.vis",OutputFileName);
734 >
735 >      FROG_Events* events = new FROG_Events(events_prim);
736 >      events->Save((char*) OutputFileName);
737 >      delete events;
738 >      delete events_prim;
739 >
740 >      events_prim = new FROG_Element_Base(C_PRIMARY);
741 >      NEvents=0;
742 >   }
743   }
744  
745  
# Line 361 | Line 752 | Frog_Analyzer::endJob() {
752   void
753   Frog_Analyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
754   {
755 <        MySimEvent* MyEvent = new MySimEvent;
755 >        if(NEvents == 0){
756 >           SRun   = iEvent.id().run();
757 >           SEvent = iEvent.id().event();
758 >        }
759  
760  
761 +        FROG_Element_Event* event =  new FROG_Element_Event(iEvent.id().run(), iEvent.id().event(), iEvent.time().value() );
762 +        events_prim->addDaughter(event);
763  
764          // access the tracker
765 <        edm::ESHandle<TrackerGeometry> theTrackerGeometry;
766 <        iSetup.get<TrackerDigiGeometryRecord>().get(theTrackerGeometry);
371 <        const TrackerGeometry& theTracker(*theTrackerGeometry);
372 <
373 <        // the DetUnits
374 <        TrackingGeometry::DetContainer theDetUnits = theTracker.dets();
765 >        edm::ESHandle<TrackerGeometry> tkGeom;
766 >        iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom );
767  
768 +        edm::ESHandle<DTGeometry> DtGeom;
769 +        iSetup.get<MuonGeometryRecord>().get( DtGeom );
770 +  
771 +        edm::ESHandle<CSCGeometry> CscGeom;
772 +        iSetup.get<MuonGeometryRecord>().get( CscGeom );
773 +
774 +        edm::ESHandle<RPCGeometry> RpcGeom;
775 +        iSetup.get<MuonGeometryRecord>().get( RpcGeom );
776 +
777 +        edm::ESHandle<CaloGeometry> CaloGeom;
778 +       iSetup.get<CaloGeometryRecord>().get( CaloGeom );
779 +
780 +        // ### SIMTRACK ###
781 +        FROG_Element_Base_With_DetId* frogSimTrkColl = new FROG_Element_Base_With_DetId(C_FEB_DETID, EVTID_SIMTRK);
782 +        event->addDaughter(frogSimTrkColl);
783  
377        // Save Data
784          for(unsigned int i=0;i<SimTrackProducers.size();i++){
785             edm::Handle<std::vector< SimTrack > > h_SimTracks;
786             iEvent.getByLabel(SimTrackProducers[i], h_SimTracks);
787             std::vector< SimTrack > SimTrackColl = *h_SimTracks.product();
788  
789             for ( unsigned int a = 0; a < SimTrackColl.size(); ++a ) {
384                MySimTrack  MysimTrack;
790                  SimTrack    simTrack    =SimTrackColl[a];
791  
792 <                MysimTrack.track_id     =simTrack.trackId();
793 <                MysimTrack.Type         =simTrack.type();
794 <                MysimTrack.parent_vertex=simTrack.vertIndex();
795 <                MysimTrack.Px           =simTrack.momentum().x();
796 <                MysimTrack.Py           =simTrack.momentum().y();
392 <                MysimTrack.Pz           =simTrack.momentum().z();
393 <                MysimTrack.E            =simTrack.momentum().e();
394 <                MysimTrack.charge       =simTrack.charge();
395 <
396 <                MyEvent->MySimTrackCollection.push_back(MysimTrack);
792 >                FROG_Element_Event_Sim_Track* frogSimTrk =  new FROG_Element_Event_Sim_Track(simTrack.trackId(),
793 >                        simTrack.momentum().x(),     simTrack.momentum().y(),     simTrack.momentum().z(),
794 >                        simTrack.momentum().e(),     simTrack.type(),             simTrack.vertIndex(),
795 >                        simTrack.charge() );
796 >                frogSimTrkColl->addDaughter(frogSimTrk);
797             }      
798          }
799  
800 +        // ### SIMVERTEX ###
801 +        FROG_Element_Base_With_DetId* frogSimVtx = new FROG_Element_Base_With_DetId(C_FEB_DETID, EVTID_SIMVTX);
802 +        event->addDaughter(frogSimVtx);
803  
804          for(unsigned int i=0;i<SimVertexProducers.size();i++){
805             edm::Handle<std::vector< SimVertex > > h_Vertex;
# Line 404 | Line 807 | Frog_Analyzer::analyze(const edm::Event&
807             std::vector< SimVertex > VertexColl = *h_Vertex.product();
808  
809             for (unsigned int b = 0; b < VertexColl.size(); ++b ) {
407                MySimVertex     MyVertex;
810                  SimVertex       Vertex  =  VertexColl[b];
811  
812 <                MyVertex.parentTrack_id =Vertex.parentIndex ();
813 <                MyVertex.x              =Vertex.position().x();
814 <                MyVertex.y              =Vertex.position().y();
413 <                MyVertex.z              =Vertex.position().z();
812 >                FROG_Element_Event_Sim_Vertex* frogSimVertex = new FROG_Element_Event_Sim_Vertex(
813 >                        Vertex.position().x(),  Vertex.position().y(),  Vertex.position().z(),
814 >                        Vertex.parentIndex());
815  
816 <                MyEvent->MySimVertexCollection.push_back(MyVertex);
816 >                frogSimVtx->addDaughter(frogSimVertex);
817             }
818          }
819  
820 +
821 +        // ### SIMHIT ###
822 +
823 +        FROG_Element_Base_With_DetId* frogSimHit = new FROG_Element_Base_With_DetId(C_FEB_DETID, EVTID_SIMHIT);
824 +        event->addDaughter(frogSimHit);
825          for(unsigned int i=0;i<SimHitProducers.size();i++){
826             edm::Handle<std::vector< PSimHit > > h_Hits;
827             iEvent.getByLabel(SimHitProducers[i], h_Hits);
828             std::vector< PSimHit > Hits = *h_Hits.product();
829  
830 +           FROG_Element_Base_With_DetId* frogSimHitColl = new FROG_Element_Base_With_DetId(C_FEB_DETID, EVTID_SIMHIT + i + 1);
831 +           frogSimHit->addDaughter(frogSimHitColl);
832 +
833             for(unsigned int h=0; h<Hits.size(); h++)
834             {
835 <               DetId theDetUnitId(Hits[h].detUnitId());
836 <               const GeomDet * theDet = theTracker.idToDet(theDetUnitId);
835 >                DetId theDetUnitId(Hits[h].detUnitId());
836 >                const GeomDet* theDet = NULL;
837 >                if(theDetUnitId.det() == DetId::Tracker)theDet = tkGeom->idToDet(theDetUnitId);
838 >                if(theDetUnitId.det() == DetId::Muon && theDetUnitId.subdetId() == MuonSubdetId::DT) theDet = DtGeom->idToDet(theDetUnitId);
839 >                if(theDetUnitId.det() == DetId::Muon && theDetUnitId.subdetId() == MuonSubdetId::CSC)theDet = CscGeom->idToDet(theDetUnitId);
840 >                if(theDetUnitId.det() == DetId::Muon && theDetUnitId.subdetId() == MuonSubdetId::RPC)theDet = RpcGeom->idToDet(theDetUnitId);
841 >
842 >                
843 >                FROG_Element_Event_Sim_Hit* frogSimHit = new FROG_Element_Event_Sim_Hit(
844 >                        theDet->surface().toGlobal(Hits[h].localPosition()).x(),theDet->surface().toGlobal(Hits[h].localPosition()).y(),theDet->surface().toGlobal(Hits[h].localPosition()).z(),
845 >                        Hits[h].energyLoss(), Hits[h].processType() );
846 >                frogSimHitColl->addDaughter(frogSimHit);
847 >           }
848 >        }
849  
850 <                MyPSimHit Hit;
430 <                Hit.x           = theDet->surface().toGlobal(Hits[h].localPosition()).x();
431 <                Hit.y           = theDet->surface().toGlobal(Hits[h].localPosition()).y();
432 <                Hit.z           = theDet->surface().toGlobal(Hits[h].localPosition()).z();
433 <                Hit.ProcessType = Hits[h].processType();
434 <                Hit.dEdX        = Hits[h].energyLoss();
850 >        // ### SIMCALOHIT ###
851  
852 <                MyEvent->MyPSimHitCollection.push_back(Hit);
852 >        for(unsigned int i=0;i<SimCaloHitProducers.size();i++){
853 >           edm::Handle<std::vector< PCaloHit > > h_CaloHits;
854 >           iEvent.getByLabel(SimCaloHitProducers[i], h_CaloHits);
855 >           std::vector< PCaloHit > CaloHits = *h_CaloHits.product();
856 >
857 >           FROG_Element_Base_With_DetId* frogSimHitColl = new FROG_Element_Base_With_DetId(C_FEB_DETID, EVTID_SIMHIT + SimHitProducers.size() + i + 1);
858 >           frogSimHit->addDaughter(frogSimHitColl);
859 >
860 >           for(unsigned int h=0; h<CaloHits.size(); h++)
861 >           {
862 >                DetId theDetUnitId(CaloHits[h].id());
863 >                const CaloCellGeometry* CellGeom = NULL;
864 >                if(theDetUnitId.det() == DetId::Ecal || theDetUnitId.det() == DetId::Hcal)CellGeom = CaloGeom->getGeometry(theDetUnitId);
865 >                if(CellGeom==NULL)continue;
866 >
867 >
868 >                FROG_Element_Event_Sim_Hit* frogSimCaloHit = new FROG_Element_Event_Sim_Hit(
869 >                        CellGeom->getPosition().x(),CellGeom->getPosition().y(),CellGeom->getPosition().z(),
870 >                        CaloHits[h].energy(), CaloHits[h].depth() );
871 >                frogSimHitColl->addDaughter(frogSimCaloHit);
872             }
873 <        }
873 >        }
874 >
875 >        // NUCLEAR INTERACTIONS
876 >        for(unsigned int i=0;i<NIProducers.size();i++) {
877 >          edm::Handle<std::vector<reco::NuclearInteraction> > h_NIs;
878 >          iEvent.getByLabel(NIProducers[i], h_NIs);
879 >          std::vector<reco::NuclearInteraction> NIs = *h_NIs.product();
880 >          FROG_Element_Base_With_DetId* frogNIColl = new FROG_Element_Base_With_DetId(C_FEB_DETID, EVTID_NUCLINT + i);
881 >          event->addDaughter(frogNIColl);
882 >
883 >          for(unsigned int h=0; h<NIs.size();h++){
884 >             reco::NuclearInteraction ni = NIs[i];
885 >             float vtx_x = ni.vertex().x();
886 >             float vtx_y = ni.vertex().y();
887 >             float vtx_z = ni.vertex().z();
888 >             float like  = ni.likelihood();
889 >             FROG_Element_Event_NuclInt*  frogNI = new FROG_Element_Event_NuclInt(vtx_x, vtx_y, vtx_z, like );
890 >             frogNIColl->addDaughter(frogNI);
891 >          }
892 >        }
893 >
894 >
895 >
896 >        // ### TRAJECTORY ###
897 >        FROG_Element_Base_With_DetId* frogTrk = new FROG_Element_Base_With_DetId(C_FEB_DETID, EVTID_TRK);
898 >        event->addDaughter(frogTrk);
899 >
900 >        for(unsigned int i=0;i<TrajectoryProducers.size();i++){
901 >             Handle<TrajTrackAssociationCollection> trajTrackAssociationHandle;
902 >             iEvent.getByLabel(TrajectoryProducers[i], trajTrackAssociationHandle);
903 >             const TrajTrackAssociationCollection TrajToTrackMap = *trajTrackAssociationHandle.product();
904 >
905 >             FROG_Element_Base_With_DetId* frogTrkColl = new FROG_Element_Base_With_DetId(C_FEB_DETID, EVTID_TRK + i + 1);
906 >             frogTrk->addDaughter(frogTrkColl);
907 >
908 >             for(TrajTrackAssociationCollection::const_iterator it = TrajToTrackMap.begin(); it!=TrajToTrackMap.end(); ++it) {
909 >                Trajectory  recoTraj     = *it->key;
910 >                FROG_Element_Event_Track* frogTrk = new FROG_Element_Event_Track(i,it->val->p(),it->val->pt(),it->key->chiSquared());
911 >                frogTrkColl->addDaughter(frogTrk);
912 >
913 >                std::vector<TrajectoryMeasurement> measurements = recoTraj.measurements();
914 >                for(unsigned int h=0;h<measurements.size();h++){
915 >
916 >                      TrajectoryMeasurement::ConstRecHitPointer h_it = measurements[h].recHit();
917 >                      if(!h_it->isValid() )continue;
918 >                      DetId detId                = h_it->geographicalId();
919 >                      GlobalPoint globalPos      = measurements[h].updatedState().globalPosition();
920  
921 +                      FROG_Element_Event_Hit* frogHit = new FROG_Element_Event_Hit(detId.rawId(), globalPos.x(),globalPos.y(),  globalPos.z(), -1);
922 +                      frogTrk->addDaughter(frogHit);
923 +                }
924 +           }
925 +        }
926 +
927 +        // ### TRACK ###
928  
929          for(unsigned int i=0;i<TrackProducers.size();i++){
930             edm::Handle<std::vector< reco::Track > > h_Tracks;
931             iEvent.getByLabel(TrackProducers[i], h_Tracks);
932             std::vector< reco::Track > TrackColl = *h_Tracks.product();
933  
934 +           FROG_Element_Base_With_DetId* frogTrkColl = new FROG_Element_Base_With_DetId(C_FEB_DETID, EVTID_TRK + TrajectoryProducers.size() + i + 1);
935 +           frogTrk->addDaughter(frogTrkColl);
936 +
937 +           //printf("Size of the TrackCOllection : %i = %i\n",i,TrackColl.size());
938             for ( unsigned int t = 0; t < TrackColl.size(); ++t ) {
939 <                MyRecoTrack  MyrecoTrack;
448 <                reco::Track  recoTrack  =TrackColl[t];
939 >              reco::Track  recoTrack  =TrackColl[t];
940  
941 <                for(unsigned int h=0;h<recoTrack.recHitsSize();h++){
942 <                      TrackingRecHitRef h_it     = recoTrack.recHit(h);
452 <                      if(!h_it->isValid() )continue;
453 <                      DetId detId                = h_it->geographicalId();
454 <                      const GeomDet * theDet     = theTracker.idToDet(detId);
455 <                      LocalPoint localPos        = h_it->localPosition();
941 >              FROG_Element_Event_Track* frogTrk = new FROG_Element_Event_Track(TrajectoryProducers.size()+i,recoTrack.p(),recoTrack.pt(), recoTrack.chi2());
942 >              frogTrkColl->addDaughter(frogTrk);
943  
944 <                      MyRecoHit hit;          
945 <                      hit.x      = theDet->surface().toGlobal(localPos).x();
946 <                      hit.y      = theDet->surface().toGlobal(localPos).y();
947 <                      hit.z      = theDet->surface().toGlobal(localPos).z();
948 <                      hit.DetId  = detId.rawId();
949 <                      hit.Charge = -1;
950 <                      MyrecoTrack.Hits.push_back(hit);
951 <                }
952 <                MyEvent->MyRecoTrackCollection.push_back(MyrecoTrack);
944 >              for(unsigned int h=0;h<recoTrack.recHitsSize();h++){
945 >                 TrackingRecHitRef h_it     = recoTrack.recHit(h);
946 >                 if(!h_it->isValid() )continue;
947 >                 DetId detId                = h_it->geographicalId();
948 >                 const GeomDet * theDet = NULL;
949 >
950 >                 if(detId.det()==DetId::Tracker)                        theDet = tkGeom->idToDet(detId);
951 >                 if(detId.det()==DetId::Muon && detId.subdetId() == 1)  theDet = DtGeom->idToDet(detId);
952 >                 if(detId.det()==DetId::Muon && detId.subdetId() == 2)  theDet = CscGeom->idToDet(detId);
953 >                 if(detId.det()==DetId::Muon && detId.subdetId() == 3)  theDet = RpcGeom->idToDet(detId);
954 >
955 >                 LocalPoint localPos        = h_it->localPosition();
956 >
957 >                 FROG_Element_Event_Hit* frogHit = new FROG_Element_Event_Hit(
958 >                        detId.rawId(),
959 >                        theDet->surface().toGlobal(localPos).x(),
960 >                        theDet->surface().toGlobal(localPos).y(),
961 >                        theDet->surface().toGlobal(localPos).z(),
962 >                        -1);
963 >                 frogTrk->addDaughter(frogHit);
964 >              }
965             }
966          }
967  
968  
969 +        // ### ECALRecHits ###
970 +        FROG_Element_Base_With_DetId* frogEcalHit = new FROG_Element_Base_With_DetId(C_FEB_DETID, EVTID_ECALHIT);
971 +        event->addDaughter(frogEcalHit);
972          for(unsigned int i=0;i<EcalRecHitProducers.size();i++){
973             edm::Handle<EcalRecHitCollection > h_Ecal_RecHits;
974             iEvent.getByLabel(EcalRecHitProducers[i], h_Ecal_RecHits);
975             EcalRecHitCollection Ecal_RecHits = *h_Ecal_RecHits.product();
976  
977 +           FROG_Element_Base_With_DetId* frogHitColl = new FROG_Element_Base_With_DetId(C_FEB_DETID, EVTID_ECALHIT + i + 1);
978 +           frogEcalHit->addDaughter(frogHitColl);
979 +
980             for(unsigned int eh=0;eh<Ecal_RecHits.size();eh++){
981 <                MyCaloHit temp_EcalHit;
982 <                temp_EcalHit.E     = Ecal_RecHits[eh].energy();
983 <                temp_EcalHit.t     = Ecal_RecHits[eh].time();
479 <                temp_EcalHit.DetId = (Ecal_RecHits[eh].detid()).rawId();
480 <        
481 <                MyEvent->MyEcalCaloHitCollection.push_back(temp_EcalHit);
981 >                FROG_Element_Event_CaloHit* frogCaloHit = new FROG_Element_Event_CaloHit((Ecal_RecHits[eh].detid()).rawId(),
982 >                        Ecal_RecHits[eh].energy(), Ecal_RecHits[eh].time());  
983 >                frogHitColl->addDaughter(frogCaloHit);
984             }
985          }
986  
987  
988 +        // ### HCALRecHits ###
989 +        FROG_Element_Base_With_DetId* frogHcalHit = new FROG_Element_Base_With_DetId(C_FEB_DETID, EVTID_HCALHIT);
990 +        event->addDaughter(frogHcalHit);
991          for(unsigned int i=0;i<HcalHBHERecHitProducers.size();i++){
992             edm::Handle<HBHERecHitCollection > h_HcalHBHE_RecHits;
993             iEvent.getByLabel(HcalHBHERecHitProducers[i], h_HcalHBHE_RecHits);
994             HBHERecHitCollection HcalHBHE_RecHits = *h_HcalHBHE_RecHits.product();
995  
996 <           for(unsigned int hh=0;hh<HcalHBHE_RecHits.size();hh++){
997 <                MyCaloHit temp_HcalHBHEHit;
493 <                temp_HcalHBHEHit.E      = HcalHBHE_RecHits[hh].energy();
494 <                temp_HcalHBHEHit.t      = HcalHBHE_RecHits[hh].time();
495 <                temp_HcalHBHEHit.DetId = (HcalHBHE_RecHits[hh].detid()).rawId();
996 >           FROG_Element_Base_With_DetId* frogHitColl = new FROG_Element_Base_With_DetId(C_FEB_DETID, EVTID_HCALHIT + i + 1);
997 >           frogHcalHit->addDaughter(frogHitColl);
998  
999 <                MyEvent->MyHcalCaloHitCollection.push_back(temp_HcalHBHEHit);
999 >           for(unsigned int hh=0;hh<HcalHBHE_RecHits.size();hh++){
1000 >                FROG_Element_Event_CaloHit* frogCaloHit = new FROG_Element_Event_CaloHit((HcalHBHE_RecHits[hh].detid()).rawId(),
1001 >                        HcalHBHE_RecHits[hh].energy(), HcalHBHE_RecHits[hh].time());
1002 >                frogHitColl->addDaughter(frogCaloHit);
1003             }
1004          }
1005  
501
1006          for(unsigned int i=0;i<HcalHORecHitProducers.size();i++){
1007             edm::Handle<HORecHitCollection > h_HcalHO_RecHits;
1008             iEvent.getByLabel(HcalHORecHitProducers[i], h_HcalHO_RecHits);
1009             HORecHitCollection HcalHO_RecHits = *h_HcalHO_RecHits.product();
1010  
1011 <           for(unsigned int hh=0;hh<HcalHO_RecHits.size();hh++){
1012 <                MyCaloHit temp_HcalHOHit;
509 <                temp_HcalHOHit.E      = HcalHO_RecHits[hh].energy();
510 <                temp_HcalHOHit.t      = HcalHO_RecHits[hh].time();
511 <                temp_HcalHOHit.DetId = (HcalHO_RecHits[hh].detid()).rawId();
1011 >           FROG_Element_Base_With_DetId* frogHitColl = new FROG_Element_Base_With_DetId(C_FEB_DETID, EVTID_HCALHIT + HcalHBHERecHitProducers.size() + i + 1);
1012 >           frogHcalHit->addDaughter(frogHitColl);
1013  
1014 <                MyEvent->MyHcalCaloHitCollection.push_back(temp_HcalHOHit);
1014 >           for(unsigned int hh=0;hh<HcalHO_RecHits.size();hh++){
1015 >                FROG_Element_Event_CaloHit* frogCaloHit = new FROG_Element_Event_CaloHit((HcalHO_RecHits[hh].detid()).rawId(),
1016 >                        HcalHO_RecHits[hh].energy(), HcalHO_RecHits[hh].time());
1017 >                frogHitColl->addDaughter(frogCaloHit);
1018             }
1019          }
1020  
517
1021          for(unsigned int i=0;i<HcalHFRecHitProducers.size();i++){
1022             edm::Handle<HFRecHitCollection > h_HcalHF_RecHits;
1023             iEvent.getByLabel(HcalHFRecHitProducers[i], h_HcalHF_RecHits);
1024             HFRecHitCollection HcalHF_RecHits = *h_HcalHF_RecHits.product();
1025  
1026 +           FROG_Element_Base_With_DetId* frogHitColl = new FROG_Element_Base_With_DetId(C_FEB_DETID, EVTID_HCALHIT + HcalHBHERecHitProducers.size() + HcalHORecHitProducers.size() + i + 1);
1027 +           frogHcalHit->addDaughter(frogHitColl);
1028 +
1029             for(unsigned int hh=0;hh<HcalHF_RecHits.size();hh++){
1030 <                MyCaloHit temp_HcalHFHit;
1031 <                temp_HcalHFHit.E      = HcalHF_RecHits[hh].energy();
1032 <                temp_HcalHFHit.t      = HcalHF_RecHits[hh].time();
1033 <                temp_HcalHFHit.DetId = (HcalHF_RecHits[hh].detid()).rawId();
1030 >                FROG_Element_Event_CaloHit* frogCaloHit = new FROG_Element_Event_CaloHit((HcalHF_RecHits[hh].detid()).rawId(),
1031 >                        HcalHF_RecHits[hh].energy(), HcalHF_RecHits[hh].time());
1032 >                frogHitColl->addDaughter(frogCaloHit);
1033 >           }
1034 >        }
1035 >
1036  
1037 <                MyEvent->MyHcalCaloHitCollection.push_back(temp_HcalHFHit);
1037 >        // ### Muon Segments ###
1038 >        FROG_Element_Base_With_DetId* frogMuonSeg = new FROG_Element_Base_With_DetId(C_FEB_DETID, EVTID_MUONSEG);
1039 >        event->addDaughter(frogMuonSeg);
1040 >
1041 >        for(unsigned int i=0;i<CSCSegmentProducers.size();i++){
1042 >           edm::Handle<CSCSegmentCollection > h_CSC_Segments;
1043 >           iEvent.getByLabel(CSCSegmentProducers[i], h_CSC_Segments);
1044 >           CSCSegmentCollection CSC_Segments = *h_CSC_Segments.product();
1045 >
1046 >           FROG_Element_Base_With_DetId* frogSegColl = new FROG_Element_Base_With_DetId(C_FEB_DETID, EVTID_MUONSEG + i + 1);
1047 >           frogMuonSeg->addDaughter(frogSegColl);
1048 >
1049 >           for(unsigned int s=0;s<CSC_Segments.size();s++){
1050 >                DetId theDetUnitId = CSC_Segments[s].geographicalId();
1051 >                const GeomDet* theDet = CscGeom->idToDet(theDetUnitId);
1052 >
1053 >                FROG_Element_Event_Segment* frogSeg = new FROG_Element_Event_Segment(theDetUnitId.rawId(),
1054 >                theDet->surface().toGlobal(CSC_Segments[s].localPosition()).x() , theDet->surface().toGlobal(CSC_Segments[s].localPosition()).y() , theDet->surface().toGlobal(CSC_Segments[s].localPosition()).z()  ,
1055 >                theDet->surface().toGlobal(CSC_Segments[s].localDirection()).x(), theDet->surface().toGlobal(CSC_Segments[s].localDirection()).y(), theDet->surface().toGlobal(CSC_Segments[s].localDirection()).z() );
1056 >                frogSegColl->addDaughter(frogSeg);
1057             }
1058          }
1059  
1060 <        MyEvents->Events.push_back(MyEvent);  
1060 >        for(unsigned int i=0;i<DTSegmentProducers.size();i++){
1061 >           edm::Handle<DTRecSegment4DCollection > h_DT_Segments;
1062 >           iEvent.getByLabel(DTSegmentProducers[i], h_DT_Segments);
1063 >           DTRecSegment4DCollection DT_Segments = *h_DT_Segments.product();
1064 >
1065 >           FROG_Element_Base_With_DetId* frogSegColl = new FROG_Element_Base_With_DetId(C_FEB_DETID, EVTID_MUONSEG + CSCSegmentProducers.size() + i + 1);
1066 >           frogMuonSeg->addDaughter(frogSegColl);
1067 >
1068 >           for(unsigned int s=0;s<DT_Segments.size();s++){
1069 >                DetId theDetUnitId = DT_Segments[s].geographicalId();
1070 >                const GeomDet* theDet = DtGeom->idToDet(theDetUnitId);
1071 >
1072 >                FROG_Element_Event_Segment* frogSeg = new FROG_Element_Event_Segment(theDetUnitId.rawId(),
1073 >                theDet->surface().toGlobal(DT_Segments[s].localPosition()).x() , theDet->surface().toGlobal(DT_Segments[s].localPosition()).y() , theDet->surface().toGlobal(DT_Segments[s].localPosition()).z()  ,
1074 >                theDet->surface().toGlobal(DT_Segments[s].localDirection()).x(), theDet->surface().toGlobal(DT_Segments[s].localDirection()).y(), theDet->surface().toGlobal(DT_Segments[s].localDirection()).z() );
1075 >                frogSegColl->addDaughter(frogSeg);
1076 >           }
1077 >        }
1078 >
1079 >        // ### Muon Hits ###
1080 >        FROG_Element_Base_With_DetId* frogMuonHit = new FROG_Element_Base_With_DetId(C_FEB_DETID, EVTID_MUONHIT);
1081 >        event->addDaughter(frogMuonHit);
1082 >        for(unsigned int i=0;i<RPCHitsProducers.size();i++){
1083 >           edm::Handle<RPCRecHitCollection > h_RPC_Hits;
1084 >           iEvent.getByLabel(RPCHitsProducers[i], h_RPC_Hits);
1085 >           RPCRecHitCollection RPC_Hits = *h_RPC_Hits.product();
1086 >
1087 >           FROG_Element_Base_With_DetId* frogHitColl = new FROG_Element_Base_With_DetId(C_FEB_DETID, EVTID_MUONHIT + i + 1);
1088 >           frogMuonHit->addDaughter(frogHitColl);
1089 >
1090 >           for(unsigned int h=0;h<RPC_Hits.size();h++){
1091 >                DetId theDetUnitId = RPC_Hits[h].geographicalId();
1092 >                const GeomDet* theDet = RpcGeom->idToDet(theDetUnitId);
1093 >
1094 >                FROG_Element_Event_Hit* frogHit = new FROG_Element_Event_Hit(theDetUnitId.rawId(),
1095 >                theDet->surface().toGlobal(RPC_Hits[h].localPosition()).x() , theDet->surface().toGlobal(RPC_Hits[h].localPosition()).y() , theDet->surface().toGlobal(RPC_Hits[h].localPosition()).z(), -1 );
1096 >                frogHitColl->addDaughter(frogHit);
1097 >           }
1098 >        }
1099 >
1100 >
1101 >
1102 >        // ### Calo Jets ###
1103 >        FROG_Element_Base_With_DetId* frogCaloJet = new FROG_Element_Base_With_DetId(C_FEB_DETID, EVTID_JET_CALO);
1104 >        event->addDaughter(frogCaloJet);
1105 >        for(unsigned int i=0;i<CaloJetsProducers.size();i++){
1106 >           edm::Handle<CaloJetCollection> h_Calo_Jets;
1107 >           iEvent.getByLabel(CaloJetsProducers[i], h_Calo_Jets);
1108 >           CaloJetCollection Calo_Jets = *h_Calo_Jets.product();
1109 >
1110 >           FROG_Element_Base_With_DetId* frogCaloJetColl = new FROG_Element_Base_With_DetId(C_FEB_DETID, EVTID_JET_CALO + i + 1);
1111 >           frogCaloJet->addDaughter(frogCaloJetColl);
1112 >
1113 >           for(unsigned int h=0;h<Calo_Jets.size();h++){
1114 > //                DetId theDetUnitId = RPC_Hits[h].geographicalId();
1115 > //                const GeomDet* theDet = RpcGeom->idToDet(theDetUnitId);
1116 >
1117 >                FROG_Element_Event_Jet* frogJet = new FROG_Element_Event_Jet(Calo_Jets[h].eta(),Calo_Jets[h].phi(),Calo_Jets[h].energy());
1118 >                frogCaloJet->addDaughter(frogJet);
1119 >                printf("AddJet\n");
1120 >           }
1121 >        }
1122 >
1123 >        // ### Calo Jets in cartesian coord ###
1124 >        FROG_Element_Base_With_DetId* frogCaloJetCand = new FROG_Element_Base_With_DetId(C_FEB_DETID, EVTID_RECOCAND);
1125 >        event->addDaughter(frogCaloJetCand);
1126 >        for(unsigned int i=0;i<CaloJetsProducers.size();i++){
1127 >           edm::Handle<CaloJetCollection> h_Calo_Jets;
1128 >           iEvent.getByLabel(CaloJetsProducers[i], h_Calo_Jets);
1129 >           CaloJetCollection Calo_Jets = *h_Calo_Jets.product();
1130 >
1131 >           FROG_Element_Base_With_DetId* frogCaloJetCollCand = new FROG_Element_Base_With_DetId(C_FEB_DETID, EVTID_RECOCAND + i + 1);
1132 >           frogCaloJetCand->addDaughter(frogCaloJetCollCand);
1133 >
1134 >           for(unsigned int h=0;h<Calo_Jets.size();h++){
1135 > //                DetId theDetUnitId = RPC_Hits[h].geographicalId();
1136 > //                const GeomDet* theDet = RpcGeom->idToDet(theDetUnitId);
1137 >
1138 >                FROG_Element_Event_Candidate* frogCandidate = new FROG_Element_Event_Candidate(Calo_Jets[h].px(),Calo_Jets[h].py(),Calo_Jets[h].pz());
1139 >                frogCaloJetCand->addDaughter(frogCandidate);
1140 >                printf("AddJetCand\n");
1141 >           }
1142 >        }
1143 >
1144 >
1145 >
1146 >   NEvents++;
1147 >   if(NEvents == NEventsInVisFile){
1148 >      char OutputFileName[1024];
1149 >      sprintf(OutputFileName,"%s",OutputFile.substr(0,OutputFile.size()-4).c_str());
1150 >      if(NEventsInVisFile>=0)sprintf(OutputFileName,"%s_R%i_E%i.vis",OutputFileName,SRun,SEvent);
1151 >      sprintf(OutputFileName,"%s.vis",OutputFileName);
1152 >
1153 >      FROG_Events* events = new FROG_Events(events_prim);
1154 >      events->Save((char*) OutputFileName);
1155 >      delete events;
1156 >      delete events_prim;
1157 >
1158 >      events_prim = new FROG_Element_Base(C_PRIMARY);
1159 >      NEvents=0;
1160 >   }
1161 >
1162   }
1163  
1164  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines