Page Menu
Home
HEPForge
Search
Configure Global Search
Log In
Files
F8309797
Frog_Analyzer.cc_for_16X
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
70 KB
Subscribers
None
Frog_Analyzer.cc_for_16X
View Options
// -*- C++ -*-
//
// Package: Frog_Analyzer
// Class: Frog_Analyzer
//
/**\class Frog_Analyzer Frog_Analyzer.cc Visualisation/Frog/src/Frog_Analyzer.cc
Description: <one line class summary>
Implementation:
<Notes on implementation>
*/
//
// Original Author: Loic QUERTENMONT
// Created: Fri Oct 26 07:22:12 CEST 2007
// $Id: Frog_Analyzer.cc_for_16X,v 1.3 2008-11-24 07:30:13 querten Exp $
//
//
// system include files
#include <memory>
// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
#include "Geometry/CommonDetUnit/interface/GeomDetUnit.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
#include "Geometry/TrackerNumberingBuilder/interface/GeometricDet.h"
#include "Geometry/CommonTopologies/interface/PixelTopology.h"
#include "Geometry/CommonTopologies/interface/StripTopology.h"
#include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetType.h"
#include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetType.h"
#include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h"
#include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h"
#include "DataFormats/GeometrySurface/interface/BoundSurface.h"
#include "DataFormats/DetId/interface/DetId.h"
#include "Geometry/CaloEventSetup/interface/CaloTopologyRecord.h"
#include "Geometry/Records/interface/IdealGeometryRecord.h"
#include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
#include "Geometry/CaloGeometry/interface/CaloGeometry.h"
//#include "Geometry/EcalBarrelAlgo/interface/EcalBarrelGeometry.h"
//#include "Geometry/EcalEndcapAlgo/interface/EcalEndcapGeometry.h"
#include "Geometry/Records/interface/IdealGeometryRecord.h"
//#include "Geometry/EcalAlgo/interface/EcalBarrelGeometry.h"
//#include "Geometry/EcalAlgo/interface/EcalEndcapGeometry.h"
#include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
#include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
#include "Geometry/CommonDetUnit/interface/TrackingGeometry.h"
#include "Geometry/Records/interface/MuonGeometryRecord.h"
#include "Geometry/DTGeometry/interface/DTGeometry.h"
#include "Geometry/CSCGeometry/interface/CSCGeometry.h"
#include "Geometry/RPCGeometry/interface/RPCGeometry.h"
#include "DataFormats/Common/interface/DetSetVector.h"
#include "DataFormats/Common/interface/DetSetVectorNew.h"
#include "DataFormats/SiStripCluster/interface/SiStripClusterCollection.h"
#include "DataFormats/CaloRecHit/interface/CaloRecHit.h"
#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
#include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
#include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
#include "SimDataFormats/TrackingHit/interface/PSimHit.h"
#include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h"
#include "SimDataFormats/CrossingFrame/interface/MixCollection.h"
#include "SimDataFormats/CaloHit/interface/PCaloHit.h"
#include "SimDataFormats/Track/interface/SimTrack.h"
#include "SimDataFormats/Vertex/interface/SimVertex.h"
#include "DataFormats/Provenance/interface/BranchDescription.h"
#include "DataFormats/Provenance/interface/Provenance.h"
#include "DataFormats/Candidate/interface/Candidate.h"
#include "DataFormats/HepMCCandidate/interface/GenParticleCandidate.h"
#include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h"
#include "DataFormats/TrackReco/interface/Track.h"
#include "TrackingTools/PatternTools/interface/Trajectory.h"
#include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h"
#include "DataFormats/HepMCCandidate/interface/GenParticle.h"
#include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h"
#include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h"
#include "DataFormats/DTRecHit/interface/DTRecHitCollection.h"
#include "DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h"
#include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h"
#include "DataFormats/Math/interface/Point3D.h"
#include "DataFormats/GeometrySurface/interface/TrapezoidalPlaneBounds.h"
#include "DataFormats/GeometrySurface/interface/RectangularPlaneBounds.h"
#include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
#include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
#include "DataFormats/SiPixelDetId/interface/PXBDetId.h"
#include "DataFormats/SiPixelDetId/interface/PXFDetId.h"
#include "DataFormats/SiStripDetId/interface/TIBDetId.h"
#include "DataFormats/SiStripDetId/interface/TIDDetId.h"
#include "DataFormats/SiStripDetId/interface/TOBDetId.h"
#include "DataFormats/SiStripDetId/interface/TECDetId.h"
#include "DataFormats/MuonDetId/interface/DTChamberId.h"
#include "DataFormats/MuonDetId/interface/CSCDetId.h"
#include "DataFormats/MuonDetId/interface/RPCDetId.h"
#include "DataFormats/EcalDetId/interface/EBDetId.h"
#include "DataFormats/EcalDetId/interface/EEDetId.h"
#include "DataFormats/EcalDetId/interface/ESDetId.h"
#include "DataFormats/HcalDetId/interface/HcalDetId.h"
//#include "DataFormats/VertexReco/interface/NuclearInteraction.h"
#include "DataFormats/JetReco/interface/Jet.h"
#include "DataFormats/JetReco/interface/BasicJetCollection.h"
#include "DataFormats/JetReco/interface/GenJetfwd.h"
#include "DataFormats/JetReco/interface/CaloJetCollection.h"
#include "DataFormats/JetReco/interface/PFJetfwd.h"
#include "DataFormats/METReco/interface/CaloMET.h"
#include "DataFormats/METReco/interface/CaloMETFwd.h"
#define FROG_ZLIB
//#include "Visualisation/Frog/soft/Includes/FROG/FROG_Element_Base_With_DetId_And_Name.h"
#include "Visualisation/Frog/soft/Includes/FROG/FROG_Element_Tools.h"
#include "Visualisation/Frog/soft/Includes/FROG/FROG_Element_Tools.cpp"
#include "Visualisation/Frog/soft/Includes/FROG/FROG_Element_Event_Track.h"
#include "Visualisation/Frog/soft/Includes/FROG/FROG_Events.h"
#include "Visualisation/Frog/soft/Includes/FROG/FROG_Events.cpp"
#include "Visualisation/Frog/soft/Includes/FROG/FROG_Geometry.h"
#include "Visualisation/Frog/soft/Includes/FROG/FROG_Geometry.cpp"
#include "Visualisation/Frog/soft/Includes/FROG/FROG_DetId.h"
#include "Visualisation/Frog/soft/Includes/FROG/FROG_ReadCards.cpp"
#include "Visualisation/Frog/soft/Includes/FROG/FROG_Coord.h"
#include "Visualisation/Frog/soft/Includes/FROG/FROG_Coord.cpp"
#include "Visualisation/Frog/soft/Includes/FROG/FROG_ZLib.h"
#include "Visualisation/Frog/soft/Includes/FROG/FROG_ZLib.cpp"
#include "Visualisation/Frog/soft/Includes/FROG/FROG_Path.h"
#include "Visualisation/Frog/soft/Includes/FROG/FROG_Path.cpp"
#include "Visualisation/Frog/soft/Includes/FROG/FROG_Net_Tools.h"
#include "Visualisation/Frog/soft/Includes/FROG/FROG_Net_Tools.cpp"
#include "Visualisation/Frog/soft/Includes/FROG/FROG.h"
#include "Visualisation/Frog/soft/Includes/FROG/FROG.cpp"
using namespace edm;
using namespace std;
using namespace reco;
//
// class decleration
//
class Frog_Analyzer : public edm::EDAnalyzer {
public:
explicit Frog_Analyzer(const edm::ParameterSet&);
~Frog_Analyzer();
private:
virtual void beginJob(const edm::EventSetup& iSetup);
virtual void analyze (const edm::Event&, const edm::EventSetup&);
virtual void endJob ();
FROG_Events* events;
std::string OutputFile;
std::vector<InputTag> GenParticlesProducers;
std::vector<InputTag> SimTrackProducers;
std::vector<InputTag> SimVertexProducers;
std::vector<InputTag> SimHitProducers;
std::vector<InputTag> SimCaloHitProducers;
std::vector<InputTag> NIProducers;
std::vector<InputTag> TrackProducers;
std::vector<InputTag> TrajectoryProducers;
std::vector<InputTag> SiStripClusterProducers;
std::vector<InputTag> EcalRecHitProducers;
std::vector<InputTag> HcalHBHERecHitProducers;
std::vector<InputTag> HcalHORecHitProducers;
std::vector<InputTag> HcalHFRecHitProducers;
std::vector<InputTag> DTSegmentProducers;
std::vector<InputTag> CSCSegmentProducers;
std::vector<InputTag> RPCHitsProducers;
std::vector<InputTag> CaloTowersProducers;
bool CaloTowersProducersBasedOnCaloHits;
std::vector<InputTag> BasicJetsProducers;
std::vector<InputTag> CaloJetsProducers;
bool CaloJetsProducersBasedOnCaloTowers;
std::vector<InputTag> RecoCandidateProducers;
std::vector<InputTag> CaloMETProducers;
// ----------member data ---------------------------
bool CompressFiles;
bool AddRunInfoInName;
bool ProduceGeom;
int NEventsInVisFile;
int NEvents;
unsigned int FileIndex
unsigned int SRun;
unsigned int SEvent;
};
//
// constructors and destructor
//
Frog_Analyzer::Frog_Analyzer(const edm::ParameterSet& iConfig)
{
OutputFile = iConfig.getParameter<std::string >("OutputFile");
GenParticlesProducers = iConfig.getParameter<std::vector<InputTag> >("GenParticlesProducers");
SimTrackProducers = iConfig.getParameter<std::vector<InputTag> >("SimTrackProducers");
SimVertexProducers = iConfig.getParameter<std::vector<InputTag> >("SimVertexProducers");
SimHitProducers = iConfig.getParameter<std::vector<InputTag> >("SimHitProducers");
SimCaloHitProducers = iConfig.getParameter<std::vector<InputTag> >("SimCaloHitProducers");
TrackProducers = iConfig.getParameter<std::vector<InputTag> >("TrackProducers");
TrajectoryProducers = iConfig.getParameter<std::vector<InputTag> >("TrajectoryProducers");
SiStripClusterProducers = iConfig.getParameter<std::vector<InputTag> >("SiStripClusterProducers");
EcalRecHitProducers = iConfig.getParameter<std::vector<InputTag> >("EcalRecHitProducers");
HcalHBHERecHitProducers = iConfig.getParameter<std::vector<InputTag> >("HcalHBHERecHitProducers");
HcalHORecHitProducers = iConfig.getParameter<std::vector<InputTag> >("HcalHORecHitProducers");
HcalHFRecHitProducers = iConfig.getParameter<std::vector<InputTag> >("HcalHFRecHitProducers");
NIProducers = iConfig.getParameter<std::vector<InputTag> >("NIProducers");
DTSegmentProducers = iConfig.getParameter<std::vector<InputTag> >("DTSegmentProducers");
CSCSegmentProducers = iConfig.getParameter<std::vector<InputTag> >("CSCSegmentProducers");
RPCHitsProducers = iConfig.getParameter<std::vector<InputTag> >("RPCHitsProducers");
CaloTowersProducers = iConfig.getParameter<std::vector<InputTag> >("CaloTowersProducers");
CaloTowersProducersBasedOnCaloHits = iConfig.getParameter<bool>("CaloTowersProducersBasedOnCaloHits");
BasicJetsProducers = iConfig.getParameter<std::vector<InputTag> >("BasicJetsProducers");
CaloJetsProducers = iConfig.getParameter<std::vector<InputTag> >("CaloJetsProducers");
CaloJetsProducersBasedOnCaloTowers = iConfig.getParameter<bool>("CaloJetsProducersBasedOnCaloTowers");
RecoCandidateProducers = iConfig.getParameter<std::vector<InputTag> >("RecoCandidateProducers");
CaloMETProducers = iConfig.getParameter<std::vector<InputTag> >("CaloMETProducers");
ProduceGeom = iConfig.getParameter<bool >("ProduceGeom" );
NEventsInVisFile = iConfig.getParameter<int >("NEventsInVisFile" );
CompressFiles = iConfig.getParameter<bool >("CompressFiles" );
AddRunInfoInName = iConfig.getParameter<bool >("AddRunInfoInName" );
NEvents = 0;
FileIndex = 0;
}
Frog_Analyzer::~Frog_Analyzer()
{
}
// ------------ method called once each job just before starting event loop ------------
void
Frog_Analyzer::beginJob(const edm::EventSetup& iSetup)
{
/*
if(ProduceGeom){
DetId Detid;
unsigned int SubDet;
unsigned int Frog_DetId;
FROG_Element_Base* FEB = NULL;
FROG_Element_Base_With_DetId_And_Name* FEB_Temp = NULL;
FROG_Element_Base* prim = new FROG_Element_Base(C_PRIMARY);
FROG_Element_Base* geom = new FROG_Element_Base(C_GEOMETRY); prim->addDaughter(geom);
FROG_Element_Base_With_DetId_And_Name* tracker = new FROG_Element_Base_With_DetId_And_Name( DETID_TRK , "Tracker"); geom->addDaughter(tracker);
FROG_Element_Base_With_DetId_And_Name* muon = new FROG_Element_Base_With_DetId_And_Name( DETID_MUON , "Muon"); geom->addDaughter(muon);
FROG_Element_Base_With_DetId_And_Name* ecal = new FROG_Element_Base_With_DetId_And_Name( DETID_ECAL , "ECAL"); geom->addDaughter(ecal);
FROG_Element_Base_With_DetId_And_Name* hcal = new FROG_Element_Base_With_DetId_And_Name( DETID_HCAL , "HCAL"); geom->addDaughter(hcal);
FROG_Element_Base_With_DetId_And_Name* calo = new FROG_Element_Base_With_DetId_And_Name( DETID_CALO , "Calo"); geom->addDaughter(calo);
// ### TRACKER GEOMETRY ###
edm::ESHandle<TrackerGeometry> tkGeom;
iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom );
vector<GeomDet*> TrackerDets = tkGeom->dets();
for(unsigned int i=0;i<TrackerDets.size();i++){
Detid = TrackerDets[i]->geographicalId();
SubDet = Detid.subdetId();
if(SubDet<1 || SubDet>6) continue;
GeomDet* DetUnit = TrackerDets[i];
if(!DetUnit)continue;
const BoundPlane plane = DetUnit->surface();
const TrapezoidalPlaneBounds* trapezoidalBounds( dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
const RectangularPlaneBounds* rectangularBounds( dynamic_cast<const RectangularPlaneBounds*>(&(plane.bounds())));
float width = 0;
float length = 0;
float thickness = 0;
float TrapezoidalParam = 0;
if(trapezoidalBounds){
std::vector<float> const & parameters = (*trapezoidalBounds).parameters();
width = parameters[0]*2;
length = parameters[3]*2;
thickness = (*trapezoidalBounds).thickness();
TrapezoidalParam = parameters[1]/parameters[0];
}else if(rectangularBounds){
width = DetUnit->surface().bounds().width();
length = DetUnit->surface().bounds().length();
thickness = DetUnit->surface().bounds().thickness();
TrapezoidalParam = 1;
}
Surface::GlobalPoint WidthVector = plane.toGlobal( LocalPoint(width/2, 0, 0) );
Surface::GlobalPoint LengthVector = plane.toGlobal( LocalPoint(0, length/2, 0) );
Surface::GlobalPoint ThickVector = plane.toGlobal( LocalPoint(0, 0, thickness/2) );
GlobalVector Pos = GlobalVector(DetUnit->position().basicVector());
FROG_Element_Geom_TrackerMod* mod = new FROG_Element_Geom_TrackerMod(
Detid.rawId(), TrapezoidalParam,
Pos.x(), Pos.y(), Pos.z(),
WidthVector.x() -Pos.x(), WidthVector.y() -Pos.y(), WidthVector.z() -Pos.z(),
LengthVector.x()-Pos.x(), LengthVector.y()-Pos.y(), LengthVector.z()-Pos.z(),
ThickVector.x() -Pos.x(), ThickVector.y() -Pos.y(), ThickVector.z() -Pos.z());
Frog_DetId = DETID_TRK;
FEB = tracker;
Frog_DetId += SubDet*100000;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
// if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId); FEB_Temp->addDaughter(FEB);}
if(SubDet==PixelSubdetector::PixelBarrel){
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "PIB"); FEB_Temp->addDaughter(FEB);}
PXBDetId detid = PXBDetId(Detid);
Frog_DetId += detid.layer()*10000;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Layer%i", detid.layer() ); FEB_Temp->addDaughter(FEB);}
Frog_DetId += detid.ladder()*100;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Ladder%i", detid.ladder() ); FEB_Temp->addDaughter(FEB);}
}else if(SubDet==PixelSubdetector::PixelEndcap){
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "PIE"); FEB_Temp->addDaughter(FEB);}
PXFDetId detid = PXFDetId(Detid);
Frog_DetId += detid.side()*10000;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Side%i",detid.side()); FEB_Temp->addDaughter(FEB);}
Frog_DetId += detid.disk()*1000;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Disk%i", detid.disk()); FEB_Temp->addDaughter(FEB);}
Frog_DetId += detid.blade()*10;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Blade%i", detid.blade()); FEB_Temp->addDaughter(FEB);}
Frog_DetId += detid.panel()*1;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Panel%i", detid.panel()); FEB_Temp->addDaughter(FEB);}
}else if(SubDet==StripSubdetector::TIB){
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "TIB"); FEB_Temp->addDaughter(FEB);}
TIBDetId detid = TIBDetId(Detid);
Frog_DetId += detid.layer()*10000;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Layer%i", detid.layer()); FEB_Temp->addDaughter(FEB);}
Frog_DetId += detid.stringNumber()*100;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "String%i", detid.stringNumber()); FEB_Temp->addDaughter(FEB);}
}else if(SubDet==StripSubdetector::TID){
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "TID"); FEB_Temp->addDaughter(FEB);}
TIDDetId detid = TIDDetId(Detid);
Frog_DetId += detid.side()*10000;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Slide%i", detid.side()); FEB_Temp->addDaughter(FEB);}
Frog_DetId += detid.wheel()*1000;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Wheel%i", detid.wheel()); FEB_Temp->addDaughter(FEB);}
Frog_DetId += detid.ring()*10;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Ring%i", detid.ring()); FEB_Temp->addDaughter(FEB);}
}else if(SubDet==StripSubdetector::TOB){
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "TOB"); FEB_Temp->addDaughter(FEB);}
TOBDetId detid = TOBDetId(Detid);
Frog_DetId += detid.layer()*10000;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Layer%i", detid.layer()); FEB_Temp->addDaughter(FEB);}
Frog_DetId += detid.rodNumber()*100;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Rod%i", detid.rodNumber()); FEB_Temp->addDaughter(FEB);}
}else if(SubDet==StripSubdetector::TEC){
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "TEC"); FEB_Temp->addDaughter(FEB);}
TECDetId detid = TECDetId(Detid);
Frog_DetId += detid.side()*10000;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Side%i",detid.side()); FEB_Temp->addDaughter(FEB);}
Frog_DetId += detid.wheel()*1000;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Wheel%i", detid.wheel() ); FEB_Temp->addDaughter(FEB);}
Frog_DetId += detid.ring()*10;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Ring%i", detid.ring()); FEB_Temp->addDaughter(FEB);}
Frog_DetId += detid.petalNumber();
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Petal%i", detid.petalNumber()); FEB_Temp->addDaughter(FEB);}
}else{
if(mod)delete mod;
continue;
}
FEB->addDaughter(mod);
}
// ### MUON GEOMETRY ###
edm::ESHandle<DTGeometry> DtGeom;
iSetup.get<MuonGeometryRecord>().get( DtGeom );
const vector<GeomDet*> DtDets = DtGeom->dets();
edm::ESHandle<CSCGeometry> CscGeom;
iSetup.get<MuonGeometryRecord>().get( CscGeom );
const vector<GeomDet*> CscDets = CscGeom->dets();
edm::ESHandle<RPCGeometry> RpcGeom;
iSetup.get<MuonGeometryRecord>().get( RpcGeom );
const vector<GeomDet*> RpcDets = RpcGeom->dets();
vector<GeomDet*> MuonDets;
for(unsigned int i=0;i<DtDets.size() ;i++){MuonDets.push_back(DtDets [i]);}
for(unsigned int i=0;i<CscDets.size();i++){MuonDets.push_back(CscDets[i]);}
for(unsigned int i=0;i<RpcDets.size();i++){MuonDets.push_back(RpcDets[i]);}
for(unsigned int i=0;i<MuonDets.size();i++)
{
Detid = DetId(MuonDets[i]->geographicalId());
SubDet = Detid.subdetId();
GeomDet* DetUnit = MuonDets[i];
if(!DetUnit)continue;
const BoundPlane plane = DetUnit->surface();
const TrapezoidalPlaneBounds* trapezoidalBounds( dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
const RectangularPlaneBounds* rectangularBounds( dynamic_cast<const RectangularPlaneBounds*>(&(plane.bounds())));
float width = 0;
float length = 0;
float thickness = 0;
float TrapezoidalParam = 0;
if(trapezoidalBounds)
{
std::vector<float> const & parameters = (*trapezoidalBounds).parameters();
width = parameters[0]*2;
length = parameters[3]*2;
thickness = (*trapezoidalBounds).thickness();
TrapezoidalParam = parameters[1]/parameters[0];
}else if(rectangularBounds){
width = DetUnit->surface().bounds().width();
length = DetUnit->surface().bounds().length();
thickness = DetUnit->surface().bounds().thickness();
TrapezoidalParam = 1;
}
Surface::GlobalPoint WidthVector = plane.toGlobal( LocalPoint(width/2, 0, 0) );
Surface::GlobalPoint LengthVector = plane.toGlobal( LocalPoint(0, length/2, 0) );
Surface::GlobalPoint ThickVector = plane.toGlobal( LocalPoint(0, 0, thickness/2) );
GlobalVector Pos = GlobalVector(DetUnit->position().basicVector());
FROG_Element_Geom_TrackerMod* mod = new FROG_Element_Geom_TrackerMod(
Detid.rawId(), TrapezoidalParam,
Pos.x(), Pos.y(), Pos.z(),
WidthVector.x() -Pos.x(), WidthVector.y() -Pos.y(), WidthVector.z() -Pos.z(),
LengthVector.x()-Pos.x(), LengthVector.y()-Pos.y(), LengthVector.z()-Pos.z(),
ThickVector.x() -Pos.x(), ThickVector.y() -Pos.y(), ThickVector.z() -Pos.z());
Frog_DetId = DETID_MUON;
FEB = muon;
Frog_DetId += SubDet*100000;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
// if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId); FEB_Temp->addDaughter(FEB);}
if(SubDet==1){
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "DT"); FEB_Temp->addDaughter(FEB);}
DTChamberId detid = DTChamberId(Detid);
Frog_DetId += (detid.wheel()+3)*10000;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Wheel%+i", detid.wheel()); FEB_Temp->addDaughter(FEB);}
Frog_DetId += detid.station()*100;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Station%i", detid.station()); FEB_Temp->addDaughter(FEB);}
Frog_DetId += detid.sector()*1;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Sector%i", detid.sector()); FEB_Temp->addDaughter(FEB);}
}else if(SubDet==2){
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "CSC"); FEB_Temp->addDaughter(FEB);}
CSCDetId detid = CSCDetId(Detid);
Frog_DetId += detid.endcap()*10000;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Side%i", detid.endcap()); FEB_Temp->addDaughter(FEB);}
Frog_DetId += detid.station()*1000;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Station%i", detid.station()); FEB_Temp->addDaughter(FEB);}
Frog_DetId += detid.ring()*100;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Ring%i", detid.ring()); FEB_Temp->addDaughter(FEB);}
Frog_DetId += detid.chamber()*1;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Chamber%i", detid.chamber()); FEB_Temp->addDaughter(FEB);}
}else if(SubDet==3){
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "RPC"); FEB_Temp->addDaughter(FEB);}
RPCDetId detid = RPCDetId(Detid);
Frog_DetId += (detid.region()+2)*10000;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Region+%i", detid.region()); FEB_Temp->addDaughter(FEB);}
// Barrel
if(detid.region()==0){
Frog_DetId += (detid.ring()+3)*1000;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Ring+%i", detid.ring()); FEB_Temp->addDaughter(FEB);}
// Endcap
}else{
Frog_DetId += detid.ring()*1000;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Ring+%i", detid.ring()); FEB_Temp->addDaughter(FEB);}
}
Frog_DetId += detid.station()*100;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Station%i", detid.station()); FEB_Temp->addDaughter(FEB);}
Frog_DetId += detid.sector()*1;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Sector%i", detid.sector()); FEB_Temp->addDaughter(FEB);}
}
FEB->addDaughter(mod);
}
// ### CALO GEOMETRY ###
edm::ESHandle<CaloGeometry> CaloGeom;
// iSetup.get<CaloGeometryRecord>().get( CaloGeom );
iSetup.get<IdealGeometryRecord>().get( CaloGeom );
const vector<DetId> CaloDets = CaloGeom->getValidDetIds();
for(unsigned int i=0;i<CaloDets.size();i++)
{
Detid = CaloDets[i];
SubDet = Detid.subdetId();
if(Detid.det()==DetId::Ecal){
if(SubDet<1 || SubDet>3) continue;
Frog_DetId = DETID_ECAL;
FEB = ecal;
Frog_DetId += SubDet*100000;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
// if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId); FEB_Temp->addDaughter(FEB);}
if(SubDet==1){
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "EB"); FEB_Temp->addDaughter(FEB);}
EBDetId detid = EBDetId(Detid);
Frog_DetId += ((detid.zside()==1)+1)*10000;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Side%+i", detid.zside()); FEB_Temp->addDaughter(FEB);}
Frog_DetId += (detid.tower_ieta()*detid.zside())*100;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "TowerIEta%+i", detid.tower_ieta()); FEB_Temp->addDaughter(FEB);}
Frog_DetId += detid.tower_iphi()*1;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "TowerIPhi%i", detid.tower_iphi()); FEB_Temp->addDaughter(FEB);}
}else if(SubDet==2){
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "EE"); FEB_Temp->addDaughter(FEB);}
EEDetId detid = EEDetId(Detid);
Frog_DetId += ((detid.zside()==1)+1)*10000;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Side%+i", detid.zside()); FEB_Temp->addDaughter(FEB);}
Frog_DetId += detid.iquadrant()*1000;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Quadran%i", detid.iquadrant()); FEB_Temp->addDaughter(FEB);}
Frog_DetId += detid.isc();
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "ISC%i", detid.isc()); FEB_Temp->addDaughter(FEB);}
}else if(SubDet==3){
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "ES"); FEB_Temp->addDaughter(FEB);}
ESDetId detid = ESDetId(Detid);
Frog_DetId += ((detid.zside()==1)+1)*10000;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Side%+i", detid.zside()); FEB_Temp->addDaughter(FEB);}
Frog_DetId += detid.plane()*1000;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Plane%i", detid.plane()); FEB_Temp->addDaughter(FEB);}
Frog_DetId += detid.six()*50;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Six%i", detid.six()); FEB_Temp->addDaughter(FEB);}
Frog_DetId += detid.siy();
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Siy%i", detid.siy()); FEB_Temp->addDaughter(FEB);}
}
}else if(Detid.det()==DetId::Hcal){
if(SubDet<1 || SubDet>4) continue;
Frog_DetId = DETID_HCAL;
FEB = hcal;
Frog_DetId += SubDet*100000;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){
if(SubDet==1){ FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "HB"); FEB_Temp->addDaughter(FEB);}
if(SubDet==2){ FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "HE"); FEB_Temp->addDaughter(FEB);}
if(SubDet==3){ FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "HO"); FEB_Temp->addDaughter(FEB);}
if(SubDet==4){ FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "HF"); FEB_Temp->addDaughter(FEB);}
}
HcalDetId detid = HcalDetId(Detid);
Frog_DetId += ((detid.zside()==1)+1)*10000;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Side%+i", detid.zside()); FEB_Temp->addDaughter(FEB);}
Frog_DetId += detid.ietaAbs()*100;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "IEta%+i", detid.ieta()); FEB_Temp->addDaughter(FEB);}
Frog_DetId += detid.iphi()*1;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "IPhi%i", detid.iphi()); FEB_Temp->addDaughter(FEB);}
}else if(Detid.det() == DetId::Calo){
Frog_DetId = DETID_CALO;
FEB = calo;
if(SubDet!=(unsigned int)CaloTowerDetId::SubdetId)continue;
Frog_DetId += SubDet*100000;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "CaloTowers"); FEB_Temp->addDaughter(FEB);}
if(SubDet==(unsigned int)CaloTowerDetId::SubdetId){
CaloTowerDetId detid = CaloTowerDetId(Detid);
Frog_DetId += ((detid.zside()==1)+1)*10000;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "Side%+i", detid.zside()); FEB_Temp->addDaughter(FEB);}
Frog_DetId += (detid.ieta()*detid.zside())*100;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "IEta%+i", detid.ieta()); FEB_Temp->addDaughter(FEB);}
Frog_DetId += detid.iphi()*1;
FEB_Temp = dynamic_cast<FROG_Element_Base_With_DetId_And_Name*>(FEB);
FEB = FEB_Temp->getDaughterWithDetId(Frog_DetId);
if(FEB==NULL){FEB = new FROG_Element_Base_With_DetId_And_Name( Frog_DetId, "IPhi%i", detid.iphi()); FEB_Temp->addDaughter(FEB);}
}
}
const CaloCellGeometry* CellGeom = CaloGeom->getGeometry(Detid);
GlobalPoint CellPos = CellGeom->getPosition();
const CaloCellGeometry::CornersVec CellCorners = CellGeom->getCorners();
float cX = (CellCorners[0].x() + CellCorners[2].x())/2;
float cY = (CellCorners[0].y() + CellCorners[2].y())/2;
float cZ = (CellCorners[0].z() + CellCorners[2].z())/2;
float wX = (CellCorners[1].x() - CellCorners[0].x())/2;
float wY = (CellCorners[1].y() - CellCorners[0].y())/2;
float wZ = (CellCorners[1].z() - CellCorners[0].z())/2;
float hX = (CellCorners[3].x() - CellCorners[0].x())/2;
float hY = (CellCorners[3].y() - CellCorners[0].y())/2;
float hZ = (CellCorners[3].z() - CellCorners[0].z())/2;
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) );
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) );
FROG_Element_Geom_CaloMod* mod = new FROG_Element_Geom_CaloMod(
Detid.rawId(), F,
cX , cY , cZ ,
wX , wY , wZ ,
hX , hY , hZ );
FEB->addDaughter(mod);
}
// ### Save .geom ###
FROG_Geometry* CMS_Geom = new FROG_Geometry(prim);
CMS_Geom->Save("CMS.geom", CompressFiles);
delete CMS_Geom;
}
*/
events = new FROG_Events();
}
// ------------ method called once each job just after ending the event loop ------------
void
Frog_Analyzer::endJob()
{
if(NEvents>0){
char OutputFileName[1024];
sprintf(OutputFileName,"%s",OutputFile.substr(0,OutputFile.size()-4).c_str());
if(NEventsInVisFile>=0){
sprintf(OutputFileName,"%s_%i",OutputFileName,FileIndex);
if(AddRunInfoInName)sprintf(OutputFileName,"%s_Run%i_1stEvent%08i",OutputFileName,SRun,SEvent);
}
sprintf(OutputFileName,"%s.vis",OutputFileName);
events->SaveInLive((char*) OutputFileName, true, CompressFiles);
delete events;
NEvents=0;
}
}
//
// member functions
//
// ------------ method called to for each event ------------
void
Frog_Analyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
{
if(NEvents == 0){
SRun = iEvent.id().run();
SEvent = iEvent.id().event();
}
FROG_Element_Event* event = new FROG_Element_Event(iEvent.id().run(), iEvent.id().event(), iEvent.time().value() );
events->AddEvent(event);
// access the tracker
edm::ESHandle<TrackerGeometry> tkGeom;
iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom );
edm::ESHandle<DTGeometry> DtGeom;
iSetup.get<MuonGeometryRecord>().get( DtGeom );
edm::ESHandle<CSCGeometry> CscGeom;
iSetup.get<MuonGeometryRecord>().get( CscGeom );
edm::ESHandle<RPCGeometry> RpcGeom;
iSetup.get<MuonGeometryRecord>().get( RpcGeom );
edm::ESHandle<CaloGeometry> CaloGeom;
// iSetup.get<CaloGeometryRecord>().get( CaloGeom );
iSetup.get<IdealGeometryRecord>().get( CaloGeom );
// ### GEN OBJECTS CONTAINER ###
FROG_Element_Base_With_DetId_And_Name* frogGen = new FROG_Element_Base_With_DetId_And_Name( EVTID_GEN, "GEN");
event->addDaughter(frogGen);
// ### GENPARTICLES ###
FROG_Element_Base_With_DetId_And_Name* frogGenPartColl = new FROG_Element_Base_With_DetId_And_Name( EVTID_GEN_CAND, "GenParticles");
frogGen->addDaughter(frogGenPartColl);
for(unsigned int i=0;i<GenParticlesProducers.size();i++){
edm::Handle<GenParticleCollection> h_gen_Particles;
iEvent.getByLabel(GenParticlesProducers[i], h_gen_Particles);
GenParticleCollection gen_Particles = *h_gen_Particles.product();
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());
frogGenPartColl->addDaughter(frogGenPartCollb);
for(unsigned int h=0;h<gen_Particles.size();h++){
if(gen_Particles[h].status()!=1)continue;
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());
frogGenPartCollb->addDaughter(frogGenPart);
}
}
// ### SIM OBJECTS CONTAINER ###
FROG_Element_Base_With_DetId_And_Name* frogSim = new FROG_Element_Base_With_DetId_And_Name( EVTID_SIM, "SIM");
event->addDaughter(frogSim);
// ### SIMTRACK ###
FROG_Element_Base_With_DetId_And_Name* frogSimTrkColl = new FROG_Element_Base_With_DetId_And_Name( EVTID_SIMTRK, "SimTracks");
frogSim->addDaughter(frogSimTrkColl);
for(unsigned int i=0;i<SimTrackProducers.size();i++){
edm::Handle<std::vector< SimTrack > > h_SimTracks;
iEvent.getByLabel(SimTrackProducers[i], h_SimTracks);
std::vector< SimTrack > SimTrackColl = *h_SimTracks.product();
for ( unsigned int a = 0; a < SimTrackColl.size(); ++a ) {
SimTrack simTrack =SimTrackColl[a];
FROG_Element_Event_Sim_Track* frogSimTrk = new FROG_Element_Event_Sim_Track(simTrack.trackId(),
simTrack.momentum().x(), simTrack.momentum().y(), simTrack.momentum().z(),
simTrack.momentum().e(), simTrack.type(), simTrack.vertIndex(),
simTrack.charge() );
frogSimTrkColl->addDaughter(frogSimTrk);
}
}
// ### SIMVERTEX ###
FROG_Element_Base_With_DetId_And_Name* frogSimVtx = new FROG_Element_Base_With_DetId_And_Name( EVTID_SIMVTX, "SimVertex");
frogSim->addDaughter(frogSimVtx);
for(unsigned int i=0;i<SimVertexProducers.size();i++){
edm::Handle<std::vector< SimVertex > > h_Vertex;
iEvent.getByLabel(SimVertexProducers[i], h_Vertex);
std::vector< SimVertex > VertexColl = *h_Vertex.product();
for (unsigned int b = 0; b < VertexColl.size(); ++b ) {
SimVertex Vertex = VertexColl[b];
FROG_Element_Event_Sim_Vertex* frogSimVertex = new FROG_Element_Event_Sim_Vertex(
Vertex.position().x(), Vertex.position().y(), Vertex.position().z(),
Vertex.parentIndex());
frogSimVtx->addDaughter(frogSimVertex);
}
}
// ### SIMHIT ###
FROG_Element_Base_With_DetId_And_Name* frogSimHit = new FROG_Element_Base_With_DetId_And_Name( EVTID_SIMHIT, "SimHits");
frogSim->addDaughter(frogSimHit);
for(unsigned int i=0;i<SimHitProducers.size();i++){
edm::Handle<std::vector< PSimHit > > h_Hits;
iEvent.getByLabel(SimHitProducers[i], h_Hits);
std::vector< PSimHit > Hits = *h_Hits.product();
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() );
frogSimHit->addDaughter(frogSimHitColl);
for(unsigned int h=0; h<Hits.size(); h++)
{
DetId theDetUnitId(Hits[h].detUnitId());
const GeomDet* theDet = NULL;
if(theDetUnitId.det() == DetId::Tracker)theDet = tkGeom->idToDet(theDetUnitId);
if(theDetUnitId.det() == DetId::Muon && theDetUnitId.subdetId() == MuonSubdetId::DT) theDet = DtGeom->idToDet(theDetUnitId);
if(theDetUnitId.det() == DetId::Muon && theDetUnitId.subdetId() == MuonSubdetId::CSC)theDet = CscGeom->idToDet(theDetUnitId);
if(theDetUnitId.det() == DetId::Muon && theDetUnitId.subdetId() == MuonSubdetId::RPC)theDet = RpcGeom->idToDet(theDetUnitId);
FROG_Element_Event_Sim_Hit* frogSimHit = new FROG_Element_Event_Sim_Hit(
theDet->surface().toGlobal(Hits[h].localPosition()).x(),theDet->surface().toGlobal(Hits[h].localPosition()).y(),theDet->surface().toGlobal(Hits[h].localPosition()).z(),
Hits[h].energyLoss(), Hits[h].processType() );
frogSimHitColl->addDaughter(frogSimHit);
}
}
// ### SIMCALOHIT ###
for(unsigned int i=0;i<SimCaloHitProducers.size();i++){
edm::Handle<std::vector< PCaloHit > > h_CaloHits;
iEvent.getByLabel(SimCaloHitProducers[i], h_CaloHits);
std::vector< PCaloHit > CaloHits = *h_CaloHits.product();
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());
frogSimHit->addDaughter(frogSimHitColl);
for(unsigned int h=0; h<CaloHits.size(); h++)
{
DetId theDetUnitId(CaloHits[h].id());
const CaloCellGeometry* CellGeom = NULL;
if(theDetUnitId.det() == DetId::Ecal || theDetUnitId.det() == DetId::Hcal)CellGeom = CaloGeom->getGeometry(theDetUnitId);
if(CellGeom==NULL)continue;
FROG_Element_Event_Sim_Hit* frogSimCaloHit = new FROG_Element_Event_Sim_Hit(
CellGeom->getPosition().x(),CellGeom->getPosition().y(),CellGeom->getPosition().z(),
CaloHits[h].energy(), 0 ); //CaloHits[h].depth() );
frogSimHitColl->addDaughter(frogSimCaloHit);
}
}
// ### LOW RECO OBJECTS CONTAINER ###
FROG_Element_Base_With_DetId_And_Name* frogLowReco = new FROG_Element_Base_With_DetId_And_Name( EVTID_LOWRECO, "RECO LOW");
event->addDaughter(frogLowReco);
// ### SiStrip Clusters ###
FROG_Element_Base_With_DetId_And_Name* frogSSTHit = new FROG_Element_Base_With_DetId_And_Name( EVTID_SISTRIPCLUSTER, "SiStrip Clusters");
frogLowReco->addDaughter(frogSSTHit);
for(unsigned int i=0;i<SiStripClusterProducers.size();i++){
edm::Handle<edmNew::DetSetVector<SiStripCluster> > h_Sst_Hits;
iEvent.getByLabel(SiStripClusterProducers[i], h_Sst_Hits);
const edmNew::DetSetVector<SiStripCluster>& Sst_Hits = *h_Sst_Hits.product();
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());
frogSSTHit->addDaughter(frogSstHitColl);
for (edmNew::DetSetVector<SiStripCluster>::const_iterator DSViter = Sst_Hits.begin(); DSViter != Sst_Hits.end(); ++DSViter) {
edmNew::DetSet<SiStripCluster>::const_iterator begin=DSViter->begin();
edmNew::DetSet<SiStripCluster>::const_iterator end =DSViter->end();
for(edmNew::DetSet<SiStripCluster>::const_iterator iCluster=begin;iCluster!=end;++iCluster){
const GeomDetUnit* detUnit = tkGeom->idToDetUnit (DetId( iCluster->geographicalId() ) );
if(!detUnit)continue;
const StripGeomDetUnit* DetUnit = dynamic_cast<const StripGeomDetUnit*> ( detUnit );
if(!DetUnit)continue;
const StripTopology& Topo = DetUnit->specificTopology();
unsigned int Charge = 0;
for(unsigned int i=0;i<iCluster->amplitudes().size();i++){Charge+=iCluster->amplitudes()[i];}
unsigned int MiddleStrip = iCluster->firstStrip() + iCluster->amplitudes().size()/2;
float Pitch = DetUnit->surface().bounds().width() / Topo.nstrips();
float XPos = (MiddleStrip * Pitch) - DetUnit->surface().bounds().width()/2;
//float YPos = DetUnit->surface().bounds().thickness()/2;
//float ZPos = DetUnit->surface().bounds().length()/2;
Surface::GlobalPoint Pos = DetUnit->surface().toGlobal( LocalPoint(XPos, 0, 0) );
FROG_Element_Event_Cluster_SiStrip* frogStripClust = new FROG_Element_Event_Cluster_SiStrip(iCluster->geographicalId(), iCluster->firstStrip(), Pitch);
for(unsigned int i=0;i<iCluster->amplitudes().size();i++){frogStripClust->Ampl_.push_back(iCluster->amplitudes()[i]);}
frogSstHitColl->addDaughter(frogStripClust);
}}
}
// ### CALORecHits ###
FROG_Element_Base_With_DetId_And_Name* frogCaloHit = new FROG_Element_Base_With_DetId_And_Name( EVTID_CALOHIT, "CALO Hits");
frogLowReco->addDaughter(frogCaloHit);
// ### ECALRecHits ###
FROG_Element_Base_With_DetId_And_Name* frogEcalHit = new FROG_Element_Base_With_DetId_And_Name( EVTID_ECALHIT, "ECAL RecHits");
frogCaloHit->addDaughter(frogEcalHit);
for(unsigned int i=0;i<EcalRecHitProducers.size();i++){
edm::Handle<EcalRecHitCollection > h_Ecal_RecHits;
iEvent.getByLabel(EcalRecHitProducers[i], h_Ecal_RecHits);
EcalRecHitCollection Ecal_RecHits = *h_Ecal_RecHits.product();
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());
frogEcalHit->addDaughter(frogHitColl);
for(unsigned int eh=0;eh<Ecal_RecHits.size();eh++){
FROG_Element_Event_CaloHit* frogCaloHit = new FROG_Element_Event_CaloHit((Ecal_RecHits[eh].detid()).rawId(),
Ecal_RecHits[eh].energy(), Ecal_RecHits[eh].time());
frogHitColl->addDaughter(frogCaloHit);
}
}
// ### HCALRecHits ###
FROG_Element_Base_With_DetId_And_Name* frogHcalHit = new FROG_Element_Base_With_DetId_And_Name( EVTID_HCALHIT, "HCAL RecHits");
frogCaloHit->addDaughter(frogHcalHit);
for(unsigned int i=0;i<HcalHBHERecHitProducers.size();i++){
edm::Handle<HBHERecHitCollection > h_HcalHBHE_RecHits;
iEvent.getByLabel(HcalHBHERecHitProducers[i], h_HcalHBHE_RecHits);
HBHERecHitCollection HcalHBHE_RecHits = *h_HcalHBHE_RecHits.product();
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());
frogHcalHit->addDaughter(frogHitColl);
for(unsigned int hh=0;hh<HcalHBHE_RecHits.size();hh++){
FROG_Element_Event_CaloHit* frogCaloHit = new FROG_Element_Event_CaloHit((HcalHBHE_RecHits[hh].detid()).rawId(),
HcalHBHE_RecHits[hh].energy(), HcalHBHE_RecHits[hh].time());
frogHitColl->addDaughter(frogCaloHit);
}
}
for(unsigned int i=0;i<HcalHORecHitProducers.size();i++){
edm::Handle<HORecHitCollection > h_HcalHO_RecHits;
iEvent.getByLabel(HcalHORecHitProducers[i], h_HcalHO_RecHits);
HORecHitCollection HcalHO_RecHits = *h_HcalHO_RecHits.product();
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());
frogHcalHit->addDaughter(frogHitColl);
for(unsigned int hh=0;hh<HcalHO_RecHits.size();hh++){
FROG_Element_Event_CaloHit* frogCaloHit = new FROG_Element_Event_CaloHit((HcalHO_RecHits[hh].detid()).rawId(),
HcalHO_RecHits[hh].energy(), HcalHO_RecHits[hh].time());
frogHitColl->addDaughter(frogCaloHit);
}
}
for(unsigned int i=0;i<HcalHFRecHitProducers.size();i++){
edm::Handle<HFRecHitCollection > h_HcalHF_RecHits;
iEvent.getByLabel(HcalHFRecHitProducers[i], h_HcalHF_RecHits);
HFRecHitCollection HcalHF_RecHits = *h_HcalHF_RecHits.product();
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());
frogHcalHit->addDaughter(frogHitColl);
for(unsigned int hh=0;hh<HcalHF_RecHits.size();hh++){
FROG_Element_Event_CaloHit* frogCaloHit = new FROG_Element_Event_CaloHit((HcalHF_RecHits[hh].detid()).rawId(),
HcalHF_RecHits[hh].energy(), HcalHF_RecHits[hh].time());
frogHitColl->addDaughter(frogCaloHit);
}
}
// ### Muon Segments ###
FROG_Element_Base_With_DetId_And_Name* frogMuonSeg = new FROG_Element_Base_With_DetId_And_Name( EVTID_MUONSEG, "MuonSegments");
frogLowReco->addDaughter(frogMuonSeg);
for(unsigned int i=0;i<CSCSegmentProducers.size();i++){
edm::Handle<CSCSegmentCollection > h_CSC_Segments;
iEvent.getByLabel(CSCSegmentProducers[i], h_CSC_Segments);
CSCSegmentCollection CSC_Segments = *h_CSC_Segments.product();
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());
frogMuonSeg->addDaughter(frogSegColl);
for(unsigned int s=0;s<CSC_Segments.size();s++){
DetId theDetUnitId = CSC_Segments[s].geographicalId();
const GeomDet* theDet = CscGeom->idToDet(theDetUnitId);
FROG_Element_Event_Segment* frogSeg = new FROG_Element_Event_Segment(theDetUnitId.rawId(),
theDet->surface().toGlobal(CSC_Segments[s].localPosition()).x() , theDet->surface().toGlobal(CSC_Segments[s].localPosition()).y() , theDet->surface().toGlobal(CSC_Segments[s].localPosition()).z() ,
theDet->surface().toGlobal(CSC_Segments[s].localDirection()).x(), theDet->surface().toGlobal(CSC_Segments[s].localDirection()).y(), theDet->surface().toGlobal(CSC_Segments[s].localDirection()).z() );
frogSegColl->addDaughter(frogSeg);
}
}
for(unsigned int i=0;i<DTSegmentProducers.size();i++){
edm::Handle<DTRecSegment4DCollection > h_DT_Segments;
iEvent.getByLabel(DTSegmentProducers[i], h_DT_Segments);
DTRecSegment4DCollection DT_Segments = *h_DT_Segments.product();
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());
frogMuonSeg->addDaughter(frogSegColl);
for(unsigned int s=0;s<DT_Segments.size();s++){
DetId theDetUnitId = DT_Segments[s].geographicalId();
const GeomDet* theDet = DtGeom->idToDet(theDetUnitId);
FROG_Element_Event_Segment* frogSeg = new FROG_Element_Event_Segment(theDetUnitId.rawId(),
theDet->surface().toGlobal(DT_Segments[s].localPosition()).x() , theDet->surface().toGlobal(DT_Segments[s].localPosition()).y() , theDet->surface().toGlobal(DT_Segments[s].localPosition()).z() ,
theDet->surface().toGlobal(DT_Segments[s].localDirection()).x(), theDet->surface().toGlobal(DT_Segments[s].localDirection()).y(), theDet->surface().toGlobal(DT_Segments[s].localDirection()).z() );
frogSegColl->addDaughter(frogSeg);
}
}
// ### Muon Hits ###
FROG_Element_Base_With_DetId_And_Name* frogMuonHit = new FROG_Element_Base_With_DetId_And_Name( EVTID_MUONHIT, "MuonHits");
frogLowReco->addDaughter(frogMuonHit);
for(unsigned int i=0;i<RPCHitsProducers.size();i++){
edm::Handle<RPCRecHitCollection > h_RPC_Hits;
iEvent.getByLabel(RPCHitsProducers[i], h_RPC_Hits);
RPCRecHitCollection RPC_Hits = *h_RPC_Hits.product();
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());
frogMuonHit->addDaughter(frogHitColl);
for(unsigned int h=0;h<RPC_Hits.size();h++){
DetId theDetUnitId = RPC_Hits[h].geographicalId();
const GeomDet* theDet = RpcGeom->idToDet(theDetUnitId);
FROG_Element_Event_Hit* frogHit = new FROG_Element_Event_Hit(theDetUnitId.rawId(),
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 );
frogHitColl->addDaughter(frogHit);
}
}
// ### Calo Towers ###
FROG_Element_Base_With_DetId_And_Name* frogCaloTower = new FROG_Element_Base_With_DetId_And_Name( EVTID_CALOTOWER, "CaloTowers");
frogLowReco->addDaughter(frogCaloTower);
for(unsigned int i=0;i<CaloTowersProducers.size();i++){
edm::Handle<CaloTowerCollection> h_Calo_Towers;
iEvent.getByLabel(CaloTowersProducers[i], h_Calo_Towers);
CaloTowerCollection Calo_Towers = *h_Calo_Towers.product();
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());
frogCaloTower->addDaughter(frogCaloTowerColl);
for(unsigned int h=0;h<Calo_Towers.size();h++){
FROG_Element_Event_CaloTower* frogTower = new FROG_Element_Event_CaloTower(Calo_Towers[h].id().rawId(), Calo_Towers[h].emEnergy(),Calo_Towers[h].hadEnergy());
frogCaloTowerColl->addDaughter(frogTower);
if(i==0 && CaloTowersProducersBasedOnCaloHits){
frogTower->Components_CollEvtId_ = EVTID_CALOHIT;
for(unsigned int D=0;D<Calo_Towers[h].constituentsSize();D++){frogTower->Components_Vector_.push_back(Calo_Towers[h].constituent(D));}
// std::vector<DetId> TowersDetIds = Calo_Towers[h].constituents();
// for(unsigned int D=0;D<TowersDetIds.size();D++){frogTower->Components_Vector_.push_back(TowersDetIds[D]);}
}
}
}
// ### MED RECO OBJECTS CONTAINER ###
FROG_Element_Base_With_DetId_And_Name* frogMedReco = new FROG_Element_Base_With_DetId_And_Name( EVTID_MEDRECO, "RECO MED");
event->addDaughter(frogMedReco);
/*
FROG_Element_Base_With_DetId_And_Name* frogNIVertex = new FROG_Element_Base_With_DetId_And_Name( EVTID_NUCLINT, "Vertex from NI");
frogMedReco->addDaughter(frogNIVertex);
// NUCLEAR INTERACTIONS
for(unsigned int i=0;i<NIProducers.size();i++) {
edm::Handle<std::vector<reco::NuclearInteraction> > h_NIs;
iEvent.getByLabel(NIProducers[i], h_NIs);
std::vector<reco::NuclearInteraction> NIs = *h_NIs.product();
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());
frogNIVertex->addDaughter(frogNIColl);
for(unsigned int h=0; h<NIs.size();h++){
reco::NuclearInteraction ni = NIs[i];
float vtx_x = ni.vertex().x();
float vtx_y = ni.vertex().y();
float vtx_z = ni.vertex().z();
float like = ni.likelihood();
FROG_Element_Event_NuclInt* frogNI = new FROG_Element_Event_NuclInt(vtx_x, vtx_y, vtx_z, like );
frogNIColl->addDaughter(frogNI);
}
}
*/
// ### TRAJECTORY ###
FROG_Element_Base_With_DetId_And_Name* frogTrk = new FROG_Element_Base_With_DetId_And_Name( EVTID_TRK, "Tracks & Trajectories");
frogMedReco->addDaughter(frogTrk);
for(unsigned int i=0;i<TrajectoryProducers.size();i++){
Handle<TrajTrackAssociationCollection> trajTrackAssociationHandle;
iEvent.getByLabel(TrajectoryProducers[i], trajTrackAssociationHandle);
const TrajTrackAssociationCollection TrajToTrackMap = *trajTrackAssociationHandle.product();
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());
frogTrk->addDaughter(frogTrkColl);
for(TrajTrackAssociationCollection::const_iterator it = TrajToTrackMap.begin(); it!=TrajToTrackMap.end(); ++it) {
Trajectory recoTraj = *it->key;
FROG_Element_Event_Track* frogTrk = new FROG_Element_Event_Track(i,it->val->p(),it->val->pt(),it->key->chiSquared());
frogTrkColl->addDaughter(frogTrk);
std::vector<TrajectoryMeasurement> measurements = recoTraj.measurements();
for(unsigned int h=0;h<measurements.size();h++){
TrajectoryMeasurement::ConstRecHitPointer h_it = measurements[h].recHit();
if(!h_it->isValid() )continue;
DetId detId = h_it->geographicalId();
GlobalPoint globalPos = measurements[h].updatedState().globalPosition();
FROG_Element_Event_Hit* frogHit = new FROG_Element_Event_Hit(detId.rawId(), globalPos.x(),globalPos.y(), globalPos.z(), -1);
frogTrk->addDaughter(frogHit);
}
// printf("Add a Trajectory\n");
}
}
// ### TRACK ###
for(unsigned int i=0;i<TrackProducers.size();i++){
edm::Handle<std::vector< reco::Track > > h_Tracks;
iEvent.getByLabel(TrackProducers[i], h_Tracks);
std::vector< reco::Track > TrackColl = *h_Tracks.product();
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());
frogTrk->addDaughter(frogTrkColl);
//printf("Size of the TrackCOllection : %i = %i\n",i,TrackColl.size());
for ( unsigned int t = 0; t < TrackColl.size(); ++t ) {
reco::Track recoTrack =TrackColl[t];
FROG_Element_Event_Track* frogTrk = new FROG_Element_Event_Track(TrajectoryProducers.size()+i,recoTrack.p(),recoTrack.pt(), recoTrack.chi2());
frogTrkColl->addDaughter(frogTrk);
for(unsigned int h=0;h<recoTrack.recHitsSize();h++){
TrackingRecHitRef h_it = recoTrack.recHit(h);
if(!h_it->isValid() )continue;
DetId detId = h_it->geographicalId();
const GeomDet * theDet = NULL;
if(detId.det()==DetId::Tracker) theDet = tkGeom->idToDet(detId);
if(detId.det()==DetId::Muon && detId.subdetId() == 1) theDet = DtGeom->idToDet(detId);
if(detId.det()==DetId::Muon && detId.subdetId() == 2) theDet = CscGeom->idToDet(detId);
if(detId.det()==DetId::Muon && detId.subdetId() == 3) theDet = RpcGeom->idToDet(detId);
LocalPoint localPos = h_it->localPosition();
FROG_Element_Event_Hit* frogHit = new FROG_Element_Event_Hit(
detId.rawId(),
theDet->surface().toGlobal(localPos).x(),
theDet->surface().toGlobal(localPos).y(),
theDet->surface().toGlobal(localPos).z(),
-1);
frogTrk->addDaughter(frogHit);
}
//printf("Add a Track\n");
}
}
// ### HIGH RECO OBJECTS CONTAINER ###
FROG_Element_Base_With_DetId_And_Name* frogHighReco = new FROG_Element_Base_With_DetId_And_Name( EVTID_HIGHRECO, "RECO HIGH");
event->addDaughter(frogHighReco);
FROG_Element_Base_With_DetId_And_Name* frogJet = new FROG_Element_Base_With_DetId_And_Name( EVTID_JET, "Jets");
frogHighReco->addDaughter(frogJet);
// ### Basic Jets ###
FROG_Element_Base_With_DetId_And_Name* frogBasicJet = new FROG_Element_Base_With_DetId_And_Name( EVTID_JET_BASIC, "BasicJets");
frogJet->addDaughter(frogBasicJet);
for(unsigned int i=0;i<BasicJetsProducers.size();i++){
edm::Handle<BasicJetCollection> h_Basic_Jets;
iEvent.getByLabel(BasicJetsProducers[i], h_Basic_Jets);
BasicJetCollection Basic_Jets = *h_Basic_Jets.product();
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());
frogBasicJet->addDaughter(frogBasicJetColl);
for(unsigned int h=0;h<Basic_Jets.size();h++){
FROG_Element_Event_Jet* frogJet = new FROG_Element_Event_Jet(Basic_Jets[h].p(), Basic_Jets[h].eta(),Basic_Jets[h].phi());
frogBasicJetColl->addDaughter(frogJet);
}
}
// ### Calo Jets ###
FROG_Element_Base_With_DetId_And_Name* frogCaloJet = new FROG_Element_Base_With_DetId_And_Name( EVTID_JET_CALO, "CaloJets");
frogJet->addDaughter(frogCaloJet);
for(unsigned int i=0;i<CaloJetsProducers.size();i++){
edm::Handle<CaloJetCollection> h_Calo_Jets;
iEvent.getByLabel(CaloJetsProducers[i], h_Calo_Jets);
CaloJetCollection Calo_Jets = *h_Calo_Jets.product();
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());
frogCaloJet->addDaughter(frogCaloJetColl);
for(unsigned int h=0;h<Calo_Jets.size();h++){
FROG_Element_Event_Jet* frogJet = new FROG_Element_Event_Jet(Calo_Jets[h].p(), Calo_Jets[h].eta(),Calo_Jets[h].phi());
frogCaloJetColl->addDaughter(frogJet);
if(CaloJetsProducersBasedOnCaloTowers){
// std::vector<CaloTowerPtr> CaloTowers = Calo_Jets[h].getCaloConstituents();
std::vector<CaloTowerRef> CaloTowers = Calo_Jets[h].getConstituents();
frogJet->Components_CollEvtId_ = EVTID_CALOTOWER + 1;
for(unsigned int t=0;t<CaloTowers.size();t++){ frogJet->Components_Vector_.push_back(CaloTowers[t]->id().rawId());}
}
}
}
// ### MET ###
FROG_Element_Base_With_DetId_And_Name* frogMET = new FROG_Element_Base_With_DetId_And_Name( EVTID_MET_CALO, "MET");
frogHighReco->addDaughter(frogMET);
for(unsigned int i=0;i<CaloMETProducers.size();i++){
edm::Handle<CaloMETCollection> h_met;
iEvent.getByLabel(CaloMETProducers[i], h_met);
CaloMETCollection reco_met = *h_met.product();
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());
frogMET->addDaughter(frogMETColl);
for(unsigned int h=0;h<reco_met.size();h++){
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());
frogMETColl->addDaughter(frogMETevt);
}
}
// ### RecoCandidates ###
FROG_Element_Base_With_DetId_And_Name* frogRecoCand = new FROG_Element_Base_With_DetId_And_Name( EVTID_RECOCAND, "RecoCandidates");
frogHighReco->addDaughter(frogRecoCand);
for(unsigned int i=0;i<RecoCandidateProducers.size();i++){
edm::Handle<CandidateCollection> h_reco_Candidates;
iEvent.getByLabel(RecoCandidateProducers[i], h_reco_Candidates);
CandidateCollection reco_Candidates = *h_reco_Candidates.product();
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());
frogRecoCand->addDaughter(frogRecoCandColl);
for(unsigned int h=0;h<reco_Candidates.size();h++){
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());
frogRecoCandColl->addDaughter(frogCandidate);
}
}
NEvents++;
char OutputFileName[1024];
sprintf(OutputFileName,"%s",OutputFile.substr(0,OutputFile.size()-4).c_str());
if(NEventsInVisFile>=0){
sprintf(OutputFileName,"%s_%i",OutputFileName,FileIndex);
if(AddRunInfoInName)sprintf(OutputFileName,"%s_Run%i_1stEvent%08i",OutputFileName,SRun,SEvent);
}
sprintf(OutputFileName,"%s.vis",OutputFileName);
events->SaveInLive((char*) OutputFileName, false, CompressFiles, (unsigned int)-1);
if(NEvents == NEventsInVisFile){
events->SaveInLive((char*) OutputFileName, true, CompressFiles, (unsigned int)-1);
FileIndex++;
delete events;
events = new FROG_Events();
NEvents=0;
}
}
//define this as a plug-in
DEFINE_FWK_MODULE(Frog_Analyzer);
File Metadata
Details
Attached
Mime Type
text/x-c++
Expires
Sat, Dec 21, 4:33 PM (18 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4023464
Default Alt Text
Frog_Analyzer.cc_for_16X (70 KB)
Attached To
rFROGSVN frogsvn
Event Timeline
Log In to Comment