import FWCore.ParameterSet.Config as cms

process = cms.Process("FROG") 
process.load("Configuration.StandardSequences.Geometry_cff") 
process.load("Configuration.StandardSequences.MagneticField_38T_cff") 
process.load("Configuration.StandardSequences.ReconstructionCosmics_cff")
process.load("Configuration.StandardSequences.RawToDigi_Data_cff")
 
process.source = cms.Source("PoolSource",
#    firstEvent = cms.untracked.uint32(589917),
#    firstRun = cms.untracked.uint32(1),
    fileNames = cms.untracked.vstring(
	XXX_INPUT_XXX
    ) 
)
process.maxEvents = cms.untracked.PSet(  input = cms.untracked.int32(XXX_NEVENTS_XXX) )

from FWCore.MessageLogger.MessageLogger_cfi import * 

#process.load("Configuration.StandardSequences.FakeConditions_cff")
process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff") 
process.prefer("GlobalTag") 
process.GlobalTag.connect = "frontier://PromptProd/CMS_COND_21X_GLOBALTAG"
process.GlobalTag.globaltag = "CRAFT_V4P::All"


process.noiseFilter = cms.EDFilter("NoiseEvents"
)

import RecoTracker.TrackProducer.TrackRefitters_cff

process.ctfWithMaterialTracksP5                             = RecoTracker.TrackProducer.TrackRefitter_cfi.TrackRefitter.clone()
process.ctfWithMaterialTracksP5.src                         = 'ctfWithMaterialTracksP5'
process.ctfWithMaterialTracksP5.TrajectoryInEvent           = True

process.ctfWithMaterialTracksBeamHaloMuon                   = RecoTracker.TrackProducer.TrackRefitter_cfi.TrackRefitter.clone()
process.ctfWithMaterialTracksBeamHaloMuon.src               = 'ctfWithMaterialTracksBeamHaloMuon'
process.ctfWithMaterialTracksBeamHaloMuon.TrajectoryInEvent = True

process.rsWithMaterialTracksP5                              = RecoTracker.TrackProducer.TrackRefitter_cfi.TrackRefitter.clone()
process.rsWithMaterialTracksP5.src                          = 'rsWithMaterialTracksP5'
process.rsWithMaterialTracksP5.TrajectoryInEvent            = True

process.cosmictrackfinderP5                                 = RecoTracker.TrackProducer.TrackRefitter_cfi.TrackRefitter.clone()
process.cosmictrackfinderP5.src                             = 'cosmictrackfinderP5'
process.cosmictrackfinderP5.TrajectoryInEvent               = True

from TrackingTools.TrackRefitter.TracksToTrajectories_cff import *

process.lhcStandAloneMuonsBarrelOnly  = cms.EDProducer("TracksToTrajectories",
                   Tracks             = cms.InputTag("lhcStandAloneMuonsBarrelOnly"),
                   TrackTransformer   = cms.PSet(DoPredictionsOnly = cms.bool(True),
                                        Fitter = cms.string('KFFitterForRefitInsideOut'),
                                        TrackerRecHitBuilder = cms.string('WithTrackAngle'),
                                        Smoother = cms.string('KFSmootherForRefitInsideOut'),
                                        MuonRecHitBuilder = cms.string('MuonRecHitBuilder'),
                                        RefitDirection = cms.string('insideOut'),
                                        RefitRPCHits = cms.bool(False),
                                        Propagator = cms.string('SmartPropagatorAnyRK')
                  )
)

process.lhcStandAloneMuonsEndCapsOnly = cms.EDProducer("TracksToTrajectories",
                   Tracks             = cms.InputTag("lhcStandAloneMuonsEndCapsOnly"),
                   TrackTransformer   = cms.PSet(DoPredictionsOnly = cms.bool(True),
                                        Fitter = cms.string('KFFitterForRefitInsideOut'),
                                        TrackerRecHitBuilder = cms.string('WithTrackAngle'),
                                        Smoother = cms.string('KFSmootherForRefitInsideOut'),
                                        MuonRecHitBuilder = cms.string('MuonRecHitBuilder'),
                                        RefitDirection = cms.string('insideOut'),
                                        RefitRPCHits = cms.bool(False),
                                        Propagator = cms.string('SmartPropagatorAnyRK')
                  )
)

process.cosmicMuons                   = cms.EDProducer("TracksToTrajectories",
                   Tracks             = cms.InputTag("cosmicMuons"),
                   TrackTransformer   = cms.PSet(DoPredictionsOnly = cms.bool(True),
                                        Fitter = cms.string('KFFitterForRefitInsideOut'),
                                        TrackerRecHitBuilder = cms.string('WithTrackAngle'),
                                        Smoother = cms.string('KFSmootherForRefitInsideOut'),
                                        MuonRecHitBuilder = cms.string('MuonRecHitBuilder'),
                                        RefitDirection = cms.string('insideOut'),
                                        RefitRPCHits = cms.bool(False),
                                        Propagator = cms.string('SmartPropagatorAnyRK')
                  )
)


process.globalCosmicMuons             = cms.EDProducer("TracksToTrajectories",
                   Tracks             = cms.InputTag("globalCosmicMuons"),
                   TrackTransformer   = cms.PSet(DoPredictionsOnly = cms.bool(True),
                                        Fitter = cms.string('KFFitterForRefitInsideOut'),
                                        TrackerRecHitBuilder = cms.string('WithTrackAngle'),
                                        Smoother = cms.string('KFSmootherForRefitInsideOut'),
                                        MuonRecHitBuilder = cms.string('MuonRecHitBuilder'),
                                        RefitDirection = cms.string('insideOut'),
                                        RefitRPCHits = cms.bool(False),
                                        Propagator = cms.string('SmartPropagatorAnyRK')
                  )
)



#FROG
process.load("Visualisation.Frog.Frog_Analyzer_cff")

process.frog.OutputFile       = 'XXX_OUTPUT_XXX_Cosmics_ctfWithMaterialTracksP5.vis'
process.frog.NEventsInVisFile =  1000
process.frog.CompressFiles    =  cms.bool(True)


process.frog.GenParticlesProducers     = []                     #Commented Lines means default value
process.frog.SimVertexProducers        = []                     #Commented Lines means default value
process.frog.SimTrackProducers         = []                     #Commented Lines means default value
process.frog.SimHitProducers           = []                     #Commented Lines means default value
process.frog.SimCaloHitProducers       = []                     #Commented Lines means default value
process.frog.SiStripClusterProducers  = []                     #Commented Lines means default value
process.frog.EcalRecHitProducers      = []                     #Commented Lines means default value
process.frog.HcalHBHERecHitProducers  = []                     #Commented Lines means default value
process.frog.HcalHORecHitProducers    = []                     #Commented Lines means default value
process.frog.HcalHFRecHitProducers    = []                     #Commented Lines means default value
process.frog.DTSegmentProducers       = []                     #Commented Lines means default value
process.frog.CSCSegmentProducers      = []                     #Commented Lines means default value
process.frog.RPCHitsProducers         = []                     #Commented Lines means default value
process.frog.CaloTowersProducers      = []                     #Commented Lines means default value
process.frog.NIProducers               = []                     #Commented Lines means default value
process.frog.TrackProducers           = []                     #Commented Lines means default value
process.frog.TrajectoryProducers       = ['ctfWithMaterialTracksP5', 'ctfWithMaterialTracksBeamHaloMuon', 'rsWithMaterialTracksP5', 'cosmictrackfinderP5', 'lhcStandAloneMuonsBarrelOnly', 'lhcStandAloneMuonsEndCapsOnly', 'cosmicMuons', 'globalCosmicMuons']
#process.frog.TrajectoryProducers       = ['ctfWithMaterialTracksP5', 'ctfWithMaterialTracksBeamHaloMuon', 'rsWithMaterialTracksP5', 'cosmictrackfinderP5']   
process.frog.BasicJetsProducers        = []                     #Commented Lines means default value
#process.frog.CaloJetsProducers        = []                     #Commented Lines means default value
#process.frog.RecoCandidateProducers   = []                     #Commented Lines means default value
#process.frog.CaloMETProducers         = []                     #Commented Lines means default value

process.p = cms.Path(process.noiseFilter  * process.ctfWithMaterialTracksP5 * process.ctfWithMaterialTracksBeamHaloMuon * process.rsWithMaterialTracksP5 * process.cosmictrackfinderP5 * process.lhcStandAloneMuonsBarrelOnly * process.lhcStandAloneMuonsEndCapsOnly * process.cosmicMuons * process.globalCosmicMuons * process.frog)


#process.p = cms.Path(process.ctfWithMaterialTracksP5 * process.ctfWithMaterialTracksBeamHaloMuon * process.rsWithMaterialTracksP5 * process.cosmictrackfinderP5 * process.lhcStandAloneMuonsBarrelOnly * process.lhcStandAloneMuonsEndCapsOnly * process.cosmicMuons * process.globalCosmicMuons * process.frog)





# OUT
#process.OUT = cms.OutputModule("PoolOutputModule",
#    fileName       = cms.untracked.string('out.root'),
#    outputCommands = cms.untracked.vstring(
#        'keep *'
#    )
#)
#process.outpath  = cms.EndPath(process.OUT)
#process.schedule = cms.Schedule(process.p, process.outpath)

