PelROOT
The Pelletron-Linac data analysis tools for ROOT

How to create a new FIL with new parameters

The basic idea of creating a new FIL file with different parameters comes from the need of calibrating parameters or just filter events (to reduce file size). This is possible with ScanRoot. ScanRoot object in the memory has a method to add new parameters. If an output file is open these new parameters will be saved (you can choose if you save only new parameters or all of them.

The procedure is the following: The above list of actions can be automated in a macro file. Bellow is an example of a macro file that automates this process. To execute the macro, save it with the name exemploFilter.C, open scanroot and type:
.x exemploFilter.C
Bellow is the macro example:
void exemploFilter()
{
	//carrega filtro de eventos
	loadL2("filter.cxx");
	
	// liga smearing (se true). O smearing sorteia
	// um valor real dentro de um canal. Isso evita 
	// problemas de binagem quando faz-se uma operacao
	// de mudanca de ganho, por exemplo
	// a funcao de smearing so esta disponivel a partir
	// da versao 4.00 do scanroot
	// se a sua versao for anterior, comente essa linha
	smearing(true);
	
	// decide se grava somente novos parametros (true)
	// ou se grava todos os parametros (false)
	saveOnlyNewPar(true);

        // seta o numero maximo de parametros (default = 128)
        setNPar(110);
	
        // abre o arquivo para leitura
	openInput("run10.fil");
	
	// abre um arquivo para escrita
	openOutput("run10_novo.fil");

	// processa os eventos
	go();
	
	// fecha output
	closeOutput();
	
	// fecha input
	closeInput();
	
	// a partir deste ponto voce pode repetir o processo. Para
	// processar um novo fil mas com o mesmo filtro e mesmas
	// configuracoes basta os comandos (as linhas estao comentadas)
	
	// openInput("run11.fil");
	// openOutput("run11_novo.fil");
	// go();
	// closeOutput();
	// closeInput();
}
The filtering code example is bellow. In this case, we create two new parameters (101 and 102) using the method addPar() that corresponds to the gain corrections we need to apply to parameters 1 and 2.
#include 
#include "ScanRoot.h"

using namespace std;
ScanRoot* meuScan = 0;
float ganho1, ganho2;

bool filtro(short npar, float *par)
{
        // nao grava se o evento for vazio
	if(npar==0) return false; 
		
        // um exemplo simples: Correcao de ganho de dois
	// parametros.
	//
	// note que nao podemos mudar o valor de um parametro
	// original. Somente podemos criar parametros novos.
	// os parametros novos terão id = 101 e 102
	// 
	// OBS: Substituindo parametros
	// ----------------------------
	// no caso se eu quiser substituir o valor de um
	// parametro eu devo criar um parametro novo com
	// o mesmo id do velho. Neste caso, se voce
	// nao setar que quer gravar somente os parametros
	// novos resultara em dois parametros de mesmo
	// identificador no arquivo. No caso do scanroot,
	// quando for ler o arquivo, o ultimo na sequencia
	// de dados sera o lido no evento. Neste caso, o
	// parametro modificado. Nao sei as consequencias
	// caso va ler o arquivo no SCAN normal, neste caso
	
	if(par[1]>0) meuScan->addPar(101, ganho1*par[1]);
	if(par[2]>0) meuScan->addPar(102, ganho2*par[2]);
	
	// para gravar o evento, precisa retornar true;
	return true;
}
void configureL2(ScanRoot* scan)
{
 	// inicializando os ganhos
	ganho1 = 1.23;
	ganho2 = 0.93;

	// esta linha conecta a funcao de filtro do ScanRoot
	// na sua funcao pessoal, neste caso, com o nome filtro
        scan->l2trigger = &filtro;
	
	// inicializo o ponteiro meuScan para o scan na memoria,
	// assim eu posso utiliza-lo em outras funcoes do
	// meu programa
	meuScan = scan;
    
        return;
}
void initL2()
{
}
void finishL2()
{
}

25 04 07 - 13:30 |

Last Comments
  
Remember personal info?

Emoticons / Textile


 

  ( Register your username / Log in )

Notify:
Hide email:

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.

Options:

Calendar

« May 2024
S M T W T F S
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  

Last Comments

admin (version 3.01): Both men and women are wo…
Appannababu (Make your questio…): Hello Patrico, Thanks, I …
Patricio Carnelli… (Make your questio…): Hi Appannababu, This scri…
Appannababu (Make your questio…): Hello, I am new t…
cheap nashville p… (Using Graphical C…): Thanks for your sharing.i…
Supra Skytop (version 3.01): This topic was really edu…
Supra Sneakers (Using Graphical C…): Hey, appreciate it for ta…
Patricio Carnelli… (Make your questio…): Hello, I’m a PhD student …
Bob (Pivot 1.30 Beta 2…): And this is what a commen…

Search site

Archives

01 Sep - 30 Sep 2006
01 Dec - 31 Dec 2006
01 Jan - 31 Jan 2007
01 Feb - 28 Feb 2007
01 Mar - 31 Mar 2007
01 Apr - 30 Apr 2007
01 Jun - 30 Jun 2007
01 Oct - 31 Oct 2007
01 May - 31 May 2008
01 Oct - 31 Oct 2008
01 May - 31 May 2013
01 Nov - 30 Nov 2013
01 Jun - 30 Jun 2014

RSS & Atom

XML: RSS Feed XML: Atom Feed