Skip to content

Commit

Permalink
Debug the crash in AlCa step and now it works
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunanda committed Jul 10, 2015
1 parent c20a59e commit 3fd20d6
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
'keep *_offlineBeamSpot_*_*',
'keep recoTracks_generalTracks_*_*',
'keep recoTrackExtras_generalTracks_*_*',
'keep edmTriggerResults_*_*_*',
'keep triggerTriggerEvent_*_*_*',
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
TkAlIsoProd.applyNHighestPt = False
TkAlIsoProd.applyIsolationCut = False
TkAlIsoProd.applyChargeCheck = False
TkAlIsoProd.src = 'IsoProd:IsoTrackTracksCollection'
#TkAlIsoProd.src = 'generalTracks'

seqALCARECOHcalCalIsoTrk = cms.Sequence(isoHLT*IsoProd*TkAlIsoProd)

Expand Down
65 changes: 36 additions & 29 deletions Calibration/HcalAlCaRecoProducers/src/AlCaHBHEMuonProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ AlCaHBHEMuonProducer::~AlCaHBHEMuonProducer() { }
void AlCaHBHEMuonProducer::produce(edm::Event& iEvent, edm::EventSetup const& iSetup) {

++nAll_;
bool valid(true);
#ifdef DebugLog
edm::LogInfo("HcalHBHEMuon") << "AlCaHBHEMuonProducer::Run "
<< iEvent.id().run() << " Event "
Expand All @@ -131,81 +132,87 @@ void AlCaHBHEMuonProducer::produce(edm::Event& iEvent, edm::EventSetup const& iS
iEvent.getByToken(tok_BS_, bmspot);
if (!bmspot.isValid()){
edm::LogWarning("HcalHBHEMuon") << "AlCaHBHEMuonProducer: Error! can't get product " << labelBS_;
return;
valid = false;
}
const reco::BeamSpot beam = *(bmspot.product());

edm::Handle<reco::VertexCollection> vt;
iEvent.getByToken(tok_Vtx_, vt);
if (!vt.isValid()) {
edm::LogWarning("HcalHBHEMuon") << "AlCaHBHEMuonProducer: Error! can't get product " << labelVtx_;
return ;
valid = false;
}
const reco::VertexCollection vtx = *(vt.product());

edm::Handle<EcalRecHitCollection> barrelRecHitsHandle;
iEvent.getByToken(tok_EB_, barrelRecHitsHandle);
if (!barrelRecHitsHandle.isValid()) {
edm::LogWarning("HcalHBHEMuon") << "AlCaHBHEMuonProducer: Error! can't get product " << labelEB_;
return ;
valid = false;
}
const EcalRecHitCollection ebcoll = *(barrelRecHitsHandle.product());

edm::Handle<EcalRecHitCollection> endcapRecHitsHandle;
iEvent.getByToken(tok_EE_, endcapRecHitsHandle);
if (!endcapRecHitsHandle.isValid()) {
edm::LogWarning("HcalHBHEMuon") << "AlCaHBHEMuonProducer: Error! can't get product " << labelEE_;
return ;
valid = false;
}
const EcalRecHitCollection eecoll = *(endcapRecHitsHandle.product());

edm::Handle<HBHERecHitCollection> hbhe;
iEvent.getByToken(tok_HBHE_, hbhe);
if (!hbhe.isValid()) {
edm::LogWarning("HcalHBHEMuon") << "AlCaHBHEMuonProducer: Error! can't get product " << labelHBHE_;
return ;
valid = false;
}
const HBHERecHitCollection hbhecoll = *(hbhe.product());

edm::Handle<reco::MuonCollection> muonhandle;
iEvent.getByToken(tok_Muon_, muonhandle);
if (!muonhandle.isValid()) {
edm::LogWarning("HcalHBHEMuon") << "AlCaHBHEMuonProducer: Error! can't get product " << labelMuon_;
return ;
valid = false;
}
const reco::MuonCollection muons = *(muonhandle.product());

#ifdef DebugLog
edm::LogInfo("HcalHBHEMuon") << "AlCaHBHEMuonProducer::Has obtained all the collections";
edm::LogInfo("HcalHBHEMuon") << "AlCaHBHEMuonProducer::obtained the collections with validity flag " << valid;
#endif

//For accepted events
bool accept = select(muons);
std::auto_ptr<reco::BeamSpot> outputBeamSpot(new reco::BeamSpot(beam.position(),beam.sigmaZ(),
beam.dxdz(),beam.dydz(),beam.BeamWidthX(),
beam.covariance(),beam.type()));
std::auto_ptr<reco::BeamSpot> outputBeamSpot(new reco::BeamSpot());
std::auto_ptr<reco::VertexCollection> outputVColl(new reco::VertexCollection);
std::auto_ptr<EBRecHitCollection> outputEBColl(new EBRecHitCollection);
std::auto_ptr<EERecHitCollection> outputEEColl(new EERecHitCollection);
std::auto_ptr<HBHERecHitCollection> outputHBHEColl(new HBHERecHitCollection);
std::auto_ptr<reco::MuonCollection> outputMColl(new reco::MuonCollection);
if (accept) {
++nGood_;

if (valid) {
const reco::BeamSpot beam = *(bmspot.product());
outputBeamSpot = std::auto_ptr<reco::BeamSpot>(new reco::BeamSpot(beam.position(),beam.sigmaZ(),
beam.dxdz(),beam.dydz(),beam.BeamWidthX(),
beam.covariance(),beam.type()));
const reco::VertexCollection vtx = *(vt.product());
const EcalRecHitCollection ebcoll = *(barrelRecHitsHandle.product());
const EcalRecHitCollection eecoll = *(endcapRecHitsHandle.product());
const HBHERecHitCollection hbhecoll = *(hbhe.product());
const reco::MuonCollection muons = *(muonhandle.product());

bool accept = select(muons);

if (accept) {
++nGood_;

for (reco::VertexCollection::const_iterator vtr=vtx.begin(); vtr!=vtx.end(); ++vtr)
outputVColl->push_back(*vtr);
for (reco::VertexCollection::const_iterator vtr=vtx.begin(); vtr!=vtx.end(); ++vtr)
outputVColl->push_back(*vtr);

for (edm::SortedCollection<EcalRecHit>::const_iterator ehit=ebcoll.begin(); ehit!=ebcoll.end(); ++ehit)
outputEBColl->push_back(*ehit);
for (edm::SortedCollection<EcalRecHit>::const_iterator ehit=ebcoll.begin(); ehit!=ebcoll.end(); ++ehit)
outputEBColl->push_back(*ehit);

for (edm::SortedCollection<EcalRecHit>::const_iterator ehit=eecoll.begin(); ehit!=eecoll.end(); ++ehit)
outputEEColl->push_back(*ehit);
for (edm::SortedCollection<EcalRecHit>::const_iterator ehit=eecoll.begin(); ehit!=eecoll.end(); ++ehit)
outputEEColl->push_back(*ehit);

for (std::vector<HBHERecHit>::const_iterator hhit=hbhecoll.begin(); hhit!=hbhecoll.end(); ++hhit)
outputHBHEColl->push_back(*hhit);
for (std::vector<HBHERecHit>::const_iterator hhit=hbhecoll.begin(); hhit!=hbhecoll.end(); ++hhit)
outputHBHEColl->push_back(*hhit);

for (reco::MuonCollection::const_iterator muon=muons.begin(); muon!=muons.end(); ++muon)
outputMColl->push_back(*muon);
for (reco::MuonCollection::const_iterator muon=muons.begin(); muon!=muons.end(); ++muon)
outputMColl->push_back(*muon);
}
}

iEvent.put(outputBeamSpot, labelBS_.label());
Expand Down
57 changes: 32 additions & 25 deletions Calibration/HcalAlCaRecoProducers/src/AlCaIsoTracksProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -231,43 +231,47 @@ void AlCaIsoTracksProducer::produce(edm::Event& iEvent, edm::EventSetup const& i
<< iEvent.luminosityBlock() << " Bunch "
<< iEvent.bunchCrossing();
#endif
bool valid(true);
//Step1: Get all the relevant containers
trigger::TriggerEvent triggerEvent;
edm::Handle<trigger::TriggerEvent> triggerEventHandle;
iEvent.getByToken(tok_trigEvt_, triggerEventHandle);
if (!triggerEventHandle.isValid()) {
edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " << labelTriggerEvent_;
return;
valid = false;
}
edm::Handle<edm::TriggerResults> triggerResults;
iEvent.getByToken(tok_trigRes_, triggerResults);
if (!triggerResults.isValid()) {
edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " << labelTriggerResults_;
return;
valid = false;
}

edm::Handle<reco::TrackCollection> trkCollection;
iEvent.getByToken(tok_genTrack_, trkCollection);
if (!trkCollection.isValid()) {
edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " << labelGenTrack_;
return;
valid = false;
}
reco::TrackCollection::const_iterator trkItr;

edm::Handle<reco::VertexCollection> recVtxs;
iEvent.getByToken(tok_recVtx_, recVtxs);
if (!trkCollection.isValid()) {
if (!recVtxs.isValid()) {
edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " << labelGenTrack_;
return;
valid = false;
}

edm::Handle<reco::BeamSpot> beamSpotH;
iEvent.getByToken(tok_bs_, beamSpotH);
math::XYZPoint leadPV(0,0,0);
if (recVtxs->size()>0 && !((*recVtxs)[0].isFake())) {
leadPV = math::XYZPoint((*recVtxs)[0].x(),(*recVtxs)[0].y(),
(*recVtxs)[0].z());
} else if (beamSpotH.isValid()) {
leadPV = beamSpotH->position();
if (valid) {
if (recVtxs->size()>0 && !((*recVtxs)[0].isFake())) {
leadPV = math::XYZPoint((*recVtxs)[0].x(),(*recVtxs)[0].y(),
(*recVtxs)[0].z());
} else if (beamSpotH.isValid()) {
leadPV = beamSpotH->position();
}
}
#ifdef DebugLog
edm::LogInfo("HcalIsoTrack") << "Primary Vertex " << leadPV;
Expand All @@ -277,37 +281,41 @@ void AlCaIsoTracksProducer::produce(edm::Event& iEvent, edm::EventSetup const& i
iEvent.getByToken(tok_EB_, barrelRecHitsHandle);
if (!barrelRecHitsHandle.isValid()) {
edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " << labelEB_;
return;
valid = false;
}
edm::Handle<EcalRecHitCollection> endcapRecHitsHandle;
iEvent.getByToken(tok_EE_, endcapRecHitsHandle);
if (!endcapRecHitsHandle.isValid()) {
edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " << labelEE_;
return;
valid = false;
}
edm::Handle<HBHERecHitCollection> hbhe;
iEvent.getByToken(tok_hbhe_, hbhe);
if (!hbhe.isValid()) {
edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " << labelHBHE_;
return;
valid = false;
}

//Get L1 trigger object
double ptL1(0), etaL1(0), phiL1(0);
edm::Handle<trigger::TriggerFilterObjectWithRefs> l1trigobj;
iEvent.getByToken(tok_hltGT_, l1trigobj);

std::vector< edm::Ref<l1extra::L1JetParticleCollection> > l1tauobjref;
l1trigobj->getObjects(trigger::TriggerL1TauJet, l1tauobjref);
setPtEtaPhi(l1tauobjref,ptL1,etaL1,phiL1);
if (l1trigobj.isValid()) {
std::vector< edm::Ref<l1extra::L1JetParticleCollection> > l1tauobjref;
l1trigobj->getObjects(trigger::TriggerL1TauJet, l1tauobjref);
setPtEtaPhi(l1tauobjref,ptL1,etaL1,phiL1);

std::vector< edm::Ref<l1extra::L1JetParticleCollection> > l1jetobjref;
l1trigobj->getObjects(trigger::TriggerL1CenJet, l1jetobjref);
setPtEtaPhi(l1jetobjref,ptL1,etaL1,phiL1);
std::vector< edm::Ref<l1extra::L1JetParticleCollection> > l1jetobjref;
l1trigobj->getObjects(trigger::TriggerL1CenJet, l1jetobjref);
setPtEtaPhi(l1jetobjref,ptL1,etaL1,phiL1);

std::vector< edm::Ref<l1extra::L1JetParticleCollection> > l1forjetobjref;
l1trigobj->getObjects(trigger::TriggerL1ForJet, l1forjetobjref);
setPtEtaPhi(l1forjetobjref,ptL1,etaL1,phiL1);
std::vector< edm::Ref<l1extra::L1JetParticleCollection> > l1forjetobjref;
l1trigobj->getObjects(trigger::TriggerL1ForJet, l1forjetobjref);
setPtEtaPhi(l1forjetobjref,ptL1,etaL1,phiL1);
} else {
valid = false;
}

std::auto_ptr<reco::HcalIsolatedTrackCandidateCollection> outputHcalIsoTrackColl(new reco::HcalIsolatedTrackCandidateCollection);
std::auto_ptr<reco::VertexCollection> outputVColl(new reco::VertexCollection);
Expand All @@ -316,9 +324,8 @@ void AlCaIsoTracksProducer::produce(edm::Event& iEvent, edm::EventSetup const& i
std::auto_ptr<HBHERecHitCollection> outputHBHEColl(new HBHERecHitCollection);

//For valid HLT record
if (!triggerEventHandle.isValid()) {
edm::LogWarning("HcalIsoTrack") << "Error! Can't get the product "
<< labelTriggerEvent_.label() ;
if (!valid) {
edm::LogWarning("HcalIsoTrack") << "Error! Can't get some of the products";
} else {
trigger::TriggerEvent triggerEvent = *(triggerEventHandle.product());
if (triggerResults.isValid()) {
Expand Down

0 comments on commit 3fd20d6

Please sign in to comment.