コード例 #1
0
if len(sys.argv)>2:
    nevent = int(sys.argv[2])
    if len(sys.argv) > 3:
        nevent2 = int(sys.argv[3])
    else:
        nevent2 = nevent+1
    tree = islice(tree, nevent, nevent2)

for event in tree:
    print("---")
    pbar.update()
    calo_simE = event.caloParticle_simEnergy
    pfCluster_energy = event.pfCluster_energy
    
    # Get all associations
    assoc, (xtal_cluster, xtal_calo, xtal_cluster_noise) = association_strategies.get_all_associations(event, cluster_type="pfCluster",debug=True)


    all_calo_clusters = list(set(map( itemgetter(2), xtal_cluster.keys())))
   

    # now the plotting
    mean_ieta_cl =   mean([ ieta for (ieta, iphi,_,_) in xtal_cluster.keys()]).round()
    mean_iphi_cl =   mean([ iphi for (ieta, iphi,_,_) in xtal_cluster.keys()]).round()
    print(mean_ieta_cl, mean_iphi_cl)

    hratio_gamma1 = R.TH1F("eratio_g1", "", 100, -1, 2)
    hxtal_cluster       = R.TH2F("xtal_cluster", "xtal_cluster", 31, -15.5, +15.5, 31, -15.5, 15.5)
    hxtal_calo          = R.TH2F("xtal_calo", "xtal_caloparticle", 31, -15.5, +15.5, 31, -15.5, 15.5)
    contours = array("d",[1,2,3,4])
    hxtal_calo.SetContour(len(contours), contours )
 calo_simE = event.caloParticle_simEnergy
 calo_pt = event.caloParticle_simPt
 calo_simE = event.caloParticle_simEnergy
 calo_eta = event.caloParticle_simEta
 calo_phi = event.caloParticle_simPhi
 calo_geneta = event.caloParticle_genEta
 calo_genphi = event.caloParticle_genPhi
 pfCluster_energy = event.pfCluster_energy
 pfCluster_eta = event.pfCluster_eta
 pfCluster_phi = event.pfCluster_phi
 gen_eta = event.genParticle_eta
 gen_phi = event.genParticle_phi
 gen_pt = event.genParticle_pt
 
 assoc, (xtal_cluster, xtal_calo, xtal_cluster_noise) = \
         association_strategies.get_all_associations(event, cluster_type="pfCluster",debug=debug)
 if debug: print(assoc)
 
 printout = False
 for strategy, (cluster_calo_assoc, calo_cluster_assoc) in assoc.items():
     has_clusters_calo = {}
     for calo, clusters in calo_cluster_assoc.items():
         trueE = calo_simE[calo]
         histos["encalo"][strategy].Fill(trueE)
         histos["etacalo"][strategy].Fill(calo_eta[calo])
         recoE = 0.  
         # Save energy of first cluster
         if abs(pfCluster_eta[clusters[0]]) > 1.5:
             histos["ereco_etrue_EE_best"][strategy].Fill(pfCluster_energy[clusters[0]]/trueE)
         else:
             histos["ereco_etrue_EB_best"][strategy].Fill(pfCluster_energy[clusters[0]]/trueE)