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.13 by roberfro, Tue Jun 24 09:20:38 2008 UTC vs.
Revision 1.22 by querten, Wed Jul 9 08:49:50 2008 UTC

# Line 124 | Line 124
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;
# Line 144 | 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_Events*          events;
148 <      FROG_Element_Base*    event_prim;
148 >      FROG_Element_Base*    events_prim;
149  
150        std::string           OutputFile;
151  
# Line 164 | Line 164 | class Frog_Analyzer : public edm::EDAnal
164  
165        std::vector<InputTag> RPCHitsProducers;
166  
167
167        // ----------member data ---------------------------
168 +
169 +      bool                  ProduceGeom;
170 +      int                   NEventsInVisFile;
171 +      int                   NEvents;
172 +
173 +      unsigned int          SRun;
174 +      unsigned int          SEvent;
175   };
176  
177   //
# Line 191 | 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 202 | Line 212 | Frog_Analyzer::~Frog_Analyzer()
212   void
213   Frog_Analyzer::beginJob(const edm::EventSetup& iSetup)
214   {
215 <   DetId  Detid;
216 <   unsigned int    SubDet;
217 <
218 <   unsigned int Frog_DetId;
219 <   FROG_Element_Base*            FEB      = NULL;
220 <   FROG_Element_Base_With_DetId* FEB_Temp = NULL;
221 <
222 <   FROG_Element_Base* prim               = new FROG_Element_Base(C_PRIMARY);
223 <   FROG_Element_Base* geom               = new FROG_Element_Base(C_GEOMETRY);                          prim->addDaughter(geom);
224 <   FROG_Element_Base_With_DetId* tracker = new FROG_Element_Base_With_DetId(C_FEB_DETID, DETID_TRK);   geom->addDaughter(tracker);
225 <   FROG_Element_Base_With_DetId* muon    = new FROG_Element_Base_With_DetId(C_FEB_DETID, DETID_MUON);  geom->addDaughter(muon);
226 <   FROG_Element_Base_With_DetId* ecal    = new FROG_Element_Base_With_DetId(C_FEB_DETID, DETID_ECAL);  geom->addDaughter(ecal);
227 <   FROG_Element_Base_With_DetId* hcal    = new FROG_Element_Base_With_DetId(C_FEB_DETID, DETID_HCAL);  geom->addDaughter(hcal);
228 <
229 <
230 <   // ### TRACKER GEOMETRY ###
231 <
232 <   edm::ESHandle<TrackerGeometry> tkGeom;
233 <   iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom );
234 <   vector<GeomDet*> TrackerDets = tkGeom->dets();
235 <
236 <   for(unsigned int i=0;i<TrackerDets.size();i++){
237 <      Detid  = TrackerDets[i]->geographicalId();
238 <      SubDet = Detid.subdetId();
239 <      if(SubDet<1 || SubDet>6) continue;
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    
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 <      }
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());
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;
281 >         Frog_DetId = DETID_TRK;
282 >         FEB        = tracker;
283  
284 <      Frog_DetId += SubDet*100000;
274 <      FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
275 <      FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
276 <      if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
277 <
278 <      if(SubDet==PixelSubdetector::PixelBarrel){
279 <         PXBDetId detid = PXBDetId(Detid);
280 <
281 <         Frog_DetId += detid.layer()*10000;
282 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
283 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
284 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
285 <
286 <         Frog_DetId += detid.ladder()*100;
287 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
288 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
289 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
290 <      }else if(SubDet==PixelSubdetector::PixelEndcap){
291 <         PXFDetId detid = PXFDetId(Detid);
292 <
293 <         Frog_DetId += detid.side()*10000;
294 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
295 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
296 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
297 <
298 <         Frog_DetId += detid.disk()*1000;
299 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
300 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
301 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
302 <
303 <         Frog_DetId += detid.blade()*10;
304 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
305 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
306 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
307 <
308 <         Frog_DetId += detid.panel()*1;
309 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
310 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
311 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
312 <      }else if(SubDet==StripSubdetector::TIB){
313 <         TIBDetId detid = TIBDetId(Detid);
314 <
315 <         Frog_DetId += detid.layer()*10000;
316 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
317 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
318 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
319 <
320 <         Frog_DetId += detid.stringNumber()*100;
321 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
322 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
323 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
324 <      }else if(SubDet==StripSubdetector::TID){
325 <         TIDDetId detid = TIDDetId(Detid);
326 <
327 <         Frog_DetId += detid.side()*10000;
328 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
329 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
330 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
331 <
332 <         Frog_DetId += detid.wheel()*1000;
333 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
334 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
335 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
336 <
337 <         Frog_DetId += detid.ring()*10;
338 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
339 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
340 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
341 <      }else if(SubDet==StripSubdetector::TOB){
342 <         TOBDetId detid = TOBDetId(Detid);
343 <
344 <         Frog_DetId += detid.layer()*10000;
345 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
346 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
347 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
348 <
349 <         Frog_DetId += detid.rodNumber()*100;
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);}
353      }else if(SubDet==StripSubdetector::TEC){
354         TECDetId detid = TECDetId(Detid);
288  
289 <         Frog_DetId += detid.side()*10000;
290 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
358 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
359 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
289 >         if(SubDet==PixelSubdetector::PixelBarrel){
290 >            PXBDetId detid = PXBDetId(Detid);
291  
292 <         Frog_DetId += detid.wheel()*1000;
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);}
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.ring()*10;
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);}
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.petalNumber();
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);}
375 <      }else{
376 <         if(mod)delete mod;
377 <         continue;
378 <      }
379 <      FEB->addDaughter(mod);
380 <   }
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 <   // ### MUON GEOMETRY ###
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 <   edm::ESHandle<DTGeometry> DtGeom;
320 <   iSetup.get<MuonGeometryRecord>().get( DtGeom );
321 <   const vector<GeomDet*> DtDets = DtGeom->dets();
322 <
323 <   edm::ESHandle<CSCGeometry> CscGeom;
324 <   iSetup.get<MuonGeometryRecord>().get( CscGeom );
391 <   const vector<GeomDet*> CscDets = CscGeom->dets();
392 <
393 <   edm::ESHandle<RPCGeometry> RpcGeom;
394 <   iSetup.get<MuonGeometryRecord>().get( RpcGeom );
395 <   const vector<GeomDet*> RpcDets = RpcGeom->dets();
396 <
397 <   vector<GeomDet*> MuonDets;
398 <   for(unsigned int i=0;i<DtDets.size() ;i++){MuonDets.push_back(DtDets [i]);}
399 <   for(unsigned int i=0;i<CscDets.size();i++){MuonDets.push_back(CscDets[i]);}
400 <   for(unsigned int i=0;i<RpcDets.size();i++){MuonDets.push_back(RpcDets[i]);}
401 <
402 <
403 <   for(unsigned int i=0;i<MuonDets.size();i++)
404 <   {
405 <      Detid  = DetId(MuonDets[i]->geographicalId());
406 <      SubDet = Detid.subdetId();
407 <
408 <      GeomDet* DetUnit = MuonDets[i];
409 <      if(!DetUnit)continue;
410 <      const BoundPlane plane = DetUnit->surface();
411 <      const TrapezoidalPlaneBounds* trapezoidalBounds( dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
412 <      const RectangularPlaneBounds* rectangularBounds( dynamic_cast<const RectangularPlaneBounds*>(&(plane.bounds())));
413 <
414 <      float width            = 0;
415 <      float length           = 0;
416 <      float thickness        = 0;
417 <      float TrapezoidalParam = 0;
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 <      if(trapezoidalBounds)
327 <      {
328 <         std::vector<float> const & parameters = (*trapezoidalBounds).parameters();
329 <         width            = parameters[0]*2;
423 <         length           = parameters[3]*2;
424 <         thickness        =  (*trapezoidalBounds).thickness();
425 <         TrapezoidalParam = parameters[1]/parameters[0];
426 <      }else if(rectangularBounds){
427 <         width            = DetUnit->surface().bounds().width();
428 <         length           = DetUnit->surface().bounds().length();
429 <         thickness        = DetUnit->surface().bounds().thickness();
430 <         TrapezoidalParam = 1;
431 <      }
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 <      Surface::GlobalPoint WidthVector  = plane.toGlobal( LocalPoint(width/2, 0, 0) );
332 <      Surface::GlobalPoint LengthVector = plane.toGlobal( LocalPoint(0, length/2, 0) );
333 <      Surface::GlobalPoint ThickVector  = plane.toGlobal( LocalPoint(0, 0, thickness/2) );
334 <
335 <      GlobalVector Pos =  GlobalVector(DetUnit->position().basicVector());
336 <
439 <      FROG_Element_Geom_TrackerMod* mod = new FROG_Element_Geom_TrackerMod(
440 <           Detid.rawId(),           TrapezoidalParam,
441 <           Pos.x(),                  Pos.y(),                  Pos.z(),
442 <           WidthVector.x() -Pos.x(), WidthVector.y() -Pos.y(), WidthVector.z() -Pos.z(),
443 <           LengthVector.x()-Pos.x(), LengthVector.y()-Pos.y(), LengthVector.z()-Pos.z(),
444 <           ThickVector.x() -Pos.x(), ThickVector.y() -Pos.y(), ThickVector.z() -Pos.z());
445 <
446 <      Frog_DetId = DETID_MUON;
447 <      FEB        = muon;
448 <
449 <      Frog_DetId += SubDet*100000;
450 <      FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
451 <      FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
452 <      if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
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 <      if(SubDet==1){
339 <         DTChamberId detid = DTChamberId(Detid);
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()+3)*10000;
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);}
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.station()*100;
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);}
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.sector()*1;
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==2){
365 <         CSCDetId detid = CSCDetId(Detid);
473 <  
474 <         Frog_DetId += detid.endcap()*10000;
475 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
476 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
477 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
478 <  
479 <         Frog_DetId += detid.station()*1000;
480 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
481 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
482 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
483 <  
484 <         Frog_DetId += detid.ring()*100;
485 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
486 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
487 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
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.chamber()*1;
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);}
493 <      }else if(SubDet==3){
494 <         RPCDetId detid = RPCDetId(Detid);
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.region()+2)*10000;
373 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
374 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
375 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
372 >            Frog_DetId += detid.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 <         // Barrel
502 <         if(detid.region()==0){
503 <            Frog_DetId += (detid.ring()+3)*1000;
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 <         // Endcap
382 <         }else{
509 <            Frog_DetId += detid.ring()*1000;
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 <
515 <         Frog_DetId += detid.station()*100;
516 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
517 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
518 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
519 <
520 <         Frog_DetId += detid.sector()*1;
521 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
522 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
523 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
390 >         FEB->addDaughter(mod);
391        }
392  
526      FEB->addDaughter(mod);
527   }
393  
394 +      // ### MUON GEOMETRY ###
395  
396 <      
397 <   // ### CALO GEOMETRY ###
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 <   edm::ESHandle<CaloGeometry> CaloGeom;
419 <   iSetup.get<IdealGeometryRecord>().get( CaloGeom );
420 <   const vector<DetId> CaloDets = CaloGeom->getValidDetIds();
421 <
422 <   for(unsigned int i=0;i<CaloDets.size();i++)
423 <   {
424 <      Detid  = CaloDets[i];
425 <      SubDet = Detid.subdetId();
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 <      if(Detid.det()==DetId::Ecal){
444 <        if(SubDet<1 || SubDet>3) continue;
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_ECAL;
457 <         FEB        = ecal;
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);
# Line 551 | Line 462 | Frog_Analyzer::beginJob(const edm::Event
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 <            EBDetId detid = EBDetId(Detid);
465 >                DTChamberId detid = DTChamberId(Detid);
466  
467 <            Frog_DetId += ((detid.zside()==1)+1)*10000;
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.tower_ieta()*detid.zside())*100;
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.tower_iphi()*1;
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 <            EEDetId detid = EEDetId(Detid);
483 <
484 <            Frog_DetId += ((detid.zside()==1)+1)*10000;
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.iquadrant()*1000;
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.isc();
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 <         }else if(SubDet==3){
499 <            ESDetId detid = ESDetId(Detid);
589 <
590 <            Frog_DetId += ((detid.zside()==1)+1)*10000;
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.plane()*1000;
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 <            Frog_DetId += detid.six()*50;
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.siy();
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           }
610      }else if(Detid.det()==DetId::Hcal){
611        if(SubDet<1 || SubDet>4) continue;
535  
536 <         Frog_DetId = DETID_HCAL;
537 <         FEB        = hcal;
536 >         FEB->addDaughter(mod);
537 >      }
538  
616         Frog_DetId += SubDet*100000;
617         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
618         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
619         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
539  
540 <         if(true){
541 <            HcalDetId detid = HcalDetId(Detid);
540 >      
541 >      // ### CALO GEOMETRY ###
542 >
543 >      edm::ESHandle<CaloGeometry> CaloGeom;
544 >      iSetup.get<IdealGeometryRecord>().get( CaloGeom );
545 >      const vector<DetId> CaloDets = CaloGeom->getValidDetIds();
546 >
547 >      for(unsigned int i=0;i<CaloDets.size();i++)
548 >      {
549 >         Detid  = CaloDets[i];
550 >         SubDet = Detid.subdetId();
551  
552 <            Frog_DetId += ((detid.zside()==1)+1)*10000;
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 <            Frog_DetId += detid.ietaAbs()*100;
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 <            Frog_DetId += detid.iphi()*1;
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 <
642 <      }else if(Detid.det() == DetId::Calo){
643 <      continue;
644 <      /*
645 <         Frog_DetId = DETID_CALO + 1000000;
646 <         FEB        = hcal;
647 <
648 <         Frog_DetId += SubDet*100000;
649 <         FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId*>(FEB);
650 <         FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
651 <         if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId(C_FEB_DETID, Frog_DetId); FEB_Temp->addDaughter(FEB);}
652 <      */
688 >         FEB->addDaughter(mod);
689        }
690  
691 <      const CaloCellGeometry* CellGeom = CaloGeom->getGeometry(Detid);
656 <      GlobalPoint CellPos =  CellGeom->getPosition();
657 <      const CaloCellGeometry::CornersVec CellCorners =  CellGeom->getCorners();
658 <
659 <      float cX = (CellCorners[0].x() + CellCorners[2].x())/2;
660 <      float cY = (CellCorners[0].y() + CellCorners[2].y())/2;
661 <      float cZ = (CellCorners[0].z() + CellCorners[2].z())/2;
662 <
663 <      float wX = (CellCorners[1].x() - CellCorners[0].x())/2;
664 <      float wY = (CellCorners[1].y() - CellCorners[0].y())/2;
665 <      float wZ = (CellCorners[1].z() - CellCorners[0].z())/2;
666 <        
667 <      float hX = (CellCorners[3].x() - CellCorners[0].x())/2;
668 <      float hY = (CellCorners[3].y() - CellCorners[0].y())/2;
669 <      float hZ = (CellCorners[3].z() - CellCorners[0].z())/2;
670 <
671 <      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) );
672 <            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) );
673 <
674 <      FROG_Element_Geom_CaloMod* mod = new FROG_Element_Geom_CaloMod(
675 <                        Detid.rawId(), F,
676 <                        cX  ,   cY  , cZ ,
677 <                        wX  ,   wY  , wZ ,
678 <                        hX  ,   hY  , hZ );
691 >      // ### Save .geom ###
692  
693 <      FEB->addDaughter(mod);
693 >      FROG_Geometry* CMS_Geom = new FROG_Geometry(prim);
694 >      CMS_Geom->Save("CMS.geom");  
695     }
696  
697 <
684 <
685 <   // ### Save .geom ###
686 <
687 <   Geometry* CMS_Geom = new Geometry(prim);
688 <   CMS_Geom->Save("CMS.geom");  
689 <
690 <   event_prim = new FROG_Element_Base(C_PRIMARY);  
691 <   events     = new FROG_Events(event_prim);
692 <
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 <     events->Save((char*) OutputFile.c_str());
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 709 | Line 727 | Frog_Analyzer::endJob()
727   void
728   Frog_Analyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
729   {
730 <        FROG_Event* event =  new FROG_Event();
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> tkGeom;
# Line 724 | Line 749 | Frog_Analyzer::analyze(const edm::Event&
749          edm::ESHandle<RPCGeometry> RpcGeom;
750          iSetup.get<MuonGeometryRecord>().get( RpcGeom );
751  
727
728        // 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 ) {
762                  SimTrack    simTrack    =SimTrackColl[a];
763  
# Line 739 | Line 765 | Frog_Analyzer::analyze(const edm::Event&
765                          simTrack.momentum().x(),     simTrack.momentum().y(),     simTrack.momentum().z(),
766                          simTrack.momentum().e(),     simTrack.type(),             simTrack.vertIndex(),
767                          simTrack.charge() );
768 <
743 <                event->addSimTrack( frogSimTrk );
744 < //              MyEvent->MySimTrackCollection.push_back(MysimTrack);
768 >                frogSimTrkColl->addDaughter(frogSimTrk);
769             }      
770          }
771  
# Line 751 | 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 ) {
782                  SimVertex       Vertex  =  VertexColl[b];
783  
# Line 758 | Line 785 | Frog_Analyzer::analyze(const edm::Event&
785                          Vertex.position().x(),  Vertex.position().y(),  Vertex.position().z(),
786                          Vertex.parentIndex());
787  
788 <                event->addSimVertex(frogSimVtx);
788 >                frogSimVtxColl->addDaughter(frogSimVtx);
789             }
790          }
791  
792  
793          // ### SIMHIT ###
794 < /*
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();
783 <                Hit->dEdX        = Hits[h].energyLoss();
784 <
785 <                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 < */
815 >
816  
817  
818          // ### TRAJECTORY ###
# Line 794 | Line 821 | Frog_Analyzer::analyze(const edm::Event&
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* frogRecoTk = new FROG_Element_Event_Track(i,it->val->p(),it->val->pt(),it->key->chiSquared());
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 806 | Line 837 | Frog_Analyzer::analyze(const edm::Event&
837                        DetId detId                = h_it->geographicalId();
838                        GlobalPoint globalPos      = measurements[h].updatedState().globalPosition();
839  
840 <                      FROG_Element_Event_Hit* frogHit =
841 <                        new FROG_Element_Event_Hit(detId.rawId(), globalPos.x(),globalPos.y(),  globalPos.z(), -1);
811 <                      frogRecoTk->addHit(frogHit);
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                  }
813 //                MyEvent->MyRecoTrackCollection.push_back(MyrecoTrack);
814                event->addRecoTrack(frogRecoTk);
843             }
844          }
845  
# Line 822 | Line 850 | Frog_Analyzer::analyze(const edm::Event&
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];
828 <
829 <                FROG_Element_Event_Track* frogRecoTk = new FROG_Element_Event_Track(TrajectoryProducers.size()+i,recoTrack.p(),recoTrack.pt(), recoTrack.chi2());
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 <                      
875 <                      LocalPoint localPos        = h_it->localPosition();
876 <
877 <                      FROG_Element_Event_Hit* frogHit = new FROG_Element_Event_Hit(
878 <                                                detId.rawId(),
879 <                                                theDet->surface().toGlobal(localPos).x(),
880 <                                                theDet->surface().toGlobal(localPos).y(),
881 <                                                theDet->surface().toGlobal(localPos).z(),
882 <                                                -1);
883 <                      frogRecoTk->addHit(frogHit);
853 <                }
854 <                event->addRecoTrack(frogRecoTk);
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  
860 /*
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 = new MyCaloHit;
900 <                temp_EcalHit->E     = Ecal_RecHits[eh].energy();
901 <                temp_EcalHit->t     = Ecal_RecHits[eh].time();
871 <                temp_EcalHit->DetId = (Ecal_RecHits[eh].detid()).rawId();
872 <        
873 <                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 881 | 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;
886 <                temp_HcalHBHEHit->E      = HcalHBHE_RecHits[hh].energy();
887 <                temp_HcalHBHEHit->t      = HcalHBHE_RecHits[hh].time();
888 <                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  
894
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;
902 <                temp_HcalHOHit->E      = HcalHO_RecHits[hh].energy();
903 <                temp_HcalHOHit->t      = HcalHO_RecHits[hh].time();
904 <                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  
910
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;
918 <                temp_HcalHFHit->E      = HcalHF_RecHits[hh].energy();
919 <                temp_HcalHFHit->t      = HcalHF_RecHits[hh].time();
920 <                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 929 | 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();
940 <                temp_CscSeg->PosZ  = theDet->surface().toGlobal(CSC_Segments[s].localPosition()).z();
941 <                temp_CscSeg->DirX  = theDet->surface().toGlobal(CSC_Segments[s].localDirection()).x();
942 <                temp_CscSeg->DirY  = theDet->surface().toGlobal(CSC_Segments[s].localDirection()).y();
943 <                temp_CscSeg->DirZ  = theDet->surface().toGlobal(CSC_Segments[s].localDirection()).z();
944 <
945 <                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 951 | 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();
962 <                temp_DtSeg->PosZ  = theDet->surface().toGlobal(DT_Segments[s].localPosition()).z();
963 <                temp_DtSeg->DirX  = theDet->surface().toGlobal(DT_Segments[s].localDirection()).x();
964 <                temp_DtSeg->DirY  = theDet->surface().toGlobal(DT_Segments[s].localDirection()).y();
965 <                temp_DtSeg->DirZ  = theDet->surface().toGlobal(DT_Segments[s].localDirection()).z();
966 <
967 <                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 974 | 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();
984 <                temp_RpcHit->y     = theDet->surface().toGlobal(RPC_Hits[h].localPosition()).y();
985 <                temp_RpcHit->z     = theDet->surface().toGlobal(RPC_Hits[h].localPosition()).z();
986 <
987 <                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);  
1011 < */
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  
994 //        event_prim->addDaughter(event);
995        events->addEvent(event);
1026   }
1027  
1028  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines