xml VPD频道生活(和映射)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了xml VPD频道生活(和映射)相关的知识,希望对你有一定的参考价值。


#include <iostream>
#include <algorithm>    // std::sort
#include <vector>       // std::vector

using namespace std;

bool found( vector<int> vec, int val ){

	for ( int i = 0; i < vec.size(); i++){
		if ( val == vec[ i ] )
			return true;
	}
	return false;

}


void channelLife( string filename = "cLife.xml" ){


	gStyle->SetOptStat( 0 );

	// get the config file
	// has data location
	// reporter output file
	// HistoBook output file etc.
	XmlConfig * cfg = new XmlConfig( filename );

	
	/**
	 * Setup the logger, reporter, and HistoBook - make all histograms
	 */
	Logger::setGlobalLogLevel( Logger::llAll );

	Logger logger;

	Reporter rp( cfg, "Reporter." );

	HistoBook book( "hbChannelLife.root", cfg );
	book.makeAll( "histograms" );

	string det=cfg->getString( "Detector" , "West" );
	int detOff = 0;
	if ( "East" == det )
		detOff = 19;


	/*
	 * Setup the chain
	 */
	//TChain * chain = new TChain( cfg->getString( "input.dst:treeName" ).c_str() );
	//ChainLoader::load( chain, cfg->getString( "input.dst:url" ), cfg->getInt( "input.dst:maxFiles", -1 ) );
	//TreeMap ds( chain );
	DataSource ds( cfg, "DataSource" );

	int nEvents = ds.getEntries();

	return;

	logger.info() << "nEvents = " << nEvents << endl;
	TaskTimer tt;
	tt.start();

	/**
	 * Loop through events to make a list of run numbers
	 */
	vector<int> runNumbers;
	vector<int> sortedRunNumbers;
	for ( int i = 0; i < nEvents; i++ ){

		ds.getEntry( i );
		int run = ds.get( "run" );
		if ( 16009013 == run ) // this run was marked as junk but i accidentally included it
			continue;
		
		if ( !found( runNumbers, run ) ){
			runNumbers.push_back( run );
			logger.trace() << "Run# " << ts( run ) << endl;
		}
	}

	while( runNumbers.size() > 0 ){

		int minRun = 100000000;
		int index = -1;
		for ( int i = 0; i < runNumbers.size(); i++ ){
			if ( runNumbers[ i ] < minRun ){
				minRun = runNumbers[ i ];
				index = i;
			}
		}

		if ( index >= 0 ){
			sortedRunNumbers.push_back( minRun );
			runNumbers.erase( runNumbers.begin()+index );	
		}
	}

	vector<string> histos = cfg->childrenOf( "histograms" );
	for ( int i = 0; i < histos.size(); i++ ){
		string hName = cfg->getString( histos[ i ] + ":name" );
		for ( int j = 0; j < sortedRunNumbers.size(); j ++ ){
			string rn = ts( sortedRunNumbers[ j ] );
			book.clone( hName, hName + "_" + rn );
		}
		
	}

	book.make2D( "offline", det+" Offline (HPTDC);Run Number;PMT Channel", sortedRunNumbers.size(), 0, sortedRunNumbers.size(), 19, detOff, 19+detOff );
	book.make2D( "online", det + " Online (Bbq);Run Number;PMT Channel", sortedRunNumbers.size(), 0, sortedRunNumbers.size(), 16, 0, 16 );

	book.get2D( "offline" )->SetBit( TH1::kCanRebin );
	book.get2D( "online" )->SetBit( TH1::kCanRebin );

	/**
	 * Loop through events
	 */
	
	for ( int i = 0; i < nEvents; i++ ){

		ds.getEntry( i );
		int run = ds.get( "run" );
		string rn = "_"+ts(run);

		for ( int j= 0; j < 19; j ++ ){

			if ( j < 16 ){
				book.fill( "bbqAdc", j, ds.get( "vpdBbqAdc"+det, j ) );
				book.fill( "bbqTdc", j, ds.get( "vpdBbqTdc"+det, j ) );
			}

			book.fill( "le", j, ds.get( "vpdLe"+det, j ) );
			book.fill( "tot", j, ds.get( "vpdTot"+det, j ) );

			if ( j < 16 ){
				book.fill( "bbqAdc"+rn, j, ds.get( "vpdBbqAdc"+det, j ) );
				book.fill( "bbqTdc"+rn, j, ds.get( "vpdBbqTdc"+det, j ) );
			}

			book.fill( "le"+rn, j, ds.get( "vpdLe"+det, j ) );
			book.fill( "tot"+rn, j, ds.get( "vpdTot"+det, j ) );


		}
	}

	int threshold = 1;
	for ( int j = 0; j < sortedRunNumbers.size(); j ++ ){
		string rn = "_"+ts( sortedRunNumbers[ j ] );

		//cout << "Run " << rn << endl;
		for ( int i = 0; i < 19; i++ ){
			int hits = book.get2D( "tot" + rn )->ProjectionY( "_py", i+1, i+1 )->Integral( 2, -1);

			if ( 5 == i || 13 == i || 14 == i )
				hits = 0;
			if ( hits > threshold ){
				char * binLabel = ts(sortedRunNumbers[ j ]).c_str();
				book.get2D( "offline" )->Fill( binLabel, (int)i+detOff, 1 );
			}

		}
	}

	book.get2D( "offline" )->LabelsDeflate("X");

	for ( int j = 0; j < sortedRunNumbers.size(); j ++ ){
		string rn = "_"+ts( sortedRunNumbers[ j ] );

		//cout << "Run " << rn << endl;
		for ( int i = 0; i < 16; i++ ){
			int hits = book.get2D( "bbqTdc" + rn )->ProjectionY( "_py", i+1, i+1 )->Integral( 10, -1);

			if ( hits > threshold ){
				char * binLabel = ts(sortedRunNumbers[ j ]).c_str();
				book.get2D( "online" )->Fill( binLabel, i, 1 );
			}

		}
	}



	rp.newPage( 1, 2 );
	book.style( "offline" )->set("draw", "colz")->draw();
	rp.next();
	book.style( "online" )->set("draw", "colz")->draw();
	rp.savePage();
	/**
	 * Print out a little report showing each channel's total activity
	 */
	rp.newPage( 1, 2 );
	book.style( "le" )->set( "draw", "colz" )->set( "logZ", 1 )->draw();
	rp.next();
	book.style( "tot" )->set( "draw", "colz" )->set( "logZ", 1 )->draw();
	rp.savePage();

	rp.newPage( 1, 2 );
	book.style( "bbqAdc" )->set( "draw", "colz" )->set( "logZ", 1 )->draw();
	rp.next();
	book.style( "bbqTdc" )->set( "draw", "colz" )->set( "logZ", 1 )->draw();
	rp.savePage();


	for ( int j = 0; j < sortedRunNumbers.size(); j ++ ){
		string rn = "_"+ts( sortedRunNumbers[ j ] );
		

		rp.newPage( 1, 2 );
		book.style( "le"+rn )->set( "draw", "colz" )->set( "logZ", 1 )->
		set("title", ts( sortedRunNumbers[ j ] ) + " le" )->draw();
		rp.next();
		book.style( "tot"+rn )->set( "draw", "colz" )->set( "logZ", 1 )->
		set("title", ts( sortedRunNumbers[ j ] ) + " tot" )->draw();
		rp.savePage();

		rp.newPage( 1, 2 );
		book.style( "bbqAdc"+rn )->set( "draw", "colz" )->set( "logZ", 1 )->
		set("title", ts( sortedRunNumbers[ j ] ) + " bbq Adc" )->draw();
		rp.next();
		book.style( "bbqTdc"+rn )->set( "draw", "colz" )->set( "logZ", 1 )->
		set("title", ts( sortedRunNumbers[ j ] ) + " bbq Tdc" )->draw();
		rp.savePage();


	}


	logger.info() << "Finished in " << tt.elapsedTime() << endl;



}
<?xml version="1.0" encoding="UTF-8"?>

<!-- A root node is required -->
<!--  It can be anything <root></root>, it just has to exist -->
<config>
			
	<input>
		<dst treeName="tof" maxFiles="2" nEvents="10000" url="/Users/danielbrandenburg/bnl/local/"/>
	</input>
	
	<Logger>
		<logLevel>all</logLevel>
	</Logger>

	<Detector>West</Detector>


	<Reporter>
		<output url="rpChannelLife.pdf"/>
	</Reporter>

	<histograms>
		<Histo name="bbqAdc" title="bbqAdc" nBinsX="16" minX="0" maxX="16" nBinsY="50" minY="1" maxY="500" />
		<Histo name="bbqTdc" title="bbqTdc" nBinsX="16" minX="0" maxX="16" nBinsY="100" minY="1" maxY="3000" />

		<Histo name="le" title="le" nBinsX="19" minX="0" maxX="19" nBinsY="50" minY="1" maxY="50000" />
		<Histo name="tot" title="tot" nBinsX="19" minX="0" maxX="19" nBinsY="20" minY="5" maxY="50" />

	</histograms>


</config>

以上是关于xml VPD频道生活(和映射)的主要内容,如果未能解决你的问题,请参考以下文章

EBS VPD介绍和使用实例

使用 NAudio 进行频道映射

将 PDF 转换为 XML 结构

PostgreSQL 中的 VPD(虚拟私有数据库)[关闭]

如何按某个属性排序进行映射

各种波形文件VCD,VPD,SHM,FSDB生成的方法