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.2 by querten, Sat Apr 19 14:34:58 2008 UTC vs.
Revision 1.27 by querten, Tue Aug 19 14:38:38 2008 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines