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

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines