void print_decay_channels(int pdgc)
{
  ostringstream pdg_table;
  pdg_table << gSystem->Getenv("GENIE") << "/data/pdg/genie_pdg_table.txt";

  TDatabasePDG * pdglib = TDatabasePDG::Instance();
  pdglib->ReadPDGTable(pdg_table.str().c_str());

  TParticlePDG * p = pdglib->GetParticle(pdgc);

  cout << " *** Printing-out decay channels for: " << p->GetName() << endl;

  double brtot=0;
  for(int j=0; j<p->NDecayChannels(); j++) {
        cout << "\t - decay channel id = " << j << ", channel = " << p->GetName() << " --> ";
	TDecayChannel * dch = p->DecayChannel(j);
        for(int k=0; k<dch->NDaughters(); k++) {
	   cout << pdglib->GetParticle(dch->DaughterPdgCode(k))->GetName();
	   if(k < dch->NDaughters() - 1) cout << " + ";
	}//k
	cout << ", BR = " << dch->BranchingRatio() << endl;
        brtot += dch->BranchingRatio();
  }//j

  cout << "Sum{BR} = " << brtot << endl;
}
Example #2
0
void AddRsnPairsRho(AliAnalysisTaskSE *task,
                    Bool_t isMC,
                    Bool_t isMixing,
                    AliPID::EParticleType pType1,
                    Int_t listID1,
                    AliPID::EParticleType pType2,
                    Int_t listID2,
                    AliRsnCutSet *cutsEvent=0,
                    AliRsnCutSet *cutsPair=0,
                    TString suffix = "") {

   Printf("id1=%d id2=%d",listID1,listID2);

   // retrieve mass from PDG database
   Int_t         pdg  = 113;
   TDatabasePDG *db   = TDatabasePDG::Instance();
   TParticlePDG *part = db->GetParticle(pdg);
   Double_t mass = part->Mass();
   Bool_t valid;
   Int_t isRsnMini = AliAnalysisManager::GetGlobalInt("rsnUseMiniPackage",valid);

   if (isRsnMini) {
      AddPairOutputMiniRho(task,isMC,isMixing,pType1,listID1,pType2,listID2,pdg,mass,cutsPair,suffix);
   } else {
      // this function is common and it is located in RsnConfig.C
      // as ouptup AddPairOutputPhi from this macro will be taken
      AddPair(task,isMC,isMixing,pType1,listID1,pType2,listID2,pdg,mass,cutsEvent,cutsPair,suffix);
   }
}
void ConvertInput(Int_t event, DelphesFactory *factory, TObjArray *allParticleOutputArray, TObjArray *stableParticleOutputArray, TObjArray *partonOutputArray)
{
  Int_t particle;

  Candidate *candidate;
  TDatabasePDG *pdg;
  TParticlePDG *pdgParticle;
  Int_t pdgCode;

  Int_t pid, status;
  Double_t px, py, pz, e, mass;
  Double_t x, y, z, t;

  pdg = TDatabasePDG::Instance();

  for(particle = 0; particle < NPARTICLES; ++particle)
  {
    pid = EVENTS[event][particle][0];
    status = EVENTS[event][particle][1];
    px = EVENTS[event][particle][2];
    py = EVENTS[event][particle][3];
    pz = EVENTS[event][particle][4];
    e = EVENTS[event][particle][5];
    mass = EVENTS[event][particle][6];
    x = EVENTS[event][particle][7];
    y = EVENTS[event][particle][8];
    z = EVENTS[event][particle][9];
    t = EVENTS[event][particle][10];

    candidate = factory->NewCandidate();

    candidate->PID = pid;
    pdgCode = TMath::Abs(candidate->PID);

    candidate->Status = status;

    pdgParticle = pdg->GetParticle(pid);
    candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999;
    candidate->Mass = mass;

    candidate->Momentum.SetPxPyPzE(px, py, pz, e);

    candidate->Position.SetXYZT(x, y, z, t);

    allParticleOutputArray->Add(candidate);

    if(!pdgParticle) return;

    if(status == 1)
    {
      stableParticleOutputArray->Add(candidate);
    }
    else if(pdgCode <= 5 || pdgCode == 21 || pdgCode == 15)
    {
      partonOutputArray->Add(candidate);
    }
  }
}
Example #4
0
  void Run(const std::string& medName, const std::string& pdgName) 
  {
    TGeant3* mc = static_cast<TGeant3*>(gMC);
    if (!mc) {
      std::cerr << "Couldn't get VMC" << std::endl;
      return;
    }
    TGeoMedium* medium = gGeoManager->GetMedium(medName.c_str());
    if (!medium) {
      std::cerr << "Couldn't find medium " << medName << std::endl;
      return;
    }
    int medNo = medium->GetMaterial()->GetUniqueID();
    TDatabasePDG* pdgDb = TDatabasePDG::Instance();
    fPDG                = pdgDb->GetParticle(pdgName.c_str());
    if (!fPDG) {
      std::cerr << "Couldn't find particle " << pdgName << std::endl;
      return;
    }
    int pdgNo = fPDG->PdgCode();
    int pidNo = mc->IdFromPDG(pdgNo);

    std::stringstream vars;
    vars << "betagamma/F";

    size_t nOk   = 0;
    // Loop over defined mechanisms 
    for (mech_array::iterator i = fMechs.begin(); i != fMechs.end(); ++i) {
      if (!(*i)->Get(mc, fTKine, fCuts, medNo, pidNo, fPDG->Mass()))continue;
      vars << ":" << (*i)->fMech.fName;
      nOk ++;
    }
    
    std::stringstream tName;
    tName << medName << "_" << pdgName;
    TTree* tree = new TTree(tName.str().c_str(), tName.str().c_str());

    float_array cache(nOk+1);
    tree->Branch("xsec", &(cache[0]), vars.str().c_str());
    for (size_t i = 0; i < fTKine.size(); i++) {
      cache[0] = fTKine[i] / fPDG->Mass();
      int k = 0;
      for (mech_array::iterator j = fMechs.begin(); j != fMechs.end(); ++j) {
	if (!(*j)->fStatus) continue;
	cache[++k] = (*j)->fValues[i];
      }
      tree->Fill();
    }
    tree->Write();
  }
Example #5
0
void AddPairOutputMiniRho(AliAnalysisTaskSE *task, Bool_t isMC,Bool_t isMixing, AliPID::EParticleType pType1,Int_t listID1, AliPID::EParticleType pType2,Int_t listID2, Int_t pdgMother,Double_t massMother, AliRsnCutSet *cutsPair=0,TString suffix = "") {

   Bool_t valid;
   Int_t isFullOutput = AliAnalysisManager::GetGlobalInt("rsnOutputFull",valid);
   Int_t useMixing = AliAnalysisManager::GetGlobalInt("rsnUseMixing",valid);
   Int_t isPP = AliAnalysisManager::GetGlobalInt("rsnIsPP",valid);

   AliRsnMiniAnalysisTask *taskRsnMini =  (AliRsnMiniAnalysisTask *)task;

   /* invariant mass   */ Int_t imID   = taskRsnMini->CreateValue(AliRsnMiniValue::kInvMass, kFALSE);
   /* IM resolution    */ Int_t resID  = taskRsnMini->CreateValue(AliRsnMiniValue::kInvMassDiff, kTRUE);
   /* transv. momentum */ Int_t ptID   = taskRsnMini->CreateValue(AliRsnMiniValue::kPt, kFALSE);
   /* centrality       */ Int_t centID = taskRsnMini->CreateValue(AliRsnMiniValue::kMult, kFALSE);
   /* eta              */ Int_t etaID = taskRsnMini->CreateValue(AliRsnMiniValue::kEta, kFALSE);


   // use an array for more compact writing, which are different on mixing and charges
   // [0] = unlike
   // [1] = mixing
   // [2] = like ++
   // [3] = like --
   Bool_t  use     [5] = { 1      ,  useMixing      ,  1      ,  1      ,  isMC  };
   TString name    [5] = {"Unlike", "Mixing", "LikePP", "LikeMM", "Trues"};
   TString comp    [5] = {"PAIR"  , "MIX"   , "PAIR"  , "PAIR"  , "TRUE" };
   Char_t  charge1 [5] = {'+'     , '+'     , '+'     , '-'     , '+'    };
   Char_t  charge2 [5] = {'-'     , '-'     , '+'     , '-'     , '-'    };

   // common definitions
   TString outputType = "HIST";
   if (isFullOutput) outputType = "SPARSE";

   Int_t nIM   = 1000; Double_t minIM   = 0.2, maxIM =  1.2;
   Int_t nEta   = 400; Double_t minEta   = -2.0, maxEta =  2.0;
//   Int_t nIM   = 1000; Double_t minIM   = 0.9, maxIM =  1.9;
   Int_t nPt   = 120; Double_t minPt   = 0.0, maxPt = 12.0;
   Int_t nCent = 100; Double_t minCent = 0.0, maxCent = 100.0;
   Int_t nRes  = 200; Double_t maxRes  = 0.01;

   // retrieve mass from PDG database
   Int_t         pdg  = 113;
   TDatabasePDG *db   = TDatabasePDG::Instance();
   TParticlePDG *part = db->GetParticle(pdg);


   Printf(suffix.Data());
   // create standard outputs
   for (Int_t i = 0; i < 5; i++) {
      if (!use[i]) continue;
      // create output
      AliRsnMiniOutput *out = taskRsnMini->CreateOutput(Form("%s_%s", suffix.Data(),name[i].Data() ), outputType.Data(), comp[i].Data());
      // selection settings
      out->SetCutID(0, listID1);
      out->SetCutID(1, listID1);
      out->SetDaughter(0, AliRsnDaughter::kPion);
      out->SetDaughter(1, AliRsnDaughter::kPion);
      out->SetCharge(0, charge1[i]);
      out->SetCharge(1, charge2[i]);
      out->SetMotherPDG(pdg);
      out->SetMotherMass(part->Mass());
      // pair cuts
      if (cutsPair) out->SetPairCuts(cutsPair);
      // axis X: invmass
      out->AddAxis(imID, nIM, minIM, maxIM);

      if (isFullOutput) {
         // axis Y: transverse momentum
         out->AddAxis(ptID, nPt, minPt, maxPt);

         out->AddAxis(etaID, nEta, minEta, maxEta);
         // axis Z: centrality
         if (!isPP) out->AddAxis(centID, nCent, minCent, maxCent);
      }
   }

   // add output for resolution
   if (isMC) {
      AliRsnMiniOutput *outRes = taskRsnMini->CreateOutput(Form("rho_Res%s", suffix.Data()), outputType.Data(), "TRUE");
      // selection settings
      outRes->SetCutID(0, listID1);
      outRes->SetCutID(1, listID1);
      outRes->SetDaughter(0, AliRsnDaughter::kPion);
      outRes->SetDaughter(1, AliRsnDaughter::kPion);
      outRes->SetCharge(0, '+');
      outRes->SetCharge(1, '-');
      outRes->SetMotherPDG(pdg);
      outRes->SetMotherMass(part->Mass());
      // pair cuts
      if (cutsPair) outRes->SetPairCuts(cutsPair);
      // axis X: resolution
      outRes->AddAxis(resID, nRes, -maxRes, maxRes);

      if (isFullOutput) {
         // axis Y: transverse momentum
         outRes->AddAxis(ptID, nPt, minPt, maxPt);
         outRes->AddAxis(etaID, nEta, minEta, maxEta);
         // axis Z: centrality
         if (!isPP) outRes->AddAxis(centID, nCent, minCent, maxCent);
      }
   }

   //
   // -- Create output for MC generated ------------------------------------------------------------
   //

   if (isMC) {
      // create ouput
      AliRsnMiniOutput *outMC = taskRsnMini->CreateOutput(Form("rho_MCGen%s", suffix.Data()), outputType.Data(), "MOTHER");
      // selection settings
      outMC->SetDaughter(0, AliRsnDaughter::kPion);
      outMC->SetDaughter(1, AliRsnDaughter::kPion);
      outMC->SetMotherPDG(pdg);
      outMC->SetMotherMass(part->Mass());
      // pair cuts
      if (cutsPair) outMC->SetPairCuts(cutsPair);
      // axis X: invmass
      outMC->AddAxis(imID, nIM, minIM, maxIM);
      if (isFullOutput) {
         // axis Y: transverse momentum
         outMC->AddAxis(ptID, nPt, minPt, maxPt);
         outMC->AddAxis(etaID, nEta, minEta, maxEta);
         // axis Z: centrality
         if (!isPP) outMC->AddAxis(centID, nCent, minCent, maxCent);
      }
   }


}
Example #6
0
Bool_t ConfigPhiPP5TeV(  
			AliRsnMiniAnalysisTask *task, 
			Bool_t                 isMC, 
			Bool_t                 isPP,
			const char             *suffix,
			AliRsnCutSet           *cutsPair,
			Int_t                  Strcut = 2011,
			Int_t                  customQualityCutsID = AliRsnCutSetDaughterParticle::kDisableCustom,
			AliRsnCutSetDaughterParticle::ERsnDaughterCutSet cutKaCandidate=AliRsnCutSetDaughterParticle::kTPCpidTOFveto3s,
			Float_t                nsigmaK  = 3.0,
			Bool_t                 enableMonitor = kTRUE
			  )
{
  
  //These are the Default values for 2011 ESD track cuts
  
  AliPID::EParticleType  type2   = AliPID::kKaon;

  // manage suffix
  if (strlen(suffix) > 0) suffix = Form("_%s", suffix);
  
  // retrieve mass from PDG database
  Int_t         pdg  = 333;
  TDatabasePDG *db   = TDatabasePDG::Instance();
  TParticlePDG *part = db->GetParticle(pdg);
  Double_t mass      = part->Mass();
  
  Float_t nsigmaKTPC=fmod(nsigmaK,1000.);
  Float_t nsigmaKTOF=(nsigmaK-fmod(nsigmaK,1000.))/1000.;
  if(nsigmaKTOF<1.e-10) nsigmaKTOF=-1.;

    // set daughter cuts
  AliRsnCutSetDaughterParticle* cutSetK;
  AliRsnCutTrackQuality* trkQualityCut= new AliRsnCutTrackQuality("myQualityCut");
  if(!trkQualityCut) return kFALSE;

  if(SetCustomQualityCut(trkQualityCut,customQualityCutsID,Strcut)){
    cutSetK=new AliRsnCutSetDaughterParticle(Form("cutK%i_%2.1fsigma",cutKaCandidate, nsigmaK),trkQualityCut,cutKaCandidate,AliPID::kKaon,nsigmaKTPC,nsigmaKTOF);
  }
  else{
    printf("Doughter Track cuts has been selected =================\n");
    return kFALSE;
  }
  Int_t iCutK  = task->AddTrackCuts(cutSetK);
  if(enableMonitor){
    Printf("======== Monitoring cut AliRsnCutSetDaughterParticle enabled");
    gROOT->LoadMacro("$ALICE_PHYSICS/PWGLF/RESONANCES/macros/mini/AddMonitorOutput.C");
    AddMonitorOutput(isMC, cutSetK->GetMonitorOutput());
  }

  // -- Values ------------------------------------------------------------------------------------
  /* invariant mass   */ Int_t imID   = task->CreateValue(AliRsnMiniValue::kInvMass,    kFALSE);
  /* IM resolution    */ Int_t resID  = task->CreateValue(AliRsnMiniValue::kInvMassRes, kTRUE);
  /* transv. momentum */ Int_t ptID   = task->CreateValue(AliRsnMiniValue::kPt,         kFALSE);
  /* centrality       */ Int_t centID = task->CreateValue(AliRsnMiniValue::kMult,       kFALSE);
  /* pseudorapidity   */ Int_t etaID  = task->CreateValue(AliRsnMiniValue::kEta,        kFALSE);
  /* rapidity         */ Int_t yID    = task->CreateValue(AliRsnMiniValue::kY,          kFALSE);
  // -- Create all needed outputs -----------------------------------------------------------------
  // use an array for more compact writing, which are different on mixing and charges
  // [0] = unlike
  // [1] = mixing
  // [2] = like ++
  // [3] = like --

  Bool_t  use     [7] = {1         ,1         ,1         ,1         ,isMC     ,isMC     ,isMC    };
  Bool_t  useIM   [7] = {1         ,1         ,1         ,1         ,1        ,1        ,0       };
  TString name    [7] = {"Unlike"  ,"Mixing"  ,"LikePP"  ,"LikeMM"  ,"MCGen"  ,"Trues", ,"ResMP" };
  TString comp    [7] = {"PAIR"    ,"MIX"     ,"PAIR"    ,"PAIR"    ,"MOTHER" ,"TRUE"   ,"TRUE"  };
  TString output  [7] = {"SPARSE"  ,"SPARSE"  ,"SPARSE"  ,"SPARSE"  ,"SPARSE" ,"SPARSE" ,"SPARSE"};
  Char_t  charge1 [7] = {'+'       ,'+'       ,'+'       ,'-'       ,'+'      ,'+'      ,'+'     };
  Char_t  charge2 [7] = {'-'       ,'-'       ,'+'       ,'-'       ,'-'      ,'-'      ,'-'     };
  Int_t   cutIDK  [7] = {iCutK     ,iCutK     ,iCutK     ,iCutK     ,iCutK    ,iCutK   ,iCutK    };
  Int_t   PDGCode [7] = {333       ,333       ,333       ,333       ,333      ,333     ,333      };

  for (Int_t i = 0; i < 7; i++) {
    if (!use[i]) continue;
    AliRsnMiniOutput *out = task->CreateOutput(Form("PHI_%s%s", name[i].Data(), suffix), output[i].Data(), comp[i].Data());
    out->SetDaughter(0, AliRsnDaughter::kKaon);
    out->SetDaughter(1, AliRsnDaughter::kKaon);
    out->SetCutID(0, cutIDK[i]);
    out->SetCutID(1, cutIDK[i]);
    out->SetCharge(0, charge1[i]);
    out->SetCharge(1, charge2[i]);
    out->SetMotherPDG(PDGCode[i]);
    out->SetMotherMass(mass);
    out->SetPairCuts(cutsPair);

    // axis X: invmass (or resolution)
    if (useIM[i]) 
      out->AddAxis(imID, 250, 0.95, 1.2);
    else
      out->AddAxis(resID, 200, -0.02, 0.02);
    
    // axis Y: transverse momentum
    out->AddAxis(ptID, 500, 0.0, 50.0);
    
    // axis Z: centrality-multiplicity
    if (!isPP)
      out->AddAxis(centID, 100, 0.0, 100.0);
    else 
      out->AddAxis(centID, 400, 0.0, 400.0);
      
    // axis W: pseudorapidity
    // out->AddAxis(etaID, 20, -1.0, 1.0);
    // axis J: rapidity
    //out->AddAxis(yID, 90, -4.5, 4.5);
    
  }
  return kTRUE;
}


Bool_t SetCustomQualityCut(AliRsnCutTrackQuality * trkQualityCut, Int_t customQualityCutsID = 0,Int_t trCut = 2011)
{
  //Sets configuration for track quality object different from std quality cuts.
  //Returns kTRUE if track quality cut object is successfully defined,
  //returns kFALSE if an invalid set of cuts (customQualityCutsID) is chosen or if the
  //object to be configured does not exist.

  if ((!trkQualityCut)){
    Printf("::::: SetCustomQualityCut:: use default quality cuts specified in task configuration.");
    return kFALSE;
  }

  if(customQualityCutsID>=1 && customQualityCutsID<100 && customQualityCutsID!=2){
    if(trCut == 2011){
      trkQualityCut->SetDefaults2011(kTRUE,kTRUE);
      Printf(Form("::::: SetCustomQualityCut:: using standard 2011 track quality cuts"));
    }
    else if(trCut == 2015){
      trkQualityCut->SetDefaults2011(kTRUE,kTRUE);
      trkQualityCut->GetESDtrackCuts()->SetCutGeoNcrNcl(3., 130., 1.5, 0.85, 0.7);
      Printf(Form("::::: SetCustomQualityCut:: using standard 2015 track quality cuts"));
    }
    if(customQualityCutsID==3){trkQualityCut->GetESDtrackCuts()->SetMaxDCAToVertexXYPtDep("0.015+0.05/pt^1.1");}//10Sig // D = 7*(0.0015+0.0050/pt^1.1)
    else if(customQualityCutsID==4){trkQualityCut->GetESDtrackCuts()->SetMaxDCAToVertexXYPtDep("0.006+0.02/pt^1.1");}//4Sig
    else if(customQualityCutsID==5){trkQualityCut->GetESDtrackCuts()->SetMaxDCAToVertexZ(3.);}// D = 2.
    else if(customQualityCutsID==6){trkQualityCut->GetESDtrackCuts()->SetMaxDCAToVertexZ(1.);} 
    else if(customQualityCutsID==7){trkQualityCut->GetESDtrackCuts()->SetMaxDCAToVertexZ(0.2);}
    else if(customQualityCutsID==8){trkQualityCut->GetESDtrackCuts()->SetMaxChi2PerClusterTPC(5.);}// D = 4
    else if(customQualityCutsID==9){trkQualityCut->GetESDtrackCuts()->SetMaxChi2PerClusterTPC(3);}
    else if(customQualityCutsID==10){trkQualityCut->GetESDtrackCuts()->SetMinNCrossedRowsTPC(60);}// D = 70
    else if(customQualityCutsID==11){trkQualityCut->GetESDtrackCuts()->SetMinNCrossedRowsTPC(80);}
    else if(customQualityCutsID==12){trkQualityCut->GetESDtrackCuts()->SetMinNCrossedRowsTPC(100);}
    else if(customQualityCutsID==13){trkQualityCut->GetESDtrackCuts()->SetMinRatioCrossedRowsOverFindableClustersTPC(0.7);}// D = 8
    else if(customQualityCutsID==14){trkQualityCut->GetESDtrackCuts()->SetMinRatioCrossedRowsOverFindableClustersTPC(0.9);}
    else if(customQualityCutsID==15){trkQualityCut->GetESDtrackCuts()->SetMaxChi2PerClusterITS(49.);}// D = 36
    else if(customQualityCutsID==16){trkQualityCut->GetESDtrackCuts()->SetMaxChi2PerClusterITS(25.);}
    else if(customQualityCutsID==17){trkQualityCut->GetESDtrackCuts()->SetMaxChi2TPCConstrainedGlobal(49.);}// D = 36
    else if(customQualityCutsID==18){trkQualityCut->GetESDtrackCuts()->SetMaxChi2TPCConstrainedGlobal(25.);}
    else if(customQualityCutsID==19){trkQualityCut->GetESDtrackCuts()->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kOff);}
    
    trkQualityCut->Print();
    return kTRUE;
  }else if(customQualityCutsID==2 || (customQualityCutsID>=100 && customQualityCutsID<200)){
    trkQualityCut->SetDefaultsTPCOnly(kTRUE);
    Printf(Form("::::: SetCustomQualityCut:: using TPC-only track quality cuts"));
    if(customQualityCutsID==103){trkQualityCut->GetESDtrackCuts()->SetMaxDCAToVertexXY(3.);}
    else if(customQualityCutsID==104){trkQualityCut->GetESDtrackCuts()->SetMaxDCAToVertexXY(1.);}
    else if(customQualityCutsID==105){trkQualityCut->GetESDtrackCuts()->SetMaxDCAToVertexZ(4.);}
    else if(customQualityCutsID==106){trkQualityCut->GetESDtrackCuts()->SetMaxDCAToVertexZ(1.);}
    else if(customQualityCutsID==107){trkQualityCut->GetESDtrackCuts()->SetMaxChi2PerClusterTPC(7.);}
    else if(customQualityCutsID==108){trkQualityCut->GetESDtrackCuts()->SetMaxChi2PerClusterTPC(2.5);}
    else if(customQualityCutsID==109){trkQualityCut->GetESDtrackCuts()->SetMinNClustersTPC(30);}
    else if(customQualityCutsID==110){trkQualityCut->GetESDtrackCuts()->SetMinNClustersTPC(85);}

    trkQualityCut->Print();
    return kTRUE;
  }else{
    Printf("::::: SetCustomQualityCut:: use default quality cuts specified in task configuration.");
    return kFALSE;
  }
  trkQualityCut->SetPtRange(0.15, 100000.0);
  trkQualityCut->SetEtaRange(-0.8, 0.8);
  
  Printf(Form("::::: SetCustomQualityCut:: using custom track quality cuts #%i",customQualityCutsID));
  trkQualityCut->Print();
  return kTRUE;
}
Example #7
0
/** @ingroup FMD_xsec_script
    @param scale 
    @param filename 
    @param var 
    @param medName 
    @param thick 
    @param pdgName 
*/
void
DrawXsection(Bool_t scale=kFALSE, 
	     const char* filename="xsec.root", 
	     const char* var="LOSS", 
	     const char* medName="FMD_Si$", 
	     Double_t thick=.03,
	     const char* pdgName="pi+")
{
  TFile*   file = TFile::Open(filename, "READ");
  TTree*   tree = static_cast<TTree*>(file->Get(Form("%s_%s",medName,
						     pdgName)));
  TLeaf* tb   = tree->GetLeaf("T");
  TLeaf* vb   = tree->GetLeaf(var);
  if (!vb) {
    std::cerr << "Leaf " << var << " not found" << std::endl;
    return;
  }
  Float_t tkine, value;
  tb->SetAddress(&tkine);
  vb->SetAddress(&value);
  Int_t n = tree->GetEntries();

  Float_t xscale = 1;
  Float_t yscale = 1;
  if (scale) {
    TDatabasePDG* pdgDb = TDatabasePDG::Instance();
    TParticlePDG* pdgP  = pdgDb->GetParticle(pdgName);
    if (!pdgP) {
      std::cerr << "Couldn't find particle " << pdgName << std::endl;
      return;
    }
    Double_t m = pdgP->Mass();
    Double_t q = pdgP->Charge() / 3;
    if (m == 0 || q == 0) {
      std::cerr  << "Mass is 0" << std::endl;
      return;
    }
    xscale = 1 / m;
    yscale = 1 / (q * q);
  }
  
  TGraphErrors* graph = new TGraphErrors(n);
  for (Int_t i = 0; i < n; i++) {
    tree->GetEntry(i);
    Double_t x = tkine*xscale;
    Double_t y = value*yscale;
    graph->SetPoint(i, x, y); 
    // 5 sigma
    graph->SetPointError(i, 0, 5 * .1 * y);
  }
  TCanvas* c = new TCanvas("c","c");
  c->SetLogx();
  c->SetLogy();
  graph->SetLineWidth(2);
  graph->SetFillStyle(3001);
  graph->SetFillColor(6);
  graph->Draw("L");
  graph->DrawClone("AL3");
  c->Modified();
  c->Update();
  c->cd();
  c->SaveAs("xsec.C");
  
}
Example #8
0
void ConvertInput(Long64_t eventCounter, Pythia8::Pythia *pythia,
  ExRootTreeBranch *branch, DelphesFactory *factory,
  TObjArray *allParticleOutputArray, TObjArray *stableParticleOutputArray, TObjArray *partonOutputArray,
  TStopwatch *readStopWatch, TStopwatch *procStopWatch)
{
  int i;

  HepMCEvent *element;
  Candidate *candidate;
  TDatabasePDG *pdg;
  TParticlePDG *pdgParticle;
  Int_t pdgCode;

  Int_t pid, status;
  Double_t px, py, pz, e, mass;
  Double_t x, y, z, t;

  // event information
  element = static_cast<HepMCEvent *>(branch->NewEntry());

  element->EventNumber = eventCounter;

  element->ProcessID = pythia->info.code();
  element->MPI = 1;
  element->Weight = pythia->info.weight();
  element->Scale = pythia->info.QRen();
  element->AlphaQED = pythia->info.alphaEM();
  element->AlphaQCD = pythia->info.alphaS();

  element->ID1 = pythia->info.id1();
  element->ID2 = pythia->info.id2();
  element->X1 = pythia->info.x1();
  element->X2 = pythia->info.x2();
  element->ScalePDF = pythia->info.QFac();
  element->PDF1 = pythia->info.pdf1();
  element->PDF2 = pythia->info.pdf2();

  element->ReadTime = readStopWatch->RealTime();
  element->ProcTime = procStopWatch->RealTime();

  pdg = TDatabasePDG::Instance();

  for(i = 0; i < pythia->event.size(); ++i)
  {
    Pythia8::Particle &particle = pythia->event[i];

    pid = particle.id();
    status = pythia->event.statusHepMC(i);
    px = particle.px(); py = particle.py(); pz = particle.pz(); e = particle.e(); mass = particle.m();
    x = particle.xProd(); y = particle.yProd(); z = particle.zProd(); t = particle.tProd();

    candidate = factory->NewCandidate();

    candidate->PID = pid;
    pdgCode = TMath::Abs(candidate->PID);

    candidate->Status = status;

    candidate->M1 = particle.mother1() - 1;
    candidate->M2 = particle.mother2() - 1;

    candidate->D1 = particle.daughter1() - 1;
    candidate->D2 = particle.daughter2() - 1;

    pdgParticle = pdg->GetParticle(pid);
    candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999;
    candidate->Mass = mass;

    candidate->Momentum.SetPxPyPzE(px, py, pz, e);

    candidate->Position.SetXYZT(x, y, z, t);

    allParticleOutputArray->Add(candidate);

    if(!pdgParticle) continue;

    if(status == 1)
    {
      stableParticleOutputArray->Add(candidate);
    }
    else if(pdgCode <= 5 || pdgCode == 21 || pdgCode == 15)
    {
      partonOutputArray->Add(candidate);
    }
  }
}
Example #9
0
Bool_t ConfigPhiMassStudy
(  
    AliRsnMiniAnalysisTask *task, 
    Bool_t                 isMC, 
    Bool_t                 isPP,
    const char             *suffix,
    AliRsnCutSet           *cutsPair,
    Int_t                  aodFilterBit = 5,
    AliRsnCutSetDaughterParticle::ERsnDaughterCutSet cutKaCandidate = AliRsnCutSetDaughterParticle::kFastTPCpidNsigma,
    Float_t                nsigmaKa = 2.0,
    Bool_t                 enableTrkSyst = kFALSE,
    Char_t                 DCAxyFormula[100] = "0.0105+0.035/pt^1.01",
    Double_t               dcazmax = 3.2,
    Double_t               minNcls = 70,
    Double_t               maxX2cls = 4.0,
    Double_t               globalX2cls = 36.0,
    Double_t               minCrossedRows = 50.0,
    Double_t               maxClsCrossedRows = 0.8,

    Bool_t                 enableMonitor = kTRUE,
    Bool_t                 IsMcTrueOnly = kFALSE,
    Int_t                  signedPdg = 333,

    TString                monitorOpt = "",  //Flag for AddMonitorOutput.C e.g."NoSIGN"
    Bool_t                 useCrossedRows = kFALSE,
    const char*            yaxisVar = "PtDaughter_PDaughter_cent",  //yaxisVar = "PtDaughter_PDaughter_cent"
    Bool_t                 useMixLS = 0
)
{
  TString opt(yaxisVar);
  opt.ToUpper();

  Bool_t isPtDaughter  = opt.Contains("PTDAUGHTER") ;
  Bool_t isPDaughter   = opt.Contains("PDAUGHTER") ;
  Bool_t iscent        = opt.Contains("CENT") ;
  Bool_t iseta         = opt.Contains("ETA") ;
  Bool_t israpidity    = opt.Contains("RAPIDITY") ;



  // manage suffix
  if (strlen(suffix) > 0) suffix = Form("_%s", suffix);
  
  // set daughter cuts
  AliRsnCutSetDaughterParticle * cutSetQ;
  AliRsnCutSetDaughterParticle * cutSetK;


  //vary track quality cuts for systematic checks
  if(enableTrkSyst){
    AliRsnCutTrackQuality * trkQualityCut =  new AliRsnCutTrackQuality("QualityCut");
    
    trkQualityCut->SetAODTestFilterBit(aodFilterBit);//reset the filter bit cut 
    trkQualityCut->SetCheckOnlyFilterBit(kFALSE);//tells the cut object to check all other cuts individually,
    trkQualityCut->SetDCARPtFormula(DCAxyFormula);
    trkQualityCut->SetDCAZmax(dcazmax);

    if(useCrossedRows) {       
      trkQualityCut->SetMinNCrossedRowsTPC(minCrossedRows, kTRUE);
      trkQualityCut->SetMinNCrossedRowsOverFindableClsTPC(maxClsCrossedRows, kTRUE); }
    else trkQualityCut->SetTPCminNClusters(minNcls);

    trkQualityCut->SetTPCmaxChi2(maxX2cls);
    trkQualityCut->SetITSmaxChi2(36);    // In Filter bit 
    trkQualityCut->SetMaxChi2TPCConstrainedGlobal(globalX2cls);  //  In the Filterbit

    trkQualityCut->SetPtRange(0.15, 20.0);
    trkQualityCut->SetEtaRange(-0.8, 0.8);
    
    trkQualityCut->Print();

    if(isPP) {
      cutSetQ  = new AliRsnCutSetDaughterParticle(Form("cutQ_bit%i",aodFilterBit), trkQualityCut, AliRsnCutSetDaughterParticle::kQualityStd2010, AliPID::kPion, -1.0);
      cutSetK  = new AliRsnCutSetDaughterParticle(Form("cutK%i_%2.1fsigma",cutKaCandidate, nsigmaKa), trkQualityCut, cutKaCandidate, AliPID::kKaon, nsigmaKa); 
    } else {
      cutSetQ  = new AliRsnCutSetDaughterParticle(Form("cutQ_bit%i",aodFilterBit), trkQualityCut, AliRsnCutSetDaughterParticle::kQualityStd2011, AliPID::kPion, -1.0);
      cutSetK  = new AliRsnCutSetDaughterParticle(Form("cutK%i_%2.1fsigma",cutKaCandidate, nsigmaKa), trkQualityCut, cutKaCandidate, AliPID::kKaon, nsigmaKa);
      cutSetK->SetUse2011StdQualityCuts(kTRUE);
    }
    
    
  }

  else
    {
      //default cuts 2010 for pp and 2011 for p-Pb
      if(isPP) {
	cutSetQ  = new AliRsnCutSetDaughterParticle("cutQuality", AliRsnCutSetDaughterParticle::kQualityStd2010, AliPID::kPion, -1.0, aodFilterBit, kFALSE);
	cutSetK  = new AliRsnCutSetDaughterParticle(Form("cutKaon_%2.1f2sigma",nsigmaKa), cutKaCandidate, AliPID::kKaon, nsigmaKa, aodFilterBit, kFALSE);
      }
      else {
	cutSetQ  = new AliRsnCutSetDaughterParticle("cutQuality", AliRsnCutSetDaughterParticle::kQualityStd2011, AliPID::kPion, -1.0, aodFilterBit, kFALSE);
	cutSetQ->SetUse2011StdQualityCuts(kTRUE);
	cutSetK  = new AliRsnCutSetDaughterParticle(Form("cutKaon2011_%2.1f2sigma",nsigmaKa), cutKaCandidate, AliPID::kKaon, nsigmaKa, aodFilterBit, kFALSE);
	cutSetK->SetUse2011StdQualityCuts(kTRUE);
      }
    }
  
  Int_t iCutQ = task->AddTrackCuts(cutSetQ);
  Int_t iCutK = task->AddTrackCuts(cutSetK);
  
  if (enableMonitor){
    Printf("======== Cut monitoring enabled");
    gROOT->LoadMacro("$ALICE_PHYSICS/PWGLF/RESONANCES/macros/mini/AddMonitorOutput.C");
    AddMonitorOutput(isMC, cutSetQ->GetMonitorOutput(), monitorOpt.Data());
    AddMonitorOutput(isMC, cutSetK->GetMonitorOutput(), monitorOpt.Data());
  }

  Int_t         pdg  = signedPdg;
  TDatabasePDG *db   = TDatabasePDG::Instance();
  TParticlePDG *part = db->GetParticle(pdg);
  Double_t      mass = part->Mass();
  
  
  // -- Values ------------------------------------------------------------------------------------
  /* invariant mass   */ Int_t imID   = task->CreateValue(AliRsnMiniValue::kInvMass, kFALSE);
  /* IM resolution    */ Int_t resID  = task->CreateValue(AliRsnMiniValue::kInvMassRes, kTRUE);
  /* transv. momentum */ Int_t ptID   = task->CreateValue(AliRsnMiniValue::kPt, kFALSE);
  /* centrality       */ Int_t centID = task->CreateValue(AliRsnMiniValue::kMult, kFALSE);
  /* pseudorapidity   */ Int_t etaID  = task->CreateValue(AliRsnMiniValue::kEta, kFALSE);
  /* rapidity         */ Int_t yID    = task->CreateValue(AliRsnMiniValue::kY, kFALSE);
  /* 1st daughter pt  */ Int_t fdpt   = task->CreateValue(AliRsnMiniValue::kFirstDaughterPt, kFALSE);
  /* 2nd daughter pt  */ Int_t sdpt   = task->CreateValue(AliRsnMiniValue::kSecondDaughterPt, kFALSE);
  /* 1st daughter p   */ Int_t fdp    = task->CreateValue(AliRsnMiniValue::kFirstDaughterP, kFALSE);
  /* 2nd daughter p   */ Int_t sdp    = task->CreateValue(AliRsnMiniValue::kSecondDaughterP, kFALSE);

  /* transv. momentum */ Int_t ptIDmc  = task->CreateValue(AliRsnMiniValue::kPt, kTRUE);
  /* 1st daughter pt  */ Int_t fdptmc  = task->CreateValue(AliRsnMiniValue::kFirstDaughterPt, kTRUE);
  /* 2nd daughter pt  */ Int_t sdptmc  = task->CreateValue(AliRsnMiniValue::kSecondDaughterPt, kTRUE);

  // -- Create all needed outputs -----------------------------------------------------------------
  // use an array for more compact writing, which are different on mixing and charges
  // [0] = unlike
  // [1] = mixing
  // [2] = like ++
  // [3] = like --

  Bool_t  use     [12] = { !IsMcTrueOnly, !IsMcTrueOnly, !IsMcTrueOnly,!IsMcTrueOnly,!IsMcTrueOnly,!IsMcTrueOnly, isMC    ,  isMC   , isMC   ,  isMC  , useMixLS , useMixLS};
  Bool_t  useIM   [12] = { 1            ,  1           ,  1           ,  1          ,  1          , 1           ,  1      ,   1     , 0      ,   0    , 1        , 1       };
  TString name    [12] = {"UnlikePM"    , "UnlikeMP"   , "MixingPM"   , "MixingMP"  , "LikePP"    , "LikeMM"    ,"TruesPM","TruesMP","ResPM" ,"ResMP" ,"MixingPP","MixingMM"};
  TString comp    [12] = {"PAIR"        , "PAIR"       , "MIX"        , "MIX"       , "PAIR"      , "PAIR"      , "TRUE"  , "TRUE"  , "TRUE" , "TRUE" , "MIX"    ,"MIX"   };
  TString output  [12] = {"SPARSE"      , "SPARSE"     , "SPARSE"     , "SPARSE"    , "SPARSE"    , "SPARSE"    , "SPARSE","SPARSE" ,"SPARSE","SPARSE","SPARSE"  ,"SPARSE"};
  Char_t  charge1 [12] = {'+'           , '-'          , '+'          , '-'         , '+'         , '-'         , '+'     ,  '-'    , '+'    ,  '-'   , '+'      , '-'    };
  Char_t  charge2 [12] = {'-'           , '+'          , '-'          , '+'         , '+'         , '-'         , '-'     ,  '+'    , '-'    ,  '+'   ,'+'       , '-'    };
  Int_t   cutID1  [12] = { iCutK        ,  iCutK       ,  iCutK       ,  iCutK      ,  iCutK      ,  iCutK      ,  iCutK  ,  iCutK  ,  iCutK ,  iCutK , iCutK    , iCutK };
  Int_t   cutID2  [12] = { iCutK        ,  iCutK       ,  iCutK       ,  iCutK      ,  iCutK      ,  iCutK      ,  iCutK  ,  iCutK  ,  iCutK ,  iCutK , iCutK    , iCutK };
  
  //TString output  [10] = {"HIST"   , "HIST"   , "HIST"   , "HIST"   , "HIST"  , "HIST"  , "HIST"  ,  "HIST"  , "HIST"  ,  "HIST"  };
  
  for (Int_t i = 0; i < 12; i++) {
    if (!use[i]) continue;
    AliRsnMiniOutput *out = task->CreateOutput(Form("Phi_%s%s", name[i].Data(), suffix), output[i].Data(), comp[i].Data());
    out->SetCutID(0, cutID1[i]);
    out->SetCutID(1, cutID2[i]);
    out->SetDaughter(0, AliRsnDaughter::kKaon);
    out->SetDaughter(1, AliRsnDaughter::kKaon);
    out->SetCharge(0, charge1[i]);
    out->SetCharge(1, charge2[i]);
    out->SetMotherPDG(pdg);
    out->SetMotherMass(mass);
    out->SetPairCuts(cutsPair);

    // axis X: invmass (or resolution)
    if (useIM[i]) 
      out->AddAxis(imID, 800, 0.8, 1.6);
    else
      out->AddAxis(resID, 200, -0.02, 0.02);
    
    // axis Y: transverse momentum of pair as default - else chosen value
    out->AddAxis(ptID, 100, 0.0, 10.0); //default use mother pt

    if(isPtDaughter) {
      out->AddAxis(fdpt, 100, 0.0, 10.0);
      out->AddAxis(sdpt, 100, 0.0, 10.0);  
    }
    if(isPDaughter) {
      out->AddAxis(fdp, 100, 0.0, 10.0);
      out->AddAxis(sdp, 100, 0.0, 10.0);  
    }
      
    // axis Z: centrality-multiplicity
    if(iscent) {
      if (!isPP)	out->AddAxis(centID, 100, 0.0, 100.0);
      else       	out->AddAxis(centID, 400, 0.0, 400.0);      
    }

    // axis W: pseudorapidity
    if(iseta)       out->AddAxis(etaID, 20, -1.0, 1.0);
    
    // axis J: rapidity
    if(israpidity)  out->AddAxis(yID, 12, -0.6, 0.6);
    
  }   
 
  if (isMC){   
    // create output
    AliRsnMiniOutput *outm = task->CreateOutput(Form("Phi_Mother%s", suffix), "SPARSE", "MOTHER");
    outm->SetDaughter(0, AliRsnDaughter::kKaon);
    outm->SetDaughter(1, AliRsnDaughter::kKaon);
    outm->SetMotherPDG(pdg);
    outm->SetMotherMass(mass);
    // pair cuts
    outm->SetPairCuts(cutsPair);
    // binnings
    outm->AddAxis(imID, 800, 0.8, 1.6);
    // axis Y: transverse momentum of pair as default - else chosen value
    outm->AddAxis(ptID, 100, 0.0, 10.0); //default use mother pt

    if(isPtDaughter) {
      outm->AddAxis(fdpt, 100, 0.0, 10.0);
      outm->AddAxis(sdpt, 100, 0.0, 10.0);
    }
    
    if(isPDaughter) {
	outm->AddAxis(fdp, 100, 0.0, 10.0);
	outm->AddAxis(sdp, 100, 0.0, 10.0);
    }

    if(iscent) {
      if (!isPP)	outm->AddAxis(centID, 100, 0.0, 100.0);
      else       	outm->AddAxis(centID, 400, 0.0, 400.0);
    }
    // axis W: pseudorapidity

    if(iseta)       outm->AddAxis(etaID, 20, -1.0, 1.0);
    // axis J: rapidity
    if(israpidity)  outm->AddAxis(yID, 12, -0.6, 0.6);

    //create plot for generated Pt of mother vs generated Pt of daughters
    AliRsnMiniOutput *outPtGen = task->CreateOutput(Form("Phi_Mother_GenPt_%s", suffix), "SPARSE", "MOTHER");
    outPtGen->SetDaughter(0, AliRsnDaughter::kKaon);
    outPtGen->SetDaughter(1, AliRsnDaughter::kKaon);
    outPtGen->SetMotherPDG(pdg);
    outPtGen->SetMotherMass(mass);
    // pair cuts
    outPtGen->SetPairCuts(cutsPair);
    // binnings
    outPtGen->AddAxis(ptIDmc, 100, 0.0, 10.0); //mother pt - generated
    outPtGen->AddAxis(fdptmc, 100, 0.0, 10.0); //first daughter pt - generated
    outPtGen->AddAxis(sdptmc, 100, 0.0, 10.0); //second daughter pt - generated

    //create plot for reconstructed Pt of true mother vs generated Pt of daughters
    AliRsnMiniOutput *outPtTrueGen = task->CreateOutput(Form("Phi_True_GenPt_%s", suffix), "SPARSE", "TRUE");
    outPtTrueGen->SetDaughter(0, AliRsnDaughter::kKaon);
    outPtTrueGen->SetDaughter(1, AliRsnDaughter::kKaon);
    outPtTrueGen->SetCutID(0, iCutK);
    outPtTrueGen->SetCutID(1, iCutK);
    outPtTrueGen->SetCharge(0, '+');
    outPtTrueGen->SetCharge(1, '-');    
    outPtTrueGen->SetMotherPDG(pdg);
    outPtTrueGen->SetMotherMass(mass);
    // pair cuts
    outPtTrueGen->SetPairCuts(cutsPair);
    // binnings
    outPtTrueGen->AddAxis(ptID, 100, 0.0, 10.0); //true pt - generated
    outPtTrueGen->AddAxis(fdptmc, 100, 0.0, 10.0); //first daughter pt - generated
    outPtTrueGen->AddAxis(sdptmc, 100, 0.0, 10.0); //second daughter pt - generated

   //create plot for reconstructed Pt of true mother vs reconstructed Pt of daughters
    AliRsnMiniOutput *outPtTrueRec = task->CreateOutput(Form("Phi_True_RecPt_%s", suffix), "SPARSE", "TRUE");
    outPtTrueRec->SetDaughter(0, AliRsnDaughter::kKaon);
    outPtTrueRec->SetDaughter(1, AliRsnDaughter::kKaon);
    outPtTrueRec->SetCutID(0, iCutK);
    outPtTrueRec->SetCutID(1, iCutK);
    outPtTrueRec->SetCharge(0, '+');
    outPtTrueRec->SetCharge(1, '-');    
    outPtTrueRec->SetMotherPDG(pdg);
    outPtTrueRec->SetMotherMass(mass);
    // pair cuts
    outPtTrueRec->SetPairCuts(cutsPair);
    // binnings
    outPtTrueRec->AddAxis(ptID, 100, 0.0, 10.0); //mother pt - reconstructed
    outPtTrueRec->AddAxis(fdpt, 100, 0.0, 10.0); //first daughter pt - reconstructed
    outPtTrueRec->AddAxis(sdpt, 100, 0.0, 10.0); //second daughter pt - reconstructed
  }
  return kTRUE;
}
Example #10
0
void Sputnik::Launch()
{
    cout << "starting RhoToolsTest" << endl;
    
    // the tests are organized as blocks to let variables
    // go out of scope.  In the output, each block is 
    // separated by a lines of ----
    
    
    // start testing OpAdd4
    
    ostream& theStream = cerr; 
    theStream  <<  "Before Testing OpAdd4 " << endl;
    theStream << endl;
    
    
    TOpAdd4 b4;
    {
	cout << "create a pair of objects:" << endl;
	TCandidate c1(TLorentzVector(1,0,0,0),0);
	TCandidate c2(TLorentzVector(0,2,0,0),0);
	TCandidate c3(TLorentzVector(0,0,3,0),0);
	PC("c1",c1);
	PC("c2",c2);
	PC("c3",c3);
	
	cout << "after OpAdd4.Fill(c3, c1, c2); "<<endl;
	b4.Fill(c3,c1,c2);
	PC("c1",c1);
	PC("c2",c2);
	PC("c3",c3);
	
	TCandidate c4(TLorentzVector(0,0,3,0),0);
	cout <<endl<< "c4(); c4 = OpAdd4().combine( c1, c2); "<<endl;
	c4 = TOpAdd4().Combine(c1,c2);
	PC("c1",c1);
	PC("c2",c2);
	PC("c3",c3);
	PC("c4",c4);
	
	cout << "---------------------------------------------------"<<endl;
    }
    
    {
	cout << "create objects:" << endl;
	TCandidate c1(TLorentzVector(1,0,0,0),0);
	TCandidate c2(TLorentzVector(0,2,0,0),0);
	TCandidate c3(TLorentzVector(0,0,3,0),0);
	TCandidate c4(TLorentzVector(0,0,0,4),0);
	PC("c1",c1);
	PC("c2",c2);
	PC("c3",c3);
	PC("c4",c4);
	
	cout <<endl<< "OpAdd4.Fill(c4,c1,c2,c3); "<<endl;
	b4.Fill(c4,c3,c2,c1);
	PC("c1",c1);
	PC("c2",c2);
	PC("c3",c3);
	PC("c4",c4);
	
	cout << "---------------------------------------------------"<<endl;
    }
    
    {
	cout << "create objects:" << endl;
	TCandidate c1(TLorentzVector(1,0,0,0),1);
	TCandidate c2(TLorentzVector(0,2,0,0),-1);
	TCandidate c3(TLorentzVector(0,0,3,0),0);
	TCandidate c4(TLorentzVector(0,0,0,4),0);
	TCandidate c5(TLorentzVector(0,0,0,0),5);
	TCandidate c6(TLorentzVector(0,0,0,0),6);
	TCandidate c7(TLorentzVector(0,0,0,0),7);
	PC("c1",c1);
	PC("c2",c2);
	PC("c3",c3);
	PC("c4",c4);
	PC("c5",c5);
	PC("c6",c6);
	PC("c7",c7);
	
	cout <<endl<< "after Add4::Fill(c5,c1,c2); Add4::Fill(c6,c3,c4); "<<endl;
	b4.Fill(c5,c1,c2);
	b4.Fill(c6,c3,c4);
	PC("c1",c1);
	PC("c2",c2);
	PC("c3",c3);
	PC("c4",c4);
	PC("c5",c5);
	PC("c6",c6);
	PC("c7",c7);
	
	cout <<endl<< "after Add4::Fill(c7,c5,c6); "<<endl;
	b4.Fill(c7,c5,c6);
	PC("c1",c1);
	PC("c2",c2);
	PC("c3",c3);
	PC("c4",c4);
	PC("c5",c5);
	PC("c6",c6);
	PC("c7",c7);
	
	// do some additional checks of copying, etc
	cout <<endl<< "after c8(c7);"<<endl;
	TCandidate c8(c7);
	PC("c1",c1);
	PC("c2",c2);
	PC("c3",c3);
	PC("c4",c4);
	PC("c5",c5);
	PC("c6",c6);
	PC("c7",c7);
	PC("c8",c8);
	
	cout <<endl<< "create c9(c1); then c9 = c7;"<<endl;
	TCandidate c9(c1); c9 = c7;
	PC("c1",c1);
	PC("c2",c2);
	PC("c3",c3);
	PC("c4",c4);
	PC("c5",c5);
	PC("c6",c6);
	PC("c7",c7);
	PC("c8",c8);
	PC("c9",c9);
	
	cout <<endl<< "c9 = c5;"<<endl;
	c9 = c5;
	PC("c1",c1);
	PC("c2",c2);
	PC("c3",c3);
	PC("c4",c4);
	PC("c5",c5);
	PC("c6",c6);
	PC("c7",c7);
	PC("c8",c8);
	PC("c9",c9);
	
	cout << endl;
	cout << "testing Overlaps:"<<endl;
	cout << "c1 and c2: "<<(c1.Overlaps(c2)?"t":"f")<<endl;
	cout << "c9 and c5: "<<(c9.Overlaps(c5)?"t":"f")<<endl;
	cout << "c8 and c5: "<<(c8.Overlaps(c5)?"t":"f")<<endl;
	cout << "c7 and c5: "<<(c7.Overlaps(c5)?"t":"f")<<endl;
	cout << "c6 and c5: "<<(c6.Overlaps(c5)?"t":"f")<<endl;
	cout << "c5 and c5: "<<(c5.Overlaps(c5)?"t":"f")<<endl;
	cout << "c5 and c9: "<<(c5.Overlaps(c9)?"t":"f")<<endl;
	cout << "c5 and c8: "<<(c5.Overlaps(c8)?"t":"f")<<endl;
	cout << "c5 and c7: "<<(c5.Overlaps(c7)?"t":"f")<<endl;
	cout << "c5 and c6: "<<(c5.Overlaps(c6)?"t":"f")<<endl;
	cout << "c5 and c5: "<<(c5.Overlaps(c5)?"t":"f")<<endl;
	cout << "---------------------------------------------------"<<endl;
    }
    
    //
    // start testing OpMakeTree
    
    theStream  <<  "Before Making Tree " << endl;
    theStream << endl;
    
    {
	
	cout << "Initialization of Pdt " << endl;
	//Pdt::readMCppTable("PARENT/PDT/pdt.table");
	TDatabasePDG *Pdt = TRho::Instance()->GetPDG();
	cout << "done." << endl;
	
	// now let's consider the Y(4S)
	double beamAngle  = 0.0204;
	double beamDeltaP = 9.-3.1; 
	
	TVector3 pY4S( -beamDeltaP*sin(beamAngle),0, 
	    beamDeltaP*cos(beamAngle) );
	TCandidate Y4S( pY4S, Pdt->GetParticle("Upsilon(4S)") );
	TTreeNavigator::PrintTree( Y4S );
	cout << "theta " << Y4S.P3().Theta() << endl;
	cout << "phi "   << Y4S.P3().Phi() << endl;
	
	// instanciate a Booster
	TBooster cmsBooster( &Y4S , kTRUE);
	
	// Let's imagine a photon with a certain angle in the CMS frame
	
	// a photon 
	double ePhot = 1.;
	double photAngle = 30*3.1416/180.;
	double photPhi   = 45*3.1416/180.;
	TCandidate 
	    photon( TVector3( ePhot*sin(photAngle)*cos(photPhi), ePhot*sin(photAngle)*sin(photPhi), ePhot*cos(photAngle) ), 
	    Pdt->GetParticle("gamma") );
	
	cout << endl << "The original photon in the CMS frame " << endl;
	TTreeNavigator::PrintTree( photon );
	cout << "theta " << photon.P3().Theta() << endl;
	cout << "phi "   << photon.P3().Phi() << endl;
	
	// the same photon in the LAB frame :
	TCandidate boostedPhoton = cmsBooster.BoostFrom( photon );
	TLorentzVector theLabP4 = cmsBooster.BoostedP4( photon, TBooster::From );
	cout << "the lab Four-Vector (" << 
	    theLabP4.X() << "," << theLabP4.Y() << "," << theLabP4.Z() << ";" << theLabP4.E() << ")" << endl;
	cout << endl << "The lab boosted photon " << endl;
	TTreeNavigator::PrintTree( boostedPhoton );
	cout << "theta " << boostedPhoton.P3().Theta() << endl;
	cout << "phi "   << boostedPhoton.P3().Phi() << endl;
	
	// now boost back in the CMS frame
	TLorentzVector theP4 = cmsBooster.BoostedP4( boostedPhoton, TBooster::To );
	cout << "the Four-Vector in CMS frame (" << 
	    theP4.X() << "," << theP4.Y() << "," << theP4.Z() << ";" << theP4.E() << ")" << endl;
	cout << " from cand :    (" << 
	    photon.P4().X() << "," << photon.P4().Y() << "," << photon.P4().Z() << ";" <<photon.P4().E() << ")" << endl;
	
	
	double mPsi = Pdt->GetParticle("J/psi")->Mass();
	double mMu  = Pdt->GetParticle("mu+")->Mass();
	double mPi  = Pdt->GetParticle("pi+")->Mass();
	double mK   = Pdt->GetParticle("K+")->Mass();
	double mB   = Pdt->GetParticle("B+")->Mass();
	double mDst = Pdt->GetParticle("D*+")->Mass();
	double mD0  = Pdt->GetParticle("D0")->Mass();
	double mRho = Pdt->GetParticle("rho+")->Mass();
	
	//
	// Let's start with a simple example   :  B+ -> J/Psi K+
	//
	
	// muons in the J/Psi frame
	double E(0.), P(0.), th(0.), ph(0.);
	TVector3 p3;
	
	th = 0.3;
	ph = 1.3;
	P  = 0.5*sqrt( pow(mPsi,2) - 4*pow(mMu,2) );
	E  = sqrt( pow(mMu,2) + pow(P,2) );
	p3 = TVector3( sin(th)*cos(ph)*P, sin(th)*sin(ph)*P, cos(th)*P );
	
	TLorentzVector mu1P4(  p3, E );
	TLorentzVector mu2P4( -p3, E );
	
	// J/psi in the B frame
	th = 1.1;
	ph = 0.5;
	P = 0.5*sqrt((pow(mB,2)-pow(mPsi-mK,2))*(pow(mB,2)-pow(mPsi+mK,2)))/mB;
	p3 = TVector3( sin(th)*cos(ph)*P, sin(th)*sin(ph)*P, cos(th)*P );
	E = sqrt( pow(mPsi,2) + pow(P,2) ); 
	TVector3 boostVector( p3.X()/E, p3.Y()/E,p3.Z()/E );
	mu1P4.Boost( boostVector );
	mu2P4.Boost( boostVector );
	E = sqrt( pow(mK,2) + pow(P,2) ); 
	TLorentzVector KP4( -p3, E );
	
	// create the TCandidates
	TCandidate* mu1 = new TCandidate( mu1P4.Vect(), Pdt->GetParticle("mu+") );
	TCandidate* mu2 = new TCandidate( mu2P4.Vect(), Pdt->GetParticle("mu-") );
	TCandidate* K   = new TCandidate( KP4.Vect(), Pdt->GetParticle("K+") );
	
	// now create the Make Tree operator
	TOpMakeTree op;
	
	// now create the J/Psi
	TCandidate psi = op.Combine( *mu1, *mu2 );
	psi.SetType( "J/psi" );
	psi.SetMassConstraint();
	
	cout << endl << "The original psi " << endl;
	TTreeNavigator::PrintTree( psi );
	
	// now create the B+
	TCandidate B = op.Combine( psi, *K );
	B.SetType( "B+" );
	B.SetMassConstraint();
	
	cout << endl << "The B " << endl;
	TTreeNavigator::PrintTree( B );
	
	// create a TTreeNavigator
	TTreeNavigator treeNavigator( B );
	TTreeNavigator::PrintTree( psi );
	
	theStream << "After tree making" << endl;
	theStream << endl;
	
	//instanciate the fitter with the B Candidate
	VAbsFitter* fitter = new TDummyFitter( psi );
	
	theStream << "After fitter construction " << endl;
	theStream << endl;
	
	// get the "fitted" TCandidates
	TCandidate fittedPsi = fitter->GetFitted( psi );
	TTreeNavigator::PrintTree( fittedPsi );
	
	TCandListIterator iterDau =  psi.DaughterIterator();
	TCandidate* dau=0;
	while( dau=iterDau.Next() )
	{
	    TCandidate fittedDau = fitter->GetFitted( *dau );
	    TTreeNavigator::PrintTree( fittedDau );
	}
	
	delete fitter;
	
	fitter = new TDummyFitter( B );
	
	// get the "fitted" TCandidates
	TCandidate fittedB = fitter->GetFitted( B );
	TTreeNavigator::PrintTree( fittedB );
	
	iterDau.Rewind();
	dau=0;
	while( dau=iterDau.Next() )
	{
	    TCandidate fittedDau = fitter->GetFitted( *dau );
	    TTreeNavigator::PrintTree( fittedDau );
	}
	
	TCandidate hello = fitter->GetFitted( psi );
	TTreeNavigator::PrintTree( hello );
	
	delete fitter;
	
	theStream << "After fitter deletion " << endl;
	theStream << endl;
	
	// first let's boost the kaon
	TCandidate boostedKaon = cmsBooster.BoostTo( *K );
	cout << endl << "The boosted Kaon " << endl;
	TTreeNavigator::PrintTree( *K );
	
	// let's boost the psi
	TCandidate boostedPsi = cmsBooster.BoostTo( psi );
	cout << endl << "The boosted Psi " << endl;
	TTreeNavigator::PrintTree( boostedPsi );
	
	
	theStream << "before tree boosting " << endl;
	theStream << endl;
	
	// now let's boost the B in the Y4S frame
	TCandidate boostedB = cmsBooster.BoostTo( B );
	
	// let's see the tree
	cout << endl << "The boosted B " << endl;
	TTreeNavigator::PrintTree( boostedB );
	
	theStream << "after tree boosting " << endl;
	theStream << endl;
	
	// now let's boost a list
	TCandList theList;
	theList.Add( psi );
	theList.Add( *K );
	theList.Add( B );
	TCandList theBoostedList;
	cmsBooster.BoostTo( theList, theBoostedList );
	TCandListIterator iter(theBoostedList);
	TCandidate* c(0);
	while( c=iter.Next() )
	{
	    cout << "boosted cand " << c->PdtEntry()->GetName() << endl;
	    TTreeNavigator::PrintTree( *c );
	}
	
	
	theBoostedList.Cleanup();
	
	PrintAncestors( *mu1 );
	
	delete mu1;
	delete mu2;
	delete K;
	
	cout << "---------------------------------------------------"<<endl;
     }
     
     theStream  <<  "At the end of the test program " << endl;
     theStream << endl;
}
Example #11
0
void ConvertInput(fwlite::Event &event, Long64_t eventCounter,
  ExRootTreeBranch *branchEvent, ExRootTreeBranch *branchRwgt,
  DelphesFactory *factory, TObjArray *allParticleOutputArray,
  TObjArray *stableParticleOutputArray, TObjArray *partonOutputArray)
{
  fwlite::Handle< GenEventInfoProduct > handleGenEventInfo;

  fwlite::Handle< LHEEventProduct > handleLHEEvent;

  fwlite::Handle< vector< reco::GenParticle > > handleParticle;
  vector< reco::GenParticle >::const_iterator itParticle;

  vector< const reco::Candidate * > vectorCandidate;
  vector< const reco::Candidate * >::iterator itCandidate;

  handleGenEventInfo.getByLabel(event, "generator");
  handleLHEEvent.getByLabel(event, "externalLHEProducer");
  handleParticle.getByLabel(event, "genParticles");

  HepMCEvent *element;
  Weight *weight;
  Candidate *candidate;
  TDatabasePDG *pdg;
  TParticlePDG *pdgParticle;
  Int_t pdgCode;

  Int_t pid, status;
  Double_t px, py, pz, e, mass;
  Double_t x, y, z;

  const vector< gen::WeightsInfo > &vectorWeightsInfo = handleLHEEvent->weights();
  vector< gen::WeightsInfo >::const_iterator itWeightsInfo;

  element = static_cast<HepMCEvent *>(branchEvent->NewEntry());

  element->Number = eventCounter;

  element->ProcessID = handleGenEventInfo->signalProcessID();
  element->MPI = 1;
  element->Weight = handleGenEventInfo->weight();
  element->Scale = handleGenEventInfo->qScale();
  element->AlphaQED = handleGenEventInfo->alphaQED();
  element->AlphaQCD = handleGenEventInfo->alphaQCD();

  element->ID1 = 0;
  element->ID2 = 0;
  element->X1 = 0.0;
  element->X2 = 0.0;
  element->ScalePDF = 0.0;
  element->PDF1 = 0.0;
  element->PDF2 = 0.0;

  element->ReadTime = 0.0;
  element->ProcTime = 0.0;

  for(itWeightsInfo = vectorWeightsInfo.begin(); itWeightsInfo != vectorWeightsInfo.end(); ++itWeightsInfo)
  {
    weight = static_cast<Weight *>(branchRwgt->NewEntry());
    weight->Weight = itWeightsInfo->wgt;
  }

  pdg = TDatabasePDG::Instance();

  for(itParticle = handleParticle->begin(); itParticle != handleParticle->end(); ++itParticle)
  {
    vectorCandidate.push_back(&*itParticle);
  }

  for(itParticle = handleParticle->begin(); itParticle != handleParticle->end(); ++itParticle)
  {
    const reco::GenParticle &particle = *itParticle;

    pid = particle.pdgId();
    status = particle.status();
    px = particle.px(); py = particle.py(); pz = particle.pz(); e = particle.energy(); mass = particle.mass();
    x = particle.vx(); y = particle.vy(); z = particle.vz();

    candidate = factory->NewCandidate();

    candidate->PID = pid;
    pdgCode = TMath::Abs(candidate->PID);

    candidate->Status = status;

    if(particle.mother())
    {
      itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.mother());
      if(itCandidate != vectorCandidate.end()) candidate->M1 = distance(vectorCandidate.begin(), itCandidate);
    }

    itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.daughter(0));
    if(itCandidate != vectorCandidate.end()) candidate->D1 = distance(vectorCandidate.begin(), itCandidate);

    itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.daughter(particle.numberOfDaughters() - 1));
    if(itCandidate != vectorCandidate.end()) candidate->D2 = distance(vectorCandidate.begin(), itCandidate);

    pdgParticle = pdg->GetParticle(pid);
    candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999;
    candidate->Mass = mass;

    candidate->Momentum.SetPxPyPzE(px, py, pz, e);

    candidate->Position.SetXYZT(x*10.0, y*10.0, z*10.0, 0.0);

    allParticleOutputArray->Add(candidate);

    if(!pdgParticle) continue;

    if(status == 1)
    {
      stableParticleOutputArray->Add(candidate);
    }
    else if(pdgCode <= 5 || pdgCode == 21 || pdgCode == 15)
    {
      partonOutputArray->Add(candidate);
    }
  }
}
Example #12
0
void ConvertInput(fwlite::Event &event, Long64_t eventCounter,
    ExRootTreeBranch *branchEvent, ExRootTreeBranch *branchRwgt,
    DelphesFactory *factory, TObjArray *allParticleOutputArray,
    TObjArray *stableParticleOutputArray, TObjArray *partonOutputArray, Bool_t firstEvent)
{

  fwlite::Handle< GenEventInfoProduct > handleGenEventInfo;
  fwlite::Handle< LHEEventProduct > handleLHEEvent;
  fwlite::Handle< vector< reco::GenParticle > > handleParticle;
  fwlite::Handle< vector< pat::PackedGenParticle > > handlePackedParticle;

  vector< reco::GenParticle >::const_iterator itParticle;
  vector< pat::PackedGenParticle >::const_iterator itPackedParticle;

  vector< const reco::Candidate * > vectorCandidate;
  vector< const reco::Candidate * >::iterator itCandidate;

  handleGenEventInfo.getByLabel(event, "generator");

  if (!((handleLHEEvent.getBranchNameFor(event, "source")).empty()))
  { 
    handleLHEEvent.getByLabel(event, "source");
  }
  else if (!((handleLHEEvent.getBranchNameFor(event, "externalLHEProducer")).empty()))
  {
    handleLHEEvent.getByLabel(event, "externalLHEProducer");
  }
  else if (firstEvent)
  {
    std::cout<<"Wrong LHEEvent Label! Please, check the input file."<<std::endl;
  }

  if (!((handleParticle.getBranchNameFor(event, "genParticles")).empty()))
  {
    handleParticle.getByLabel(event, "genParticles");
  }
  else if (!((handlePackedParticle.getBranchNameFor(event, "packedGenParticles")).empty()) && !((handleParticle.getBranchNameFor(event,"prunedGenParticles")).empty()))
  {
    handleParticle.getByLabel(event, "prunedGenParticles");
    handlePackedParticle.getByLabel(event, "packedGenParticles");
  }
  else
  {
    std::cout<<"Wrong GenParticle Label! Please, check the input file."<<std::endl;
    exit(-1);
  }

  Bool_t foundLHE = !((handleLHEEvent.getBranchNameFor(event, "source")).empty()) || !((handleLHEEvent.getBranchNameFor(event, "externalLHEProducer")).empty());
  Bool_t isMiniAOD = !((handlePackedParticle.getBranchNameFor(event, "packedGenParticles")).empty()) && ((handleParticle.getBranchNameFor(event, "genParticles")).empty()) ;

  HepMCEvent *element;
  Weight *weight;
  Candidate *candidate;
  TDatabasePDG *pdg;
  TParticlePDG *pdgParticle;
  Int_t pdgCode;

  Int_t pid, status;
  Double_t px, py, pz, e, mass;
  Double_t x, y, z;

  element = static_cast<HepMCEvent *>(branchEvent->NewEntry());

  element->Number = eventCounter;

  element->ProcessID = handleGenEventInfo->signalProcessID();
  element->MPI = 1;
  element->Weight = handleGenEventInfo->weight();
  element->Scale = handleGenEventInfo->qScale();
  element->AlphaQED = handleGenEventInfo->alphaQED();
  element->AlphaQCD = handleGenEventInfo->alphaQCD();

  element->ID1 = 0;
  element->ID2 = 0;
  element->X1 = 0.0;
  element->X2 = 0.0;
  element->ScalePDF = 0.0;
  element->PDF1 = 0.0;
  element->PDF2 = 0.0;

  element->ReadTime = 0.0;
  element->ProcTime = 0.0;


  if(foundLHE)
  {
    const vector< gen::WeightsInfo > &vectorWeightsInfo = handleLHEEvent->weights();
    vector< gen::WeightsInfo >::const_iterator itWeightsInfo;

    for(itWeightsInfo = vectorWeightsInfo.begin(); itWeightsInfo != vectorWeightsInfo.end(); ++itWeightsInfo)
    {
      weight = static_cast<Weight *>(branchRwgt->NewEntry());
      weight->Weight = itWeightsInfo->wgt;
    }  
  }

  pdg = TDatabasePDG::Instance();

  for(itParticle = handleParticle->begin(); itParticle != handleParticle->end(); ++itParticle)
  {
    const reco::GenParticle &particle = *itParticle;
    if( !isMiniAOD || particle.status() != 1 ) vectorCandidate.push_back(&*itParticle);
  }

  for(itParticle = handleParticle->begin(); itParticle != handleParticle->end(); ++itParticle)
  {
    const reco::GenParticle &particle = *itParticle;

    pid = particle.pdgId();
    status = particle.status();
    if( isMiniAOD && particle.status() == 1 ) continue;
    px = particle.px(); py = particle.py(); pz = particle.pz(); e = particle.energy(); mass = particle.mass();
    x = particle.vx(); y = particle.vy(); z = particle.vz();

    candidate = factory->NewCandidate();

    candidate->PID = pid;
    pdgCode = TMath::Abs(candidate->PID);

    candidate->Status = status;

    if(particle.mother())
    {
      itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.mother());
      if(itCandidate != vectorCandidate.end()) candidate->M1 = distance(vectorCandidate.begin(), itCandidate);
    }

    itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.daughter(0));
    if(itCandidate != vectorCandidate.end()) candidate->D1 = distance(vectorCandidate.begin(), itCandidate);

    itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.daughter(particle.numberOfDaughters() - 1));
    if(itCandidate != vectorCandidate.end()) candidate->D2 = distance(vectorCandidate.begin(), itCandidate);

    pdgParticle = pdg->GetParticle(pid);
    candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999;
    candidate->Mass = mass;

    candidate->Momentum.SetPxPyPzE(px, py, pz, e);

    candidate->Position.SetXYZT(x*10.0, y*10.0, z*10.0, 0.0);

    allParticleOutputArray->Add(candidate);

    if(!pdgParticle) continue;

    if( status == 1)
    {
      // Prevent duplicated particle.
      if ( !isMiniAOD ) stableParticleOutputArray->Add(candidate);
    }
    else if(pdgCode <= 5 || pdgCode == 21 || pdgCode == 15)
    {
      partonOutputArray->Add(candidate);
    }
  }
  if ( !isMiniAOD) return ;
  // For MiniAOD sample,
  // Only status==1 particles are saved to packedGenParticles.
  for(itPackedParticle = handlePackedParticle->begin(); itPackedParticle != handlePackedParticle->end(); ++itPackedParticle)
  {
    vectorCandidate.push_back(&*itPackedParticle);
  }

  for(itPackedParticle = handlePackedParticle->begin(); itPackedParticle != handlePackedParticle->end(); ++itPackedParticle)
  {
    const pat::PackedGenParticle &particle = *itPackedParticle;

    pid = particle.pdgId();
    status = particle.status();
    px = particle.px(); py = particle.py(); pz = particle.pz(); e = particle.energy(); mass = particle.mass();
    x = particle.vx(); y = particle.vy(); z = particle.vz();

    candidate = factory->NewCandidate();

    candidate->PID = pid;
    pdgCode = TMath::Abs(candidate->PID);

    candidate->Status = status;

    if(particle.mother(0))
    {
      itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.mother(0));
      if(itCandidate != vectorCandidate.end()) candidate->M1 = distance(vectorCandidate.begin(), itCandidate);
    }

    itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.daughter(0));
    if(itCandidate != vectorCandidate.end()) candidate->D1 = distance(vectorCandidate.begin(), itCandidate);

    itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.daughter(particle.numberOfDaughters() - 1));
    if(itCandidate != vectorCandidate.end()) candidate->D2 = distance(vectorCandidate.begin(), itCandidate);

    pdgParticle = pdg->GetParticle(pid);
    candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999;
    candidate->Mass = mass;

    candidate->Momentum.SetPxPyPzE(px, py, pz, e);

    candidate->Position.SetXYZT(x*10.0, y*10.0, z*10.0, 0.0);

    allParticleOutputArray->Add(candidate);

    if(!pdgParticle) continue;

    if(status == 1)
    {
      stableParticleOutputArray->Add(candidate);
    }
  }
}
int HFMLTriggerHepMCTrigger::process_event(PHCompositeNode* topNode)
{
  assert(m_Geneventmap);

  PHHepMCGenEvent* genevt = m_Geneventmap->get(_embedding_id);
  if (!genevt)
  {
    std::cout << PHWHERE << " - Fatal error - node PHHepMCGenEventMap missing subevent with embedding ID " << _embedding_id;
    std::cout << ". Print PHHepMCGenEventMap:";
    m_Geneventmap->identify();
    return Fun4AllReturnCodes::ABORTRUN;
  }

  HepMC::GenEvent* theEvent = genevt->getEvent();
  assert(theEvent);
  if (Verbosity() >= VERBOSITY_MORE)
  {
    cout << "HFMLTriggerHepMCTrigger::process_event - process HepMC::GenEvent with signal_process_id = "
         << theEvent->signal_process_id();
    if (theEvent->signal_process_vertex())
    {
      cout << " and signal_process_vertex : ";
      theEvent->signal_process_vertex()->print();
    }
    cout << "  - Event record:" << endl;
    theEvent->print();
  }

  TDatabasePDG* pdg = TDatabasePDG::Instance();

  int targetPID = std::abs(pdg->GetParticle("D0")->PdgCode());
  int daughter1PID = std::abs(pdg->GetParticle("pi+")->PdgCode());
  int daughter2PID = std::abs(pdg->GetParticle("K+")->PdgCode());

  bool acceptEvent = false;

  assert(m_hNorm);
  m_hNorm->Fill("Event", 1);

  unsigned int nD0(0);
  unsigned int nD0PiK(0);

  auto range = theEvent->particle_range();
  for (HepMC::GenEvent::particle_const_iterator piter = range.begin(); piter != range.end(); ++piter)
  {
    const HepMC::GenParticle* p = *piter;
    assert(p);

    if (std::abs(p->pdg_id()) == targetPID)
    {
      if (Verbosity())
      {
        cout << "HFMLTriggerHepMCTrigger::process_event - Accept signal particle : ";
        p->print();
        cout << endl;
      }

      m_hNorm->Fill("D0", 1);
      ++nD0;

      assert(m_DRapidity);
      const double rapidity = 0.5 * log((p->momentum().e() + p->momentum().z()) /
                                        (p->momentum().e() - p->momentum().z()));

      m_DRapidity->Fill(rapidity, 0);

      const HepMC::GenVertex* decayVertex = p->end_vertex();

      int hasDecay1(0);
      int hasDecay2(0);
      int hasDecayOther(0);

      if (decayVertex)
      {
        for (auto diter = decayVertex->particles_out_const_begin();
             diter != decayVertex->particles_out_const_end();
             ++diter)

        {
          const HepMC::GenParticle* pd = *diter;
          assert(pd);

          if (Verbosity())
          {
            cout << "HFMLTriggerHepMCTrigger::process_event - Testing daughter particle: ";
            pd->print();
            cout << endl;
          }

          if (std::abs(pd->pdg_id()) == daughter1PID)
          {
            const double eta = pd->momentum().eta();

            if (eta > _eta_min and eta < _eta_max)
              ++hasDecay1;
          }
          else if (std::abs(pd->pdg_id()) == daughter2PID)
          {
            const double eta = pd->momentum().eta();

            if (eta > _eta_min and eta < _eta_max)
              ++hasDecay2;
          }
          else
            ++hasDecayOther;
        }

        if (hasDecay1 == 1 and hasDecay2 == 1 and hasDecayOther == 0)
        {
          m_hNorm->Fill("D0->PiK", 1);
          ++nD0PiK;

          acceptEvent = true;

          m_DRapidity->Fill(rapidity, 1);
        }

      }  //      if (decayVertex)
      else
      {
        cout << "HFMLTriggerHepMCTrigger::process_event - Warning - target particle did not have decay vertex : ";
        p->print();
        cout << endl;
      }

    }  //    if (std::abs(p-> pdg_id()) == targetPID)
  }    //  for (HepMC::GenEvent::particle_const_iterator piter = range.begin(); piter != range.end(); ++piter)

  if (nD0 >= 2)
  {
    cout <<"HFMLTriggerHepMCTrigger::process_event - D0-Pair with nD0 = "<<nD0<<endl;
    m_hNorm->Fill("D0-Pair", nD0 * (nD0 - 1) / 2);
  }
  if (nD0PiK >= 2)
  {
    m_hNorm->Fill("D0->PiK-Pair", nD0PiK * (nD0PiK - 1) / 2);
  }

  ++_ievent;

  if (Verbosity())
  {
    cout << "HFMLTriggerHepMCTrigger::process_event - acceptEvent = " << acceptEvent;
    cout << endl;

    if (acceptEvent)
    {
      cout << "HFMLTriggerHepMCTrigger::process_event - processed HepMC::GenEvent with signal_process_id = "
           << theEvent->signal_process_id();
      if (theEvent->signal_process_vertex())
      {
        cout << " and signal_process_vertex : ";
        theEvent->signal_process_vertex()->print();
      }
      cout << "  - Event record:" << endl;
      theEvent->print();
    }
  }

  assert(m_Flags);
  m_Flags->set_int_param(Name(), acceptEvent);

  if (acceptEvent)
  {
    m_hNorm->Fill("Accepted", 1);
    return Fun4AllReturnCodes::EVENT_OK;
  }
  else
    return m_RejectReturnCode;
}
Example #14
0
void ConvertInput(fwlite::Event &event, DelphesFactory *factory, TObjArray *allParticleOutputArray, TObjArray *stableParticleOutputArray, TObjArray *partonOutputArray)
{
  fwlite::Handle< vector< reco::GenParticle > > handleParticle;
  vector< reco::GenParticle >::const_iterator itParticle;

  vector< const reco::Candidate * > vectorCandidate;
  vector< const reco::Candidate * >::iterator itCandidate;

  handleParticle.getByLabel(event, "genParticles");

  Candidate *candidate;
  TDatabasePDG *pdg;
  TParticlePDG *pdgParticle;
  Int_t pdgCode;

  Int_t pid, status;
  Double_t px, py, pz, e, mass;
  Double_t x, y, z;

  pdg = TDatabasePDG::Instance();

  for(itParticle = handleParticle->begin(); itParticle != handleParticle->end(); ++itParticle)
  {
    vectorCandidate.push_back(&*itParticle);
  }

  for(itParticle = handleParticle->begin(); itParticle != handleParticle->end(); ++itParticle)
  {
    const reco::GenParticle &particle = *itParticle;

    pid = particle.pdgId();
    status = particle.status();
    px = particle.px(); py = particle.py(); pz = particle.pz(); e = particle.energy(); mass = particle.mass();
    x = particle.vx(); y = particle.vy(); z = particle.vz();

    candidate = factory->NewCandidate();

    candidate->PID = pid;
    pdgCode = TMath::Abs(candidate->PID);

    candidate->Status = status;

    itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.daughter(0));
    if(itCandidate != vectorCandidate.end()) candidate->D1 = distance(vectorCandidate.begin(), itCandidate);

    itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.daughter(particle.numberOfDaughters() - 1));
    if(itCandidate != vectorCandidate.end()) candidate->D2 = distance(vectorCandidate.begin(), itCandidate);

    pdgParticle = pdg->GetParticle(pid);
    candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999;
    candidate->Mass = mass;

    candidate->Momentum.SetPxPyPzE(px, py, pz, e);

    candidate->Position.SetXYZT(x, y, z, 0.0);

    allParticleOutputArray->Add(candidate);

    if(!pdgParticle) continue;

    if(status == 1)
    {
      stableParticleOutputArray->Add(candidate);
    }
    else if(pdgCode <= 5 || pdgCode == 21 || pdgCode == 15)
    {
      partonOutputArray->Add(candidate);
    }
  }
}
Example #15
0
Bool_t ConfigKstarPP13TeV(  
			AliRsnMiniAnalysisTask *task, 
			Bool_t                 isMC, 
			Bool_t                 isPP,
			const char             *suffix,
			AliRsnCutSet           *cutsPair,
			Float_t                nsigmaPi = 3.0,
			Float_t                nsigmaK  = 3.0,
			Bool_t                 enableMonitor = kTRUE,
			TString                optSys = "DefaultITSTPC2011"
			  )
{
  
  //These are the Default values for 2011 ESD track cuts
  
  AliPID::EParticleType  type1   = AliPID::kPion;
  AliPID::EParticleType  type2   = AliPID::kKaon;

  // manage suffix
  if (strlen(suffix) > 0) suffix = Form("_%s", suffix);
  
  // retrieve mass from PDG database
  Int_t         pdg  = 313;
  TDatabasePDG *db   = TDatabasePDG::Instance();
  TParticlePDG *part = db->GetParticle(pdg);
  Double_t mass      = part->Mass();
  
  // set daughter cuts
  AliRsnCutSetDaughterParticle* cutSetPi;
  AliRsnCutSetDaughterParticle* cutSetK;

  /* AliRsnCutTrackQuality* trkQualityCut= new AliRsnCutTrackQuality("myQualityCut");
  if(optSyt.Contains("DefaultITSTPC2011")){ 
    trkQualityCut->SetDefaults2011(kTRUE,kTRUE);
    Printf(Form("::::: SetCustomQualityCut:: using standard 2011 track quality cuts"));
  }
  else if(optSyt.Contains("DefaultTPCOnly")){
    trkQualityCut->SetDefaultsTPCOnly(kTRUE);
    Printf(Form("::::: SetCustomQualityCut:: using TPC-only track quality cuts"));
  }
  trkQualityCut->Print();*/
  
   AliRsnCutTrackQuality *fQualityTrackCut = new AliRsnCutTrackQuality("AliRsnCutTrackQuality");

  //Analysis Track cuts are implemented here
  AliESDtrackCuts * esdTrackCuts = MyTrackCuts(1, kTRUE,optSys.Data());
  fQualityTrackCut->SetESDtrackCuts(esdTrackCuts);
  fQualityTrackCut->SetPtRange(0.15,30);
  fQualityTrackCut->SetEtaRange(-0.8,0.8);   
  //kTPCpidTOFveto4s
  //kTPCpidTOFveto3s
  //kFastTPCpidNsigma
  cutSetPi=new AliRsnCutSetDaughterParticle(Form("cutPi%i_%2.1fsigma",AliRsnCutSetDaughterParticle::kTPCpidTOFveto3s,nsigmaPi),fQualityTrackCut,AliRsnCutSetDaughterParticle::kTPCpidTOFveto3s,AliPID::kPion,nsigmaPi);
  cutSetK=new AliRsnCutSetDaughterParticle(Form("cutK%i_%2.1fsigma",AliRsnCutSetDaughterParticle::kTPCpidTOFveto3s, nsigmaK),fQualityTrackCut,AliRsnCutSetDaughterParticle::kTPCpidTOFveto3s,AliPID::kKaon,nsigmaK);
  
  Int_t iCutPi = task->AddTrackCuts(cutSetPi);
  Int_t iCutK  = task->AddTrackCuts(cutSetK);
  
  if(enableMonitor){
    Printf("======== Monitoring cut AliRsnCutSetDaughterParticle enabled");
    gROOT->LoadMacro("$ALICE_PHYSICS/PWGLF/RESONANCES/macros/mini/AddMonitorOutput.C");
    AddMonitorOutput(isMC, cutSetPi->GetMonitorOutput());
    AddMonitorOutput(isMC, cutSetK->GetMonitorOutput());
  }  
  // -- Values ------------------------------------------------------------------------------------
  /* invariant mass   */ Int_t imID   = task->CreateValue(AliRsnMiniValue::kInvMass,    kFALSE);
  /* IM resolution    */ Int_t resID  = task->CreateValue(AliRsnMiniValue::kInvMassRes, kTRUE);
  /* transv. momentum */ Int_t ptID   = task->CreateValue(AliRsnMiniValue::kPt,         kFALSE);
  /* centrality       */ Int_t centID = task->CreateValue(AliRsnMiniValue::kMult,       kFALSE);
  /* pseudorapidity   */ Int_t etaID  = task->CreateValue(AliRsnMiniValue::kEta,        kFALSE);
  /* rapidity         */ Int_t yID    = task->CreateValue(AliRsnMiniValue::kY,          kFALSE);
  // -- Create all needed outputs -----------------------------------------------------------------
  // use an array for more compact writing, which are different on mixing and charges
  // [0] = unlike
  // [1] = mixing
  // [2] = like ++
  // [3] = like --

  Bool_t  use     [12] = {1         ,1         ,1         ,1         ,1       ,1       ,isMC     ,isMC     ,isMC     ,isMC     ,isMC    ,isMC    };
  Bool_t  useIM   [12] = {1         ,1         ,1         ,1         ,1       ,1       ,1        ,1        ,1        ,1        ,0       ,0       };
  TString name    [12] = {"UnlikePM","UnlikeMP","MixingPM","MixingMP","LikePP","LikeMM","MCGenPM","MCGenMP","TruesPM","TruesMP","ResPM" ,"ResMP" };
  TString comp    [12] = {"PAIR"    ,"PAIR"    ,"MIX"     ,"MIX"     ,"PAIR"  ,"PAIR"  ,"MOTHER" ,"MOTHER" ,"TRUE"   ,"TRUE"   ,"TRUE"  ,"TRUE"  };
  TString output  [12] = {"SPARSE"  ,"SPARSE"  ,"SPARSE"  ,"SPARSE"  ,"SPARSE","SPARSE","SPARSE" ,"SPARSE" ,"SPARSE" ,"SPARSE" ,"SPARSE","SPARSE"};
  Char_t  charge1 [12] = {'+'       ,'-'       ,'+'       ,'-'       ,'+'     ,'-'     ,'+'      ,'-'      ,'+'      ,'-'      ,'+'     ,'-'     };
  Char_t  charge2 [12] = {'-'       ,'+'       ,'-'       ,'+'       ,'+'     ,'-'     ,'-'      ,'+'      ,'_'      ,'+'      ,'-'     ,'+'     };
  Int_t   cutIDPi [12] = {iCutPi    ,iCutPi    ,iCutPi    ,iCutPi    ,iCutPi  ,iCutPi  ,iCutPi   ,iCutPi   ,iCutPi   ,iCutPi   ,iCutPi  ,iCutPi  };
  Int_t   cutIDK  [12] = {iCutK     ,iCutK     ,iCutK     ,iCutK     ,iCutK   ,iCutK   ,iCutK    ,iCutK    ,iCutK    ,iCutK    ,iCutK   ,iCutK   };
  Int_t   PDGCode [12] = {313       ,313       ,313       ,313       ,313     ,313     ,313      ,-313     ,313      ,313      ,313     ,-313    };

  for (Int_t i = 0; i < 12; i++) {
    if (!use[i]) continue;
    AliRsnMiniOutput *out = task->CreateOutput(Form("KSTAR_%s%s", name[i].Data(), suffix), output[i].Data(), comp[i].Data());
    out->SetDaughter(0, AliRsnDaughter::kKaon);
    out->SetDaughter(1, AliRsnDaughter::kPion);
    out->SetCutID(0, cutIDK[i]);
    out->SetCutID(1, cutIDPi[i]);
    out->SetCharge(0, charge1[i]);
    out->SetCharge(1, charge2[i]);
    out->SetMotherPDG(PDGCode[i]);
    out->SetMotherMass(mass);
    out->SetPairCuts(cutsPair);

    // axis X: invmass (or resolution)
    if (useIM[i]) 
      out->AddAxis(imID, 90, 0.6, 1.5);
    else
      out->AddAxis(resID, 200, -0.02, 0.02);
    
    // axis Y: transverse momentum
    out->AddAxis(ptID, 200, 0.0, 20.0);
    
    // axis Z: centrality-multiplicity
    if (!isPP)
      out->AddAxis(centID, 100, 0.0, 100.0);
    else 
      out->AddAxis(centID, 400, 0.0, 400.0);
      
    // axis W: pseudorapidity
    // out->AddAxis(etaID, 20, -1.0, 1.0);
    // axis J: rapidity
    //out->AddAxis(yID, 90, -4.5, 4.5);
    
  }
  return kTRUE;
}
Example #16
0
void ConvertInput(fwlite::Event &event, Long64_t eventCounter, ExRootTreeBranch *branch, DelphesFactory *factory, TObjArray *allParticleOutputArray, TObjArray *stableParticleOutputArray, TObjArray *partonOutputArray)
{
    LHEFEvent *lheEvt;
    lheEvt = static_cast<LHEFEvent *>(branch->NewEntry());

    fwlite::Handle<LHEEventProduct> lheEvtInfo;

    lheEvtInfo.getByLabel(event, "source");

    if (lheEvtInfo.isValid()) {
      lheEvt->Number = eventCounter;
      lheEvt->Weight = lheEvtInfo->originalXWGTUP();
      lheEvt->ProcessID = ((lhef::HEPEUP)lheEvtInfo->hepeup()).IDPRUP;
      lheEvt->ScalePDF = ((lhef::HEPEUP)lheEvtInfo->hepeup()).IDPRUP;
      lheEvt->AlphaQED = ((lhef::HEPEUP)lheEvtInfo->hepeup()).SCALUP;
      lheEvt->AlphaQCD = ((lhef::HEPEUP)lheEvtInfo->hepeup()).AQCDUP;
    }
    else {
      lheEvt->Number = 0;
      lheEvt->Weight = 1;
      lheEvt->ProcessID = 0;
      lheEvt->ScalePDF = 0;
      lheEvt->AlphaQED = 0;
      lheEvt->AlphaQCD = 0;
    }

    fwlite::Handle< vector< reco::GenParticle > > handleParticle;
    vector< reco::GenParticle >::const_iterator itParticle;

    vector< const reco::Candidate * > vectorCandidate;
    vector< const reco::Candidate * >::iterator itCandidate;

    handleParticle.getByLabel(event, "genParticles");

    Candidate *candidate;
    TDatabasePDG *pdg;
    TParticlePDG *pdgParticle;
    Int_t pdgCode;

    Int_t pid, status;
    Double_t px, py, pz, e, mass;
    Double_t x, y, z;

    pdg = TDatabasePDG::Instance();

    for(itParticle = handleParticle->begin(); itParticle != handleParticle->end(); ++itParticle)
    {
        vectorCandidate.push_back(&*itParticle);
    }

    for(itParticle = handleParticle->begin(); itParticle != handleParticle->end(); ++itParticle)
    {
        const reco::GenParticle &particle = *itParticle;

        pid = particle.pdgId();
        status = particle.status();
        px = particle.px(); py = particle.py(); pz = particle.pz(); e = particle.energy(); mass = particle.mass();
        x = particle.vx(); y = particle.vy(); z = particle.vz();

        candidate = factory->NewCandidate();

        candidate->PID = pid;
        pdgCode = TMath::Abs(candidate->PID);

        candidate->Status = status;

        //M1
        if(particle.mother()){
            itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.mother());
            if(itCandidate != vectorCandidate.end()) candidate->M1 = distance(vectorCandidate.begin(), itCandidate);
        }

        //D1
        itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.daughter(0));
        if(itCandidate != vectorCandidate.end()) candidate->D1 = distance(vectorCandidate.begin(), itCandidate);

        //D2
        if(particle.numberOfDaughters() > 1)
            itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.daughter(1));
        else
            itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.daughter(particle.numberOfDaughters() - 1));

        if(itCandidate != vectorCandidate.end()) candidate->D2 = distance(vectorCandidate.begin(), itCandidate);

        pdgParticle = pdg->GetParticle(pid);
        candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999;
        candidate->Mass = mass;

        candidate->Momentum.SetPxPyPzE(px, py, pz, e);

        candidate->Position.SetXYZT(x, y, z, 0.0);

        allParticleOutputArray->Add(candidate);

        if(!pdgParticle) continue;

        if(status == 1)
        {
            stableParticleOutputArray->Add(candidate);
        }
        else if(pdgCode <= 5 || pdgCode == 21 || pdgCode == 15)
        {
            partonOutputArray->Add(candidate);
        }
    }
}