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

Comparing UserCode/FastOpenGlDisplayer/src/Frog_Analyzer.cc (file contents):
Revision 1.1 by querten, Sat Apr 19 06:16:28 2008 UTC vs.
Revision 1.22 by querten, Wed Jul 9 08:49:50 2008 UTC

# Line 61 | Line 61
61   #include "Geometry/RPCGeometry/interface/RPCGeometry.h"
62  
63  
64
64   #include "DataFormats/CaloRecHit/interface/CaloRecHit.h"
65   #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
66   #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
# Line 80 | Line 79
79   #include "DataFormats/HepMCCandidate/interface/GenParticleCandidate.h"
80   #include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h"
81   #include "DataFormats/TrackReco/interface/Track.h"
82 + #include "TrackingTools/PatternTools/interface/Trajectory.h"
83 + #include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h"
84 +
85 +
86 + #include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h"
87 + #include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h"
88 +
89 + #include "DataFormats/DTRecHit/interface/DTRecHitCollection.h"
90 + #include "DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h"
91 + #include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h"
92  
93   #include "DataFormats/Math/interface/Point3D.h"
94   #include "DataFormats/GeometrySurface/interface/TrapezoidalPlaneBounds.h"
95   #include "DataFormats/GeometrySurface/interface/RectangularPlaneBounds.h"
96  
97 < #include "Visualisation/Frog/interface/SimEvent.h"
98 < #include "Visualisation/Frog/interface/Geometry.h"
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 106 | 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;
111 <      Geometry*    Geom_Tracker;
112 <      Geometry*    Geom_ECAL;
113 <      Geometry*    Geom_HCAL;
114 <      Geometry*    Geom_Muon;
115 <
116 <
117 <      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;
160        std::vector<InputTag> HcalHORecHitProducers;
161        std::vector<InputTag> HcalHFRecHitProducers;
162 +      std::vector<InputTag> DTSegmentProducers;
163 +      std::vector<InputTag> CSCSegmentProducers;
164  
165 +      std::vector<InputTag> RPCHitsProducers;
166  
167 +      // ----------member data ---------------------------
168  
169 +      bool                  ProduceGeom;
170 +      int                   NEventsInVisFile;
171 +      int                   NEvents;
172  
173 <      // ----------member data ---------------------------
173 >      unsigned int          SRun;
174 >      unsigned int          SEvent;
175   };
176  
177   //
# Line 144 | Line 186 | Frog_Analyzer::Frog_Analyzer(const edm::
186      SimHitProducers         = iConfig.getParameter<std::vector<InputTag> >("SimHitProducers");
187  
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");
193      HcalHFRecHitProducers   = iConfig.getParameter<std::vector<InputTag> >("HcalHFRecHitProducers");
194  
195 +    DTSegmentProducers      = iConfig.getParameter<std::vector<InputTag> >("DTSegmentProducers");
196 +    CSCSegmentProducers     = iConfig.getParameter<std::vector<InputTag> >("CSCSegmentProducers");
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 160 | Line 212 | Frog_Analyzer::~Frog_Analyzer()
212   void
213   Frog_Analyzer::beginJob(const edm::EventSetup& iSetup)
214   {
215 <   DetId  Detid;
216 <   int    SubDet;
217 <
218 <   MyEvents     = new MySimEvents();
219 <   Geom_Tracker = new Geometry();
220 <   Geom_ECAL    = new Geometry();
221 <   Geom_HCAL    = new Geometry();
222 <   Geom_Muon    = new Geometry();
223 <
224 <
225 <   // ### TRACKER GEOMETRY ###
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  
175   edm::ESHandle<TrackerGeometry> tkGeom;
176   iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom );
177   vector<GeomDet*> TrackerDets = tkGeom->dets();
178
179   for(unsigned int i=0;i<TrackerDets.size();i++){
180      Detid  = TrackerDets[i]->geographicalId();
181 //    SubDet = Detid.subdetId();
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;
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 <      if(trapezoidalBounds)
281 <      {
282 <         std::vector<float> const & parameters = (*trapezoidalBounds).parameters();      
283 <         width            = parameters[0]*2;
284 <         length           = parameters[3]*2;  
285 <         thickness        =  (*trapezoidalBounds).thickness();
286 <         TrapezoidalParam = parameters[1]/parameters[0];
287 <      }else if(rectangularBounds){
288 <         width            = DetUnit->surface().bounds().width();
289 <         length           = DetUnit->surface().bounds().length();
290 <         thickness        = DetUnit->surface().bounds().thickness();
291 <         TrapezoidalParam = 1;
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  
208      Surface::GlobalPoint WidthVector  = plane.toGlobal( LocalPoint(width/2, 0, 0) );
209      Surface::GlobalPoint LengthVector = plane.toGlobal( LocalPoint(0, length/2, 0) );
210      Surface::GlobalPoint ThickVector  = plane.toGlobal( LocalPoint(0, 0, thickness/2) );
211
212      GlobalVector Pos =  GlobalVector(DetUnit->position().basicVector());
213
214      Geom_Tracker->Add_TrackerDet(Detid.rawId(), TrapezoidalParam,
215           Pos.x(),                  Pos.y(),                  Pos.z(),
216           WidthVector.x() -Pos.x(), WidthVector.y() -Pos.y(), WidthVector.z() -Pos.z(),
217           LengthVector.x()-Pos.x(), LengthVector.y()-Pos.y(), LengthVector.z()-Pos.z(),
218           ThickVector.x() -Pos.x(), ThickVector.y() -Pos.y(), ThickVector.z() -Pos.z());
219      
393  
394 <   }
394 >      // ### MUON GEOMETRY ###
395 >
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 +      for(unsigned int i=0;i<MuonDets.size();i++)
414 +      {
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;
227 <   iSetup.get<IdealGeometryRecord>().get( CaloGeom );
228 <   const vector<DetId> CaloDets = CaloGeom->getValidDetIds();
229 <
230 <   for(unsigned int i=0;i<CaloDets.size();i++)
231 <   {
232 <      Detid  = CaloDets[i];
233 <      SubDet = Detid.subdetId();
234 <
235 <      Geometry* Geom_temp = NULL;
236 <      if(Detid.det()==DetId::Ecal){
237 <        Geom_temp = Geom_ECAL;
238 <
239 <        if(SubDet<1 || SubDet>3){
240 <                printf("Don't Save EcalTriggerTower or EcalLaserPnDiode\n");
241 <                continue;
242 <        }
243 <      }else if(Detid.det()==DetId::Hcal){
244 <        Geom_temp = Geom_HCAL;
245 <
246 <        if(SubDet<1 || SubDet>4){
247 <                printf("Don't Save HcalEmpty, HcalTriggerTower, HcalOther\n");
248 <                continue;
249 <        }
250 <      }else{
251 <        continue;
536 >         FEB->addDaughter(mod);
537        }
538  
254      const CaloCellGeometry* CellGeom = CaloGeom->getGeometry(Detid);
255      GlobalPoint CellPos =  CellGeom->getPosition();
256      const CaloCellGeometry::CornersVec CellCorners =  CellGeom->getCorners();
257
258      Geom_temp->Add_CaloDet(Detid.rawId(),
259                        CellPos.x()         ,   CellPos.y()         ,   CellPos.z(),
260                        CellCorners[0].x()  ,   CellCorners[0].y()  ,   CellCorners[0].z()  ,
261                        CellCorners[1].x()  ,   CellCorners[1].y()  ,   CellCorners[1].z()  ,
262                        CellCorners[2].x()  ,   CellCorners[2].y()  ,   CellCorners[2].z()  ,
263                        CellCorners[3].x()  ,   CellCorners[3].y()  ,   CellCorners[3].z()  ,
264                        CellCorners[4].x()  ,   CellCorners[4].y()  ,   CellCorners[4].z()  ,
265                        CellCorners[5].x()  ,   CellCorners[5].y()  ,   CellCorners[5].z()  ,
266                        CellCorners[6].x()  ,   CellCorners[6].y()  ,   CellCorners[6].z()  ,
267                        CellCorners[7].x()  ,   CellCorners[7].y()  ,   CellCorners[7].z()  );
268   }
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();
275 <
276 <   edm::ESHandle<CSCGeometry> CscGeom;
277 <   iSetup.get<MuonGeometryRecord>().get( CscGeom );
278 <   const vector<GeomDet*> CscDets = CscGeom->dets();
279 <
280 <   edm::ESHandle<RPCGeometry> RpcGeom;
281 <   iSetup.get<MuonGeometryRecord>().get( RpcGeom );
282 <   const vector<GeomDet*> RpcDets = RpcGeom->dets();
283 <
284 <   vector<GeomDet*> MuonDets;
285 <   for(unsigned int i=0;i<DtDets.size() ;i++){MuonDets.push_back(DtDets [i]);}
286 <   for(unsigned int i=0;i<CscDets.size();i++){MuonDets.push_back(CscDets[i]);}
287 <   for(unsigned int i=0;i<RpcDets.size();i++){MuonDets.push_back(RpcDets[i]);}
288 <
289 <
290 <   for(unsigned int i=0;i<MuonDets.size();i++)
291 <   {
292 <      Detid  = DetId(MuonDets[i]->geographicalId());
293 <      SubDet = Detid.subdetId();
294 <
295 <      GeomDet* DetUnit = MuonDets[i];
296 <      if(!DetUnit)continue;
297 <      const BoundPlane plane = DetUnit->surface();
298 <      const TrapezoidalPlaneBounds* trapezoidalBounds( dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
299 <      const RectangularPlaneBounds* rectangularBounds( dynamic_cast<const RectangularPlaneBounds*>(&(plane.bounds())));
300 <
301 <      float width            = 0;
302 <      float length           = 0;
303 <      float thickness        = 0;
304 <      float TrapezoidalParam = 0;
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;
310 <         length           = parameters[3]*2;
311 <         thickness        =  (*trapezoidalBounds).thickness();
312 <         TrapezoidalParam = parameters[1]/parameters[0];
313 <      }else if(rectangularBounds){
314 <         width            = DetUnit->surface().bounds().width();
315 <         length           = DetUnit->surface().bounds().length();
316 <         thickness        = DetUnit->surface().bounds().thickness();
317 <         TrapezoidalParam = 1;
318 <      }
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) );
322 <      Surface::GlobalPoint ThickVector  = plane.toGlobal( LocalPoint(0, 0, thickness/2) );
323 <
324 <      GlobalVector Pos =  GlobalVector(DetUnit->position().basicVector());
325 <
326 <      Geom_Muon->Add_TrackerDet(Detid.rawId(), TrapezoidalParam,
327 <           Pos.x(),                  Pos.y(),                  Pos.z(),
328 <           WidthVector.x() -Pos.x(), WidthVector.y() -Pos.y(), WidthVector.z() -Pos.z(),
329 <           LengthVector.x()-Pos.x(), LengthVector.y()-Pos.y(), LengthVector.z()-Pos.z(),
330 <           ThickVector.x() -Pos.x(), ThickVector.y() -Pos.y(), ThickVector.z() -Pos.z());
331 <   }
552 >         if(Detid.det()==DetId::Ecal){
553 >             if(SubDet<1 || SubDet>3) continue;
554  
555 +            Frog_DetId = DETID_ECAL;
556 +            FEB        = ecal;
557 +
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 <   // ### Save .geom ###
688 >         FEB->addDaughter(mod);
689 >      }
690  
691 <   Geom_Tracker->Save("Tracker.geom");    
337 <   Geom_ECAL   ->Save("Ecal.geom");
338 <   Geom_HCAL   ->Save("Hcal.geom");
691 >      // ### Save .geom ###
692  
693 <   printf("RPC = %i\n",Geom_Muon   ->Det_Muon_RPC.size());
693 >      FROG_Geometry* CMS_Geom = new FROG_Geometry(prim);
694 >      CMS_Geom->Save("CMS.geom");  
695 >   }
696  
697 <   Geom_Muon   ->Save("Muon.geom");
343 <
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 361 | 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();
737 +        events_prim->addDaughter(event);
738  
739          // access the tracker
740 <        edm::ESHandle<TrackerGeometry> theTrackerGeometry;
741 <        iSetup.get<TrackerDigiGeometryRecord>().get(theTrackerGeometry);
371 <        const TrackerGeometry& theTracker(*theTrackerGeometry);
372 <
373 <        // the DetUnits
374 <        TrackingGeometry::DetContainer theDetUnits = theTracker.dets();
740 >        edm::ESHandle<TrackerGeometry> tkGeom;
741 >        iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom );
742  
743 +        edm::ESHandle<DTGeometry> DtGeom;
744 +        iSetup.get<MuonGeometryRecord>().get( DtGeom );
745 +  
746 +        edm::ESHandle<CSCGeometry> CscGeom;
747 +        iSetup.get<MuonGeometryRecord>().get( CscGeom );
748  
749 <        // Save Data
749 >        edm::ESHandle<RPCGeometry> RpcGeom;
750 >        iSetup.get<MuonGeometryRecord>().get( RpcGeom );
751 >
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 ) {
384                MySimTrack  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();
392 <                MysimTrack.Pz           =simTrack.momentum().z();
393 <                MysimTrack.E            =simTrack.momentum().e();
394 <                MysimTrack.charge       =simTrack.charge();
395 <
396 <                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  
772 <
772 >        // ### SIMVERTEX ###
773          for(unsigned int i=0;i<SimVertexProducers.size();i++){
774             edm::Handle<std::vector< SimVertex > > h_Vertex;
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 ) {
407                MySimVertex     MyVertex;
782                  SimVertex       Vertex  =  VertexColl[b];
783  
784 <                MyVertex.parentTrack_id =Vertex.parentIndex ();
785 <                MyVertex.x              =Vertex.position().x();
786 <                MyVertex.y              =Vertex.position().y();
413 <                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 = theTracker.idToDet(theDetUnitId);
428 <
429 <                MyPSimHit Hit;
430 <                Hit.x           = theDet->surface().toGlobal(Hits[h].localPosition()).x();
431 <                Hit.y           = theDet->surface().toGlobal(Hits[h].localPosition()).y();
432 <                Hit.z           = theDet->surface().toGlobal(Hits[h].localPosition()).z();
433 <                Hit.ProcessType = Hits[h].processType();
434 <                Hit.dEdX        = Hits[h].energyLoss();
805 >                DetId theDetUnitId(Hits[h].detUnitId());
806 >                const GeomDet* theDet = tkGeom->idToDet(theDetUnitId);
807  
808 <                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 +
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 +                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++){
834 +
835 +                      TrajectoryMeasurement::ConstRecHitPointer h_it = measurements[h].recHit();
836 +                      if(!h_it->isValid() )continue;
837 +                      DetId detId                = h_it->geographicalId();
838 +                      GlobalPoint globalPos      = measurements[h].updatedState().globalPosition();
839 +
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 +                }
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 <                MyRecoTrack  MyrecoTrack;
448 <                reco::Track  recoTrack  =TrackColl[t];
858 >              reco::Track  recoTrack  =TrackColl[t];
859  
860 <                for(unsigned int h=0;h<recoTrack.recHitsSize();h++){
861 <                      TrackingRecHitRef h_it     = recoTrack.recHit(h);
452 <                      if(!h_it->isValid() )continue;
453 <                      DetId detId                = h_it->geographicalId();
454 <                      const GeomDet * theDet     = theTracker.idToDet(detId);
455 <                      LocalPoint localPos        = h_it->localPosition();
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 <                      MyRecoHit hit;          
864 <                      hit.x      = theDet->surface().toGlobal(localPos).x();
865 <                      hit.y      = theDet->surface().toGlobal(localPos).y();
866 <                      hit.z      = theDet->surface().toGlobal(localPos).z();
867 <                      hit.DetId  = detId.rawId();
868 <                      hit.Charge = -1;
869 <                      MyrecoTrack.Hits.push_back(hit);
870 <                }
871 <                MyEvent->MyRecoTrackCollection.push_back(MyrecoTrack);
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++){
891             edm::Handle<EcalRecHitCollection > h_Ecal_RecHits;
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;
900 <                temp_EcalHit.E     = Ecal_RecHits[eh].energy();
901 <                temp_EcalHit.t     = Ecal_RecHits[eh].time();
479 <                temp_EcalHit.DetId = (Ecal_RecHits[eh].detid()).rawId();
480 <        
481 <                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  
905  
906 +        // ### HCALRecHits ###
907          for(unsigned int i=0;i<HcalHBHERecHitProducers.size();i++){
908             edm::Handle<HBHERecHitCollection > h_HcalHBHE_RecHits;
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;
493 <                temp_HcalHBHEHit.E      = HcalHBHE_RecHits[hh].energy();
494 <                temp_HcalHBHEHit.t      = HcalHBHE_RecHits[hh].time();
495 <                temp_HcalHBHEHit.DetId = (HcalHBHE_RecHits[hh].detid()).rawId();
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  
501
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;
509 <                temp_HcalHOHit.E      = HcalHO_RecHits[hh].energy();
510 <                temp_HcalHOHit.t      = HcalHO_RecHits[hh].time();
511 <                temp_HcalHOHit.DetId = (HcalHO_RecHits[hh].detid()).rawId();
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  
517
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 +           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             for(unsigned int hh=0;hh<HcalHF_RecHits.size();hh++){
946 <                MyCaloHit temp_HcalHFHit;
947 <                temp_HcalHFHit.E      = HcalHF_RecHits[hh].energy();
948 <                temp_HcalHFHit.t      = HcalHF_RecHits[hh].time();
949 <                temp_HcalHFHit.DetId = (HcalHF_RecHits[hh].detid()).rawId();
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 >
952 >        // ### Muon Segments ###
953 >        for(unsigned int i=0;i<CSCSegmentProducers.size();i++){
954 >           edm::Handle<CSCSegmentCollection > h_CSC_Segments;
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 >                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  
972 <                MyEvent->MyHcalCaloHitCollection.push_back(temp_HcalHFHit);
972 >        for(unsigned int i=0;i<DTSegmentProducers.size();i++){
973 >           edm::Handle<DTRecSegment4DCollection > h_DT_Segments;
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 >                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  
991 <        MyEvents->Events.push_back(MyEvent);  
991 >        // ### Muon Hits ###
992 >        for(unsigned int i=0;i<RPCHitsProducers.size();i++){
993 >           edm::Handle<RPCRecHitCollection > h_RPC_Hits;
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 >                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 >   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