Ejemplo n.º 1
0
void beffAnalysis(const char* input, const char* output) {
  // input
  TFile* inputFile = TFile::Open(input);
  TTree* btagEff = (TTree*)inputFile->Get("btagEff");

  // output
  TFile* outputFile = TFile::Open(output,"RECREATE");

  // histogram with proper binning... cloned later on 
  Double_t binning[23] = {20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,120,140,160,180,200,1000};
  TH1F* ptSpectrum = new TH1F("PtSpectrum","PtSpectrum",22,binning);
  ptSpectrum->Sumw2();

  // produce the ratio plot for the 12 combinations of (CSVL,CSVM,CSVT),(Barrel,Endcap),(b,c,l)
  TClonesArray algorithms("TCut",3);
  new(algorithms[0]) TCut("CSVL","csv>0.244");
  new(algorithms[1]) TCut("CSVM","csv>0.679");
  new(algorithms[2]) TCut("CSVT","csv>0.898");

  TClonesArray etaRegions("TCut",2);
  new(etaRegions[0]) TCut("Barrel","abs(eta)<=1.2");
  new(etaRegions[1]) TCut("Endcaps","abs(eta)>1.2");

  TClonesArray flavor("TCut",3);
  new(flavor[0]) TCut("l","abs(flavor)!=4 && abs(flavor)!=5");
  new(flavor[1]) TCut("c","abs(flavor)==4");
  new(flavor[2]) TCut("b","abs(flavor)==5");

  for(int i=0; i< algorithms.GetEntries() ; ++i) {
    outputFile->mkdir(((TCut*)algorithms.At(i))->GetName());
    outputFile->cd(((TCut*)algorithms.At(i))->GetName());
    for(int j=0; j< etaRegions.GetEntries() ; ++j) {
      for(int k=0; k< flavor.GetEntries() ; ++k) {
        // histogram before tagging
        TH1F* pretag = ptSpectrum->Clone("pretag");
        btagEff->Draw("pt>>pretag",((*(TCut*)etaRegions.At(j))&&(*(TCut*)flavor.At(k)))*"eventWeight");
        // histogram after tagging
        TH1F* posttag = ptSpectrum->Clone("posttag");
        btagEff->Draw("pt>>posttag",((*(TCut*)algorithms.At(i))&&(*(TCut*)etaRegions.At(j))&&(*(TCut*)flavor.At(k)))*"eventWeight");
        // ratio
        TH1F* ratio = posttag->Clone(Form("h_eff_bTagOverGoodJet_pt%s_%s",((TCut*)flavor.At(k))->GetName(),
                                                                          ((TCut*)etaRegions.At(j))->GetName()));
        ratio->Divide(pretag);
        // cleanup
        delete pretag;
        delete posttag;
      }
    }
  }

  // cleanup
  algorithms.Delete();
  etaRegions.Delete();
  flavor.Delete();
  ptSpectrum->SetDirectory(0);
  outputFile->Write();
  outputFile->Close();
  inputFile->Close();
}
Ejemplo n.º 2
0
void
QMacPasteboard::setMimeData(QMimeData *mime_src)
{
    if (!paste)
        return;

    if (mime == mime_src || (!mime_src && mime && mac_mime_source))
        return;
    mac_mime_source = false;
    delete mime;
    mime = mime_src;

    QList<QMacPasteboardMime*> availableConverters = QMacPasteboardMime::all(mime_type);
    if (mime != 0) {
        clear_helper();
        QStringList formats = mime_src->formats();

#ifdef QT_MAC_USE_COCOA
        // QMimeData sub classes reimplementing the formats() might not expose the
        // temporary "application/x-qt-mime-type-name" mimetype. So check the existence
        // of this mime type while doing drag and drop.
        QString dummyMimeType(QLatin1String("application/x-qt-mime-type-name"));
        if (!formats.contains(dummyMimeType)) {
            QByteArray dummyType = mime_src->data(dummyMimeType);
            if (!dummyType.isEmpty()) {
                formats.append(dummyMimeType);
            }
        }
#endif
        for(int f = 0; f < formats.size(); ++f) {
            QString mimeType = formats.at(f);
            for (QList<QMacPasteboardMime *>::Iterator it = availableConverters.begin(); it != availableConverters.end(); ++it) {
                QMacPasteboardMime *c = (*it);
                QString flavor(c->flavorFor(mimeType));
                if(!flavor.isEmpty()) {
                    QVariant mimeData = static_cast<QMacMimeData*>(mime_src)->variantData(mimeType);
#if 0
                    //### Grrr, why didn't I put in a virtual int QMacPasteboardMime::count()? --Sam
                    const int numItems = c->convertFromMime(mimeType, mimeData, flavor).size();
#else
                    int numItems = 1; //this is a hack but it is much faster than allowing conversion above
                    if(c->convertorName() == QLatin1String("FileURL"))
                        numItems = mime_src->urls().count();
#endif
                    for(int item = 0; item < numItems; ++item) {
                        const int itemID = item+1; //id starts at 1
                        promises.append(QMacPasteboard::Promise(itemID, c, mimeType, mimeData, item));
                        PasteboardPutItemFlavor(paste, (PasteboardItemID)itemID, QCFString(flavor), 0, kPasteboardFlavorNoFlags);
#ifdef DEBUG_PASTEBOARD
                        qDebug(" -  adding %d %s [%s] <%s> [%d]",
                               itemID, qPrintable(mimeType), qPrintable(flavor), qPrintable(c->convertorName()), item);
#endif
                    }
                }
            }
        }
    }
}
Ejemplo n.º 3
0
void Lexer::pull()
{
    _white = "";
    _text = "";

    char c;

    // skipping whitespace
    while (true)
    {
        _in.get(c);

        if (!_in)
        {
            _type = TOK_EOF;
            return;
        }
        if (whitespace.count(c))
        {
            _white += c;
            continue;
        }

        if (c != '\\')
            break;

        _white += c;
        _in.get(c);
        if (!_in || !whitespace.count(c))
            die("toplevel backslash not followed by whitespace");
        _white += c;
    }

    _text += c;
    auto it = operators.find(_text);
    if (it != operators.end())
    {
        while (true)
        {
            if (_in.get(c) && it->second.count(c))
            {
                _text += c;
                it = operators.find(_text);
                assert (it != operators.end());
                continue;
            }
            else
            {
                _in.unget();
                break;
            }
        }
        if (_text == "##" && !_macro_body)
        {
            die("'##' is only valid in a macro body");
        }
        if (_text == "#" && !_macro_body)
        {
            while ((_in.get(c)) && (c != '\n'))
            {
                if (c == '\\')
                {
                    _in.get(c);
                    if (!_in || !whitespace.count(c))
                        die("macro-level backslash not followed by whitespace");
                }
                _text += c;
            }
            // whatever?
            _in.unget();
            _type = TOK_PP;
            return;
        }
        if (_text == "//")
        {
            while ((_in.get(c)) && (c != '\n'))
            {
                if (c == '\\')
                {
                    _in.get(c);
                    if (!_in || !whitespace.count(c))
                        die("comment-level backslash not followed by whitespace");
                }
                _text += c;
            }
            // whatever!
            _in.unget();
            _type = TOK_SLC;
            return;
        }
        if (_text == "/*")
        {
            bool prev_star = false;
            while (true)
            {
                _in.get(c);
                if (!_in)
                    die("unclosed block comment");
                _text += c;
                prev_star = c == '*';
                if (prev_star && c == '/')
                    break;
            }
            _type = TOK_MLC;
            return;
        }
        _type = TOK_OP;
        return;
    }
    // not an operator or comment
    if (c == '"' || c == '\'')
    {
        char match = c;
        while (true)
        {
            _in.get(c);
            if (!_in)
                die("unclosed string/char literal");
            _text += c;
            if (c == match)
                break;
            if (c == '\\')
            {
                _in.get(c);
                if (!_in)
                    die("EOF after backslash in string/char literal");
                // we don't care if it's valid or not, just add it
                _text += c;
            }
        }
        _type = TOK_LIT;
        return;
    }
    if (digits.count(c))
    {
        std::set<char> *digs = &digits;
        if (c == '0')
        {
            if ((_in.get(c)) && (c == 'x' || c == 'X'))
            {
                digs = &higits;
                _text += c;
            }
            else
                _in.unget();
        }
        while ((_in.get(c)) && digs->count(c))
        {
            _text += c;
        }
        _in.unget();
        _type = TOK_LIT;
        return;
    }
    if (word_first.count(c))
    {
        while ((_in.get(c)) && word_rest.count(c))
            _text += c;
        _in.unget();
        _type = flavor(_text);
        return;
    }
    die("Unknown character");
}