if (fDebug>1) printf("AliCFTaskVertexingHF::Init()");
AliRDHFCuts *copyfCuts = 0x0;
-
+ if (!fCuts){
+ AliFatal("No cuts defined - Exiting...");
+ return;
+ }
+
switch (fDecayChannel){
case 2:{
copyfCuts = new AliRDHFCutsD0toKpi(*(dynamic_cast<AliRDHFCutsD0toKpi*>(fCuts)));
}
const char* nameoutput=GetOutputSlot(4)->GetContainer()->GetName();
- copyfCuts->SetName(nameoutput);
-
- //Post the data
- PostData(4, copyfCuts);
+ if (copyfCuts){
+ copyfCuts->SetName(nameoutput);
+
+ //Post the data
+ PostData(4, copyfCuts);
+ }
+ else{
+ AliFatal("Failing initializing AliRDHFCuts object - Exiting...");
+ }
return;
}
default:
break;
}
+ if (!cfVtxHF){
+ AliError("No AliCFVertexingHF initialized");
+ return;
+ }
Double_t zPrimVertex = aodVtx ->GetZ();
Double_t zMCVertex = mcHeader->GetVtxZ();
for (Int_t iPart=0; iPart<mcArray->GetEntriesFast(); iPart++) {
AliAODMCParticle* mcPart = dynamic_cast<AliAODMCParticle*>(mcArray->At(iPart));
-
+ if (!mcPart){
+ AliError("Failed casting particle from MC array!, Skipping particle");
+ continue;
+ }
// check the MC-level cuts, must be the desidered particle
if (!fCFManager->CheckParticleCuts(0, mcPart)) continue; // 0 stands for MC level
// setting the parameters (candidate and n. daughters)
//
- fmcPartCandidate = dynamic_cast <AliAODMCParticle*> (fmcArray->At(label));
- fNDaughters = fmcPartCandidate->GetNDaughters();
+ fmcPartCandidate = dynamic_cast <AliAODMCParticle*> (fmcArray->At(label));
+ if (fmcPartCandidate){
+ fNDaughters = fmcPartCandidate->GetNDaughters();
+ }
+ else {
+ AliError(Form("Dynamic cast failed, fNdaughters will remain set to %d",fNDaughters));
+ }
return;
}
//
Int_t cquarks = 0;
- if (mcPart->GetPdgCode() == 4) cquarks++;
- if (mcPart->GetPdgCode() == -4) cquarks++;
- if (!mcPart) {
+ if (mcPart) {
+ if (mcPart->GetPdgCode() == 4) cquarks++;
+ if (mcPart->GetPdgCode() == -4) cquarks++;
+ }
+ else {
AliWarning("Particle not found in tree, skipping\n");
return cquarks;
}
istep++;
AliDebug(2,Form("mother at step %d = %d", istep, mother));
AliAODMCParticle* mcGranma = dynamic_cast<AliAODMCParticle*>(fmcArray->At(mother));
- pdgGranma = mcGranma->GetPdgCode();
- AliDebug(2,Form("Pdg mother at step %d = %d", istep, pdgGranma));
- abspdgGranma = TMath::Abs(pdgGranma);
- if ((abspdgGranma > 500 && abspdgGranma < 600) || (abspdgGranma > 5000 && abspdgGranma < 6000)) {
- if (!fKeepDfromB) return -9999; //skip particle if come from a B meson.
-
- else{
- break;
+ if (mcGranma){
+ pdgGranma = mcGranma->GetPdgCode();
+ AliDebug(2,Form("Pdg mother at step %d = %d", istep, pdgGranma));
+ abspdgGranma = TMath::Abs(pdgGranma);
+ if ((abspdgGranma > 500 && abspdgGranma < 600) || (abspdgGranma > 5000 && abspdgGranma < 6000)) {
+ if (!fKeepDfromB) return -9999; //skip particle if come from a B meson.
+
+ else{
+ break;
+ }
}
+ mother = mcGranma->GetMother();
+ }
+ else {
+ AliError("Failed casting the mother particle!");
+ break;
}
- mother = mcGranma->GetMother();
}
if (!((abspdgGranma > 500 && abspdgGranma < 600) || (abspdgGranma > 5000 && abspdgGranma < 6000))){
if (fKeepDfromBOnly) return -999;
if (label1 - label0 == fProngs-1){
for (Int_t iProng = 0; iProng<fProngs; iProng++){
mcPartDaughter = dynamic_cast<AliAODMCParticle*>(fmcArray->At(label0+iProng));
- fLabelArray[iProng] = mcPartDaughter->GetLabel();
+ if (mcPartDaughter){
+ fLabelArray[iProng] = mcPartDaughter->GetLabel();
+ }
+ else{
+ AliError("Failed casting the daughter particle, returning a NULL label array");
+ delete [] fLabelArray;
+ fLabelArray = 0x0;
+ return bLabelArray;
+ }
}
}
AliAODMCParticle* part = dynamic_cast<AliAODMCParticle*>(fmcArray->At(iLabelDau));
Int_t pdgCode=TMath::Abs(part->GetPdgCode());
if(pdgCode==211 || pdgCode==321 || pdgCode==2212){
- fLabelArray[foundDaughters] = part->GetLabel();
- foundDaughters++;
+ if (part) {
+ fLabelArray[foundDaughters] = part->GetLabel();
+ foundDaughters++;
+ }
+ else{
+ AliError("Error while casting particle! returning a NULL array");
+ delete [] fLabelArray;
+ fLabelArray = 0x0;
+ return bLabelArray;
+ }
}
else{
Int_t nDauRes=part->GetNDaughters();
for(Int_t iDauRes=0; iDauRes<nDauRes; iDauRes++){
Int_t iLabelDauRes = labelFirstDauRes+iDauRes;
AliAODMCParticle* dauRes = dynamic_cast<AliAODMCParticle*>(fmcArray->At(iLabelDauRes));
- fLabelArray[foundDaughters] = dauRes->GetLabel();
- foundDaughters++;
+ if (dauRes){
+ fLabelArray[foundDaughters] = dauRes->GetLabel();
+ foundDaughters++;
+ }
+ else{
+ AliError("Error while casting resonant daughter! returning a NULL array");
+ delete [] fLabelArray;
+ fLabelArray = 0x0;
+ return bLabelArray;
+ }
}
}
}