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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines