Analysis Open Space

Introdução

Este é um espaço para que sejam discutidas questões relacionadas a análises desenvolvidas no grupo do SPRACE. Objetivos e condutas gerais são:

  • Colocar para o grupo problemas de caráter técnico (CMSSW, ROOT, condorg, crab, etc...) ou físico (questões teóricas)
  • Todos estão convidados a responder/opinar sobre os problemas colocados
  • Perguntas e respostas devem ser mantidas na página para referência futura
  • Coloque seu nome entre parêntesis ao fazer uma pergunta ou dar uma resposta
Crie uma nova questão com ---+++ dentro da seção correspondente (CMSSW, ROOT, grid, ...) para que ela apareça no sumário no topo da página (como no Exemplo 1 abaixo).

Exemplo 1: Como uso LaTeX no ROOT?

(Fulano) Preciso fazer o título de um gráfico com símbolo LaTeX, como faço?

(Cicrano) É só usar # antes do comando (ao invés de usar /)

(Beutrano) Por exemplo ->SetTitle("#theta (graus)")

(Fulano) Ok, resolvido

CMSSW

How to skip bad files in a CMSSW job

(Thiago) Sometimes, a CMSSW job is running over hundreds of input files, and it happens that one of then is bad/corrupted/cannot be opened. To avoid the job from crashing, you can do the following in your configuration:

process.source.skipBadFiles = cms.untracked.bool( True )

Remember to check which files are bad and take action afterwards!

How to setup debugging symbols in CMSSW

(Thiago) The best thing you can do when you encounter seg faults is add debugging symbols to your compiled code. To do this, edit the BuildFile for the package that is crashing with the following line:

<flags CXXFLAGS="-O0 -g3 -fno-inline"/>

Then, recompile your package and re-run. This time, the stack trace should tell you a line number in one of your files where the error is occurring.

How to setup random seeds in the Python config file.

(Thiago) Add the following lines to your _cfg.py file:

import uuid
import random
x = uuid.uuid4()
random.seed(x)

and them, after you load the RandomNumberGeneratorService (usually wish something like process.load('Configuration.StandardSequences.Services_cff') ), add:

randService = process.RandomNumberGeneratorService
for param in [x for x in randService.parameterNames_()
             if type(getattr(randService, x)) == cms.PSet]:
   getattr(randService, param).initialSeed = random.randint(1,100000)

How to find the corresponding Monte Carlo of a dataset

(Caio) I need to find a MC corresponding to a specific dataset. This MC must simulates detector conditions during datataking, as well as the physics of the collision. How to find it? In the specific case the dataset is:

/MinimumBias/Run2010A-Apr21ReReco-v1/RECO com CMSSW_4_2_1_patch1 e global tag FT_R_42_V10A.

Esse link tem informações sobre os dados de 2010 e esse outro sobre os MC, mas como relacionar esses dados com esses MCs? Qual MC corresponde a qual dado? Tem a ver com a estação do ano?

Finding datasets

(Caio) In CMS, data are found in the DAS website, which is a better version of DBS. Example of DAS commands for dataset search:

  • dataset = /Min*Bias*TuneZ2*7TeV*pythia6*Summer11*AODSIM (The star is the wildcard character, e.g. all of these are similar: "heavy_ion" "h*y_ion" "heav*y_ion" "heavy_ion*"
  • dataset = /MinimumBias/Run2010A*AOD
  • block = /MinimumBias/Run2010A-Apr21ReReco-v1/AOD#f9fe2e80-703d-11e0-9135-003048f1c5d0
  • release dataset = *7TeV*pythia*GEN-SIM-RECO Shows all CMSSW releases which have this dataset
  • dataset release = CMSSW_4_2_1_patch1 Shows all the datasets which have his CMSSW release
  • dataset site = T2_BR_SPRACE Shows all datasets which are available in SPRACE

How to create my own track collection?

(Caio) I have a RAW-RECO data file and I would like to create a track collection, like the "generalTracks" one, but something along the lines of a "myTracks" collection, where I put only tracks which pass a certain set of requirements. I would like to save that "myTracks" collection in other data file to be run over with cmsRun. How can I do that?

(Thiago) Use the following EDFilter, with the parameters you want:

process.myTracks = cms.EDFilter("RecoTrackSelector",
    src = cms.InputTag("generalTracks"),
    maxChi2 = cms.double(10000.0),
    tip = cms.double(120.0),
    minRapidity = cms.double(-5.0),
    lip = cms.double(300.0),
    ptMin = cms.double(0.1),
    maxRapidity = cms.double(5.0),
    quality = cms.vstring('loose'),
    algorithm = cms.vstring(),
    minHit = cms.int32(3),
    min3DHit = cms.int32(0),
    beamSpot = cms.InputTag("offlineBeamSpot")
)

and add an OutputModule to save your new tracks into the output file.

process.out = cms.OutputModule("PoolOutputModule",
    fileName = cms.untracked.string('patTuple.root'),
    outputCommands = cms.untracked.vstring(
        'keep *_myTracks_*_*',
    )
)

ROOT

Changing the individual colors of entries in a TLegend

(Thiago) If you want to change the individual colors of entries in a TLegend (for matching the colors of the objects they're related to), use the following recipe:

// Say that you have a valid pointer for the TLegend
TLegend* leg = (TLegend*)0x0000000106bcfe20;
// Get the list of entries
TList* list->GetListOfPrimitives();
// Get each entry individually
TLegendEntry* l1 = (TLegendEntry*)list->At(0);
TLegendEntry* l2 = (TLegendEntry*)list->At(1);
// Now you can set text attributes
l1->SetTextColor(kBlue)
l2->SetTextColor(kRed)

N-dimensional histograms with ROOT

(Caio) I know its possible to make an up-to-10 dimensions using ROOT. How to declare it and manipulate its content? (Caio) N-dimensional histograms are declared using THnSparse as following:

    //                 {qT, qL, kT,  Nch}
    Int_t bins[4] =    {40, 40, 100, 150};
    Double_t xmin[4] = {0., 0., 0.,  0.};
    Double_t xmax[4] = {2., 2., 5.,  150.};
    THnSparse *FourDHistogram = new THnSparseF("4d-hist", "4d-hist", 4, bins, xmin, xmax);
    FourDHistogram->Sumw2();

The call of Sumw2() right after histogram creation is to store statistics error. Although N-dimensional histogram is useful, is will use a lot of space in memory. If it space goes beyond 4 GB (that happened to me in a 5D histo) your program will crash. The best way to manipulate Ntuples of data is using TTree.

Dois Pads num Canvas sem o espaço em branco

(Angelo) Já vi no ROOT casos em que dois Pads (um em cima do outro) aparecem num único Canvas, mas sem a linha branca que aparece entre dois Pads quando se usa, por exemplo:

canvas->Divide(1,2)
canvas->cd(1)
canvas->cd(2)

Por exemplo: o Pad superior mostraria dois histogramas (data/MC), enquanto que o inferior mostraria algo como "(Data - MC)/sigma". Acredito que não se trata de usar canvas->Divide(1,2). Porém, deve haver alguma forma de dizer onde começa e onde termina cada Pad. Alguma idéia?

(Caio) Estava fazendo uns testes e encontrei essa opção:

//faz o seu Canvas
TCanvas *canvas = new TCanvas();
//depois cria dois Pads
TPad *pad1 = new TPad();
TPad *pad2 = new TPad();
//e desenha seus pads dentro do canvas
canvas->cd();
pad1->Draw();
pad2->Draw();
//os pads vao cobrir todo o canvas, precisa ir com o mouse e redimensionar eles
//note que o pad2 vai ficar por cima do pad1
//aí vc desenha seu gráfico principal no pad1
pad1->cd();
grafico->Draw("ap");
//e o de residuos no pad 2
pad2->cd();
residuos->Draw();
//ai tem que ajustar com o mouse pro pad2 ficar por cima do eixo-X do pad 1

Esse gráfico é um exemplo de como as coisas podem ficar, e esse é o arquivo root correspondente. É uma solução meio grosseira, mas funcional. Alguma idéia melhor?

(Angelo) Após testar o seu método, achei uma novo caminho que permite fazer tudo automático sem a necessidade de usar o mouse. Basta colocar as dimensões correspondentes do pad usando Pad(), além de funcões como SetTopMargin() e SetBottomMargin():

TCanvas *canvas = new TCanvas();
canvas->cd();
// Aqui você declara as dimensões do pad superior, por exemplo.
// A ordem correta é TPad("", "", xMin, yMin, xMax, yMax)
TPad *pad1 = new TPad("pad1","",0.,0.3,1.,1.);
pad1->Draw();
pad1->cd();
// Desapareça com que o espaço em branco na parte de baixo do pad superior.
pad1->SetBottomMargin(0.);
// Se preferir, apague o label e o título do eixo "x" do gráfico superior.
grafico1->GetXaxis()->SetLabelSize(0.);
grafico1->GetXaxis()->SetTitleSize(0.);
grafico1->Draw();
canvas->cd();
// Aqui o pad inferior é declarado.
// Veja que o eixo vertical ("y") do pad2 termina onde o pad1 começa.
TPad *pad2 = new TPad("pad2","",0.,0.,1.,0.3);
pad2->Draw();
pad2->cd();
// Desapareça com que o espaço em branco no top do pad inferior
pad2->SetTopMargin(0.0);
// Diga ao ROOT onde que o gráfico do pad inferior vai ser iniciado.
// Isto é importante para permitir que o label do eixo "x" apareça e não seja cortado.
pad2->SetBottomMargin(0.2);
// É provável que não seja possível ver o label do gráfico do pad2, pois pode
// estar automaticamente com tamanho "0".
// Caso isso acontença, forneça o tamanho do label e do título. Por exemplo:
grafico2->GetXaxis()->SetLabelSize(0.07);
grafico2->GetXaxis()->SetTitleSize(0.07);
grafico2->Draw();

Como construir histogramas com bins não homogêneos?

(Angelo) Esse é um exemplo de como plotar histogramas com bins variáveis (Franciole's example):

void variable_bin(){

  //histo with variable size bins

  //# of bins = 3 
  int nbins = 3;

  //# of edges. Includes the lowest and highest
  const int nedges = nbins+1;

  //Defines edges
  float xbins[nedges] = {0.0,1.0,3.0,6.0};

  //creates histo
  TH1F *hvar = new TH1F("hvar","hvar title",nbins,xbins);

  //Writes width of all bins
  //Note bin zero is reserved for other purposes (see ROOT documentation)
  //size will be equals to 1
  std::cout << "first bin size:  " << hvar->GetBinWidth(1) << std::endl;
  std::cout << "second bin size: " << hvar->GetBinWidth(2) << std::endl;
  std::cout << "third bin size:  " << hvar->GetBinWidth(3) << std::endl;
}

Grid

First login to access machine

To log on, use ssh

 ssh <username>@access.sprace.org.br 

Set up the CMS VO certificate according to instructions here. Verify it all works by executing

voms-proxy-init --voms cms

To navigate through the T2_BR_SPRACE storage use srmls command

srmls srm://osg-se.sprace.org.br:8443/srm/managerv2?SFN=/pnfs/sprace.org.br/data/cms/store/user/<username>

More useful srm commands here.

Using condorg

(Franciole) Temos utilizado o cluster com o condorg para fazer parte de nossas analises. Os jobs variam desde producao de ntuplas, pequenas producoes de MC, codigos privados do ROOT e por ai vai. No entanto, temos cada um uma solucao particular para seu problema. Sera que poderiamos partilhar essas solucoes? Sera que isso ajudaria num futuro proximo?

(Caio) I create a TTree with cmsRun and then run ROOT over it using condor. This is the way how to do that:

tar-compact the area where your ROOT macro are. The TTree might be in this directory or it can be in the storage element.

tar -czvf CMSSW_3_6_2.tgz CMSSW_3_6_2/

then gets proxy

grid-proxy-init -debug -verify

voms-proxy-init -voms cms

and submit the job with

condor_submit condor_run

The script I pass to condor to run ROOT is this. (see this link for useful information about bash programming). This is the condor configuration file (might be obsolete, not sure).

(Cesar) Eu utilizo um script similar a esse do Caio para executar o cmsRun com o condor_g ( condor_test). Testei uns dois dias atrás e funcionou na versão CMSSW_4_2_5. O arquivo de configuração no caso lê um arquivo .root do dCache. Não consegui fazer funcionar quando o aquivo .root está na tarball, ou seja, em um dos subdiretórios do CMSSW (Alguém tem alguma idéia? Já tentei usar $WORKING_DIR/CMSSW_4_2_5/src/flatTuple/patTuple_PATandPF2PAT.root e $IWD/CMSSW_4_2_5/src/flatTuple/patTuple_PATandPF2PAT.root, uma vez que o caminho na access, por exemplo, seria /home/bernardes/CMSSW_4_2_5/src/flatTuple/patTuple_PATandPF2PAT.root). A solução encontrada no momento foi copiar o arquivo para meu diretório no dCache, usando:

srmcp -2 file:///CMSSW_4_2_5/src/flatTuple/patTuple_PATandPF2PAT.root srm://osg-se.sprace.org.br:8443/srm/managerv2?SFN=/pnfs/sprace.org.br/data/cms/store/user/caber/te st/patTuple_PATandPF2PAT.root

Opening files in dcap

(Caio) It is possible to open ROOT with a file in dcap as paremeter. The syntax (thanks to Marco) is given in the following example, where the file 7TeV_Jul16th_Tree_All+-Tracks_2Nch150_noSplitTracks-beamSpot_Rxy.root is opened

root dcap://osg-se.sprace.org.br:/pnfs/sprace.org.br/data/cms/store/user/lagana/7TeV_Jul16th_Tree_All+-Tracks_2Nch150_noSplitTracks-beamSpot_Rxy.root
root [0] 
Attaching file dcap://osg-se.sprace.org.br:/pnfs/sprace.org.br/data/cms/store/user/lagana/7TeV_Jul16th_Tree_All+-Tracks_2Nch150_noSplitTracks-beamSpot_Rxy.root as _file0...
root [2] _file0->ls()
TDCacheFile**           dcap://osg-se.sprace.org.br/pnfs/sprace.org.br/data/cms/store/user/lagana/7TeV_Jul16th_Tree_All+-Tracks_2Nch150_noSplitTracks-beamSpot_Rxy.root
 TDCacheFile*           dcap://osg-se.sprace.org.br/pnfs/sprace.org.br/data/cms/store/user/lagana/7TeV_Jul16th_Tree_All+-Tracks_2Nch150_noSplitTracks-beamSpot_Rxy.root
  KEY: TTree    track_tree;2    track_tree
  KEY: TTree    track_tree;1    track_tree
  KEY: TH1F     Rxy;1   Ray
  KEY: TTree    ev_tree;1       ev_tree

To hadd several root files located in the storage, make a list of root_files_to_merge.txt and use the haddScript.sh

source haddScript.sh root_files_to_merge.txt

Useful srmcp commands

To request a proxy valid for seven days, execute:

voms-proxy-init --voms cms -valid 168:00

To get information about the proxy, execute:

voms-proxy-info --all

These are some useful srm commands

  • Listing files at T2_SPRACE
 srmls srm://osg-se.sprace.org.br:8443/srm/managerv2?SFN=/pnfs/sprace.org.br/data/cms/store/user/lagana/MinimumBias/MB-C10-398p2-MINBIASTRKANASKIM-v3

  • Delete files at T2_SPRACE
 srmrm srm://osg-se.sprace.org.br:8443/srm/managerv2?SFN=/pnfs/sprace.org.br/data/cms/store/user/jruizvar/test.root

To delete several files at once, type the names in a list_to_remove.txt and use xargs command

xargs srmrm < list_to_remove.txt

  • Making a new directory at T2_SPRACE
srmmkdir srm://osg-se.sprace.org.br:8443/srm/managerv2?SFN=/pnfs/sprace.org.br/data/cms/store/user/lagana/MinimumBias/MB-C10-398p2-MINBIASTRKANASKIM-v3

  • Copying from T2_SPRACE to directory at access
srmcp srm://osg-se.sprace.org.br:8443/pnfs/sprace.org.br/data/cms/store/himc/Fall10/Hydjet_Quenched_MinBias_2760GeV/GEN-SIM-RECO/Pyquen_GammaJet_pt15_MC_38Y_V12-v2/0001//2439BAA1-FDDF-DF11-ACC0-001D096760DE.root file:////home/lagana/2439BAA1-FDDF-DF11-ACC0-001D096760DE.root

You can also use the this: copy_from_SPRACE.txt

  • Copying from directory at access to T2_SPRACE
srmcp -2 file:///rootlogon.C srm://osg-se.sprace.org.br:8443/srm/managerv2?SFN=/pnfs/sprace.org.br/data/cms/store/user/lagana/rootlogon.C

  • Copying from castor to SPRACE:
srmcp --debug=true  -srm_protocol_version=2 srm://srm-cms.cern.ch:8443/srm/managerv2?SFN=/castor/cern.ch/user/m/mohammed/MC_PYTHIA8/edmfile_9900.root file:////home/lagana/edmfile_9900.root

  • Listing files at T2_MIT
srmls -2 srm://se01.cmsaf.mit.edu:8443/srm/v2/server?SFN=/mnt/hadoop/cms/store/user/davidlw/MinimumBias/

  • Copying 1 file from T2_MIT to T2_SPRACE
srmcp -2 srm://se01.cmsaf.mit.edu:8443/srm/v2/server?SFN=/mnt/hadoop/cms/store/user/davidlw/MinimumBias/MB-C10-398p2-MINBIASTRKANASKIM-v3/b6b6bdfea548f61b58c6395522e54da5/nohup.out srm://osg-se.sprace.org.br:8443/srm/managerv2?SFN=/pnfs/sprace.org.br/data/cms/store/user/lagana/nohup.out

  • Copying many files from T2_MIT to T2_SPRACE
for i in $(srmls -2 srm://se01.cmsaf.mit.edu:8443/srm/v2/server?SFN=/mnt/hadoop/cms/store/user/davidlw/MinimumBias/MB-C10-398p2-MINBIASTRKANASKIM-v3/b6b6bdfea548f61b58c6395522e54da5/ | cut -d " " -f 8 | cut -c115-); do echo "srmcp -2 srm://se01.cmsaf.mit.edu:8443/srm/v2/server?SFN=/mnt/hadoop/cms/store/user/davidlw/MinimumBias/MB-C10-398p2-MINBIASTRKANASKIM-v3/b6b6bdfea548f61b58c6395522e54da5/$i srm://osg-se.sprace.org.br:8443/srm/managerv2?SFN=/pnfs/sprace.org.br/data/cms/store/user/lagana/MinimumBias/MB-C10-398p2-MINBIASTRKANASKIM-v3/$i";done

  • Saving srmls output in a format ready to be read by _cfg.py file
for i in $(srmls srm://osg-se.sprace.org.br:8443/srm/managerv2?SFN=/pnfs/sprace.org.br/data/cms/store/user/lagana/MinimumBias/MB-C10-398p2-MINBIASTRKANASKIM-v3 | cut -d " " -f 8 | cut -c29-); do echo "'$i',";done > to_cfg_file.out

Using CRAB to publish FullSim dataset in 2012

(César) We have some instructions to do FullSim using CRAB in FullSim2012

Analysis in 2012

(Thiago) I am going to prepare a Twiki about the analyses we will be setting up in 2012. It will reside in AnalysisSprace

Analysis in 2013

(Cesar) Detailed recipe for DoubleMuon HLT triggers in EXOTICA here .

(Jose) Pixel Detector Simulation. Instructions here.

(Angelo) AngeloLogBook: this is Angelo's log book of work.

Analysis in 2014

(Jose) Efficiency and fake rate of the cut-based electron ID for Run2. Link.

Subscription

Para receber um email de notificação toda vez que alguém faz alguma modificação no Analysis Open Space, coloque seu nome nessa área do WebNotify.

-- CaioLagana - 18 Jul 2011 -- ThiagoTomei - 09 May 2012

Topic attachments
I Attachment History Action Size Date Who Comment
Texttxt Zprime_M1500GeV_to_WW_8TeV_pythia8_cff_py_GEN_SIM.py.txt r1 manage 4.0 K 2012-09-03 - 19:14 CesarBernardes  
Texttxt Zprime_M1500GeV_to_WW_8TeV_pythia8_cff_py_GEN_SIM_REDIGI_DIGI_L1_DIGI2RAW_HLT_PU.py.txt r1 manage 3.5 K 2012-09-03 - 19:54 CesarBernardes  
Unknown file formatEXT condor_ROOT r2 r1 manage 0.6 K 2011-10-21 - 18:38 CaioLagana script para rodar ROOT via condor
Unknown file formatEXT condor_run r1 manage 0.5 K 2011-09-20 - 02:50 CaioLagana condor default script
Unknown file formatEXT condor_run_root r1 manage 0.5 K 2011-10-21 - 18:39 CaioLagana script para rodar ROOT via condor
Unknown file formatEXT condor_test r1 manage 0.9 K 2011-09-20 - 10:01 CesarBernardes condor_test
Texttxt copy_from_SPRACE.txt r2 r1 manage 0.7 K 2016-04-09 - 21:55 UnknownUser  
Unknown file formatcfg crab02.cfg r1 manage 1.1 K 2012-09-03 - 18:47 CesarBernardes  
Unknown file formatcfg crab03.cfg r1 manage 1.5 K 2012-09-03 - 20:11 CesarBernardes  
PNGpng dois-pads-num-canvas.png r1 manage 10.0 K 2011-07-23 - 17:26 CaioLagana Teste para desenhar dois graficos sem espaço entre eles
Unknown file formatroot dois-pads-num-canvas.root r1 manage 19.0 K 2011-07-23 - 19:18 CaioLagana  
Texttxt haddScript.sh.txt r1 manage 0.4 K 2015-02-17 - 20:31 UnknownUser Script to merge root files in the storage
Topic revision: r55 - 2016-09-21 - bernardes
 

This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback

antalya escort bursa escort eskisehir escort istanbul escort izmir escort