Ejemplo n.º 1
0
TVec<TPair<TFltV, TFltV> > TLSHash::GetAllCandidatePairs() {
  THashSet<TPair<TInt, TInt> > CandidateIdPairs;
  for (int i=0; i<Bands; i++) {
    TVec<TIntV> BucketVV;
    SigBucketVHV[i].GetDatV(BucketVV);
    for (int j=0; j<BucketVV.Len(); j++) {
      TIntV BucketV = BucketVV[j];

      for (int k=0; k<BucketV.Len(); k++) {
        for (int l=k+1; l<BucketV.Len(); l++) {
          int First = BucketV[k], Second = BucketV[l];
          if (First > Second) { 
            int Temp = First;
            First = Second;
            Second = Temp;
          }
          CandidateIdPairs.AddKey(TPair<TInt, TInt> (First, Second));
        }
      }
    }
  }

  TVec<TPair<TFltV, TFltV> > CandidatePairs;
  int Ind = CandidateIdPairs.FFirstKeyId();
  while (CandidateIdPairs.FNextKeyId(Ind)) {
    TPair<TInt, TInt> IdPair = CandidateIdPairs[Ind];
    TPair<TFltV, TFltV> Pair(DataV[IdPair.GetVal1()], DataV[IdPair.GetVal2()]);
    CandidatePairs.Add(Pair);
  }
  return CandidatePairs;
}
Ejemplo n.º 2
0
void TMultimodalGraphImplB::DelEdge(const TPair<TInt,TInt>& SrcNId, const TPair<TInt,TInt>& DstNId) {
  IAssertR(IsNode(SrcNId) && IsNode(DstNId), TStr::Fmt("%d or %d not a node.", SrcNId.GetVal2(), DstNId.GetVal2()).CStr());
  if (!IsEdge(SrcNId, DstNId)) {
    return; // Edge doesn't exist
  }
  NEdges--;

  TPair<TInt,TInt> ModeIdsKey = GetModeIdsKey(SrcNId.GetVal1(), DstNId.GetVal1());
  Graphs.GetDat(ModeIdsKey).DelEdge(SrcNId.GetVal2(), DstNId.GetVal2());
}
Ejemplo n.º 3
0
bool TMultimodalGraphImplB::IsEdge(const TPair<TInt,TInt>& SrcNId, const TPair<TInt,TInt>& DstNId) const {
  if (!IsNode(SrcNId) || !IsNode(DstNId)) return false;

  TPair<TInt,TInt> ModeIdsKey = GetModeIdsKey(SrcNId.GetVal1(), DstNId.GetVal2());
  if (!Graphs.IsKey(ModeIdsKey)) {
    return false;
  }

  return Graphs.GetDat(ModeIdsKey).IsEdge(SrcNId.GetVal2(), DstNId.GetVal2());
}
Ejemplo n.º 4
0
void Patch1400(const char* runlist1400, const char* srcOCDBPath="alien://folder=/alice/data/2016/OCDB", const char* destOCDBPath="alien://folder=/alice/cern.ch/user/l/laphecet/OCDBCH4L")
{
    // function to patch the OCDB MUON/Calib/HV for the one sector that had problems  
    // runlist1400 = list of runs where Chamber03Left/Quad2Sect1 was struggling at 1400 V
    // for the runs in runlist1400, the HV will be forced to zero for that sector
    // note that Chamber04Left/Quad3Sect2 (on DE 402) = Chamber03Left/Quad2Sect1 in DCS alias world
     
  AliAnalysisTriggerScalers ts1400(runlist1400,srcOCDBPath);
  std::vector<int> vrunlist1400 = ts1400.GetRunList();

  AliCDBManager* man = AliCDBManager::Instance();

  TObjString sector("MchHvLvLeft/Chamber03Left/Quad2Sect1.actual.vMon");

  for ( auto r : vrunlist1400 )
  {
      man->SetDefaultStorage(srcOCDBPath);
      man->SetRun(r);
      std::cout << "Run " << r << std::endl;

      AliCDBEntry* entry = man->Get("MUON/Calib/HV");
      TMap* hvmap = static_cast<TMap*>(entry->GetObject()->Clone());

      TPair* p = hvmap->RemoveEntry(&sector);

      if ( std::find(vrunlist1400.begin(),vrunlist1400.end(),r) != vrunlist1400.end() )
      {
        TObjArray* a1 = static_cast<TObjArray*>(p->Value());
        AliDCSValue* first = static_cast<AliDCSValue*>(a1->First());
        AliDCSValue* last = static_cast<AliDCSValue*>(a1->Last());
        a1->Delete();
        a1->Add(new AliDCSValue(0.0f,first->GetTimeStamp()));
        a1->Add(new AliDCSValue(0.0f,last->GetTimeStamp()));
      }

      hvmap->Add(new TObjString(sector),p->Value());

      delete p->Key();

      man->SetDefaultStorage(destOCDBPath);
      hvmap->SetUniqueID( hvmap->GetUniqueID() | ( 1 << 9 ) );
      AliMUONCDB::WriteToCDB(hvmap,"MUON/Calib/HV",r,r,"Patched for CH4L DE402 Quad3Sect2 struggling at 1400 V","L. Aphecetche");
      man->ClearCache();
  }
}
Ejemplo n.º 5
0
cmsListDir( const TObjString * firstdirname, const TDirectory * firstDir )
 {
  TObjArray * dirs = new TObjArray ;
  dirs->AddLast(new TPair(firstdirname,firstDir)) ;
  TList * keys ;
  TKey * key ;
  TH1 * histo ;
  TIter nextDir(dirs) ;
  TPair * pair ;
  const TObjString * dirname ;
  const TDirectory * dir ;
  while (pair = (TPair *)nextDir())
   {
    dirname = (TObjString *)pair->Key() ;
    dir = (TDirectory *)pair->Value() ;
    keys = dir->GetListOfKeys() ;
    TIter nextKey(keys) ;
    while (key = (TKey *)nextKey())
     {
      obj = key->ReadObj() ;
      if (obj->IsA()->InheritsFrom("TDirectory"))
       {
        dirs->AddLast(new TPair(new TObjString(dirname->String()+"/"+obj->GetName()),obj)) ;
       }
      else if (obj->IsA()->InheritsFrom("TH1"))
       {
        histo = (TH1 *)obj ;
        std::cout
          <<"Histo "<<dirname->String()<<"/"<<histo->GetName()
          <<" has "<<histo->GetEffectiveEntries()<<" entries"
          <<" of mean value "<<histo->GetMean()
          <<std::endl ;
       }
      else
       { std::cout<<"What is "<<obj->GetName()<<" ?"<<std::endl ; }
     }
   }
 }
Ejemplo n.º 6
0
void TMultimodalGraphImplB::DelNode(const TPair<TInt,TInt>& NId) {
  IAssertR(IsNode(NId), TStr::Fmt("NodeId %d does not exist", NId.GetVal2()));
  int ModeId = NId.GetVal1();
  // Remove NId from all relevant graphs
  for (TGraphs::TIter it = Graphs.BegI(); it < Graphs.EndI(); it++) {
    TPair<TInt, TInt> ModeIdPair = it.GetKey();
    if (ModeIdPair.GetVal1() == ModeId || ModeIdPair.GetVal2() == ModeId) {
      TNGraph& Graph = it.GetDat();
      if (Graph.IsNode(NId.GetVal2())) {
        Graph.DelNode(NId.GetVal2());
      }
    }
  }
  // Remove NId from NodeToModeMapping as well
  NodeToModeMapping.DelKey(NId.GetVal2());
}
Ejemplo n.º 7
0
TMultimodalGraphImplB::TEdgeI TMultimodalGraphImplB::GetEI(const TPair<TInt,TInt>& SrcNId, const TPair<TInt,TInt>& DstNId) const {
  TNodeI CurNode = TNodeI(NodeToModeMapping.GetI(SrcNId.GetVal2()), &Graphs, &NodeToModeMapping);
  TIntV AdjacentModes = TIntV();
  CurNode.GetAdjacentModes(AdjacentModes);

  TPair<TInt,TInt> ModeIdsKey = GetModeIdsKey(SrcNId.GetVal1(), DstNId.GetVal1());

  int CurAdjacentMode = 0;
  for (int i=0; i<AdjacentModes.Len();i++) {
    if (AdjacentModes.GetDat(i) == DstNId.GetVal1()) {
      CurAdjacentMode=i;
      break;
    }
  }

  return TEdgeI(CurNode, EndNI(), Graphs.GetDat(ModeIdsKey).GetEI(SrcNId.GetVal2(), DstNId.GetVal2()).GetCurEdge(), AdjacentModes, CurAdjacentMode);
}
Ejemplo n.º 8
0
Bool_t EventSelector_Unf::Process(Long64_t entry)
{

   //Int_t trig = 0;
   bool isMC = true;  //SHould alkways be true - we will always run it on data

   //FIXME do this before we find a better option
   double Mass_xbin2[7] = {20, 30, 45, 60, 120, 200, 1500};
   double Mass_xbin2_156[8] = {0,20, 30, 45, 60, 120, 200, 1500};

   //FIXME deprecated
   // _runopt = 0;
   // if( momCorrType == "RunC")  _runopt = 1;
   
   // The Process() function is called for each entry in the tree (or possibly
   // keyed object in the case of PROOF) to be processed. The entry argument
   // specifies which entry in the currently loaded tree is to be processed.
   // It can be passed to either EventSelector_Unf::GetEntry() or TBranch::GetEntry()
   // to read either all or the required parts of the data. When processing
   // keyed objects with PROOF, the object is already loaded and is available
   // via the fObject pointer.
   //
   // This function should contain the "body" of the analysis. It can contain
   // simple or elaborate selection criteria, run algorithms on the data
   // of the event and typically fill histograms.
   //
   // The processing can be stopped by calling Abort().
   //
   // Use fStatus to set the return value of TTree::Process().
   //
   // The return value is currently not used.

   // Link to current element, if any
   TString filename = dataset;

   TPair* elemPair = 0;
   if (fInput && (elemPair = dynamic_cast<TPair*>(fInput->FindObject("PROOF_CurrentElement")))) {
     TDSetElement* current = dynamic_cast<TDSetElement*>(elemPair->Value());
     if (current) {
       filename = current->GetFileName();
       if (current->TestBit(TDSetElement::kNewRun)) {
         Info("Process", "entry %lld: starting new run for dataset '%s'",
                          entry, current->GetDataSet());
       }
       if (current->TestBit(TDSetElement::kNewPacket)) {
         dataset = current->GetDataSet();
         ds->SetTitle(dataset);
         Info("Process", "entry %lld: new packet from: %s, first: %lld, last: %lld",
                          entry, current->GetName(), current->GetFirst(),
                          current->GetFirst()+current->GetNum()-1);
       }
     }
   }

   Int_t eventSize = fChain->GetTree()->GetEntry(entry);
   ++fNumberOfEvents;

   //normalization purposes
   if (dataset != "DATA") Nntuple->Fill(0.5);

   // compute the total size of all events
   fTotalDataSize += eventSize;

   if ( fNumberOfEvents % 100000 == 0 ) std::cout << dataset << " : " << fNumberOfEvents << std::endl;

   //split below by trigger path
   for (Int_t trig = 0; trig < 1; trig++) {
    //reset weights
     Double_t WEIGHT = 1.;
     Double_t FEWZ_WEIGHT = 1.;
     Double_t PU_WEIGHT = 1.;

     //split data mc 
     if ( dataset == "DATA") {
        isMC = false; 
        //FIXME important requirement
        if (trig != 0) continue;
     }

      //pick up the weight
      if (isMC) {
           if (filename.Contains("DYM1020") || filename.Contains("DYE1020")) {
              WEIGHT = Sigma_DY1020*FilterEff_DY1020;
           } else if (filename.Contains("DYM200") || filename.Contains("DYE200")) {
              WEIGHT = Sigma_DY200*FilterEff_DY200;
           } else if ((filename.Contains("DYM20") && !filename.Contains("DYM200")) || (filename.Contains("DYE20") && !filename.Contains("DYE200"))) {
              WEIGHT = Sigma_DY20*FilterEff_DY20;
           } else if (filename.Contains("DYM400") || filename.Contains("DYE400")) {
              WEIGHT = Sigma_DY400*FilterEff_DY400;
           } else if (filename.Contains("DYM500") || filename.Contains("DYE500")) {
              WEIGHT = Sigma_DY500*FilterEff_DY500;
           } else if (filename.Contains("DYM700") || filename.Contains("DYE700")) {
              WEIGHT = Sigma_DY700*FilterEff_DY700;
           } else if (filename.Contains("DYM800") || filename.Contains("DYE800")) {
              WEIGHT = Sigma_DY800*FilterEff_DY800;
           } else if (filename.Contains("DYM1000") || filename.Contains("DYE1000")) {
              WEIGHT = Sigma_DY1000*FilterEff_DY1000;
           };
      } //isMC

     if (filename.Contains("DYM") || filename.Contains("DYE")) {

         b_GENnPair->GetEntry(entry);
         b_GENInvMass->GetEntry(entry);
         b_GENRapidity->GetEntry(entry);
         b_GENLepton1_eta->GetEntry(entry);
         b_GENLepton1_pT->GetEntry(entry);
         b_GENLepton1_pdgID->GetEntry(entry);
         b_GENLepton1_status->GetEntry(entry);
         b_GENLepton1_charge->GetEntry(entry);
         b_GENLepton2_eta->GetEntry(entry);
         b_GENLepton2_pT->GetEntry(entry);
         b_GENLepton2_pdgID->GetEntry(entry);
         b_GENLepton2_status->GetEntry(entry);


         // gen. mass
         double genMass = -1;
         double genRapidity = -1;
         double genDiMuPt = -1;
         int GENIndex = -1;
         for( int j = 0; j < GENnPair; j++ ) {
          if( (fabs(GENLepton1_pdgID[j]) != 13 && mode == "MuMu") || (fabs(GENLepton1_pdgID[j]) != 11 && mode == "EE")) continue;
          if( (fabs(GENLepton2_pdgID[j]) != 13 && mode == "MuMu") || (fabs(GENLepton2_pdgID[j]) != 11 && mode == "EE")) continue;
          //pre FSR
          if( GENLepton1_status[j] != 3 ) continue;
          if( GENLepton2_status[j] != 3 ) continue;

          genMass = GENInvMass[j];
          GENIndex = j;
          break;
         }

         //binned in GEN mass samples

         //if ((filename.Contains("DYM400") || filename.Contains("DYE400")) && genMass > 400) { continue; }

         if ((filename.Contains("DYM200") || filename.Contains("DYE200")) && genMass > 400) { continue; }
         else if (((filename.Contains("DYM20") && !filename.Contains("DYM200")) || (filename.Contains("DYE20") && !filename.Contains("DYE200"))) && genMass > 200) {continue;}
         else if ((filename.Contains("DYM400") || filename.Contains("DYE400")) && genMass > 500) { continue; }
         else if ((filename.Contains("DYM500") || filename.Contains("DYE500")) && genMass > 700) { continue; }
         else if ((filename.Contains("DYM700") || filename.Contains("DYE700")) && genMass > 800) { continue; }
         else if ((filename.Contains("DYM800") || filename.Contains("DYE800")) && genMass > 1000) { continue; }

         //pre FSR values
         genRapidity = GENRapidity[GENIndex];
         genDiMuPt = sqrt((GENLepton1_Px[GENIndex]+GENLepton2_Px[GENIndex])*(GENLepton1_Px[GENIndex]+GENLepton2_Px[GENIndex])+(GENLepton1_Py[GENIndex]+GENLepton2_Py[GENIndex])*(GENLepton1_Py[GENIndex]+GENLepton2_Py[GENIndex]));
         //FIXME look up FEWZ weight
         FEWZ_WEIGHT = weight(genDiMuPt, fabs(genRapidity), genMass, true);
        }

        b_HLT_trigFired->GetEntry(entry);
        bool isTriggered = false;
 
        //lepton loop
        double best_val_mu = -99999;
        std::vector<purdue::Dimuon>::const_iterator index_mu;
        double best_val_e = -99999;
        std::vector<purdue::Dielectron>::const_iterator index_e;

        if (mode == "MuMu") {

          if (hlt_trigFired[1] == 1) isTriggered = true;
          if( !isTriggered ) return kTRUE;

          muons->clear();
          b_muons->GetEntry(entry);
          dimuons->clear();
          b_dimuons->GetEntry(entry);

          if (muons->size()==0 || dimuons->size()==0) continue;

          for (std::vector<purdue::Dimuon>::const_iterator dimu_it = dimuons->begin(); dimu_it != dimuons->end(); ++dimu_it) {
            //get the links
            purdue::Muon* mu1 = &(muons->at(dimu_it->muon_links_.first));
            purdue::Muon* mu2 = &(muons->at(dimu_it->muon_links_.second));

            if( mu1->pt_ < 20 || mu2->pt_ < 10 ) {
                if( mu2->pt_ < 20 || mu1->pt_ < 10 ) continue;
                 }

            if (!(goodMuon(*mu1) && goodMuon(*mu2))) continue;
            //Dimuon cuts section

          // 3D angle
            if( dimu_it->angle_ < 0.005 ) continue;
         
          // vtx prob
            if( dimu_it->vtxTrkProb_ < 0.02 ) continue;
            if( mu1->q_*mu2->q_ >= 0) continue;

            if( dimu_it->vtxTrkProb_ > best_val_mu ) {
              best_val_mu = dimu_it->vtxTrkProb_;
              index_mu = dimu_it;
            }
         }
        } else if (mode == "EE") {
          //Up to date selection requirements
          //http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/UserCode/ikravchenko/DrellYanDMDY/Include/EleIDCuts.hh?revision=1.6&view=markup
          if (hlt_trigFired[6] == 1) isTriggered = true;
          if( !isTriggered ) return kTRUE;

          electrons->clear();
          b_electrons->GetEntry(entry);
          dielectrons->clear();
          b_dielectrons->GetEntry(entry);

          if (electrons->size()==0 || dielectrons->size()==0) continue;
          //lepton loop
          for (std::vector<purdue::Dielectron>::const_iterator diel_it = dielectrons->begin(); diel_it != dielectrons->end(); ++diel_it) {
            //get the links
            purdue::Electron* ele1 = &(electrons->at(diel_it->ele_links_.first));
            purdue::Electron* ele2 = &(electrons->at(diel_it->ele_links_.second));

            if( ele1->scEt_ < 20 || ele2->scEt_ < 10 ) {
               if( ele2->scEt_ < 20 || ele1->scEt_ < 10 ) continue;
              }
            if (!(goodElectron(*ele1) && goodElectron(*ele2))) continue;
             
            index_e = diel_it;
            best_val_e = 0;
         }
       }

        if(mode == "MuMu" && best_val_mu == -99999) continue;
        if(mode == "EE" && best_val_e == -99999) continue;

        // setup for momentum correction
        // Only for RECO, do nothing for GEN
        TLorentzVector muMinus;
        TLorentzVector muPlus;
        TLorentzVector recoDYcand;

        //in case you apply correction
        double recoMass_corr = -1.;
        double recoRap_corr = -1.;
        double recoMass = -1.;
        double recoRap = -1.;

        if(mode == "MuMu") {
          //take back the links of best muons
          purdue::Muon* bestMu1 = &(muons->at(index_mu->muon_links_.first));
          purdue::Muon* bestMu2 = &(muons->at(index_mu->muon_links_.second));

          //Use one for systematics
          float dummy = 0;
          MomScaleCorrection(rmcor, muMinus, muPlus,
                bestMu1->px_,bestMu1->py_,bestMu1->pz_,bestMu1->q_,
                bestMu2->px_,bestMu2->py_,bestMu2->pz_,bestMu2->q_,
                dummy, _runopt, !isMC);

          recoDYcand = muPlus + muMinus;
    
          //in case you apply correction
          recoMass_corr = recoDYcand.M();
          recoRap_corr = fabs(recoDYcand.Rapidity());
          //Common for mumu and ee but diferenbt pointer of course
          recoMass = index_mu->mass_;
          recoRap = index_mu->y_;
        } //mom scale correction - for muons only 
        else if (mode == "EE") {
          recoMass = index_e->mass_;
          recoRap = index_e->y_;
        } 

        // gen. mass
        double simMass = -1;
        int simIndex = -1;
        double simRapidity = -1;
        for( int j = 0; j < GENnPair; j++ ) {
            if( (fabs(GENLepton1_pdgID[j]) != 13 && mode == "MuMu") || (fabs(GENLepton1_pdgID[j]) != 11 && mode == "EE")) continue;
            if( (fabs(GENLepton2_pdgID[j]) != 13 && mode == "MuMu") || (fabs(GENLepton2_pdgID[j]) != 11 && mode == "EE")) continue;
            //pre FSR
            if( GENLepton1_status[j] != 1 ) continue;
            if( GENLepton2_status[j] != 1 ) continue;
             
            // cout << "genMass " << genMass << endl;
            simMass = GENInvMass[j];
            simRapidity = GENRapidity[j];
            break;
          }

          //put the fills 
  	  htrue->Fill(simMass, WEIGHT);
 	  hmeas->Fill(recoMass, WEIGHT);
	  hden->Fill(simMass, recoMass, WEIGHT);

          htrue_PU->Fill(simMass, PU_WEIGHT*WEIGHT);
          hmeas_PU->Fill(recoMass, PU_WEIGHT*WEIGHT);
          hden_PU->Fill(simMass, recoMass, PU_WEIGHT*WEIGHT);

          if (mode == "MuMu") {
            htrue_Roch->Fill(simMass, WEIGHT);
            hmeas_Roch->Fill(recoMass_corr, WEIGHT);
            hden_Roch->Fill(simMass, recoMass_corr, WEIGHT);

            htrue_corr->Fill(simMass, FEWZ_WEIGHT*PU_WEIGHT*WEIGHT);
            hmeas_corr->Fill(recoMass_corr, FEWZ_WEIGHT*PU_WEIGHT*WEIGHT);
            hden_corr->Fill(simMass, recoMass_corr, FEWZ_WEIGHT*PU_WEIGHT*WEIGHT);
          }

          //2D case
          double val_reco = -1;
          double val_sim = -1;

          for( int j = 0; j < 6; j++ ) {
            if( recoMass > Mass_xbin2[j] && recoMass < Mass_xbin2[j+1] ) {
              int nbins; 
              double bin_size;
              if( j == 5 ) {
                nbins = 12;
                bin_size = 0.2;
              }
              else {
                nbins = 24;
                bin_size = 0.1;
              }
              for( int k = 0; k < nbins; k++ ) {
                if( fabs(recoRap) > k*bin_size && fabs(recoRap) < (k+1)*bin_size ) val_reco = k + j*24;
              }   
            }     
            if( simMass > Mass_xbin2[j] && simMass < Mass_xbin2[j+1] ) {
              int nbins;
              double bin_size;
              if( j == 5 ) {
                nbins = 12;
                bin_size = 0.2;
              }
              else {
                nbins = 24;
                bin_size = 0.1;
              }
              for( int k = 0; k < nbins; k++ ) {
                if (fabs(simRapidity) > k*bin_size && fabs(simRapidity) < (k+1)*bin_size ) val_sim = k + j*24;
              }
            }
          }

          hmeas2->Fill(val_reco, WEIGHT);
          htrue2->Fill(val_sim, WEIGHT);
          hden2->Fill(val_reco, val_sim, WEIGHT);

          hmeas2_PU->Fill(val_reco, PU_WEIGHT*WEIGHT);
          htrue2_PU->Fill(val_sim, PU_WEIGHT*WEIGHT);
          hden2_PU->Fill(val_reco, val_sim, PU_WEIGHT*WEIGHT);

          if (mode == "MuMu") {
            //with the rochester correction
            val_reco = -1;
            val_sim = -1;
            for( int j = 0; j < 6; j++ ) {
              if( recoMass_corr > Mass_xbin2[j] && recoMass_corr < Mass_xbin2[j+1] ) {
                int nbins;
                double bin_size;
               if( j == 5 ) {
                  nbins = 12;
                  bin_size = 0.2;
                }
                else {
                  nbins = 24;
                  bin_size = 0.1;
                }
                for( int k = 0; k < nbins; k++ ) {
                  if( fabs(recoRap_corr) > k*bin_size && fabs(recoRap_corr) < (k+1)*bin_size ) val_reco = k + j*24;
                }
              }
             if( simMass > Mass_xbin2[j] && simMass < Mass_xbin2[j+1] ) {
               int nbins;
               double bin_size;
               if( j == 5 ) {
                 nbins = 12;
                 bin_size = 0.2;
               }
               else {
                 nbins = 24;
                 bin_size = 0.1;
               }
               for( int k = 0; k < nbins; k++ ) {
                 if (fabs(simRapidity) > k*bin_size && fabs(simRapidity) < (k+1)*bin_size ) val_sim = k + j*24;
               }
             }
           }

           hmeas2_Roch->Fill(val_reco, WEIGHT);
           htrue2_Roch->Fill(val_sim, WEIGHT);
           hden2_Roch->Fill(val_reco, val_sim, WEIGHT);
  
           hmeas2_corr->Fill(val_reco, FEWZ_WEIGHT*PU_WEIGHT*WEIGHT);
           htrue2_corr->Fill(val_sim, FEWZ_WEIGHT*PU_WEIGHT*WEIGHT);
           hden2_corr->Fill(val_reco, val_sim, FEWZ_WEIGHT*PU_WEIGHT*WEIGHT);

          //over under flows
           if( recoMass_corr > 0 && recoMass_corr < 20 ) {
             double bin_size = 0.1;
            //FIXME reset
            val_reco = -1;
            for( int k = 0; k < 24; k++ ) {
              if( fabs(recoRap_corr) > k*bin_size && fabs(recoRap_corr) < (k+1)*bin_size ) val_reco = k;
            }

            hmeas2_24_Roch->Fill(val_reco, WEIGHT);
            hmeas2_24_corr->Fill(val_reco, FEWZ_WEIGHT*PU_WEIGHT*WEIGHT);
         }
         if( simMass > 0 && simMass < 20 ) {
            double bin_size = 0.1;
            //FIXME reset
            val_sim = -1;
            for( int k = 0; k < 24; k++ ) {
              if (fabs(simRapidity) > k*bin_size && fabs(simRapidity) < (k+1)*bin_size ) val_sim = k;
            }

            htrue2_24->Fill(val_sim, WEIGHT);
            htrue2_24_Roch->Fill(val_sim, WEIGHT);
            htrue2_24_corr->Fill(val_sim, FEWZ_WEIGHT*PU_WEIGHT*WEIGHT);
         }
       } //mumu only


         //over under flows
         val_reco = -1;
         val_sim = -1;
         if( recoMass > 0 && recoMass < 20 ) {
             double bin_size = 0.1;
            //FIXME reset
            val_reco = -1;
            for( int k = 0; k < 24; k++ ) {
              if( fabs(recoRap) > k*bin_size && fabs(recoRap) < (k+1)*bin_size ) val_reco = k;
            }

            hmeas2_24->Fill(val_reco, WEIGHT);
         }
         val_reco = -1;
         val_sim = -1;
         for( int jj = 0; jj < 7; jj++ ) {
           if( recoMass > Mass_xbin2_156[jj] && recoMass < Mass_xbin2_156[jj+1] ) {
            int nbins;
            double bin_size;
            if( jj == 6) {
              nbins = 12;
              bin_size = 0.2;
            }
            else {
              nbins = 24;
              bin_size = 0.1;
            }
            for( int kk = 0; kk < nbins; kk++ ) {
              if( fabs(recoRap) > kk*bin_size && fabs(recoRap) < (kk+1)*bin_size ) val_reco = kk + jj*24;
            }
          }   
          if( simMass > Mass_xbin2_156[jj] && simMass < Mass_xbin2_156[jj+1] ) {
            int nbins;
            double bin_size;
            if(jj == 6) {
              nbins = 12;
              bin_size = 0.2;
            }
            else {
              nbins = 24;
              bin_size = 0.1;
            }
            for( int kk = 0; kk < nbins; kk++ ) {
              if (fabs(simRapidity) > kk*bin_size && fabs(simRapidity) < (kk+1)*bin_size ) val_sim = kk + jj*24;
            }
          }
         }
         hden2_156->Fill(val_reco, val_sim, WEIGHT);
         hden2_156_PU->Fill(val_reco, val_sim, PU_WEIGHT*WEIGHT);


       if (mode == "MuMu") {
         val_reco = -1;
         val_sim = -1;
         for( int jj = 0; jj < 7; jj++ ) {
          if( recoMass_corr > Mass_xbin2_156[jj] && recoMass_corr < Mass_xbin2_156[jj+1] ) {
            int nbins;
            double bin_size;
            if( jj == 6) {
              nbins = 12;
              bin_size = 0.2;
            }
            else { 
              nbins = 24;
              bin_size = 0.1;
            }
            for( int kk = 0; kk < nbins; kk++ ) {
              if( fabs(recoRap_corr) > kk*bin_size && fabs(recoRap_corr) < (kk+1)*bin_size ) val_reco = kk + jj*24;
            }
          }
          if( simMass > Mass_xbin2_156[jj] && simMass < Mass_xbin2_156[jj+1] ) {
            int nbins;
            double bin_size;
            if(jj == 6) {
              nbins = 12;
              bin_size = 0.2;
            }
            else {
              nbins = 24;
              bin_size = 0.1;
            }
            for( int kk = 0; kk < nbins; kk++ ) {
              if (fabs(simRapidity) > kk*bin_size && fabs(simRapidity) < (kk+1)*bin_size ) val_sim = kk + jj*24;
            }
          }
        }
        hden2_156_Roch->Fill(val_reco, val_sim, WEIGHT);
        hden2_156_corr->Fill(val_reco, val_sim, FEWZ_WEIGHT*PU_WEIGHT*WEIGHT);
      } //mumu only

   }//end split by trig path

   return kTRUE;
}
Ejemplo n.º 9
0
void TMultimodalGraphImplB::AddNode(const TPair<TInt,TInt>& NodeId) {
  NodeToModeMapping.AddDat(NodeId.GetVal2(), NodeId.GetVal1());
}
Ejemplo n.º 10
0
TMultimodalGraphImplB::TNodeI TMultimodalGraphImplB::GetNI(const TPair<TInt,TInt>& NId) const {
  return TNodeI(NodeToModeMapping.GetI(NId.GetVal2()), &Graphs, &NodeToModeMapping);
}
Ejemplo n.º 11
0
void TMultimodalGraphImplB::AddEdgeBatch(const TPair<TInt,TInt>& SrcNId, const TVec<TPair<TInt,TInt> >& DstNIds) {
  IAssertR(IsNode(SrcNId), TStr::Fmt("%d not a node.", SrcNId.GetVal2()).CStr());
  for (TVec<TPair<TInt,TInt> >::TIter DstNId = DstNIds.BegI(); DstNId < DstNIds.EndI(); DstNId++) {
    AddEdge(SrcNId, *DstNId);
  }
}
Ejemplo n.º 12
0
int TMultimodalGraphImplB::AddEdge(const TPair<TInt,TInt>& SrcNId, const TPair<TInt,TInt>& DstNId) {
  IAssertR(IsNode(SrcNId) && IsNode(DstNId), TStr::Fmt("%d or %d not a node.", SrcNId.GetVal2(), DstNId.GetVal2()).CStr());

  TPair<TInt,TInt> ModeIdsKey = GetModeIdsKey(SrcNId.GetVal1(), DstNId.GetVal1());
  if (!Graphs.IsKey(ModeIdsKey)) {
    Graphs.AddDat(ModeIdsKey, TNGraph());
  }

  if (!Graphs.GetDat(ModeIdsKey).IsNode(SrcNId.GetVal2())) {
    Graphs.GetDat(ModeIdsKey).AddNode(SrcNId.GetVal2());
  }
  if (!Graphs.GetDat(ModeIdsKey).IsNode(DstNId.GetVal2())) {
    Graphs.GetDat(ModeIdsKey).AddNode(DstNId.GetVal2());
  }

  if (Graphs.GetDat(ModeIdsKey).IsEdge(SrcNId.GetVal2(), DstNId.GetVal2())) {
    return -2; // Edge already exists
  }
  NEdges++;
  return Graphs.GetDat(ModeIdsKey).AddEdge(SrcNId.GetVal2(), DstNId.GetVal2());
}
Ejemplo n.º 13
0
//_____________________________________________________________________________
Bool_t ProofAux::Process(Long64_t entry)
{
   // The Process() function is called for each entry in the tree (or possibly
   // keyed object in the case of PROOF) to be processed. The entry argument
   // specifies which entry in the currently loaded tree is to be processed.
   // It can be passed to either ProofAux::GetEntry() or TBranch::GetEntry()
   // to read either all or the required parts of the data. When processing
   // keyed objects with PROOF, the object is already loaded and is available
   // via the fObject pointer.
   //
   // This function should contain the "body" of the analysis. It can contain
   // simple or elaborate selection criteria, run algorithms on the data
   // of the event and typically fill histograms.
   //
   // The processing can be stopped by calling Abort().
   //
   // Use fStatus to set the return value of TTree::Process().
   //
   // The return value is currently not used.

   // Nothing to do if the action if not defined
   if (fAction < 0) {
      Error("Process", "action not specified!");
      return kFALSE;
   }

   // Link to current element, if any
   TDSetElement *fCurrent = 0;
   TPair *elemPair = 0;
   if (fInput && (elemPair = dynamic_cast<TPair *>(fInput->FindObject("PROOF_CurrentElement")))) {
      if ((fCurrent = dynamic_cast<TDSetElement *>(elemPair->Value()))) {
         Info("Process", "entry %lld: file: '%s'", entry, fCurrent->GetName());
      } else {
         Error("Process", "entry %lld: no file specified!", entry);
         return kFALSE;
      }
   }

   // Act now
   if (fAction == 0) {
      TString fnt;
      // Generate the TTree and save it in the specified file
      if (GenerateTree(fCurrent->GetName(), fNEvents, fnt) != 0) {
         Error("Process", "problems generating tree (%lld, %s, %lld)",
                          entry, fCurrent->GetName(), fNEvents);
         return kFALSE;
      }
      // The output filename
      TString fnf(fnt);
      TString xf = gSystem->BaseName(fnf);
      fnf = gSystem->DirName(fnf);
      if (xf.Contains("tree")) {
         xf.ReplaceAll("tree", "friend");
      } else {
         if (xf.EndsWith(".root")) {
            xf.ReplaceAll(".root", "_friend.root");
         } else {
            xf += "_friend";
         }
      }
      fnf += TString::Format("/%s", xf.Data());
      // Generate the TTree friend and save it in the specified file
      if (GenerateFriend(fnt, fnf) != 0) {
         Error("Process", "problems generating friend tree for %s (%s)",
                          fCurrent->GetName(), fnt.Data());
         return kFALSE;
      }
   } else if (fAction == 1) {
      TString fnt;
      // Generate the TTree and save it in the specified file
      if (GenerateTree(fCurrent->GetName(), fNEvents, fnt) != 0) {
         Error("Process", "problems generating tree (%lld, %s, %lld)",
                          entry, fCurrent->GetName(), fNEvents);
         return kFALSE;
      }
      // Generate the TTree friend and save it in the specified file
      if (GenerateFriend(fnt) != 0) {
         Error("Process", "problems generating friend tree for %s (%s)",
                          fCurrent->GetName(), fnt.Data());
         return kFALSE;
      }
   } else {
      // Unknown action
      Warning("Process", "do not know how to process action %d - do nothing", fAction);
      return kFALSE;
   }

   return kTRUE;
}
Bool_t EventSelector_FSRUnfBBB::Process(Long64_t entry)
{

   //Int_t trig = 0;
   bool isMC = true;  //SHould alkways be true - we will always run it on data

   //FIXME do this before we find a better option
   double Mass_xbin2[7] = {20, 30, 45, 60, 120, 200, 1500};

   // The Process() function is called for each entry in the tree (or possibly
   // keyed object in the case of PROOF) to be processed. The entry argument
   // specifies which entry in the currently loaded tree is to be processed.
   // It can be passed to either EventSelector_FSRUnfBBB::GetEntry() or TBranch::GetEntry()
   // to read either all or the required parts of the data. When processing
   // keyed objects with PROOF, the object is already loaded and is available
   // via the fObject pointer.
   //
   // This function should contain the "body" of the analysis. It can contain
   // simple or elaborate selection criteria, run algorithms on the data
   // of the event and typically fill histograms.
   //
   // The processing can be stopped by calling Abort().
   //
   // Use fStatus to set the return value of TTree::Process().
   //
   // The return value is currently not used.

   // Link to current element, if any
   TString filename = dataset;

   TPair* elemPair = 0;
   if (fInput && (elemPair = dynamic_cast<TPair*>(fInput->FindObject("PROOF_CurrentElement")))) {
     TDSetElement* current = dynamic_cast<TDSetElement*>(elemPair->Value());
     if (current) {
       filename = current->GetFileName();
       if (current->TestBit(TDSetElement::kNewRun)) {
         Info("Process", "entry %lld: starting new run for dataset '%s'",
                          entry, current->GetDataSet());
       }
       if (current->TestBit(TDSetElement::kNewPacket)) {
         dataset = current->GetDataSet();
         ds->SetTitle(dataset);
         Info("Process", "entry %lld: new packet from: %s, first: %lld, last: %lld",
                          entry, current->GetName(), current->GetFirst(),
                          current->GetFirst()+current->GetNum()-1);
       }
     }
   }

   Int_t eventSize = fChain->GetTree()->GetEntry(entry);
   ++fNumberOfEvents;

   //normalization purposes
   if (dataset != "DATA") Nntuple->Fill(0.5);

   // compute the total size of all events
   fTotalDataSize += eventSize;

   if ( fNumberOfEvents % 100000 == 0 ) std::cout << dataset << " : " << fNumberOfEvents << std::endl;

   //split below by trigger path
   for (Int_t trig = 0; trig < 1; trig++) {
    //reset weights
     Double_t WEIGHT = 1.;
     Double_t FEWZ_WEIGHT = 1.;

     //split data mc 
     if ( dataset == "DATA") {
        isMC = false; 
        //FIXME important requirement
        if (trig != 0) continue;
     }

      //pick up the weight
      if (isMC) {
           if (filename.Contains("DYM1020") || filename.Contains("DYE1020")) {
              WEIGHT = Sigma_DY1020*FilterEff_DY1020;
           } else if (filename.Contains("DYM200") || filename.Contains("DYE200")) {
              WEIGHT = Sigma_DY200*FilterEff_DY200;
           } else if ((filename.Contains("DYM20") && !filename.Contains("DYM200")) || (filename.Contains("DYE20") && !filename.Contains("DYE200"))) {
              WEIGHT = Sigma_DY20*FilterEff_DY20;
           } else if (filename.Contains("DYM400") || filename.Contains("DYE400")) {
              WEIGHT = Sigma_DY400*FilterEff_DY400;
           } else if (filename.Contains("DYM500") || filename.Contains("DYE500")) {
              WEIGHT = Sigma_DY500*FilterEff_DY500;
           } else if (filename.Contains("DYM700") || filename.Contains("DYE700")) {
              WEIGHT = Sigma_DY700*FilterEff_DY700;
           } else if (filename.Contains("DYM800") || filename.Contains("DYE800")) {
              WEIGHT = Sigma_DY800*FilterEff_DY800;
           } else if (filename.Contains("DYM1000") || filename.Contains("DYE1000")) {
              WEIGHT = Sigma_DY1000*FilterEff_DY1000;
           } else if (filename.Contains("DYM1500") || filename.Contains("DYE1500")) {
              WEIGHT = Sigma_DY1500*FilterEff_DY1500;
           } else if (filename.Contains("DYM2000") || filename.Contains("DYE2000")) {
              WEIGHT = Sigma_DY2000*FilterEff_DY2000;
           };
       } //isMC

      //FIXME just a hack to make sure samples are right
         // gen. mass
         double genMass = -1;
         double genRapidity = -1;
         double genDiMuPt = -1;
         int GENIndex = -1;
          for( int j = 0; j < GENnPair; j++ ) {
           if( GENMuon1_status[j] != 3 ) continue;
           if( GENMuon2_status[j] != 3 ) continue;

           genMass = GENInvMass[j];
           GENIndex = j;
           break;
        }

       //binned in GEN mass samples
        if ((filename.Contains("DYM200") || filename.Contains("DYE200")) && genMass > 400) { continue; }
         else if (((filename.Contains("DYM20") && !filename.Contains("DYM200")) || (filename.Contains("DYE20") && !filename.Contains("DYE200"))) && genMass > 200) {continue;}
         else if ((filename.Contains("DYM400") || filename.Contains("DYE400")) && genMass > 500) { continue; }
         else if ((filename.Contains("DYM500") || filename.Contains("DYE500")) && genMass > 700) { continue; }
         else if ((filename.Contains("DYM700") || filename.Contains("DYE700")) && genMass > 800) { continue; }
         else if ((filename.Contains("DYM800") || filename.Contains("DYE800")) && genMass > 1000) { continue; }
         else if ((filename.Contains("DYM1000") || filename.Contains("DYE1000")) && genMass > 1500) { continue; }
         else if ((filename.Contains("DYM1500") || filename.Contains("DYE1500")) && genMass > 2000) { continue; }

        //pre FSR values
         genRapidity = GENRapidity[GENIndex];
         genDiMuPt = sqrt((GENMuon1_Px[GENIndex]+GENMuon2_Px[GENIndex])*(GENMuon1_Px[GENIndex]+GENMuon2_Px[GENIndex])+(GENMuon1_Py[GENIndex]+GENMuon2_Py[GENIndex])*(GENMuon1_Py[GENIndex]+GENMuon2_Py[GENIndex]));
         //look up FEWZ weight
         FEWZ_WEIGHT = weight(genDiMuPt, fabs(genRapidity), genMass, true);

       //construction begin
       double GENMass = -1;
       double simMass = -1;
       int simIndex = -1;
       for( int j = 0; j < GENnPair; j++ ) {
          if( GENMuon1_status[j] == 1 && GENMuon2_status[j] == 1 ) {
              simIndex = j;
          }
          if( GENMuon1_status[j] == 3 && GENMuon2_status[j] == 3 ) {
              GENIndex = j;
          }
       } 

        GENMass = GENInvMass[GENIndex];
        simMass = GENInvMass[simIndex];

        double simRapidity = GENRapidity[simIndex];

        hpreFSR->Fill(GENMass, WEIGHT);
        hpostFSR->Fill(simMass, WEIGHT);

        hpreFSR_corr->Fill(GENMass, WEIGHT*FEWZ_WEIGHT);
        hpostFSR_corr->Fill(simMass, WEIGHT*FEWZ_WEIGHT);

        double val_gen = -1;
        double val_sim = -1;
        for( int j = 0; j < 6; j++ ) {
          if( GENMass > Mass_xbin2[j] && GENMass < Mass_xbin2[j+1] ) {
            int nbins;
            double bin_size;
            if( j == 5 ) {
                nbins = 13;
                bin_size = 0.2;
              }
              else {
                nbins = 25;
                bin_size = 0.1;
              }
              for( int k = 0; k < nbins; k++ ) {
                if( fabs(genRapidity) > k*bin_size && fabs(genRapidity) < (k+1)*bin_size ) val_gen = k + j*25;
              }
            }
            if( simMass > Mass_xbin2[j] && simMass < Mass_xbin2[j+1] ) {
              int nbins;
              double bin_size;
              if( j == 5 ) {
                nbins = 13;
                bin_size = 0.2;
              }
              else {
                nbins = 25;
                bin_size = 0.1;
              }
              for( int k = 0; k < nbins; k++ ) {
                if (fabs(simRapidity) > k*bin_size && fabs(simRapidity) < (k+1)*bin_size ) val_sim = k + j*25;
              }
           }
        }
       
        hpreFSR2->Fill(val_gen, WEIGHT);
        hpostFSR2->Fill(val_sim, WEIGHT);

        hpreFSR_corr2->Fill(val_gen, WEIGHT*FEWZ_WEIGHT);
        hpostFSR_corr2->Fill(val_sim, WEIGHT*FEWZ_WEIGHT);

   }//end split by trig path

   return kTRUE;
}
Bool_t EventSelector_MCTruthEff::Process(Long64_t entry)
{

   bool isMC = true;

   double Mass_xbin2[7] = {20, 30, 45, 60, 120, 200, 1500};

   // The Process() function is called for each entry in the tree (or possibly
   // keyed object in the case of PROOF) to be processed. The entry argument
   // specifies which entry in the currently loaded tree is to be processed.
   // It can be passed to either EventSelector_MCTruthEff::GetEntry() or TBranch::GetEntry()
   // to read either all or the required parts of the data. When processing
   // keyed objects with PROOF, the object is already loaded and is available
   // via the fObject pointer.
   //
   // This function should contain the "body" of the analysis. It can contain
   // simple or elaborate selection criteria, run algorithms on the data
   // of the event and typically fill histograms.
   //
   // The processing can be stopped by calling Abort().
   //
   // Use fStatus to set the return value of TTree::Process().
   //
   // The return value is currently not used.

   // Link to current element, if any
   TString filename = dataset;

   TPair* elemPair = 0;
   if (fInput && (elemPair = dynamic_cast<TPair*>(fInput->FindObject("PROOF_CurrentElement")))) {
     TDSetElement* current = dynamic_cast<TDSetElement*>(elemPair->Value());
     if (current) {
       filename = current->GetFileName();
       if (current->TestBit(TDSetElement::kNewRun)) {
         Info("Process", "entry %lld: starting new run for dataset '%s'",
                          entry, current->GetDataSet());
       }
       if (current->TestBit(TDSetElement::kNewPacket)) {
         dataset = current->GetDataSet();
         ds->SetTitle(dataset);
         Info("Process", "entry %lld: new packet from: %s, first: %lld, last: %lld",
                          entry, current->GetName(), current->GetFirst(),
                          current->GetFirst()+current->GetNum()-1);
       }
     }
   }

   Int_t eventSize = fChain->GetTree()->GetEntry(entry);
   ++fNumberOfEvents;

   //normalization purposes
   if (dataset != "DATA") Nntuple->Fill(0.5);

   // compute the total size of all events
   fTotalDataSize += eventSize;

   if ( fNumberOfEvents % 100000 == 0 ) std::cout << dataset << " : " << fNumberOfEvents << std::endl;

   //FIXME hardcode number of trigger paths. 
   for (Int_t trig = 0; trig < 1; trig++) {
    //reset weights
     Double_t WEIGHT = 1.;
     Double_t FEWZ_WEIGHT = 1.;
     Double_t PU_WEIGHT = 1.;

     //split data mc
     if ( dataset == "DATA") isMC = false;

      if (isMC) {
           if (filename.Contains("DYM1020") || filename.Contains("DYE1020")) {
              WEIGHT = Sigma_DY1020*FilterEff_DY1020;
           } else if (filename.Contains("DYM200") || filename.Contains("DYE200")) {
              WEIGHT = Sigma_DY200*FilterEff_DY200;
           } else if ((filename.Contains("DYM20") && !filename.Contains("DYM200")) || (filename.Contains("DYE20") && !filename.Contains("DYE200"))) {
              WEIGHT = Sigma_DY20*FilterEff_DY20;
           } else if (filename.Contains("DYM400") || filename.Contains("DYE400")) {
              WEIGHT = Sigma_DY400*FilterEff_DY400;
           } else if (filename.Contains("DYM500") || filename.Contains("DYE500")) {
              WEIGHT = Sigma_DY500*FilterEff_DY500;
           } else if (filename.Contains("DYM700") || filename.Contains("DYE700")) {
              WEIGHT = Sigma_DY700*FilterEff_DY700;
           } else if (filename.Contains("DYM800") || filename.Contains("DYE800")) {
              WEIGHT = Sigma_DY800*FilterEff_DY800;
           } else if (filename.Contains("DYM1000") || filename.Contains("DYE1000")) {
              WEIGHT = Sigma_DY1000*FilterEff_DY1000;
           }
      }

      //pileup. FIXME do not apply pile-up to QCD samples yet
      if (isMC && !filename.Contains("QCD")) {
        PU_WEIGHT = pileUpReweight;
      }    

      //construction begin
      double genDiMuPt = -1;
      double genRapidity = -1;
      double genMass = -1;
      int GENIndex = -1;
      double simMass = -1;
      double simRapidity = -999;
      int simIndex = -1; 
      bool passAccpreFSR = false;
      bool passAccpostFSR = false;
      for( int j = 0; j < GENnPair; j++ ) {
         if( GENMuon1_status[j] != 3 ) continue;
         if( GENMuon2_status[j] != 3 ) continue;
              
         GENIndex = j;
         break;
      }   

       //pre FSr values
       genMass = GENInvMass[GENIndex];
       genRapidity = GENRapidity[GENIndex];

       //binned in GEN mass samples
        if ((filename.Contains("DYM200") || filename.Contains("DYE200")) && genMass > 400) { continue; }
         else if (((filename.Contains("DYM20") && !filename.Contains("DYM200")) || (filename.Contains("DYE20") && !filename.Contains("DYE200"))) && genMass > 200) {continue;}
         else if ((filename.Contains("DYM400") || filename.Contains("DYE400")) && genMass > 500) { continue; }
         else if ((filename.Contains("DYM500") || filename.Contains("DYE500")) && genMass > 700) { continue; }
         else if ((filename.Contains("DYM700") || filename.Contains("DYE700")) && genMass > 800) { continue; }
         else if ((filename.Contains("DYM800") || filename.Contains("DYE800")) && genMass > 1000) { continue; }

       //pre FSr values
       genDiMuPt = sqrt((GENMuon1_Px[GENIndex]+GENMuon2_Px[GENIndex])*(GENMuon1_Px[GENIndex]+GENMuon2_Px[GENIndex])+(GENMuon1_Py[GENIndex]+GENMuon2_Py[GENIndex])*(GENMuon1_Py[GENIndex]+GENMuon2_Py[GENIndex]));

       //set up FEWZ reweight
       FEWZ_WEIGHT = weight(genDiMuPt, fabs(genRapidity), genMass, true);

       //2D sliced 
       double value_full = -1;

       for( int jj = 0; jj < 6; jj++ ) {
           if( genMass > Mass_xbin2[jj] && genMass < Mass_xbin2[jj+1] ) {
              int nbins;
              double bin_size;
              if( jj == 5 ) {
                  nbins = 12;
                  bin_size = 0.2;
              }
               else {
                 nbins = 24;
                 bin_size = 0.1;
              }
              for( int k = 0; k < nbins; k++ ) {
                 if( fabs(genRapidity) > k*bin_size && fabs(genRapidity) < (k+1)*bin_size ) value_full = k + jj*24;
              }
            }
          }
       fAbsRap_full->Fill(value_full);//, WEIGHT);
       fAbsRap_full_PU->Fill(value_full, PU_WEIGHT);//, WEIGHT);
       fAbsRap_full_corr->Fill(value_full,PU_WEIGHT*FEWZ_WEIGHT);//, WEIGHT);

       if( genMass > 15 && genMass < 1500 ) {
              hfull->Fill(genMass);//,WEIGHT);
              hfull_PU->Fill(genMass,PU_WEIGHT);//*WEIGHT);
              hfull_corr->Fill(genMass,PU_WEIGHT*FEWZ_WEIGHT);//*WEIGHT);
       }

       // FSR in Acc
       if( (GENMuon1_pT[GENIndex] > 20 && fabs(GENMuon1_eta[GENIndex]) < 2.4 && GENMuon2_pT[GENIndex] > 10 && fabs(GENMuon2_eta[GENIndex]) < 2.4)
            || (GENMuon1_pT[GENIndex] > 10 && fabs(GENMuon1_eta[GENIndex]) < 2.4 && GENMuon2_pT[GENIndex] > 20 && fabs(GENMuon2_eta[GENIndex]) < 2.4) ) {
             passAccpreFSR = true;
       }

       if (passAccpreFSR) {  
         //2D sliced 
         double value_acc = -1;

         for( int jj = 0; jj < 6; jj++ ) {
            if( genMass > Mass_xbin2[jj] && genMass < Mass_xbin2[jj+1] ) {
              int nbins;
              double bin_size;
              if( jj == 5 ) {
                 nbins = 12;
                 bin_size = 0.2;
              }
              else {
                 nbins = 24;
                 bin_size = 0.1;
              }
                for( int k = 0; k < nbins; k++ ) {
                  if( fabs(genRapidity) > k*bin_size && fabs(genRapidity) < (k+1)*bin_size ) value_acc = k + jj*24;
                }
             }
          }
          fAbsRap_acc->Fill(value_acc);//, WEIGHT);
          fAbsRap_acc_PU->Fill(value_acc,PU_WEIGHT);//, WEIGHT);
          fAbsRap_acc_corr->Fill(value_acc,PU_WEIGHT*FEWZ_WEIGHT);//, WEIGHT);

          if( genMass > 15 && genMass < 1500 ) {
              hacc->Fill(genMass);//,WEIGHT);
              hacc_PU->Fill(genMass,PU_WEIGHT);//*WEIGHT);
              hacc_corr->Fill(genMass,PU_WEIGHT*FEWZ_WEIGHT);//*WEIGHT);
          }
       } //end passAccpreFSR

       // sim. mass
       for( int j = 0; j < GENnPair; j++ ) {
          //if( GENMuon1_mother[j] != 23 ) continue;
          //if( GENMuon2_mother[j] != 23 ) continue;
          if( GENMuon1_status[j] != 1 ) continue;
          if( GENMuon2_status[j] != 1 ) continue;

          simIndex = j;
          break;
       }
       //post FSr values
       simMass = GENInvMass[simIndex];
       simRapidity = GENRapidity[simIndex];

       double value_sim = -1;
           
       for( int jj = 0; jj < 6; jj++ ) {
          if( simMass > Mass_xbin2[jj] && simMass < Mass_xbin2[jj+1] ) {
              int nbins;
              double bin_size;
            if( jj == 5 ) {
               nbins = 12;
               bin_size = 0.2;
           }
           else {
              nbins = 24;
              bin_size = 0.1;
          }
          for( int k = 0; k < nbins; k++ ) {
             if( fabs(simRapidity) > k*bin_size && fabs(simRapidity) < (k+1)*bin_size ) value_sim = k + jj*24;
           }
         }
       }
       fAbsRap_sim->Fill(value_sim);//, WEIGHT);
       fAbsRap_sim_PU->Fill(value_sim,PU_WEIGHT);//, WEIGHT);
       fAbsRap_sim_corr->Fill(value_sim,PU_WEIGHT*FEWZ_WEIGHT);//, WEIGHT);

       if( simMass > 15 && simMass < 1500 ) {
            hsim->Fill(simMass);//,WEIGHT);
            hsim_PU->Fill(simMass,PU_WEIGHT);//*WEIGHT);
            hsim_corr->Fill(simMass,PU_WEIGHT*FEWZ_WEIGHT);//*WEIGHT);
       }

       // FSR in Acc
       if( (GENMuon1_pT[simIndex] > 20 && fabs(GENMuon1_eta[simIndex]) < 2.4 && GENMuon2_pT[simIndex] > 10 && fabs(GENMuon2_eta[simIndex]) < 2.4)
              || (GENMuon1_pT[simIndex] > 10 && fabs(GENMuon1_eta[simIndex]) < 2.4 && GENMuon2_pT[simIndex] > 20 && fabs(GENMuon2_eta[simIndex]) < 2.4) ) {
             passAccpostFSR = true;
       }

       if (!passAccpostFSR) continue;

       //2D sliced 
       double value_accFSR = -1;

       for( int jj = 0; jj < 6; jj++ ) {
            if( simMass > Mass_xbin2[jj] && simMass < Mass_xbin2[jj+1] ) {
                  int nbins;
                  double bin_size;
                  if( jj == 5 ) {
                    nbins = 12;
                    bin_size = 0.2;
                 }
                  else {
                   nbins = 24;
                   bin_size = 0.1;
                 }
                 for( int k = 0; k < nbins; k++ ) {
                   if( fabs(simRapidity) > k*bin_size && fabs(simRapidity) < (k+1)*bin_size ) value_accFSR = k + jj*24;
              }
            }
          }
        fAbsRap_accFSR->Fill(value_accFSR);//, WEIGHT);
        fAbsRap_accFSR_PU->Fill(value_accFSR,PU_WEIGHT);//, WEIGHT);
        fAbsRap_accFSR_corr->Fill(value_accFSR,PU_WEIGHT*FEWZ_WEIGHT);//, WEIGHT);

        if( simMass > 15 && simMass < 1500 ) { 
           haccFSR->Fill(simMass);//,WEIGHT);
           haccFSR_PU->Fill(simMass,PU_WEIGHT);//*WEIGHT);
           haccFSR_corr->Fill(simMass,PU_WEIGHT*FEWZ_WEIGHT);//*WEIGHT);
        }

        int index = -1;
        double best_val = -99999;
        for( int j = 0; j < nPair; j++ ) {
         if( Muon1_muonType[j] != 1 ) continue;
         if( Muon2_muonType[j] != 1 ) continue;

         if( Muon1_pT[j] < 20 || Muon2_pT[j] < 10 ) {
            if( Muon2_pT[j] < 20 || Muon1_pT[j] < 10 ) continue;
            }

	 if( fabs(Muon1_eta[j]) > 2.4 ) continue;
	 if( fabs(Muon2_eta[j]) > 2.4 ) continue;

	  // Muon id
	  if( Muon1_chi2dof[j] >= 10 || Muon1_chi2dof[j] < 0 ) continue;
	  if( Muon2_chi2dof[j] >= 10 || Muon2_chi2dof[j] < 0 ) continue;
    
	  if( Muon1_trackerHits[j] <= 10 ) continue;
	  if( Muon2_trackerHits[j] <= 10 ) continue;
	  if( Muon1_pixelHits[j] < 1 ) continue;
	  if( Muon2_pixelHits[j] < 1 ) continue;
	  if( Muon1_muonHits[j] < 1 ) continue;
	  if( Muon2_muonHits[j] < 1 ) continue;
	  if( Muon1_nMatches[j] < 2 ) continue;
	  if( Muon2_nMatches[j] < 2 ) continue;
          if (Muon1_nTrackerLayers[j] < 6) continue;
          if (Muon2_nTrackerLayers[j] < 6) continue;

	  if( fabs(Muon1_dxyBS[j]) > 0.2 ) continue;
	  if( fabs(Muon2_dxyBS[j]) > 0.2 ) continue;
 
	  // isolation
          if( (Muon1_PfGammaIsoR03[j]+Muon1_PfChargedHadronIsoR03[j]+Muon1_PfNeutralHadronIsoR03[j])/Muon1_pT[j] > 0.15) continue;
          if( (Muon2_PfGammaIsoR03[j]+Muon2_PfChargedHadronIsoR03[j]+Muon2_PfNeutralHadronIsoR03[j])/Muon2_pT[j] > 0.15) continue;
          //if( (Muon1_PfChargedHadronIsoR03[j]+Muon1_PfNeutralHadronIsoR03[j])/Muon1_pT[j] > 0.2) continue;
          //if( (Muon2_PfChargedHadronIsoR03[j]+Muon2_PfNeutralHadronIsoR03[j])/Muon2_pT[j] > 0.2) continue;

	  // 3D angle
	  if( CosAngle[j] < 0.005 ) continue;

	  // vtx prob
	  if( vtxTrkProb[j] < 0.02 ) continue;

          if( !isOppSign[j]) continue;

	    if( vtxTrkProb[j] > best_val ) {
	      best_val = vtxTrkProb[j];
              index = j;
            }
        }
	if( index == -1 ) continue;

        bool isTriggered = false;
        //Current 2012 way
        if (hlt_trigFired[2] == 1) isTriggered = true;
        if( !isTriggered ) return kTRUE;

         //trigger matching begin
         int isMatched = 0;
         double trigEta[2] = {-999};
         double trigPhi[2] = {-999};
         int _ntrig = 0;
         for( int k = 0; k < hlt_ntrig; k++ ) {
           bool isFired = false;
           if (hlt_trigFired[2] == 1) isFired = true;
           if( !isFired ) continue;
           if( _ntrig == 0 ) {
              trigEta[_ntrig] = hlt_trigEta[k];
              trigPhi[_ntrig] = hlt_trigPhi[k];
              _ntrig++;
           }
           else {
              if( deltaR(hlt_trigEta[k], hlt_trigPhi[k], trigEta[0], trigPhi[0]) < 0.001 ) continue;
              else {
                if( _ntrig == 1 ) {
                  trigEta[_ntrig] = hlt_trigEta[k];
                  trigPhi[_ntrig] = hlt_trigPhi[k];
                  _ntrig++;
                }
                else {
                  if( deltaR(hlt_trigEta[k], hlt_trigPhi[k], trigEta[0], trigPhi[0]) < 0.001 ) continue;
                  if( deltaR(hlt_trigEta[k], hlt_trigPhi[k], trigEta[1], trigPhi[1]) < 0.001 ) continue;
               }
             }
           }
         }
        for( int k = 0; k < 2; k++ ) {
            double dR1 = deltaR(trigEta[k], trigPhi[k], Muon1_eta[index], Muon1_phi[index]);
            double dR2 = deltaR(trigEta[k], trigPhi[k], Muon2_eta[index], Muon2_phi[index]);
            if( dR1 < 0.2 || dR2 < 0.2 ) {
                isMatched++;
            }
        }
        //if( isMatched < 2) continue;

        //2D sliced 
        double value_sel = -1;

        for( int jj = 0; jj < 6; jj++ ) {
           if( simMass > Mass_xbin2[jj] && simMass < Mass_xbin2[jj+1] ) {
              int nbins; 
              double bin_size;
              if( jj == 5 ) { 
                  nbins = 12;
                  bin_size = 0.2;
              }
              else {
                 nbins = 24;
                 bin_size = 0.1;
              }
              for( int k = 0; k < nbins; k++ ) {
                if( fabs(simRapidity) > k*bin_size && fabs(simRapidity) < (k+1)*bin_size ) value_sel = k + jj*24;
              }
           }
        }
        fAbsRap_sel->Fill(value_sel); //, WEIGHT);
        fAbsRap_sel_PU->Fill(value_sel,PU_WEIGHT); //, WEIGHT);
        fAbsRap_sel_corr->Fill(value_sel,PU_WEIGHT*FEWZ_WEIGHT); //, WEIGHT);

        if( simMass > 15 && simMass < 1500 ) {
          hsel->Fill(simMass); //,WEIGHT);
          hsel_PU->Fill(simMass,PU_WEIGHT); //*WEIGHT);
          hsel_corr->Fill(simMass,PU_WEIGHT*FEWZ_WEIGHT); //*WEIGHT);
        }

   }//end split by trig path

   return kTRUE;
}
Ejemplo n.º 16
0
void MakeSnapshot(Int_t run, const char* defStorage, TMap* specStorages, const char* snapshotFileName)
{
    AliCDBManager *cdb = AliCDBManager::Instance();
    cdb->SetDefaultStorage(defStorage);
    cdb->SetRun(run);

    TIter iter(specStorages->GetTable());
    TPair *pair = 0;
    while((pair = dynamic_cast<TPair*> (iter.Next()))){
	TObjString* caltype = dynamic_cast<TObjString*> (pair->Key());
	TObjString* specstor= dynamic_cast<TObjString*> (pair->Value());
	if (caltype && specstor)
	    //TString calType = caltype->GetString();
	    //TString specStor = specstor->GetString();
	    //cdb->SetSpecificStorage(calType.Data(),specStor.Data());
	    cdb->SetSpecificStorage(caltype->GetString().Data(),specstor->GetString().Data());
	else
	    //AliFatal("Error reading info for specific storage")
	    Printf("Error reading info for specific storage");
    }

    // ********************************** GRP ******************************************
    cdb->Get("GRP/CTP/Config");
    cdb->Get("GRP/Calib/LHCClockPhase");
    cdb->Get("GRP/GRP/Data");
    cdb->Get("GRP/Align/Data");
    cdb->Get("GRP/Calib/MeanVertexSPD");
    cdb->Get("GRP/Calib/MeanVertex");
    cdb->Get("GRP/Calib/MeanVertexTPC");
    cdb->Get("GRP/Calib/CosmicTriggers");
    cdb->Get("GRP/CTP/Scalers");
    cdb->Get("GRP/CTP/CTPtiming");
    cdb->Get("GRP/CTP/TimeAlign");
    cdb->Get("GRP/GRP/LHCData");
    cdb->Get("GRP/Calib/RecoParam");

    // ********************************** ALL ******************************************
    TString detStr = ("ITS TPC TRD TOF PHOS HMPID EMCAL MUON ZDC PMD T0 VZERO");
    //TString detStr = ("ITS MUON TPC");
    TObjArray *arr = detStr.Tokenize(' ');
    for (Int_t iDet=0; iDet<arr->GetEntries(); iDet++) {
	TObjString *detOStr = dynamic_cast<TObjString*>(arr->At(iDet));
	AliCDBManager::Instance()->GetAll(Form("%s/Calib/*",detOStr->GetString().Data()));
	AliCDBManager::Instance()->Get(Form("%s/Align/Data",detOStr->GetString().Data()));
    }

    // ******************************** TRIGGER ****************************************
    // Temporary fix - one has to define the correct policy in order
    // to load the trigger OCDB entries only for the detectors that
    // in the trigger or that are needed in order to put correct
    // information in ESD
    AliCDBManager::Instance()->GetAll("TRIGGER/*/*");

    // ********************************** HLT ******************************************
    // cdb->Get("HLT/ConfigHLT/esdLayout");
    // cdb->Get("HLT/Calib/StreamerInfo");

    TMap* entriesMap = const_cast<TMap*>(cdb->GetEntryCache());
    Printf("\nentriesMap has %d entries!\n", entriesMap->GetEntries());

    TList* entriesList = const_cast<TList*>(cdb->GetRetrievedIds());
    Printf("\nentriesList has %d entries!\n", entriesList->GetEntries());

    //TString filename(TString::Format("CDBsnapshot_Run%d.root",run));
    TString filename(snapshotFileName);
    TFile *f = new TFile(filename.Data(),"recreate");
    f->cd();
    f->WriteObject(entriesMap,"entriesMap");
    f->WriteObject(entriesList,"entriesList");
    f->Close();
    entriesMap->SetOwnerKeyValue(kFALSE,kFALSE);
    entriesList->SetOwner(kFALSE);
}