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.14 by roberfro, Tue Jun 24 15:17:22 2008 UTC vs.
Revision 1.45 by querten, Mon Oct 13 06:54:15 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 >
56 > #include "Geometry/EcalAlgo/interface/EcalBarrelGeometry.h"
57 > #include "Geometry/EcalAlgo/interface/EcalEndcapGeometry.h"
58   #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
59   #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
60  
# Line 60 | Line 64
64   #include "Geometry/CSCGeometry/interface/CSCGeometry.h"
65   #include "Geometry/RPCGeometry/interface/RPCGeometry.h"
66  
67 + #include "DataFormats/Common/interface/DetSetVector.h"
68 + #include "DataFormats/Common/interface/DetSetVectorNew.h"
69 +
70 + #include "DataFormats/SiStripCluster/interface/SiStripClusterCollection.h"
71  
72   #include "DataFormats/CaloRecHit/interface/CaloRecHit.h"
73   #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
# Line 82 | Line 90
90   #include "TrackingTools/PatternTools/interface/Trajectory.h"
91   #include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h"
92  
93 + #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
94 +
95  
96   #include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h"
97   #include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h"
# Line 112 | Line 122
122   #include "DataFormats/EcalDetId/interface/ESDetId.h"
123   #include "DataFormats/HcalDetId/interface/HcalDetId.h"
124  
125 < #include "Visualisation/Frog/soft/Includes/FROG/FROG_Element_Base_With_DetId.h"
125 > #include "DataFormats/VertexReco/interface/NuclearInteraction.h"
126 >
127 > #include "DataFormats/JetReco/interface/Jet.h"
128 > #include "DataFormats/JetReco/interface/BasicJetCollection.h"
129 > #include "DataFormats/JetReco/interface/GenJetCollection.h"
130 > #include "DataFormats/JetReco/interface/CaloJetCollection.h"
131 > #include "DataFormats/JetReco/interface/PFJetCollection.h"
132 > #include "DataFormats/METReco/interface/CaloMET.h"
133 > #include "DataFormats/METReco/interface/CaloMETFwd.h"
134 >
135 > #define FROG_ZLIB
136 >
137 > //#include "Visualisation/Frog/soft/Includes/FROG/FROG_Element_Base_With_DetId_And_Name.h"
138   #include "Visualisation/Frog/soft/Includes/FROG/FROG_Element_Tools.h"
139   #include "Visualisation/Frog/soft/Includes/FROG/FROG_Element_Tools.cpp"
140   #include "Visualisation/Frog/soft/Includes/FROG/FROG_Element_Event_Track.h"
# Line 124 | Line 146
146   #include "Visualisation/Frog/soft/Includes/FROG/FROG_Geometry.cpp"
147  
148   #include "Visualisation/Frog/soft/Includes/FROG/FROG_DetId.h"
149 + #include "Visualisation/Frog/soft/Includes/FROG/FROG_ReadCards.cpp"
150 + #include "Visualisation/Frog/soft/Includes/FROG/FROG_Element_Event_NuclInt.h"
151 +
152 + #include "Visualisation/Frog/soft/Includes/FROG/FROG_Coord.h"
153 + #include "Visualisation/Frog/soft/Includes/FROG/FROG_Coord.cpp"
154 +
155 + #include "Visualisation/Frog/soft/Includes/FROG/FROG_ZLib.h"
156 + #include "Visualisation/Frog/soft/Includes/FROG/FROG_ZLib.cpp"
157 +
158  
159  
160   using namespace edm;
161   using namespace std;
162 + using namespace reco;
163  
164   //
165   // class decleration
# Line 144 | Line 176 | class Frog_Analyzer : public edm::EDAnal
176        virtual void analyze (const edm::Event&, const edm::EventSetup&);
177        virtual void endJob  ();
178  
179 <      FROG_Events*          events;
148 <      FROG_Element_Base*    event_prim;
179 >      FROG_Element_Base*    events_prim;
180  
181        std::string           OutputFile;
182  
183 +      std::vector<InputTag> GenParticlesProducers;
184 +
185        std::vector<InputTag> SimTrackProducers;
186        std::vector<InputTag> SimVertexProducers;
187        std::vector<InputTag> SimHitProducers;
188 +      std::vector<InputTag> SimCaloHitProducers;
189 +
190 +      std::vector<InputTag> NIProducers;
191  
192        std::vector<InputTag> TrackProducers;
193        std::vector<InputTag> TrajectoryProducers;
194 +      std::vector<InputTag> SiStripClusterProducers;
195        std::vector<InputTag> EcalRecHitProducers;
196        std::vector<InputTag> HcalHBHERecHitProducers;
197        std::vector<InputTag> HcalHORecHitProducers;
# Line 164 | Line 201 | class Frog_Analyzer : public edm::EDAnal
201  
202        std::vector<InputTag> RPCHitsProducers;
203  
204 +      std::vector<InputTag> CaloTowersProducers;
205 +      bool                  CaloTowersProducersBasedOnCaloHits;
206 +
207 +      std::vector<InputTag> BasicJetsProducers;
208 +      std::vector<InputTag> CaloJetsProducers;
209 +      bool                  CaloJetsProducersBasedOnCaloTowers;
210 +
211 +      std::vector<InputTag> RecoCandidateProducers;
212 +      std::vector<InputTag> CaloMETProducers;
213 +
214  
215        // ----------member data ---------------------------
216 +
217 +      bool                  CompressFiles;
218 +
219 +
220 +      bool                  ProduceGeom;
221 +      int                   NEventsInVisFile;
222 +      int                   NEvents;
223 +
224 +      unsigned int          SRun;
225 +      unsigned int          SEvent;
226   };
227  
228   //
# Line 175 | Line 232 | Frog_Analyzer::Frog_Analyzer(const edm::
232   {
233      OutputFile              = iConfig.getParameter<std::string >("OutputFile");
234  
235 +    GenParticlesProducers   = iConfig.getParameter<std::vector<InputTag> >("GenParticlesProducers");
236 +
237      SimTrackProducers       = iConfig.getParameter<std::vector<InputTag> >("SimTrackProducers");
238      SimVertexProducers      = iConfig.getParameter<std::vector<InputTag> >("SimVertexProducers");
239      SimHitProducers         = iConfig.getParameter<std::vector<InputTag> >("SimHitProducers");
240 +    SimCaloHitProducers     = iConfig.getParameter<std::vector<InputTag> >("SimCaloHitProducers");
241 +
242  
243      TrackProducers          = iConfig.getParameter<std::vector<InputTag> >("TrackProducers");
244      TrajectoryProducers     = iConfig.getParameter<std::vector<InputTag> >("TrajectoryProducers");
245 +    SiStripClusterProducers = iConfig.getParameter<std::vector<InputTag> >("SiStripClusterProducers");
246      EcalRecHitProducers     = iConfig.getParameter<std::vector<InputTag> >("EcalRecHitProducers");
247      HcalHBHERecHitProducers = iConfig.getParameter<std::vector<InputTag> >("HcalHBHERecHitProducers");
248      HcalHORecHitProducers   = iConfig.getParameter<std::vector<InputTag> >("HcalHORecHitProducers");
249      HcalHFRecHitProducers   = iConfig.getParameter<std::vector<InputTag> >("HcalHFRecHitProducers");
250  
251 +    NIProducers             = iConfig.getParameter<std::vector<InputTag> >("NIProducers");
252 +
253      DTSegmentProducers      = iConfig.getParameter<std::vector<InputTag> >("DTSegmentProducers");
254      CSCSegmentProducers     = iConfig.getParameter<std::vector<InputTag> >("CSCSegmentProducers");
255  
256      RPCHitsProducers        = iConfig.getParameter<std::vector<InputTag> >("RPCHitsProducers");
257  
258 +    CaloTowersProducers     = iConfig.getParameter<std::vector<InputTag> >("CaloTowersProducers");
259 +    CaloTowersProducersBasedOnCaloHits = iConfig.getParameter<bool>("CaloTowersProducersBasedOnCaloHits");
260 +
261 +
262 +    BasicJetsProducers      = iConfig.getParameter<std::vector<InputTag> >("BasicJetsProducers");
263 +    CaloJetsProducers       = iConfig.getParameter<std::vector<InputTag> >("CaloJetsProducers");
264 +    CaloJetsProducersBasedOnCaloTowers = iConfig.getParameter<bool>("CaloJetsProducersBasedOnCaloTowers");
265 +
266 +    RecoCandidateProducers  = iConfig.getParameter<std::vector<InputTag> >("RecoCandidateProducers");
267 +    CaloMETProducers        = iConfig.getParameter<std::vector<InputTag> >("CaloMETProducers");
268 +
269 +    ProduceGeom             = iConfig.getParameter<bool  >("ProduceGeom"       );
270 +    NEventsInVisFile        = iConfig.getParameter<int   >("NEventsInVisFile"  );
271 +    CompressFiles           = iConfig.getParameter<bool  >("CompressFiles"     );
272 +
273 +
274 +    NEvents = 0;
275   }
276  
277  
# Line 202 | Line 283 | Frog_Analyzer::~Frog_Analyzer()
283   void
284   Frog_Analyzer::beginJob(const edm::EventSetup& iSetup)
285   {
286 <   DetId  Detid;
287 <   unsigned int    SubDet;
288 <
289 <   unsigned int Frog_DetId;
290 <   FROG_Element_Base*            FEB      = NULL;
291 <   FROG_Element_Base_With_DetId* FEB_Temp = NULL;
292 <
293 <   FROG_Element_Base* prim               = new FROG_Element_Base(C_PRIMARY);
294 <   FROG_Element_Base* geom               = new FROG_Element_Base(C_GEOMETRY);                          prim->addDaughter(geom);
295 <   FROG_Element_Base_With_DetId* tracker = new FROG_Element_Base_With_DetId(C_FEB_DETID, DETID_TRK);   geom->addDaughter(tracker);
296 <   FROG_Element_Base_With_DetId* muon    = new FROG_Element_Base_With_DetId(C_FEB_DETID, DETID_MUON);  geom->addDaughter(muon);
297 <   FROG_Element_Base_With_DetId* ecal    = new FROG_Element_Base_With_DetId(C_FEB_DETID, DETID_ECAL);  geom->addDaughter(ecal);
298 <   FROG_Element_Base_With_DetId* hcal    = new FROG_Element_Base_With_DetId(C_FEB_DETID, DETID_HCAL);  geom->addDaughter(hcal);
299 <
300 <
220 <   // ### TRACKER GEOMETRY ###
221 <
222 <   edm::ESHandle<TrackerGeometry> tkGeom;
223 <   iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom );
224 <   vector<GeomDet*> TrackerDets = tkGeom->dets();
225 <
226 <   for(unsigned int i=0;i<TrackerDets.size();i++){
227 <      Detid  = TrackerDets[i]->geographicalId();
228 <      SubDet = Detid.subdetId();
229 <      if(SubDet<1 || SubDet>6) continue;
230 <
231 <  
232 <      GeomDet* DetUnit = TrackerDets[i];
233 <      if(!DetUnit)continue;
234 <      const BoundPlane plane = DetUnit->surface();
235 <      const TrapezoidalPlaneBounds* trapezoidalBounds( dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
236 <      const RectangularPlaneBounds* rectangularBounds( dynamic_cast<const RectangularPlaneBounds*>(&(plane.bounds())));  
237 <
238 <      float width            = 0;
239 <      float length           = 0;
240 <      float thickness        = 0;
241 <      float TrapezoidalParam = 0;
242 <
243 <      if(trapezoidalBounds){
244 <         std::vector<float> const & parameters = (*trapezoidalBounds).parameters();      
245 <         width            = parameters[0]*2;
246 <         length           = parameters[3]*2;  
247 <         thickness        = (*trapezoidalBounds).thickness();
248 <         TrapezoidalParam = parameters[1]/parameters[0];
249 <      }else if(rectangularBounds){
250 <         width            = DetUnit->surface().bounds().width();
251 <         length           = DetUnit->surface().bounds().length();
252 <         thickness        = DetUnit->surface().bounds().thickness();
253 <         TrapezoidalParam = 1;
254 <      }
255 <
256 <      Surface::GlobalPoint WidthVector  = plane.toGlobal( LocalPoint(width/2, 0, 0) );
257 <      Surface::GlobalPoint LengthVector = plane.toGlobal( LocalPoint(0, length/2, 0) );
258 <      Surface::GlobalPoint ThickVector  = plane.toGlobal( LocalPoint(0, 0, thickness/2) );
259 <
260 <      GlobalVector Pos =  GlobalVector(DetUnit->position().basicVector());
261 <
262 <      FROG_Element_Geom_TrackerMod* mod = new FROG_Element_Geom_TrackerMod(
263 <           Detid.rawId(),           TrapezoidalParam,
264 <           Pos.x(),                  Pos.y(),                  Pos.z(),
265 <           WidthVector.x() -Pos.x(), WidthVector.y() -Pos.y(), WidthVector.z() -Pos.z(),
266 <           LengthVector.x()-Pos.x(), LengthVector.y()-Pos.y(), LengthVector.z()-Pos.z(),
267 <           ThickVector.x() -Pos.x(), ThickVector.y() -Pos.y(), ThickVector.z() -Pos.z());
268 <
269 <
270 <      Frog_DetId = DETID_TRK;
271 <      FEB        = tracker;
272 <
273 <      Frog_DetId += SubDet*100000;
274 <      FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
275 <      FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
276 <      if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
277 <
278 <      if(SubDet==PixelSubdetector::PixelBarrel){
279 <         PXBDetId detid = PXBDetId(Detid);
286 >   if(ProduceGeom){
287 >      DetId  Detid;
288 >      unsigned int    SubDet;
289 >
290 >      unsigned int Frog_DetId;
291 >      FROG_Element_Base*            FEB      = NULL;
292 >      FROG_Element_Base_With_DetId_And_Name* FEB_Temp = NULL;
293 >
294 >      FROG_Element_Base* prim               = new FROG_Element_Base(C_PRIMARY);
295 >      FROG_Element_Base* geom               = new FROG_Element_Base(C_GEOMETRY);                                  prim->addDaughter(geom);
296 >      FROG_Element_Base_With_DetId_And_Name* tracker = new FROG_Element_Base_With_DetId_And_Name( DETID_TRK  , "Tracker"); geom->addDaughter(tracker);
297 >      FROG_Element_Base_With_DetId_And_Name* muon    = new FROG_Element_Base_With_DetId_And_Name( DETID_MUON , "Muon");    geom->addDaughter(muon);
298 >      FROG_Element_Base_With_DetId_And_Name* ecal    = new FROG_Element_Base_With_DetId_And_Name( DETID_ECAL , "ECAL");    geom->addDaughter(ecal);
299 >      FROG_Element_Base_With_DetId_And_Name* hcal    = new FROG_Element_Base_With_DetId_And_Name( DETID_HCAL , "HCAL");    geom->addDaughter(hcal);
300 >      FROG_Element_Base_With_DetId_And_Name* calo    = new FROG_Element_Base_With_DetId_And_Name( DETID_CALO , "Calo");    geom->addDaughter(calo);
301  
281         Frog_DetId += detid.layer()*10000;
282         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
283         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
284         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
302  
286         Frog_DetId += detid.ladder()*100;
287         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
288         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
289         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
290      }else if(SubDet==PixelSubdetector::PixelEndcap){
291         PXFDetId detid = PXFDetId(Detid);
292
293         Frog_DetId += detid.side()*10000;
294         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
295         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
296         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
303  
304 <         Frog_DetId += detid.disk()*1000;
305 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
306 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
307 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
304 >      // ### TRACKER GEOMETRY ###
305 >
306 >      edm::ESHandle<TrackerGeometry> tkGeom;
307 >      iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom );
308 >      vector<GeomDet*> TrackerDets = tkGeom->dets();
309 >
310 >      for(unsigned int i=0;i<TrackerDets.size();i++){
311 >         Detid  = TrackerDets[i]->geographicalId();
312 >         SubDet = Detid.subdetId();
313 >         if(SubDet<1 || SubDet>6) continue;
314  
315 <         Frog_DetId += detid.blade()*10;
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);}
315 >  
316 >         GeomDet* DetUnit = TrackerDets[i];
317 >         if(!DetUnit)continue;
318 >         const BoundPlane plane = DetUnit->surface();
319 >         const TrapezoidalPlaneBounds* trapezoidalBounds( dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
320 >         const RectangularPlaneBounds* rectangularBounds( dynamic_cast<const RectangularPlaneBounds*>(&(plane.bounds())));  
321 >
322 >         float width            = 0;
323 >         float length           = 0;
324 >         float thickness        = 0;
325 >         float TrapezoidalParam = 0;
326 >
327 >         if(trapezoidalBounds){
328 >            std::vector<float> const & parameters = (*trapezoidalBounds).parameters();      
329 >            width            = parameters[0]*2;
330 >            length           = parameters[3]*2;  
331 >            thickness        = (*trapezoidalBounds).thickness();
332 >            TrapezoidalParam = parameters[1]/parameters[0];
333 >         }else if(rectangularBounds){
334 >            width            = DetUnit->surface().bounds().width();
335 >            length           = DetUnit->surface().bounds().length();
336 >            thickness        = DetUnit->surface().bounds().thickness();
337 >            TrapezoidalParam = 1;
338 >         }
339  
340 <         Frog_DetId += detid.panel()*1;
341 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
342 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
343 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
344 <      }else if(SubDet==StripSubdetector::TIB){
345 <         TIBDetId detid = TIBDetId(Detid);
340 >         Surface::GlobalPoint WidthVector  = plane.toGlobal( LocalPoint(width/2, 0, 0) );
341 >         Surface::GlobalPoint LengthVector = plane.toGlobal( LocalPoint(0, length/2, 0) );
342 >         Surface::GlobalPoint ThickVector  = plane.toGlobal( LocalPoint(0, 0, thickness/2) );
343 >
344 >         GlobalVector Pos =  GlobalVector(DetUnit->position().basicVector());
345 >
346 >         FROG_Element_Geom_TrackerMod* mod = new FROG_Element_Geom_TrackerMod(
347 >              Detid.rawId(),           TrapezoidalParam,
348 >              Pos.x(),                  Pos.y(),                  Pos.z(),
349 >              WidthVector.x() -Pos.x(), WidthVector.y() -Pos.y(), WidthVector.z() -Pos.z(),
350 >              LengthVector.x()-Pos.x(), LengthVector.y()-Pos.y(), LengthVector.z()-Pos.z(),
351 >              ThickVector.x() -Pos.x(), ThickVector.y() -Pos.y(), ThickVector.z() -Pos.z());
352  
315         Frog_DetId += detid.layer()*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);}
353  
354 <         Frog_DetId += detid.stringNumber()*100;
355 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
354 >         Frog_DetId = DETID_TRK;
355 >         FEB        = tracker;
356 >
357 >         Frog_DetId += SubDet*100000;
358 >         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
359           FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
360 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
324 <      }else if(SubDet==StripSubdetector::TID){
325 <         TIDDetId detid = TIDDetId(Detid);
360 > //         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId); FEB_Temp->addDaughter(FEB);}
361  
362 <         Frog_DetId += detid.side()*10000;
363 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
329 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
330 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
362 >         if(SubDet==PixelSubdetector::PixelBarrel){
363 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "PIB"); FEB_Temp->addDaughter(FEB);}
364  
365 <         Frog_DetId += detid.wheel()*1000;
333 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
334 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
335 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
365 >            PXBDetId detid = PXBDetId(Detid);
366  
367 <         Frog_DetId += detid.ring()*10;
368 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
369 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
370 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
341 <      }else if(SubDet==StripSubdetector::TOB){
342 <         TOBDetId detid = TOBDetId(Detid);
367 >            Frog_DetId += detid.layer()*10000;
368 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
369 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
370 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Layer%i", detid.layer() ); FEB_Temp->addDaughter(FEB);}
371  
372 <         Frog_DetId += detid.layer()*10000;
373 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
374 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
375 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
372 >            Frog_DetId += detid.ladder()*100;
373 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
374 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
375 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Ladder%i", detid.ladder() ); FEB_Temp->addDaughter(FEB);}
376 >         }else if(SubDet==PixelSubdetector::PixelEndcap){
377 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "PIE"); FEB_Temp->addDaughter(FEB);}
378 >
379 >            PXFDetId detid = PXFDetId(Detid);
380 >
381 >            Frog_DetId += detid.side()*10000;
382 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
383 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
384 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Side%i",detid.side()); FEB_Temp->addDaughter(FEB);}
385  
386 <         Frog_DetId += detid.rodNumber()*100;
387 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
388 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
389 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
353 <      }else if(SubDet==StripSubdetector::TEC){
354 <         TECDetId detid = TECDetId(Detid);
386 >            Frog_DetId += detid.disk()*1000;
387 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
388 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
389 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Disk%i", detid.disk()); FEB_Temp->addDaughter(FEB);}
390  
391 <         Frog_DetId += detid.side()*10000;
392 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
393 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
394 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
391 >            Frog_DetId += detid.blade()*10;
392 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
393 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
394 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Blade%i", detid.blade()); FEB_Temp->addDaughter(FEB);}
395  
396 <         Frog_DetId += detid.wheel()*1000;
397 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
398 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
399 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
396 >            Frog_DetId += detid.panel()*1;
397 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
398 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
399 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Panel%i", detid.panel()); FEB_Temp->addDaughter(FEB);}
400 >         }else if(SubDet==StripSubdetector::TIB){
401 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "TIB"); FEB_Temp->addDaughter(FEB);}
402  
403 <         Frog_DetId += detid.ring()*10;
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);}
403 >            TIBDetId detid = TIBDetId(Detid);
404  
405 <         Frog_DetId += detid.petalNumber();
406 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
407 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
408 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
375 <      }else{
376 <         if(mod)delete mod;
377 <         continue;
378 <      }
379 <      FEB->addDaughter(mod);
380 <   }
405 >            Frog_DetId += detid.layer()*10000;
406 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
407 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
408 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Layer%i", detid.layer()); FEB_Temp->addDaughter(FEB);}
409  
410 +            Frog_DetId += detid.stringNumber()*100;
411 +            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
412 +            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
413 +            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "String%i", detid.stringNumber()); FEB_Temp->addDaughter(FEB);}
414 +         }else if(SubDet==StripSubdetector::TID){
415 +            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "TID"); FEB_Temp->addDaughter(FEB);}
416  
417 <   // ### MUON GEOMETRY ###
417 >            TIDDetId detid = TIDDetId(Detid);
418  
419 <   edm::ESHandle<DTGeometry> DtGeom;
420 <   iSetup.get<MuonGeometryRecord>().get( DtGeom );
421 <   const vector<GeomDet*> DtDets = DtGeom->dets();
422 <
389 <   edm::ESHandle<CSCGeometry> CscGeom;
390 <   iSetup.get<MuonGeometryRecord>().get( CscGeom );
391 <   const vector<GeomDet*> CscDets = CscGeom->dets();
392 <
393 <   edm::ESHandle<RPCGeometry> RpcGeom;
394 <   iSetup.get<MuonGeometryRecord>().get( RpcGeom );
395 <   const vector<GeomDet*> RpcDets = RpcGeom->dets();
396 <
397 <   vector<GeomDet*> MuonDets;
398 <   for(unsigned int i=0;i<DtDets.size() ;i++){MuonDets.push_back(DtDets [i]);}
399 <   for(unsigned int i=0;i<CscDets.size();i++){MuonDets.push_back(CscDets[i]);}
400 <   for(unsigned int i=0;i<RpcDets.size();i++){MuonDets.push_back(RpcDets[i]);}
401 <
402 <
403 <   for(unsigned int i=0;i<MuonDets.size();i++)
404 <   {
405 <      Detid  = DetId(MuonDets[i]->geographicalId());
406 <      SubDet = Detid.subdetId();
407 <
408 <      GeomDet* DetUnit = MuonDets[i];
409 <      if(!DetUnit)continue;
410 <      const BoundPlane plane = DetUnit->surface();
411 <      const TrapezoidalPlaneBounds* trapezoidalBounds( dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
412 <      const RectangularPlaneBounds* rectangularBounds( dynamic_cast<const RectangularPlaneBounds*>(&(plane.bounds())));
413 <
414 <      float width            = 0;
415 <      float length           = 0;
416 <      float thickness        = 0;
417 <      float TrapezoidalParam = 0;
419 >            Frog_DetId += detid.side()*10000;
420 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
421 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
422 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Slide%i", detid.side()); FEB_Temp->addDaughter(FEB);}
423  
424 <      if(trapezoidalBounds)
425 <      {
426 <         std::vector<float> const & parameters = (*trapezoidalBounds).parameters();
427 <         width            = parameters[0]*2;
428 <         length           = parameters[3]*2;
429 <         thickness        =  (*trapezoidalBounds).thickness();
430 <         TrapezoidalParam = parameters[1]/parameters[0];
431 <      }else if(rectangularBounds){
432 <         width            = DetUnit->surface().bounds().width();
433 <         length           = DetUnit->surface().bounds().length();
434 <         thickness        = DetUnit->surface().bounds().thickness();
430 <         TrapezoidalParam = 1;
431 <      }
424 >            Frog_DetId += detid.wheel()*1000;
425 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
426 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
427 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Wheel%i", detid.wheel()); FEB_Temp->addDaughter(FEB);}
428 >
429 >            Frog_DetId += detid.ring()*10;
430 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
431 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
432 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Ring%i", detid.ring()); FEB_Temp->addDaughter(FEB);}
433 >         }else if(SubDet==StripSubdetector::TOB){
434 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "TOB"); FEB_Temp->addDaughter(FEB);}
435  
436 <      Surface::GlobalPoint WidthVector  = plane.toGlobal( LocalPoint(width/2, 0, 0) );
434 <      Surface::GlobalPoint LengthVector = plane.toGlobal( LocalPoint(0, length/2, 0) );
435 <      Surface::GlobalPoint ThickVector  = plane.toGlobal( LocalPoint(0, 0, thickness/2) );
436 <
437 <      GlobalVector Pos =  GlobalVector(DetUnit->position().basicVector());
438 <
439 <      FROG_Element_Geom_TrackerMod* mod = new FROG_Element_Geom_TrackerMod(
440 <           Detid.rawId(),           TrapezoidalParam,
441 <           Pos.x(),                  Pos.y(),                  Pos.z(),
442 <           WidthVector.x() -Pos.x(), WidthVector.y() -Pos.y(), WidthVector.z() -Pos.z(),
443 <           LengthVector.x()-Pos.x(), LengthVector.y()-Pos.y(), LengthVector.z()-Pos.z(),
444 <           ThickVector.x() -Pos.x(), ThickVector.y() -Pos.y(), ThickVector.z() -Pos.z());
445 <
446 <      Frog_DetId = DETID_MUON;
447 <      FEB        = muon;
448 <
449 <      Frog_DetId += SubDet*100000;
450 <      FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
451 <      FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
452 <      if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
436 >            TOBDetId detid = TOBDetId(Detid);
437  
438 <      if(SubDet==1){
439 <         DTChamberId detid = DTChamberId(Detid);
438 >            Frog_DetId += detid.layer()*10000;
439 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
440 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
441 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Layer%i",  detid.layer()); FEB_Temp->addDaughter(FEB);}
442  
443 <         Frog_DetId += (detid.wheel()+3)*10000;
444 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
445 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
446 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
443 >            Frog_DetId += detid.rodNumber()*100;
444 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
445 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
446 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Rod%i", detid.rodNumber()); FEB_Temp->addDaughter(FEB);}
447 >         }else if(SubDet==StripSubdetector::TEC){
448 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "TEC"); FEB_Temp->addDaughter(FEB);}
449  
450 <         Frog_DetId += detid.station()*100;
463 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
464 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
465 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
450 >            TECDetId detid = TECDetId(Detid);
451  
452 <         Frog_DetId += detid.sector()*1;
453 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
454 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
455 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
471 <      }else if(SubDet==2){
472 <         CSCDetId detid = CSCDetId(Detid);
473 <  
474 <         Frog_DetId += detid.endcap()*10000;
475 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
476 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
477 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
478 <  
479 <         Frog_DetId += detid.station()*1000;
480 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
481 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
482 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
483 <  
484 <         Frog_DetId += detid.ring()*100;
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);}
452 >            Frog_DetId += detid.side()*10000;
453 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
454 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
455 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Side%i",detid.side()); FEB_Temp->addDaughter(FEB);}
456  
457 <         Frog_DetId += detid.chamber()*1;
458 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
459 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
460 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
493 <      }else if(SubDet==3){
494 <         RPCDetId detid = RPCDetId(Detid);
457 >            Frog_DetId += detid.wheel()*1000;
458 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
459 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
460 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Wheel%i", detid.wheel() ); FEB_Temp->addDaughter(FEB);}
461  
462 <         Frog_DetId += (detid.region()+2)*10000;
463 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
464 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
465 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
462 >            Frog_DetId += detid.ring()*10;
463 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
464 >            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
465 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Ring%i", detid.ring()); FEB_Temp->addDaughter(FEB);}
466  
467 <         // Barrel
468 <         if(detid.region()==0){
503 <            Frog_DetId += (detid.ring()+3)*1000;
504 <            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
467 >            Frog_DetId += detid.petalNumber();
468 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
469              FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
470 <            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
507 <         // Endcap
470 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Petal%i", detid.petalNumber()); FEB_Temp->addDaughter(FEB);}
471           }else{
472 <            Frog_DetId += detid.ring()*1000;
473 <            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);}
472 >            if(mod)delete mod;
473 >            continue;
474           }
475 <
515 <         Frog_DetId += detid.station()*100;
516 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
517 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
518 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
519 <
520 <         Frog_DetId += detid.sector()*1;
521 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
522 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
523 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
475 >         FEB->addDaughter(mod);
476        }
477  
526      FEB->addDaughter(mod);
527   }
478  
479 +      // ### MUON GEOMETRY ###
480  
481 <      
482 <   // ### CALO GEOMETRY ###
481 >      edm::ESHandle<DTGeometry> DtGeom;
482 >      iSetup.get<MuonGeometryRecord>().get( DtGeom );
483 >      const vector<GeomDet*> DtDets = DtGeom->dets();
484 >
485 >      edm::ESHandle<CSCGeometry> CscGeom;
486 >      iSetup.get<MuonGeometryRecord>().get( CscGeom );
487 >      const vector<GeomDet*> CscDets = CscGeom->dets();
488 >
489 >      edm::ESHandle<RPCGeometry> RpcGeom;
490 >      iSetup.get<MuonGeometryRecord>().get( RpcGeom );
491 >      const vector<GeomDet*> RpcDets = RpcGeom->dets();
492 >
493 >      vector<GeomDet*> MuonDets;
494 >      for(unsigned int i=0;i<DtDets.size() ;i++){MuonDets.push_back(DtDets [i]);}
495 >      for(unsigned int i=0;i<CscDets.size();i++){MuonDets.push_back(CscDets[i]);}
496 >      for(unsigned int i=0;i<RpcDets.size();i++){MuonDets.push_back(RpcDets[i]);}
497  
498 <   edm::ESHandle<CaloGeometry> CaloGeom;
499 <   iSetup.get<IdealGeometryRecord>().get( CaloGeom );
500 <   const vector<DetId> CaloDets = CaloGeom->getValidDetIds();
501 <
537 <   for(unsigned int i=0;i<CaloDets.size();i++)
538 <   {
539 <      Detid  = CaloDets[i];
540 <      SubDet = Detid.subdetId();
498 >      for(unsigned int i=0;i<MuonDets.size();i++)
499 >      {
500 >         Detid  = DetId(MuonDets[i]->geographicalId());
501 >         SubDet = Detid.subdetId();
502  
503 <      if(Detid.det()==DetId::Ecal){
504 <        if(SubDet<1 || SubDet>3) continue;
503 >         GeomDet* DetUnit = MuonDets[i];
504 >         if(!DetUnit)continue;
505 >         const BoundPlane plane = DetUnit->surface();
506 >         const TrapezoidalPlaneBounds* trapezoidalBounds( dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
507 >         const RectangularPlaneBounds* rectangularBounds( dynamic_cast<const RectangularPlaneBounds*>(&(plane.bounds())));
508 >
509 >         float width            = 0;
510 >         float length           = 0;
511 >         float thickness        = 0;
512 >         float TrapezoidalParam = 0;
513 >
514 >         if(trapezoidalBounds)
515 >         {
516 >            std::vector<float> const & parameters = (*trapezoidalBounds).parameters();
517 >            width            = parameters[0]*2;
518 >            length           = parameters[3]*2;
519 >            thickness        =  (*trapezoidalBounds).thickness();
520 >            TrapezoidalParam = parameters[1]/parameters[0];
521 >         }else if(rectangularBounds){
522 >            width            = DetUnit->surface().bounds().width();
523 >            length           = DetUnit->surface().bounds().length();
524 >            thickness        = DetUnit->surface().bounds().thickness();
525 >            TrapezoidalParam = 1;
526 >         }
527  
528 <         Frog_DetId = DETID_ECAL;
529 <         FEB        = ecal;
528 >         Surface::GlobalPoint WidthVector  = plane.toGlobal( LocalPoint(width/2, 0, 0) );
529 >         Surface::GlobalPoint LengthVector = plane.toGlobal( LocalPoint(0, length/2, 0) );
530 >         Surface::GlobalPoint ThickVector  = plane.toGlobal( LocalPoint(0, 0, thickness/2) );
531 >
532 >         GlobalVector Pos =  GlobalVector(DetUnit->position().basicVector());
533 >
534 >         FROG_Element_Geom_TrackerMod* mod = new FROG_Element_Geom_TrackerMod(
535 >              Detid.rawId(),           TrapezoidalParam,
536 >              Pos.x(),                  Pos.y(),                  Pos.z(),
537 >              WidthVector.x() -Pos.x(), WidthVector.y() -Pos.y(), WidthVector.z() -Pos.z(),
538 >              LengthVector.x()-Pos.x(), LengthVector.y()-Pos.y(), LengthVector.z()-Pos.z(),
539 >              ThickVector.x() -Pos.x(), ThickVector.y() -Pos.y(), ThickVector.z() -Pos.z());
540 >
541 >         Frog_DetId = DETID_MUON;
542 >         FEB        = muon;
543  
544           Frog_DetId += SubDet*100000;
545 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
545 >         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(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);}
547 > //         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId); FEB_Temp->addDaughter(FEB);}
548  
549           if(SubDet==1){
550 <            EBDetId detid = EBDetId(Detid);
550 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "DT"); FEB_Temp->addDaughter(FEB);}
551 >
552 >            DTChamberId detid = DTChamberId(Detid);
553  
554 <            Frog_DetId += ((detid.zside()==1)+1)*10000;
555 <            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
554 >            Frog_DetId += (detid.wheel()+3)*10000;
555 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
556              FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
557 <            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
557 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Wheel%+i", detid.wheel()); FEB_Temp->addDaughter(FEB);}
558  
559 <            Frog_DetId += (detid.tower_ieta()*detid.zside())*100;
560 <            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
559 >            Frog_DetId += detid.station()*100;
560 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
561              FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
562 <            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
562 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Station%i", detid.station()); FEB_Temp->addDaughter(FEB);}
563  
564 <            Frog_DetId += detid.tower_iphi()*1;
565 <            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
564 >            Frog_DetId += detid.sector()*1;
565 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
566              FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
567 <            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
567 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Sector%i", detid.sector()); FEB_Temp->addDaughter(FEB);}
568           }else if(SubDet==2){
569 <            EEDetId detid = EEDetId(Detid);
569 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "CSC"); FEB_Temp->addDaughter(FEB);}
570  
571 <            Frog_DetId += ((detid.zside()==1)+1)*10000;
572 <            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
571 >            CSCDetId detid = CSCDetId(Detid);
572 >  
573 >            Frog_DetId += detid.endcap()*10000;
574 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
575              FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
576 <            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
577 <
578 <            Frog_DetId += detid.iquadrant()*1000;
579 <            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
576 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Side%i", detid.endcap()); FEB_Temp->addDaughter(FEB);}
577 >  
578 >            Frog_DetId += detid.station()*1000;
579 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
580              FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
581 <            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
582 <
583 <            Frog_DetId += detid.isc();
584 <            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
581 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Station%i", detid.station()); FEB_Temp->addDaughter(FEB);}
582 >  
583 >            Frog_DetId += detid.ring()*100;
584 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(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 <         }else if(SubDet==3){
588 <            ESDetId detid = ESDetId(Detid);
589 <
590 <            Frog_DetId += ((detid.zside()==1)+1)*10000;
591 <            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
586 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Ring%i", detid.ring()); FEB_Temp->addDaughter(FEB);}
587 >
588 >            Frog_DetId += detid.chamber()*1;
589 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
590              FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
591 <            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
591 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Chamber%i", detid.chamber()); FEB_Temp->addDaughter(FEB);}
592 >         }else if(SubDet==3){
593 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "RPC"); FEB_Temp->addDaughter(FEB);}
594  
595 <            Frog_DetId += detid.plane()*1000;
596 <            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
595 >            RPCDetId detid = RPCDetId(Detid);
596 >
597 >            Frog_DetId += (detid.region()+2)*10000;
598 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
599              FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
600 <            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
600 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Region+%i", detid.region()); FEB_Temp->addDaughter(FEB);}
601 >
602 >            // Barrel
603 >            if(detid.region()==0){
604 >               Frog_DetId += (detid.ring()+3)*1000;
605 >               FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
606 >               FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
607 >               if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Ring+%i", detid.ring()); FEB_Temp->addDaughter(FEB);}
608 >            // Endcap
609 >            }else{
610 >               Frog_DetId += detid.ring()*1000;
611 >               FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
612 >               FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
613 >               if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Ring+%i", detid.ring()); FEB_Temp->addDaughter(FEB);}
614 >            }
615  
616 <            Frog_DetId += detid.six()*50;
617 <            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
616 >            Frog_DetId += detid.station()*100;
617 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(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);}
619 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Station%i", detid.station()); FEB_Temp->addDaughter(FEB);}
620  
621 <            Frog_DetId += detid.siy();
622 <            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
621 >            Frog_DetId += detid.sector()*1;
622 >            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(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);}
624 >            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Sector%i", detid.sector()); FEB_Temp->addDaughter(FEB);}
625           }
610      }else if(Detid.det()==DetId::Hcal){
611        if(SubDet<1 || SubDet>4) continue;
626  
627 <         Frog_DetId = DETID_HCAL;
628 <         FEB        = hcal;
627 >         FEB->addDaughter(mod);
628 >      }
629  
616         Frog_DetId += SubDet*100000;
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);}
630  
631 <         if(true){
632 <            HcalDetId detid = HcalDetId(Detid);
631 >      
632 >      // ### CALO GEOMETRY ###
633  
634 <            Frog_DetId += ((detid.zside()==1)+1)*10000;
635 <            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
636 <            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
637 <            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
634 >      edm::ESHandle<CaloGeometry> CaloGeom;
635 > //      iSetup.get<CaloGeometryRecord>().get( CaloGeom );
636 >      iSetup.get<CaloGeometryRecord>().get( CaloGeom );
637 >      const vector<DetId> CaloDets = CaloGeom->getValidDetIds();
638  
639 <            Frog_DetId += detid.ietaAbs()*100;
640 <            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
641 <            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
642 <            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
639 >      for(unsigned int i=0;i<CaloDets.size();i++)
640 >      {
641 >         Detid  = CaloDets[i];
642 >         SubDet = Detid.subdetId();
643  
644 <            Frog_DetId += detid.iphi()*1;
645 <            FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
636 <            FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
637 <            if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
638 <         }
644 >                 if(Detid.det()==DetId::Ecal){
645 >                        if(SubDet<1 || SubDet>3) continue;
646  
647 +                        Frog_DetId = DETID_ECAL;
648 +                        FEB        = ecal;
649  
650 +                        Frog_DetId += SubDet*100000;
651 +                        FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
652 +                        FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
653 + //                      if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId); FEB_Temp->addDaughter(FEB);}
654 +
655 +                        if(SubDet==1){
656 +                           if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "EB"); FEB_Temp->addDaughter(FEB);}
657 +
658 +                           EBDetId detid = EBDetId(Detid);
659 +
660 +                           Frog_DetId += ((detid.zside()==1)+1)*10000;
661 +                           FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
662 +                           FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
663 +                           if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Side%+i", detid.zside()); FEB_Temp->addDaughter(FEB);}
664 +
665 +                           Frog_DetId += (detid.tower_ieta()*detid.zside())*100;
666 +                           FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
667 +                           FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
668 +                           if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "TowerIEta%+i", detid.tower_ieta()); FEB_Temp->addDaughter(FEB);}
669 +
670 +                           Frog_DetId += detid.tower_iphi()*1;
671 +                           FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
672 +                           FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
673 +                           if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "TowerIPhi%i", detid.tower_iphi()); FEB_Temp->addDaughter(FEB);}
674 +                        }else if(SubDet==2){
675 +                           if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "EE"); FEB_Temp->addDaughter(FEB);}
676 +
677 +                           EEDetId detid = EEDetId(Detid);
678 +
679 +                           Frog_DetId += ((detid.zside()==1)+1)*10000;
680 +                           FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
681 +                           FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
682 +                           if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Side%+i", detid.zside()); FEB_Temp->addDaughter(FEB);}
683 +
684 +                           Frog_DetId += detid.iquadrant()*1000;
685 +                           FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
686 +                           FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
687 +                           if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Quadran%i", detid.iquadrant()); FEB_Temp->addDaughter(FEB);}
688 +
689 +                           Frog_DetId += detid.isc();
690 +                           FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
691 +                           FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
692 +                           if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "ISC%i", detid.isc()); FEB_Temp->addDaughter(FEB);}
693 +                        }else if(SubDet==3){
694 +                           if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "ES"); FEB_Temp->addDaughter(FEB);}
695  
696 <      }else if(Detid.det() == DetId::Calo){
643 <      continue;
644 <      /*
645 <         Frog_DetId = DETID_CALO + 1000000;
646 <         FEB        = hcal;
696 >                           ESDetId detid = ESDetId(Detid);
697  
698 <         Frog_DetId += SubDet*100000;
699 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
700 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
701 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
702 <      */
703 <      }
698 >                           Frog_DetId += ((detid.zside()==1)+1)*10000;
699 >                           FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
700 >                           FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
701 >                           if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Side%+i", detid.zside()); FEB_Temp->addDaughter(FEB);}
702 >
703 >                           Frog_DetId += detid.plane()*1000;
704 >                           FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
705 >                           FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
706 >                           if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Plane%i", detid.plane()); FEB_Temp->addDaughter(FEB);}
707 >
708 >                           Frog_DetId += detid.six()*50;
709 >                           FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
710 >                           FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
711 >                           if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Six%i", detid.six()); FEB_Temp->addDaughter(FEB);}
712 >
713 >                           Frog_DetId += detid.siy();
714 >                           FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
715 >                           FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
716 >                           if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Siy%i", detid.siy()); FEB_Temp->addDaughter(FEB);}
717 >                         }
718 >                 }else if(Detid.det()==DetId::Hcal){
719 >                        if(SubDet<1 || SubDet>4) continue;
720 >
721 >                        Frog_DetId = DETID_HCAL;
722 >                        FEB        = hcal;
723 >
724 >                        Frog_DetId += SubDet*100000;
725 >                        FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
726 >                        FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
727 >                        if(FEB==NULL){
728 >                                if(SubDet==1){   FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "HB"); FEB_Temp->addDaughter(FEB);}
729 >                                if(SubDet==2){   FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "HE"); FEB_Temp->addDaughter(FEB);}
730 >                                if(SubDet==3){   FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "HO"); FEB_Temp->addDaughter(FEB);}
731 >                                if(SubDet==4){   FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "HF"); FEB_Temp->addDaughter(FEB);}
732 >                        }
733 >
734 >                        HcalDetId detid = HcalDetId(Detid);
735 >
736 >                        Frog_DetId += ((detid.zside()==1)+1)*10000;
737 >                        FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
738 >                        FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
739 >                        if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Side%+i", detid.zside()); FEB_Temp->addDaughter(FEB);}
740 >
741 >                        Frog_DetId += detid.ietaAbs()*100;
742 >                        FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
743 >                        FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
744 >                        if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "IEta%+i", detid.ieta()); FEB_Temp->addDaughter(FEB);}
745 >
746 >                        Frog_DetId += detid.iphi()*1;
747 >                        FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
748 >                        FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
749 >                        if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "IPhi%i", detid.iphi()); FEB_Temp->addDaughter(FEB);}
750  
751 <      const CaloCellGeometry* CellGeom = CaloGeom->getGeometry(Detid);
656 <      GlobalPoint CellPos =  CellGeom->getPosition();
657 <      const CaloCellGeometry::CornersVec CellCorners =  CellGeom->getCorners();
658 <
659 <      float cX = (CellCorners[0].x() + CellCorners[2].x())/2;
660 <      float cY = (CellCorners[0].y() + CellCorners[2].y())/2;
661 <      float cZ = (CellCorners[0].z() + CellCorners[2].z())/2;
662 <
663 <      float wX = (CellCorners[1].x() - CellCorners[0].x())/2;
664 <      float wY = (CellCorners[1].y() - CellCorners[0].y())/2;
665 <      float wZ = (CellCorners[1].z() - CellCorners[0].z())/2;
666 <        
667 <      float hX = (CellCorners[3].x() - CellCorners[0].x())/2;
668 <      float hY = (CellCorners[3].y() - CellCorners[0].y())/2;
669 <      float hZ = (CellCorners[3].z() - CellCorners[0].z())/2;
751 >                 }else if(Detid.det() == DetId::Calo){        
752  
753 <      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) );
754 <            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) );
753 >                   Frog_DetId = DETID_CALO;
754 >                   FEB        = calo;
755  
756 <      FROG_Element_Geom_CaloMod* mod = new FROG_Element_Geom_CaloMod(
757 <                        Detid.rawId(), F,
758 <                        cX  ,   cY  , cZ ,
759 <                        wX  ,   wY  , wZ ,
760 <                        hX  ,   hY  , hZ );
756 >                   if(SubDet!=(unsigned int)CaloTowerDetId::SubdetId)continue;
757 >
758 >                   Frog_DetId += SubDet*100000;
759 >                   FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
760 >                   FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
761 >                   if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "CaloTowers"); FEB_Temp->addDaughter(FEB);}
762 >
763 >                   if(SubDet==(unsigned int)CaloTowerDetId::SubdetId){
764 >                      CaloTowerDetId detid = CaloTowerDetId(Detid);
765 >
766 >                      Frog_DetId += ((detid.zside()==1)+1)*10000;
767 >                      FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
768 >                      FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
769 >                      if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Side%+i", detid.zside()); FEB_Temp->addDaughter(FEB);}
770 >
771 >                      Frog_DetId += (detid.ieta()*detid.zside())*100;
772 >                      FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
773 >                      FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
774 >                      if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "IEta%+i", detid.ieta()); FEB_Temp->addDaughter(FEB);}
775 >
776 >                      Frog_DetId += detid.iphi()*1;
777 >                      FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
778 >                      FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
779 >                      if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "IPhi%i", detid.iphi()); FEB_Temp->addDaughter(FEB);}
780 >                   }
781 >                }
782  
783 <      FEB->addDaughter(mod);
784 <   }
783 >                 const CaloCellGeometry* CellGeom = CaloGeom->getGeometry(Detid);
784 >                 GlobalPoint CellPos =  CellGeom->getPosition();
785 >                 const CaloCellGeometry::CornersVec CellCorners =  CellGeom->getCorners();
786 >
787 >                 float cX = (CellCorners[0].x() + CellCorners[2].x())/2;
788 >                 float cY = (CellCorners[0].y() + CellCorners[2].y())/2;
789 >                 float cZ = (CellCorners[0].z() + CellCorners[2].z())/2;
790 >
791 >                 float wX = (CellCorners[1].x() - CellCorners[0].x())/2;
792 >                 float wY = (CellCorners[1].y() - CellCorners[0].y())/2;
793 >                 float wZ = (CellCorners[1].z() - CellCorners[0].z())/2;
794 >                
795 >                 float hX = (CellCorners[3].x() - CellCorners[0].x())/2;
796 >                 float hY = (CellCorners[3].y() - CellCorners[0].y())/2;
797 >                 float hZ = (CellCorners[3].z() - CellCorners[0].z())/2;
798  
799 +                 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) );
800 +                           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) );
801  
802 +                 FROG_Element_Geom_CaloMod* mod = new FROG_Element_Geom_CaloMod(
803 +                        Detid.rawId(), F,
804 +                        cX  ,   cY  , cZ ,
805 +                        wX  ,   wY  , wZ ,
806 +                        hX  ,   hY  , hZ );
807  
808 <   // ### Save .geom ###
808 >                 FEB->addDaughter(mod);  
809 >      }
810  
811 <   Geometry* CMS_Geom = new Geometry(prim);
688 <   CMS_Geom->Save("CMS.geom");  
811 >      // ### Save .geom ###
812  
813 <   event_prim = new FROG_Element_Base(C_PRIMARY);  
814 <   events     = new FROG_Events(event_prim);
813 >      FROG_Geometry* CMS_Geom = new FROG_Geometry(prim);
814 >      CMS_Geom->Save("CMS.geom", CompressFiles);  
815 >      delete CMS_Geom;
816 >   }
817  
818 +   events_prim = new FROG_Element_Base(C_PRIMARY);  
819   }
820  
821   // ------------ method called once each job just after ending the event loop  ------------
822   void
823   Frog_Analyzer::endJob()
824 < {
825 <     events->Save((char*) OutputFile.c_str());
824 > {
825 >   if(NEvents>0){
826 >      char OutputFileName[1024];
827 >      sprintf(OutputFileName,"%s",OutputFile.substr(0,OutputFile.size()-4).c_str());
828 >      if(NEventsInVisFile>=0)sprintf(OutputFileName,"%s_Run%i_1stEvent%08i",OutputFileName,SRun,SEvent);
829 >      sprintf(OutputFileName,"%s.vis",OutputFileName);
830 >
831 >      FROG_Events* events = new FROG_Events(events_prim);
832 >      events->Save((char*) OutputFileName, CompressFiles);
833 >      delete events;
834 >      delete events_prim;
835 >
836 >      events_prim = new FROG_Element_Base(C_PRIMARY);
837 >      NEvents=0;
838 >   }
839   }
840  
841  
# Line 709 | Line 848 | Frog_Analyzer::endJob()
848   void
849   Frog_Analyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
850   {
851 <        FROG_Event* event =  new FROG_Event();
851 >        if(NEvents == 0){
852 >           SRun   = iEvent.id().run();
853 >           SEvent = iEvent.id().event();
854 >        }
855 >
856 >
857 >        FROG_Element_Event* event =  new FROG_Element_Event(iEvent.id().run(), iEvent.id().event(), iEvent.time().value() );
858 >        events_prim->addDaughter(event);
859  
860          // access the tracker
861          edm::ESHandle<TrackerGeometry> tkGeom;
# Line 724 | Line 870 | Frog_Analyzer::analyze(const edm::Event&
870          edm::ESHandle<RPCGeometry> RpcGeom;
871          iSetup.get<MuonGeometryRecord>().get( RpcGeom );
872  
873 +        edm::ESHandle<CaloGeometry> CaloGeom;
874 +        iSetup.get<CaloGeometryRecord>().get( CaloGeom );
875 +
876 +
877 +        // ### GEN OBJECTS CONTAINER ###
878 +        FROG_Element_Base_With_DetId_And_Name* frogGen = new FROG_Element_Base_With_DetId_And_Name( EVTID_GEN, "GEN");
879 +        event->addDaughter(frogGen);
880 +
881 +        // ### GENPARTICLES ###
882 +        FROG_Element_Base_With_DetId_And_Name* frogGenPartColl = new FROG_Element_Base_With_DetId_And_Name( EVTID_GEN_CAND, "GenParticles");
883 +        frogGen->addDaughter(frogGenPartColl);
884 +
885 +
886 +        for(unsigned int i=0;i<GenParticlesProducers.size();i++){
887 +           edm::Handle<GenParticleCollection> h_gen_Particles;
888 +           iEvent.getByLabel(GenParticlesProducers[i], h_gen_Particles);
889 +           GenParticleCollection gen_Particles = *h_gen_Particles.product();
890 +
891 +           FROG_Element_Base_With_DetId_And_Name* frogGenPartCollb = new FROG_Element_Base_With_DetId_And_Name( EVTID_GEN_CAND + i + 1, GenParticlesProducers[i].encode().c_str());
892 +           frogGenPartColl->addDaughter(frogGenPartCollb);
893 +
894 +           for(unsigned int h=0;h<gen_Particles.size();h++){
895 +             if(gen_Particles[h].status()!=1)continue;
896 +             FROG_Element_Event_Candidate* frogGenPart = new FROG_Element_Event_Candidate(gen_Particles[h].pdgId(), gen_Particles[h].p(), gen_Particles[h].eta(), gen_Particles[h].phi());
897 +             frogGenPartCollb->addDaughter(frogGenPart);
898 +           }
899 +        }
900 +
901 +
902 +        // ### SIM OBJECTS CONTAINER ###
903 +        FROG_Element_Base_With_DetId_And_Name* frogSim = new FROG_Element_Base_With_DetId_And_Name( EVTID_SIM, "SIM");
904 +        event->addDaughter(frogSim);
905  
728        // Save Data
906          // ### SIMTRACK ###
907 +        FROG_Element_Base_With_DetId_And_Name* frogSimTrkColl = new FROG_Element_Base_With_DetId_And_Name( EVTID_SIMTRK, "SimTracks");
908 +        frogSim->addDaughter(frogSimTrkColl);
909 +
910          for(unsigned int i=0;i<SimTrackProducers.size();i++){
911             edm::Handle<std::vector< SimTrack > > h_SimTracks;
912             iEvent.getByLabel(SimTrackProducers[i], h_SimTracks);
# Line 739 | Line 919 | Frog_Analyzer::analyze(const edm::Event&
919                          simTrack.momentum().x(),     simTrack.momentum().y(),     simTrack.momentum().z(),
920                          simTrack.momentum().e(),     simTrack.type(),             simTrack.vertIndex(),
921                          simTrack.charge() );
922 <
743 <                event->addSimTrack( frogSimTrk );
744 < //              MyEvent->MySimTrackCollection.push_back(MysimTrack);
922 >                frogSimTrkColl->addDaughter(frogSimTrk);
923             }      
924          }
925  
926          // ### SIMVERTEX ###
927 +        FROG_Element_Base_With_DetId_And_Name* frogSimVtx = new FROG_Element_Base_With_DetId_And_Name( EVTID_SIMVTX, "SimVertex");
928 +        frogSim->addDaughter(frogSimVtx);
929 +
930          for(unsigned int i=0;i<SimVertexProducers.size();i++){
931             edm::Handle<std::vector< SimVertex > > h_Vertex;
932             iEvent.getByLabel(SimVertexProducers[i], h_Vertex);
# Line 754 | Line 935 | Frog_Analyzer::analyze(const edm::Event&
935             for (unsigned int b = 0; b < VertexColl.size(); ++b ) {
936                  SimVertex       Vertex  =  VertexColl[b];
937  
938 <                FROG_Element_Event_Sim_Vertex* frogSimVtx = new FROG_Element_Event_Sim_Vertex(
938 >                FROG_Element_Event_Sim_Vertex* frogSimVertex = new FROG_Element_Event_Sim_Vertex(
939                          Vertex.position().x(),  Vertex.position().y(),  Vertex.position().z(),
940                          Vertex.parentIndex());
941  
942 <                event->addSimVertex(frogSimVtx);
942 >                frogSimVtx->addDaughter(frogSimVertex);
943             }
944          }
945  
946  
947          // ### SIMHIT ###
948 < /*
948 >
949 >        FROG_Element_Base_With_DetId_And_Name* frogSimHit = new FROG_Element_Base_With_DetId_And_Name( EVTID_SIMHIT, "SimHits");
950 >        frogSim->addDaughter(frogSimHit);
951          for(unsigned int i=0;i<SimHitProducers.size();i++){
952             edm::Handle<std::vector< PSimHit > > h_Hits;
953             iEvent.getByLabel(SimHitProducers[i], h_Hits);
954             std::vector< PSimHit > Hits = *h_Hits.product();
955  
956 +           FROG_Element_Base_With_DetId_And_Name* frogSimHitColl = new FROG_Element_Base_With_DetId_And_Name( EVTID_SIMHIT + i + 1, SimHitProducers[i].encode().c_str() );
957 +           frogSimHit->addDaughter(frogSimHitColl);
958 +
959             for(unsigned int h=0; h<Hits.size(); h++)
960             {
961                  DetId theDetUnitId(Hits[h].detUnitId());
962 <                const GeomDet* theDet = tkGeom->idToDet(theDetUnitId);
962 >                const GeomDet* theDet = NULL;
963 >                if(theDetUnitId.det() == DetId::Tracker)theDet = tkGeom->idToDet(theDetUnitId);
964 >                if(theDetUnitId.det() == DetId::Muon && theDetUnitId.subdetId() == MuonSubdetId::DT) theDet = DtGeom->idToDet(theDetUnitId);
965 >                if(theDetUnitId.det() == DetId::Muon && theDetUnitId.subdetId() == MuonSubdetId::CSC)theDet = CscGeom->idToDet(theDetUnitId);
966 >                if(theDetUnitId.det() == DetId::Muon && theDetUnitId.subdetId() == MuonSubdetId::RPC)theDet = RpcGeom->idToDet(theDetUnitId);
967 >
968 >                
969 >                FROG_Element_Event_Sim_Hit* frogSimHit = new FROG_Element_Event_Sim_Hit(
970 >                        theDet->surface().toGlobal(Hits[h].localPosition()).x(),theDet->surface().toGlobal(Hits[h].localPosition()).y(),theDet->surface().toGlobal(Hits[h].localPosition()).z(),
971 >                        Hits[h].energyLoss(), Hits[h].processType() );
972 >                frogSimHitColl->addDaughter(frogSimHit);
973 >           }
974 >        }
975  
976 <                MyPSimHit* Hit   = new MyPSimHit;
779 <                Hit->x           = theDet->surface().toGlobal(Hits[h].localPosition()).x();
780 <                Hit->y           = theDet->surface().toGlobal(Hits[h].localPosition()).y();
781 <                Hit->z           = theDet->surface().toGlobal(Hits[h].localPosition()).z();
782 <                Hit->ProcessType = Hits[h].processType();
783 <                Hit->dEdX        = Hits[h].energyLoss();
976 >        // ### SIMCALOHIT ###
977  
978 <                MyEvent->MyPSimHitCollection.push_back(Hit);
978 >        for(unsigned int i=0;i<SimCaloHitProducers.size();i++){
979 >           edm::Handle<std::vector< PCaloHit > > h_CaloHits;
980 >           iEvent.getByLabel(SimCaloHitProducers[i], h_CaloHits);
981 >           std::vector< PCaloHit > CaloHits = *h_CaloHits.product();
982 >
983 >           FROG_Element_Base_With_DetId_And_Name* frogSimHitColl = new FROG_Element_Base_With_DetId_And_Name( EVTID_SIMHIT + SimHitProducers.size() + i + 1, SimCaloHitProducers[i].encode().c_str());
984 >           frogSimHit->addDaughter(frogSimHitColl);
985 >
986 >           for(unsigned int h=0; h<CaloHits.size(); h++)
987 >           {
988 >                DetId theDetUnitId(CaloHits[h].id());
989 >                const CaloCellGeometry* CellGeom = NULL;
990 >                if(theDetUnitId.det() == DetId::Ecal || theDetUnitId.det() == DetId::Hcal)CellGeom = CaloGeom->getGeometry(theDetUnitId);
991 >                if(CellGeom==NULL)continue;
992 >
993 >
994 >                FROG_Element_Event_Sim_Hit* frogSimCaloHit = new FROG_Element_Event_Sim_Hit(
995 >                        CellGeom->getPosition().x(),CellGeom->getPosition().y(),CellGeom->getPosition().z(),
996 >                        CaloHits[h].energy(), CaloHits[h].depth() );
997 >                frogSimHitColl->addDaughter(frogSimCaloHit);
998             }
999 <        }
788 < */
999 >        }
1000  
1001  
791        // ### TRAJECTORY ###
792        for(unsigned int i=0;i<TrajectoryProducers.size();i++){
793             Handle<TrajTrackAssociationCollection> trajTrackAssociationHandle;
794             iEvent.getByLabel(TrajectoryProducers[i], trajTrackAssociationHandle);
795             const TrajTrackAssociationCollection TrajToTrackMap = *trajTrackAssociationHandle.product();
1002  
797             for(TrajTrackAssociationCollection::const_iterator it = TrajToTrackMap.begin(); it!=TrajToTrackMap.end(); ++it) {
798                Trajectory  recoTraj     = *it->key;
799                FROG_Element_Event_Track* frogRecoTk = new FROG_Element_Event_Track(i,it->val->p(),it->val->pt(),it->key->chiSquared());
1003  
1004 <                std::vector<TrajectoryMeasurement> measurements = recoTraj.measurements();
1005 <                for(unsigned int h=0;h<measurements.size();h++){
1004 >        // ### LOW RECO OBJECTS CONTAINER ###
1005 >        FROG_Element_Base_With_DetId_And_Name* frogLowReco = new FROG_Element_Base_With_DetId_And_Name( EVTID_LOWRECO, "RECO LOW");
1006 >        event->addDaughter(frogLowReco);
1007  
804                      TrajectoryMeasurement::ConstRecHitPointer h_it = measurements[h].recHit();
805                      if(!h_it->isValid() )continue;
806                      DetId detId                = h_it->geographicalId();
807                      GlobalPoint globalPos      = measurements[h].updatedState().globalPosition();
1008  
809                      FROG_Element_Event_Hit* frogHit =
810                        new FROG_Element_Event_Hit(detId.rawId(), globalPos.x(),globalPos.y(),  globalPos.z(), -1);
811                      frogRecoTk->addHit(frogHit);
812                }
813 //                MyEvent->MyRecoTrackCollection.push_back(MyrecoTrack);
814                event->addRecoTrack(frogRecoTk);
815           }
816        }
1009  
1010 <        // ### TRACK ###
1010 >        // ### SiStrip Clusters ###
1011 >        FROG_Element_Base_With_DetId_And_Name* frogSSTHit = new FROG_Element_Base_With_DetId_And_Name( EVTID_SISTRIPHIT, "SiStrip Clusters");
1012 >        frogLowReco->addDaughter(frogSSTHit);
1013 >        for(unsigned int i=0;i<SiStripClusterProducers.size();i++){
1014 >           edm::Handle<edmNew::DetSetVector<SiStripCluster> > h_Sst_Hits;
1015 >           iEvent.getByLabel(SiStripClusterProducers[i], h_Sst_Hits);
1016 >           const edmNew::DetSetVector<SiStripCluster>&  Sst_Hits = *h_Sst_Hits.product();
1017  
820        for(unsigned int i=0;i<TrackProducers.size();i++){
821           edm::Handle<std::vector< reco::Track > > h_Tracks;
822           iEvent.getByLabel(TrackProducers[i], h_Tracks);
823           std::vector< reco::Track > TrackColl = *h_Tracks.product();
1018  
1019 <           //printf("Size of the TrackCOllection : %i = %i\n",i,TrackColl.size());
1020 <           for ( unsigned int t = 0; t < TrackColl.size(); ++t ) {
827 <                reco::Track  recoTrack  =TrackColl[t];
1019 >           FROG_Element_Base_With_DetId_And_Name* frogSstHitColl = new FROG_Element_Base_With_DetId_And_Name( EVTID_SISTRIPHIT + i + 1, SiStripClusterProducers[i].encode().c_str());
1020 >           frogSSTHit->addDaughter(frogSstHitColl);
1021  
829                FROG_Element_Event_Track* frogRecoTk = new FROG_Element_Event_Track(TrajectoryProducers.size()+i,recoTrack.p(),recoTrack.pt(), recoTrack.chi2());
1022  
1023 +           for (edmNew::DetSetVector<SiStripCluster>::const_iterator DSViter = Sst_Hits.begin(); DSViter != Sst_Hits.end(); ++DSViter) {
1024 +           edmNew::DetSet<SiStripCluster>::const_iterator begin=DSViter->begin();
1025 +           edmNew::DetSet<SiStripCluster>::const_iterator end  =DSViter->end();
1026 +           for(edmNew::DetSet<SiStripCluster>::const_iterator iCluster=begin;iCluster!=end;++iCluster){
1027  
1028 <                for(unsigned int h=0;h<recoTrack.recHitsSize();h++){
1029 <                      TrackingRecHitRef h_it     = recoTrack.recHit(h);
1030 <                      if(!h_it->isValid() )continue;
1031 <                      DetId detId                = h_it->geographicalId();
1032 <                      const GeomDet * theDet = NULL;
1028 >                const GeomDetUnit* detUnit = tkGeom->idToDetUnit (DetId( iCluster->geographicalId() ) );
1029 >                if(!detUnit)continue;
1030 >
1031 >                const StripGeomDetUnit* DetUnit = dynamic_cast<const StripGeomDetUnit*> ( detUnit  );
1032 >                if(!DetUnit)continue;
1033 >
1034 >                const StripTopology& Topo  = DetUnit->specificTopology();
1035 >
1036 >                unsigned int Charge = 0;
1037 >                for(unsigned int i=0;i<iCluster->amplitudes().size();i++){Charge+=iCluster->amplitudes()[i];}
1038 >
1039 >                unsigned int MiddleStrip = iCluster->firstStrip() + iCluster->amplitudes().size()/2;
1040 >
1041 >                float Pitch = DetUnit->surface().bounds().width() / Topo.nstrips();
1042 >                float XPos = (MiddleStrip * Pitch) - DetUnit->surface().bounds().width()/2;
1043 >                //float YPos = DetUnit->surface().bounds().thickness()/2;
1044 >                //float ZPos = DetUnit->surface().bounds().length()/2;
1045 >
1046 >                Surface::GlobalPoint Pos  = DetUnit->surface().toGlobal( LocalPoint(XPos, 0, 0) );
1047 >
1048 >
1049 >                FROG_Element_Event_Hit_SiStrip* frogStripHit = new FROG_Element_Event_Hit_SiStrip(iCluster->geographicalId(), iCluster->firstStrip(), Pitch);
1050 >                for(unsigned int i=0;i<iCluster->amplitudes().size();i++){frogStripHit->Ampl_.push_back(iCluster->amplitudes()[i]);}
1051 >                frogSstHitColl->addDaughter(frogStripHit);
1052 >           }}
1053  
838                      if(detId.det()==DetId::Tracker)                        theDet = tkGeom->idToDet(detId);
839                      if(detId.det()==DetId::Muon && detId.subdetId() == 1)  theDet = DtGeom->idToDet(detId);
840                      if(detId.det()==DetId::Muon && detId.subdetId() == 2)  theDet = CscGeom->idToDet(detId);
841                      if(detId.det()==DetId::Muon && detId.subdetId() == 3)  theDet = RpcGeom->idToDet(detId);
842
843                      
844                      LocalPoint localPos        = h_it->localPosition();
845
846                      FROG_Element_Event_Hit* frogHit = new FROG_Element_Event_Hit(
847                                                detId.rawId(),
848                                                theDet->surface().toGlobal(localPos).x(),
849                                                theDet->surface().toGlobal(localPos).y(),
850                                                theDet->surface().toGlobal(localPos).z(),
851                                                -1);
852                      frogRecoTk->addHit(frogHit);
853                }
854                event->addRecoTrack(frogRecoTk);
855           }
1054          }
1055  
1056  
1057  
1058 +        // ### CALORecHits ###
1059 +        FROG_Element_Base_With_DetId_And_Name* frogCaloHit = new FROG_Element_Base_With_DetId_And_Name( EVTID_CALOHIT, "CALO Hits");
1060 +        frogLowReco->addDaughter(frogCaloHit);
1061 +
1062 +
1063          // ### ECALRecHits ###
1064 +        FROG_Element_Base_With_DetId_And_Name* frogEcalHit = new FROG_Element_Base_With_DetId_And_Name( EVTID_ECALHIT, "ECAL RecHits");
1065 +        frogCaloHit->addDaughter(frogEcalHit);
1066          for(unsigned int i=0;i<EcalRecHitProducers.size();i++){
1067             edm::Handle<EcalRecHitCollection > h_Ecal_RecHits;
1068             iEvent.getByLabel(EcalRecHitProducers[i], h_Ecal_RecHits);
1069             EcalRecHitCollection Ecal_RecHits = *h_Ecal_RecHits.product();
1070  
1071 +           FROG_Element_Base_With_DetId_And_Name* frogHitColl = new FROG_Element_Base_With_DetId_And_Name( EVTID_ECALHIT + i + 1, EcalRecHitProducers[i].encode().c_str());
1072 +           frogEcalHit->addDaughter(frogHitColl);
1073 +
1074             for(unsigned int eh=0;eh<Ecal_RecHits.size();eh++){
867                temp_EcalHit->DetId = (Ecal_RecHits[eh].detid()).rawId();
1075                  FROG_Element_Event_CaloHit* frogCaloHit = new FROG_Element_Event_CaloHit((Ecal_RecHits[eh].detid()).rawId(),
1076                          Ecal_RecHits[eh].energy(), Ecal_RecHits[eh].time());  
1077 <                event->addCaloHit(frogCaloHit);
1077 >                frogHitColl->addDaughter(frogCaloHit);
1078             }
1079          }
1080  
1081  
1082          // ### HCALRecHits ###
1083 +        FROG_Element_Base_With_DetId_And_Name* frogHcalHit = new FROG_Element_Base_With_DetId_And_Name( EVTID_HCALHIT, "HCAL RecHits");
1084 +        frogCaloHit->addDaughter(frogHcalHit);
1085          for(unsigned int i=0;i<HcalHBHERecHitProducers.size();i++){
1086             edm::Handle<HBHERecHitCollection > h_HcalHBHE_RecHits;
1087             iEvent.getByLabel(HcalHBHERecHitProducers[i], h_HcalHBHE_RecHits);
1088             HBHERecHitCollection HcalHBHE_RecHits = *h_HcalHBHE_RecHits.product();
1089  
1090 +           FROG_Element_Base_With_DetId_And_Name* frogHitColl = new FROG_Element_Base_With_DetId_And_Name( EVTID_HCALHIT + i + 1, HcalHBHERecHitProducers[i].encode().c_str());
1091 +           frogHcalHit->addDaughter(frogHitColl);
1092 +
1093             for(unsigned int hh=0;hh<HcalHBHE_RecHits.size();hh++){
1094                  FROG_Element_Event_CaloHit* frogCaloHit = new FROG_Element_Event_CaloHit((HcalHBHE_RecHits[hh].detid()).rawId(),
1095                          HcalHBHE_RecHits[hh].energy(), HcalHBHE_RecHits[hh].time());
1096 <                event->addCaloHit(frogCaloHit);
1096 >                frogHitColl->addDaughter(frogCaloHit);
1097             }
1098          }
1099  
888
1100          for(unsigned int i=0;i<HcalHORecHitProducers.size();i++){
1101             edm::Handle<HORecHitCollection > h_HcalHO_RecHits;
1102             iEvent.getByLabel(HcalHORecHitProducers[i], h_HcalHO_RecHits);
1103             HORecHitCollection HcalHO_RecHits = *h_HcalHO_RecHits.product();
1104  
1105 <           for(unsigned int hh=0;hh<HcalHO_RecHits.size();hh++){
1106 <                MyCaloHit* temp_HcalHOHit = new MyCaloHit;
896 <                temp_HcalHOHit->E      = HcalHO_RecHits[hh].energy();
897 <                temp_HcalHOHit->t      = HcalHO_RecHits[hh].time();
898 <                temp_HcalHOHit->DetId = (HcalHO_RecHits[hh].detid()).rawId();
1105 >           FROG_Element_Base_With_DetId_And_Name* frogHitColl = new FROG_Element_Base_With_DetId_And_Name( EVTID_HCALHIT + HcalHBHERecHitProducers.size() + i + 1, HcalHORecHitProducers[i].encode().c_str());
1106 >           frogHcalHit->addDaughter(frogHitColl);
1107  
1108 <                MyEvent->MyHcalCaloHitCollection.push_back(temp_HcalHOHit);
1108 >           for(unsigned int hh=0;hh<HcalHO_RecHits.size();hh++){
1109 >                FROG_Element_Event_CaloHit* frogCaloHit = new FROG_Element_Event_CaloHit((HcalHO_RecHits[hh].detid()).rawId(),
1110 >                        HcalHO_RecHits[hh].energy(), HcalHO_RecHits[hh].time());
1111 >                frogHitColl->addDaughter(frogCaloHit);
1112             }
1113          }
1114  
904
1115          for(unsigned int i=0;i<HcalHFRecHitProducers.size();i++){
1116             edm::Handle<HFRecHitCollection > h_HcalHF_RecHits;
1117             iEvent.getByLabel(HcalHFRecHitProducers[i], h_HcalHF_RecHits);
1118             HFRecHitCollection HcalHF_RecHits = *h_HcalHF_RecHits.product();
1119  
1120 <           for(unsigned int hh=0;hh<HcalHF_RecHits.size();hh++){
1121 <                MyCaloHit* temp_HcalHFHit = new MyCaloHit;
912 <                temp_HcalHFHit->E      = HcalHF_RecHits[hh].energy();
913 <                temp_HcalHFHit->t      = HcalHF_RecHits[hh].time();
914 <                temp_HcalHFHit->DetId = (HcalHF_RecHits[hh].detid()).rawId();
1120 >           FROG_Element_Base_With_DetId_And_Name* frogHitColl = new FROG_Element_Base_With_DetId_And_Name( EVTID_HCALHIT + HcalHBHERecHitProducers.size() + HcalHORecHitProducers.size() + i + 1, HcalHFRecHitProducers[i].encode().c_str());
1121 >           frogHcalHit->addDaughter(frogHitColl);
1122  
1123 <                MyEvent->MyHcalCaloHitCollection.push_back(temp_HcalHFHit);
1123 >           for(unsigned int hh=0;hh<HcalHF_RecHits.size();hh++){
1124 >                FROG_Element_Event_CaloHit* frogCaloHit = new FROG_Element_Event_CaloHit((HcalHF_RecHits[hh].detid()).rawId(),
1125 >                        HcalHF_RecHits[hh].energy(), HcalHF_RecHits[hh].time());
1126 >                frogHitColl->addDaughter(frogCaloHit);
1127             }
1128          }
1129  
1130 +
1131          // ### Muon Segments ###
1132 +        FROG_Element_Base_With_DetId_And_Name* frogMuonSeg = new FROG_Element_Base_With_DetId_And_Name( EVTID_MUONSEG, "MuonSegments");
1133 +        frogLowReco->addDaughter(frogMuonSeg);
1134 +
1135          for(unsigned int i=0;i<CSCSegmentProducers.size();i++){
1136             edm::Handle<CSCSegmentCollection > h_CSC_Segments;
1137             iEvent.getByLabel(CSCSegmentProducers[i], h_CSC_Segments);
1138             CSCSegmentCollection CSC_Segments = *h_CSC_Segments.product();
1139  
1140 +           FROG_Element_Base_With_DetId_And_Name* frogSegColl = new FROG_Element_Base_With_DetId_And_Name( EVTID_MUONSEG + i + 1, CSCSegmentProducers[i].encode().c_str());
1141 +           frogMuonSeg->addDaughter(frogSegColl);
1142 +
1143             for(unsigned int s=0;s<CSC_Segments.size();s++){
1144                  DetId theDetUnitId = CSC_Segments[s].geographicalId();
1145                  const GeomDet* theDet = CscGeom->idToDet(theDetUnitId);
1146  
1147 <                MyMuonSegment* temp_CscSeg = new MyMuonSegment;
1148 <                temp_CscSeg->DetId = theDetUnitId.rawId();
1149 <                temp_CscSeg->PosX  = theDet->surface().toGlobal(CSC_Segments[s].localPosition()).x();
1150 <                temp_CscSeg->PosY  = theDet->surface().toGlobal(CSC_Segments[s].localPosition()).y();
934 <                temp_CscSeg->PosZ  = theDet->surface().toGlobal(CSC_Segments[s].localPosition()).z();
935 <                temp_CscSeg->DirX  = theDet->surface().toGlobal(CSC_Segments[s].localDirection()).x();
936 <                temp_CscSeg->DirY  = theDet->surface().toGlobal(CSC_Segments[s].localDirection()).y();
937 <                temp_CscSeg->DirZ  = theDet->surface().toGlobal(CSC_Segments[s].localDirection()).z();
938 <
939 <                MyEvent->MyMuonSegmentCollection.push_back(temp_CscSeg);
1147 >                FROG_Element_Event_Segment* frogSeg = new FROG_Element_Event_Segment(theDetUnitId.rawId(),
1148 >                theDet->surface().toGlobal(CSC_Segments[s].localPosition()).x() , theDet->surface().toGlobal(CSC_Segments[s].localPosition()).y() , theDet->surface().toGlobal(CSC_Segments[s].localPosition()).z()  ,
1149 >                theDet->surface().toGlobal(CSC_Segments[s].localDirection()).x(), theDet->surface().toGlobal(CSC_Segments[s].localDirection()).y(), theDet->surface().toGlobal(CSC_Segments[s].localDirection()).z() );
1150 >                frogSegColl->addDaughter(frogSeg);
1151             }
1152          }
1153  
# Line 945 | Line 1156 | Frog_Analyzer::analyze(const edm::Event&
1156             iEvent.getByLabel(DTSegmentProducers[i], h_DT_Segments);
1157             DTRecSegment4DCollection DT_Segments = *h_DT_Segments.product();
1158  
1159 +           FROG_Element_Base_With_DetId_And_Name* frogSegColl = new FROG_Element_Base_With_DetId_And_Name( EVTID_MUONSEG + CSCSegmentProducers.size() + i + 1, DTSegmentProducers[i].encode().c_str());
1160 +           frogMuonSeg->addDaughter(frogSegColl);
1161 +
1162             for(unsigned int s=0;s<DT_Segments.size();s++){
1163                  DetId theDetUnitId = DT_Segments[s].geographicalId();
1164                  const GeomDet* theDet = DtGeom->idToDet(theDetUnitId);
1165  
1166 <                MyMuonSegment* temp_DtSeg = new MyMuonSegment;
1167 <                temp_DtSeg->DetId = theDetUnitId.rawId();
1168 <                temp_DtSeg->PosX  = theDet->surface().toGlobal(DT_Segments[s].localPosition()).x();
1169 <                temp_DtSeg->PosY  = theDet->surface().toGlobal(DT_Segments[s].localPosition()).y();
956 <                temp_DtSeg->PosZ  = theDet->surface().toGlobal(DT_Segments[s].localPosition()).z();
957 <                temp_DtSeg->DirX  = theDet->surface().toGlobal(DT_Segments[s].localDirection()).x();
958 <                temp_DtSeg->DirY  = theDet->surface().toGlobal(DT_Segments[s].localDirection()).y();
959 <                temp_DtSeg->DirZ  = theDet->surface().toGlobal(DT_Segments[s].localDirection()).z();
960 <
961 <                MyEvent->MyMuonSegmentCollection.push_back(temp_DtSeg);
1166 >                FROG_Element_Event_Segment* frogSeg = new FROG_Element_Event_Segment(theDetUnitId.rawId(),
1167 >                theDet->surface().toGlobal(DT_Segments[s].localPosition()).x() , theDet->surface().toGlobal(DT_Segments[s].localPosition()).y() , theDet->surface().toGlobal(DT_Segments[s].localPosition()).z()  ,
1168 >                theDet->surface().toGlobal(DT_Segments[s].localDirection()).x(), theDet->surface().toGlobal(DT_Segments[s].localDirection()).y(), theDet->surface().toGlobal(DT_Segments[s].localDirection()).z() );
1169 >                frogSegColl->addDaughter(frogSeg);
1170             }
1171          }
1172  
1173          // ### Muon Hits ###
1174 +        FROG_Element_Base_With_DetId_And_Name* frogMuonHit = new FROG_Element_Base_With_DetId_And_Name( EVTID_MUONHIT, "MuonHits");
1175 +        frogLowReco->addDaughter(frogMuonHit);
1176          for(unsigned int i=0;i<RPCHitsProducers.size();i++){
1177             edm::Handle<RPCRecHitCollection > h_RPC_Hits;
1178             iEvent.getByLabel(RPCHitsProducers[i], h_RPC_Hits);
1179             RPCRecHitCollection RPC_Hits = *h_RPC_Hits.product();
1180  
1181 +           FROG_Element_Base_With_DetId_And_Name* frogHitColl = new FROG_Element_Base_With_DetId_And_Name( EVTID_MUONHIT + i + 1, RPCHitsProducers[i].encode().c_str());
1182 +           frogMuonHit->addDaughter(frogHitColl);
1183 +
1184             for(unsigned int h=0;h<RPC_Hits.size();h++){
1185                  DetId theDetUnitId = RPC_Hits[h].geographicalId();
1186                  const GeomDet* theDet = RpcGeom->idToDet(theDetUnitId);
1187  
1188 <                MyMuonHit* temp_RpcHit = new MyMuonHit;
1189 <                temp_RpcHit->DetId = theDetUnitId.rawId();
1190 <                temp_RpcHit->x     = theDet->surface().toGlobal(RPC_Hits[h].localPosition()).x();
1191 <                temp_RpcHit->y     = theDet->surface().toGlobal(RPC_Hits[h].localPosition()).y();
1192 <                temp_RpcHit->z     = theDet->surface().toGlobal(RPC_Hits[h].localPosition()).z();
1188 >                FROG_Element_Event_Hit* frogHit = new FROG_Element_Event_Hit(theDetUnitId.rawId(),
1189 >                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 );
1190 >                frogHitColl->addDaughter(frogHit);
1191 >           }
1192 >        }
1193 >
1194 >
1195 >        // ### Calo Towers ###
1196 >        FROG_Element_Base_With_DetId_And_Name* frogCaloTower = new FROG_Element_Base_With_DetId_And_Name( EVTID_CALOTOWER, "CaloTowers");
1197 >        frogLowReco->addDaughter(frogCaloTower);
1198 >        for(unsigned int i=0;i<CaloTowersProducers.size();i++){
1199 >           edm::Handle<CaloTowerCollection> h_Calo_Towers;
1200 >           iEvent.getByLabel(CaloTowersProducers[i], h_Calo_Towers);
1201 >           CaloTowerCollection Calo_Towers = *h_Calo_Towers.product();
1202 >
1203 >           FROG_Element_Base_With_DetId_And_Name* frogCaloTowerColl = new FROG_Element_Base_With_DetId_And_Name( EVTID_CALOTOWER + i + 1, CaloTowersProducers[i].encode().c_str());
1204 >           frogCaloTower->addDaughter(frogCaloTowerColl);
1205 >
1206 >           for(unsigned int h=0;h<Calo_Towers.size();h++){
1207 >                FROG_Element_Event_CaloTower* frogTower = new FROG_Element_Event_CaloTower(Calo_Towers[h].id().rawId(), Calo_Towers[h].emEnergy(),Calo_Towers[h].hadEnergy());
1208 >                frogCaloTowerColl->addDaughter(frogTower);
1209 >
1210 >                if(i==0 && CaloTowersProducersBasedOnCaloHits){
1211 >                   frogTower->Components_CollEvtId_ = EVTID_CALOHIT;
1212 >
1213 >
1214 >                     for(unsigned int D=0;D<Calo_Towers[h].constituentsSize();D++){frogTower->Components_Vector_.push_back(Calo_Towers[h].constituent(D));}                  
1215 >
1216 > //                   std::vector<DetId> TowersDetIds = Calo_Towers[h].constituents();
1217 > //                   for(unsigned int D=0;D<TowersDetIds.size();D++){frogTower->Components_Vector_.push_back(TowersDetIds[D]);}
1218 >                }
1219  
981                MyEvent->MyMuonHitCollection.push_back(temp_RpcHit);
1220             }
1221          }
1222  
985        MyEvents->Events.push_back(MyEvent);  
986 */
1223  
1224 < //        event_prim->addDaughter(event);
1225 <        events->addEvent(event);
1224 >
1225 >        // ### MED RECO OBJECTS CONTAINER ###
1226 >        FROG_Element_Base_With_DetId_And_Name* frogMedReco = new FROG_Element_Base_With_DetId_And_Name( EVTID_MEDRECO, "RECO MED");
1227 >        event->addDaughter(frogMedReco);
1228 >
1229 >
1230 >
1231 >
1232 >
1233 >        FROG_Element_Base_With_DetId_And_Name* frogNIVertex = new FROG_Element_Base_With_DetId_And_Name( EVTID_NUCLINT, "Vertex from NI");
1234 >        frogMedReco->addDaughter(frogNIVertex);
1235 >
1236 >        // NUCLEAR INTERACTIONS
1237 >        for(unsigned int i=0;i<NIProducers.size();i++) {
1238 >          edm::Handle<std::vector<reco::NuclearInteraction> > h_NIs;
1239 >          iEvent.getByLabel(NIProducers[i], h_NIs);
1240 >          std::vector<reco::NuclearInteraction> NIs = *h_NIs.product();
1241 >          FROG_Element_Base_With_DetId_And_Name* frogNIColl = new FROG_Element_Base_With_DetId_And_Name( EVTID_NUCLINT + i + 1, NIProducers[i].encode().c_str());
1242 >          frogNIVertex->addDaughter(frogNIColl);
1243 >
1244 >          for(unsigned int h=0; h<NIs.size();h++){
1245 >             reco::NuclearInteraction ni = NIs[i];
1246 >             float vtx_x = ni.vertex().x();
1247 >             float vtx_y = ni.vertex().y();
1248 >             float vtx_z = ni.vertex().z();
1249 >             float like  = ni.likelihood();
1250 >             FROG_Element_Event_NuclInt*  frogNI = new FROG_Element_Event_NuclInt(vtx_x, vtx_y, vtx_z, like );
1251 >             frogNIColl->addDaughter(frogNI);
1252 >          }
1253 >        }
1254 >
1255 >
1256 >
1257 >        // ### TRAJECTORY ###
1258 >        FROG_Element_Base_With_DetId_And_Name* frogTrk = new FROG_Element_Base_With_DetId_And_Name( EVTID_TRK, "Tracks & Trajectories");
1259 >        frogMedReco->addDaughter(frogTrk);
1260 >
1261 >        for(unsigned int i=0;i<TrajectoryProducers.size();i++){
1262 >             Handle<TrajTrackAssociationCollection> trajTrackAssociationHandle;
1263 >             iEvent.getByLabel(TrajectoryProducers[i], trajTrackAssociationHandle);
1264 >             const TrajTrackAssociationCollection TrajToTrackMap = *trajTrackAssociationHandle.product();
1265 >
1266 >             FROG_Element_Base_With_DetId_And_Name* frogTrkColl = new FROG_Element_Base_With_DetId_And_Name( EVTID_TRK + i + 1,  "Traj  | %s", TrajectoryProducers[i].encode().c_str());
1267 >             frogTrk->addDaughter(frogTrkColl);
1268 >
1269 >             for(TrajTrackAssociationCollection::const_iterator it = TrajToTrackMap.begin(); it!=TrajToTrackMap.end(); ++it) {
1270 >                Trajectory  recoTraj     = *it->key;
1271 >                FROG_Element_Event_Track* frogTrk = new FROG_Element_Event_Track(i,it->val->p(),it->val->pt(),it->key->chiSquared());
1272 >                frogTrkColl->addDaughter(frogTrk);
1273 >
1274 >                std::vector<TrajectoryMeasurement> measurements = recoTraj.measurements();
1275 >                for(unsigned int h=0;h<measurements.size();h++){
1276 >
1277 >                      TrajectoryMeasurement::ConstRecHitPointer h_it = measurements[h].recHit();
1278 >                      if(!h_it->isValid() )continue;
1279 >                      DetId detId                = h_it->geographicalId();
1280 >                      GlobalPoint globalPos      = measurements[h].updatedState().globalPosition();
1281 >
1282 >                      FROG_Element_Event_Hit* frogHit = new FROG_Element_Event_Hit(detId.rawId(), globalPos.x(),globalPos.y(),  globalPos.z(), -1);
1283 >                      frogTrk->addDaughter(frogHit);
1284 >                }
1285 >              //  printf("Add a Trajectory\n");
1286 >           }
1287 >        }
1288 >
1289 >
1290 >
1291 >
1292 >        // ### TRACK ###
1293 >
1294 >        for(unsigned int i=0;i<TrackProducers.size();i++){
1295 >           edm::Handle<std::vector< reco::Track > > h_Tracks;
1296 >           iEvent.getByLabel(TrackProducers[i], h_Tracks);
1297 >           std::vector< reco::Track > TrackColl = *h_Tracks.product();
1298 >
1299 >           FROG_Element_Base_With_DetId_And_Name* frogTrkColl = new FROG_Element_Base_With_DetId_And_Name( EVTID_TRK + TrajectoryProducers.size() + i + 1, "Track | %s", TrackProducers[i].encode().c_str());
1300 >           frogTrk->addDaughter(frogTrkColl);
1301 >
1302 >           //printf("Size of the TrackCOllection : %i = %i\n",i,TrackColl.size());
1303 >           for ( unsigned int t = 0; t < TrackColl.size(); ++t ) {
1304 >              reco::Track  recoTrack  =TrackColl[t];
1305 >
1306 >              FROG_Element_Event_Track* frogTrk = new FROG_Element_Event_Track(TrajectoryProducers.size()+i,recoTrack.p(),recoTrack.pt(), recoTrack.chi2());
1307 >              frogTrkColl->addDaughter(frogTrk);
1308 >
1309 >              for(unsigned int h=0;h<recoTrack.recHitsSize();h++){
1310 >                 TrackingRecHitRef h_it     = recoTrack.recHit(h);
1311 >                 if(!h_it->isValid() )continue;
1312 >                 DetId detId                = h_it->geographicalId();
1313 >                 const GeomDet * theDet = NULL;
1314 >
1315 >                 if(detId.det()==DetId::Tracker)                        theDet = tkGeom->idToDet(detId);
1316 >                 if(detId.det()==DetId::Muon && detId.subdetId() == 1)  theDet = DtGeom->idToDet(detId);
1317 >                 if(detId.det()==DetId::Muon && detId.subdetId() == 2)  theDet = CscGeom->idToDet(detId);
1318 >                 if(detId.det()==DetId::Muon && detId.subdetId() == 3)  theDet = RpcGeom->idToDet(detId);
1319 >
1320 >                 LocalPoint localPos        = h_it->localPosition();
1321 >
1322 >                 FROG_Element_Event_Hit* frogHit = new FROG_Element_Event_Hit(
1323 >                        detId.rawId(),
1324 >                        theDet->surface().toGlobal(localPos).x(),
1325 >                        theDet->surface().toGlobal(localPos).y(),
1326 >                        theDet->surface().toGlobal(localPos).z(),
1327 >                        -1);
1328 >                 frogTrk->addDaughter(frogHit);
1329 >              }
1330 >              //printf("Add a Track\n");
1331 >
1332 >           }
1333 >        }
1334 >
1335 >
1336 >
1337 >
1338 >
1339 >
1340 >        // ### HIGH RECO OBJECTS CONTAINER ###
1341 >        FROG_Element_Base_With_DetId_And_Name* frogHighReco = new FROG_Element_Base_With_DetId_And_Name( EVTID_HIGHRECO, "RECO HIGH");
1342 >        event->addDaughter(frogHighReco);
1343 >
1344 >
1345 >
1346 >        FROG_Element_Base_With_DetId_And_Name* frogJet = new FROG_Element_Base_With_DetId_And_Name( EVTID_JET, "Jets");
1347 >        frogHighReco->addDaughter(frogJet);
1348 >
1349 >
1350 >        // ### Basic Jets ###
1351 >        FROG_Element_Base_With_DetId_And_Name* frogBasicJet = new FROG_Element_Base_With_DetId_And_Name( EVTID_JET_BASIC, "BasicJets");
1352 >        frogJet->addDaughter(frogBasicJet);
1353 >        for(unsigned int i=0;i<BasicJetsProducers.size();i++){
1354 >           edm::Handle<BasicJetCollection> h_Basic_Jets;
1355 >           iEvent.getByLabel(BasicJetsProducers[i], h_Basic_Jets);
1356 >           BasicJetCollection Basic_Jets = *h_Basic_Jets.product();
1357 >
1358 >           FROG_Element_Base_With_DetId_And_Name* frogBasicJetColl = new FROG_Element_Base_With_DetId_And_Name( EVTID_JET_BASIC + i + 1, BasicJetsProducers[i].encode().c_str());
1359 >           frogBasicJet->addDaughter(frogBasicJetColl);
1360 >
1361 >           for(unsigned int h=0;h<Basic_Jets.size();h++){
1362 >                FROG_Element_Event_Jet* frogJet = new FROG_Element_Event_Jet(Basic_Jets[h].p(), Basic_Jets[h].eta(),Basic_Jets[h].phi());
1363 >                frogBasicJet->addDaughter(frogJet);
1364 >           }
1365 >        }
1366 >
1367 >
1368 >        // ### Calo Jets ###
1369 >        FROG_Element_Base_With_DetId_And_Name* frogCaloJet = new FROG_Element_Base_With_DetId_And_Name( EVTID_JET_CALO, "CaloJets");
1370 >        frogJet->addDaughter(frogCaloJet);
1371 >        for(unsigned int i=0;i<CaloJetsProducers.size();i++){
1372 >           edm::Handle<CaloJetCollection> h_Calo_Jets;
1373 >           iEvent.getByLabel(CaloJetsProducers[i], h_Calo_Jets);
1374 >           CaloJetCollection Calo_Jets = *h_Calo_Jets.product();
1375 >
1376 >           FROG_Element_Base_With_DetId_And_Name* frogCaloJetColl = new FROG_Element_Base_With_DetId_And_Name( EVTID_JET_CALO + i + 1, CaloJetsProducers[i].encode().c_str());
1377 >           frogCaloJet->addDaughter(frogCaloJetColl);
1378 >
1379 >           for(unsigned int h=0;h<Calo_Jets.size();h++){
1380 >                FROG_Element_Event_Jet* frogJet = new FROG_Element_Event_Jet(Calo_Jets[h].p(), Calo_Jets[h].eta(),Calo_Jets[h].phi());
1381 >                frogCaloJetColl->addDaughter(frogJet);
1382 >
1383 >                if(CaloJetsProducersBasedOnCaloTowers){
1384 >
1385 >                   std::vector<CaloTowerPtr> CaloTowers = Calo_Jets[h].getCaloConstituents();
1386 >                   frogJet->Components_CollEvtId_ = EVTID_CALOTOWER + 1;
1387 >                   for(unsigned int t=0;t<CaloTowers.size();t++){  frogJet->Components_Vector_.push_back(CaloTowers[t]->id().rawId());}
1388 >                }
1389 >           }
1390 >        }
1391 >
1392 >        // ### MET ###
1393 >        FROG_Element_Base_With_DetId_And_Name* frogMET = new FROG_Element_Base_With_DetId_And_Name( EVTID_MET_CALO, "MET");
1394 >        frogHighReco->addDaughter(frogMET);
1395 >        for(unsigned int i=0;i<CaloMETProducers.size();i++){
1396 >           edm::Handle<CaloMETCollection> h_met;
1397 >           iEvent.getByLabel(CaloMETProducers[i], h_met);
1398 >           CaloMETCollection reco_met = *h_met.product();
1399 >
1400 >           FROG_Element_Base_With_DetId_And_Name* frogMETColl = new FROG_Element_Base_With_DetId_And_Name( EVTID_MET_CALO + i + 1, CaloMETProducers[i].encode().c_str());
1401 >           frogMET->addDaughter(frogMETColl);
1402 >
1403 >           for(unsigned int h=0;h<reco_met.size();h++){
1404 >                FROG_Element_Event_MET* frogMETevt = new FROG_Element_Event_MET(i, reco_met[h].p(), reco_met[h].eta(),reco_met[h].phi(), reco_met[h].sumEt());
1405 >                frogMETColl->addDaughter(frogMETevt);
1406 >           }
1407 >        }
1408 >
1409 >
1410 >        // ### RecoCandidates ###
1411 >        FROG_Element_Base_With_DetId_And_Name* frogRecoCand = new FROG_Element_Base_With_DetId_And_Name( EVTID_RECOCAND, "RecoCandidates");
1412 >        frogHighReco->addDaughter(frogRecoCand);
1413 >        for(unsigned int i=0;i<RecoCandidateProducers.size();i++){
1414 >           edm::Handle<CandidateCollection> h_reco_Candidates;
1415 >           iEvent.getByLabel(RecoCandidateProducers[i], h_reco_Candidates);
1416 >           CandidateCollection reco_Candidates = *h_reco_Candidates.product();
1417 >
1418 >           FROG_Element_Base_With_DetId_And_Name* frogRecoCandColl = new FROG_Element_Base_With_DetId_And_Name( EVTID_RECOCAND + i + 1, RecoCandidateProducers[i].encode().c_str());
1419 >           frogRecoCand->addDaughter(frogRecoCandColl);
1420 >
1421 >           for(unsigned int h=0;h<reco_Candidates.size();h++){
1422 >                FROG_Element_Event_Candidate* frogCandidate = new FROG_Element_Event_Candidate(reco_Candidates[h].pdgId(), reco_Candidates[h].p(), reco_Candidates[h].eta(),reco_Candidates[h].phi());
1423 >                frogRecoCandColl->addDaughter(frogCandidate);
1424 >           }
1425 >        }
1426 >
1427 >
1428 >
1429 >   NEvents++;
1430 >   if(NEvents == NEventsInVisFile){
1431 >      char OutputFileName[1024];
1432 >      sprintf(OutputFileName,"%s",OutputFile.substr(0,OutputFile.size()-4).c_str());
1433 >      if(NEventsInVisFile>=0)sprintf(OutputFileName,"%s_Run%i_1stEvent%08i",OutputFileName,SRun,SEvent);
1434 >      sprintf(OutputFileName,"%s.vis",OutputFileName);
1435 >
1436 >      FROG_Events* events = new FROG_Events(events_prim);
1437 >      events->Save((char*) OutputFileName, CompressFiles);
1438 >      delete events;
1439 >      delete events_prim;
1440 >
1441 >      events_prim = new FROG_Element_Base(C_PRIMARY);
1442 >      NEvents=0;
1443 >   }
1444 >
1445   }
1446  
1447  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines