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.7 by querten, Sun May 4 06:46:30 2008 UTC vs.
Revision 1.23 by querten, Fri Jul 11 04:38:40 2008 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines