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.9 by querten, Sat May 10 14:14:03 2008 UTC vs.
Revision 1.44 by querten, Fri Oct 10 06:05:49 2008 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines