本文整理汇总了C++中TLeaf::GetValue方法的典型用法代码示例。如果您正苦于以下问题:C++ TLeaf::GetValue方法的具体用法?C++ TLeaf::GetValue怎么用?C++ TLeaf::GetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TLeaf
的用法示例。
在下文中一共展示了TLeaf::GetValue方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getDataProfile
void DataInterface::getDataProfile(TH2F *hProfile, TH2F *hProjection, Int_t energy) {
if (!existsEnergyFile(energy)) {
cout << "There are no data files with energy " << energy << endl;
return;
}
TString fn = Form("Data/ExperimentalData/DataFrame_%i_MeV.root", energy);
TFile *f = new TFile(fn);
TTree *tree = (TTree*) f->Get("tree");
Int_t nentries = tree->GetEntries();
printf("Found %d frames in the DataFrame.\n", nentries);
TLeaf *lX = tree->GetLeaf("fDataFrame.fX");
TLeaf *lY = tree->GetLeaf("fDataFrame.fY");
TLeaf *lLayer = tree->GetLeaf("fDataFrame.fLayer");
Float_t x, y, layer;
for (Int_t i=0; i<nentries; i++) {
tree->GetEntry(i);
for (Int_t j=0; j<lY->GetLen(); j++) {
x = lX->GetValue(j) + nx/2;
y = lY->GetValue(j) + ny/2;
layer = lLayer->GetValue(j);
hProfile->Fill(y, layer);
hProjection->Fill(x, y);
}
}
}
示例2: addTree
void NCIdeogram::addTree(TTree *tree, const char *mu, const char *sigma)
{
TLeaf *leafMu = tree->FindLeaf(mu);
TLeaf *leafSigma = tree->FindLeaf(sigma);
TEventList *elist = tree->GetEventList();
Long64_t j,ix,nbr;
nbr = elist ? elist->GetN() : tree->GetEntries();
for (j = 0; j < nbr; j++) {
ix = elist ? elist->GetEntry(j) : j;
tree->GetEntry(ix);
addPoint(leafMu->GetValue(), leafSigma->GetValue());
}
} // addTree()
示例3: getDataFrame
void DataInterface::getDataFrame(Int_t runNo, CalorimeterFrame * cf, Int_t energy) {
if (!existsEnergyFile(energy)) {
cout << "There are no data files with energy " << energy << endl;
return;
}
Int_t eventIdFrom = runNo * kEventsPerRun;
Int_t eventIdTo = eventIdFrom + kEventsPerRun;
TString fn = Form("Data/ExperimentalData/DataFrame_%i_MeV.root", energy);
TFile *f = new TFile(fn);
TTree *tree = (TTree*) f->Get("tree");
Int_t nentries = tree->GetEntries();
if (eventIdTo > nentries) {
eventIdTo = nentries;
}
cout << "Found " << nentries << " frames in the DataFrame.\n";
TLeaf *lX = tree->GetLeaf("fDataFrame.fX");
TLeaf *lY = tree->GetLeaf("fDataFrame.fY");
TLeaf *lLayer = tree->GetLeaf("fDataFrame.fLayer");
Int_t counter = 0;
for (Int_t i=eventIdFrom; i<eventIdTo; i++) {
tree->GetEntry(i);
for (Int_t j=0; j<lX->GetLen(); j++) {
Int_t x = lX->GetValue(j) + nx/2;
Int_t y = lY->GetValue(j) + ny/2;
Int_t z = lLayer->GetValue(j);
cf->fillAt(z, x, y);
}
counter++;
}
delete f;
}
示例4: CacheTestMCProductions
/// \brief Cache MC production trees, store summary information in formated text files -> root trees
/// \param dataType -
/// \param fileList
void CacheTestMCProductions(TString dataType, const char *fileList=NULL){
AliExternalInfo info;
info.fLoadMetadata=kFALSE;
TObjArray* periodList = NULL;
TArrayI nRuns;
if (fileList!=NULL) {
periodList=(gSystem->GetFromPipe(TString::Format("cat %s", fileList).Data())).Tokenize("\n");
nRuns.Set(periodList->GetEntries());
}else{
TTree * tree = info.GetTree("MonALISA.ProductionMC","","");
Int_t nProd=tree->GetEntries();
periodList = new TObjArray(nProd);
nRuns.Set(nProd);
TLeaf *leaf = tree->GetLeaf("Tag");
TLeaf *leafRuns = tree->GetLeaf("Number_of_runs");
for (Int_t iProd=0; iProd<nProd; iProd++){
tree->GetEntry(iProd);
TString prodName=((char*)leaf->GetValuePointer());
if (prodName.Contains("LHC")==0) continue;
periodList->AddAt(new TObjString(((char*)leaf->GetValuePointer())),iProd);
nRuns[iProd]=leafRuns->GetValue();
}
delete tree;
}
for (Int_t iPeriod=0; iPeriod<periodList->GetEntriesFast(); iPeriod++){
TObjString * pName= (TObjString*)periodList->At(iPeriod);
if (pName==NULL) continue;
TTree* tree = info.GetTree(dataType.Data(),periodList->At(iPeriod)->GetName(),"passMC");
if (tree){
Int_t entries=tree->Draw("run","1","goff");
TString sInfo=periodList->At(iPeriod)->GetName();
sInfo+="\t";
sInfo+=dataType;
sInfo+="\t";
sInfo+=TString::Format("%d\t",entries);
sInfo+=TString::Format("%d\t",nRuns[iPeriod]);
for (Int_t j=0; j<entries; j++) {
sInfo+=TString::Format("%2.0f,",tree->GetV1()[j]);
::Info("CacheTestMCProductionsRun:","%s\t%s\t%d\t%d\t%d\t%2.0f",periodList->At(iPeriod)->GetName(),dataType.Data(),entries,nRuns[iPeriod],j, tree->GetV1()[j]);
}
sInfo+="0";
::Info("CacheTestMCProductionsPeriod:","%s\n",sInfo.Data());
delete tree;
}else{
::Error("CacheTestMCProductionsPeriod:","%s\t%s\t-1\t%d\t0",periodList->At(iPeriod)->GetName(), dataType.Data(),nRuns[iPeriod]);
}
}
}
示例5: main
int main() {
// Get a map of the histograms of the Z Masses
const std::string Tree_HighCut = "ZFinder/Combined Single Reco/Combined Single Reco";
const std::string Tree_LowCut = "ZFinder/Combined Single Lowered Threshold Reco/Combined Single Lowered Threshold Reco";
const std::string file_name = "/data/whybee0a/user/gude_2/Data/20150324_SingleElectron_2012ALL/hadded.root";
// Open the file and load the tree
TTree* treeH = GetTTree(file_name, Tree_HighCut);
TBranch* event_infoH = treeH->GetBranch("event_info");
TLeaf* EVNumbH = event_infoH->GetLeaf("event_number");
// Pack into a hitogram
std::set<int> eventnumber;
std::set<int> eventnumberLow;
for (int i = 0; i < treeH->GetEntries(); i++) {
treeH->GetEntry(i);
if (eventnumber.find(EVNumbH->GetValue()) == eventnumber.end()) {
eventnumber.insert(EVNumbH->GetValue());
} else {
cout << "multiple events numbered :" << EVNumbH->GetValue()<<" in higher cuts" << endl;
}
}
TTree* TreeLow = GetTTree(file_name, Tree_LowCut);
TBranch* event_infoL = TreeLow->GetBranch("event_info");
TLeaf* EVNumbLow = event_infoL->GetLeaf("event_number");
for (int i = 0; i < TreeLow->GetEntries(); i++) {
TreeLow->GetEntry(i);
eventnumberLow.insert(EVNumbLow->GetValue());
if (eventnumberLow.find(EVNumbLow->GetValue()) == eventnumber.end()) {
eventnumberLow.insert(EVNumbLow->GetValue());
} else {
cout << "multiple events numbered :" << EVNumbLow->GetValue()<<" in lowered cuts" << endl;
}
}
return EXIT_SUCCESS;
}
示例6: analysis
int analysis(char* filename)
{
// char* filename = "combined.root";
// Read in the file
TFile* f = new TFile(filename);
TDirectory* hists = f->GetDirectory("hists;1");
TDirectory* tuples = f->GetDirectory("tuples;1");
TTree* accum = tuples->GetObjectUnchecked("AccumulatedEnergy;1");
TLeaf* einit = accum->GetLeaf("Einit");
TLeaf* edepo = accum->GetLeaf("Edep");
TTree* edeps = tuples->GetObjectUnchecked("EnergyDepositions;1");
TTree* secs = tuples->GetObjectUnchecked("SecondarySpectrum;1");
TLeaf* secsenergy = secs->GetLeaf("KineticEnergy");
double ein = 0;
double eout = 0;
int nevents = accum->GetEntries();
cout << "Making Summary\n";
FILE* summary = fopen("summ.txt", "a+");
for (int ii = 0; ii<nevents; ii++)
{
accum->GetEntry(ii);
ein+=einit->GetValue();
eout+=edepo->GetValue();
}
FILE* summary = fopen("summ.txt", "a+");
time_t t = time(NULL);
char* c_time_string = ctime(&t);
char* mytime[20];
strncpy(mytime, c_time_string, 19);
mytime[ strlen(mytime) - 1 ] = '\0';
fprintf(summary, "%s,%s,%e,%e\n", mytime, filename, ein, eout);//*c_time_string, *filename, ein, eout);
//cout << *c_time_string << "," << *filename << "," << ein << "," << eout << "\n";
fclose(summary);
// Print out or save these values
cout << "Making Histogram\n";
nevents = secs->GetEntries();
TH1F* secondaries = new TH1F("secondaries", "Secondary Electrons <100 keV", 92, 0.010, 0.102);
for (int ii = 0; ii<nevents; ii++)
{
secs->GetEntry(ii);
secondaries->Fill(secsenergy->GetValue());
}
char* suffix = ".secondaryhisto";
cout << "Making Filenames\n";
char* outfilename = malloc(strlen(filename) + strlen(suffix) + 1);
strcpy(outfilename, filename);
strcat(outfilename, suffix);
printf("Saving Histogram: %s \n", outfilename);
h12ascii(secondaries, outfilename);
return 0;
}
示例7: Example_tags
void Example_tags(TString topDir = "/star/rcf/GC/daq/tags")
{
//////////////////////////////////////////////////////////////////////////
// //
// Example_tags.C //
// //
// shows how to use the STAR tags files //
// Input: top level directory //
// //
// what it does: //
// 1. creates TChain from all tags files down from the topDir //
// 2. loops over all events in the chain //
// //
// owner: Alexandre V. Vaniachine <[email protected]> //
//////////////////////////////////////////////////////////////////////////
gSystem->Load("libTable");
gSystem->Load("St_base");
// start benchmarks
gBenchmark = new TBenchmark();
gBenchmark->Start("total");
// set loop optimization level
gROOT->ProcessLine(".O4");
// gather all files from the same top directory into one chain
// topDir must end with "/"
topDir +='/';
St_FileSet dirs(topDir);
St_DataSetIter next(&dirs,0);
St_DataSet *set = 0;
TChain chain("Tag");
while ( (set = next()) ) {
if (strcmp(set->GetTitle(),"file") ||
!(strstr(set->GetName(),".tags.root"))) continue;
chain.Add(gSystem->ConcatFileName(topDir,set->Path()));
}
UInt_t nEvents = chain->GetEntries();
cout<<"chained "<<nEvents<<" events "<<endl;
TObjArray *files = chain.GetListOfFiles();
UInt_t nFiles = files->GetEntriesFast();
cout << "chained " << nFiles << " files from " << topDir << endl;
TObjArray *leaves = chain.GetListOfLeaves();
Int_t nleaves = leaves->GetEntriesFast();
TString tableName = " ";
TObjArray *tagTable = new TObjArray;
Int_t tableCount = 0;
Int_t *tableIndex = new Int_t[nleaves];
Int_t tagCount = 0;
// decode tag table names
for (Int_t l=0;l<nleaves;l++) {
TLeaf *leaf = (TLeaf*)leaves->UncheckedAt(l);
tagCount+=leaf->GetNdata();
TBranch *branch = leaf->GetBranch();
// new tag table name
if ( strstr(branch->GetName(), tableName.Data()) == 0 ) {
tableName = branch->GetName();
// the tableName is encoded in the branch Name before the "."
tableName.Resize(tableName->Last('.'));
tagTable->AddLast(new TObjString(tableName.Data()));
tableCount++;
}
tableIndex[l]=tableCount-1;
}
cout << " tot num tables, tags = " << tableCount << " "
<< tagCount << endl << endl;
//EXAMPLE 1: how to print out names of all tags and values for first event
for (l=0;l<nleaves;l++) {
leaf = (TLeaf*)leaves->UncheckedAt(l);
branch = leaf->GetBranch();
branch->GetEntry();
// tag comment is in the title
TString Title = leaf->GetTitle();
Int_t dim = leaf->GetNdata();
if (dim==1) {
Title.ReplaceAll('['," '");
Title.ReplaceAll(']',"'");
}
cout << "\n Table: ";
cout.width(10);
cout << ((TObjString*)tagTable->UncheckedAt(tableIndex[l]))->GetString()
<<" -- has tag: " << Title << endl;
for (Int_t i=0;i<dim;i++) {
cout <<" "<< leaf->GetName();
if (dim>1) cout << '['<<i<<']';
cout << " = " << leaf->GetValue(i) << endl;
}
}
// EXAMPLE 2: how to make a plot
c1 = new TCanvas("c1","Beam-Gas Rejection",600,1000);
gStyle->SetMarkerStyle(8);
chain->Draw("n_trk_tpc[0]:n_trk_tpc[1]");
// EXAMPLE 3: how to make a selection (write selected event numbers on the plot)
//.........这里部分代码省略.........
示例8: main
int main() {
// Get7 a map of the histograms of the Z Masses
const std::string file_name = "/data/whybee0a/user/lesko_2/fermi/MadWithInitial/Mad2016_8_25/results/AllMHWithMothers.root";
// Open the file and load the tree
const std::string TreeName = "ZFinder/Combined Gen Cuts Reco/Combined Gen Cuts Reco";
TTree* tree = GetTTree(file_name, TreeName);
TBranch* reco = tree->GetBranch("reco");
TLeaf* PhiStar = reco->GetLeaf("z_phistar_born");
TLeaf* Mom1 = reco->GetLeaf("z_mom1PDG");
TLeaf* Mom2 = reco->GetLeaf("z_mom2PDG");
TLeaf* PenUltimateMom1 = reco->GetLeaf("z_penultimate1PDG");
TLeaf* PenUltimateMom2 = reco->GetLeaf("z_penultimate2PDG");
TLeaf* Z_YBorn = reco->GetLeaf("z_yBorn");
ExploreTree(tree, Mom1, PenUltimateMom1, Mom2, PenUltimateMom2);
TBranch* event_info = tree->GetBranch("event_info");
//TLeaf* EVNumb = event_info->GetLeaf("event_number");
// Pack into a hitogram
for (int w = 0; w < 2; w++) {
string PlotName;
TLeaf* MomOrPenUltimateMom1 = w == 0 ? Mom1 : PenUltimateMom1;
TLeaf* MomOrPenUltimateMom2 = w == 0 ? Mom2 : PenUltimateMom2;
vector<string> NamesOfPlots;
NamesOfPlots.push_back("UpQuarkPair"); //0
NamesOfPlots.push_back("DownQuarkPair"); //1
NamesOfPlots.push_back("StrangeQuarkPair"); //2
NamesOfPlots.push_back("CharmQuarkPair"); //3
NamesOfPlots.push_back("BottomQuarkPair"); //4
NamesOfPlots.push_back("SingleQuark"); //5
NamesOfPlots.push_back("Gluon"); //6
NamesOfPlots.push_back("TwoQuarks"); //7
NamesOfPlots.push_back("TwoAntiQuarks"); //8
NamesOfPlots.push_back("QuarkAntiQuarkPair"); //9
NamesOfPlots.push_back("QuarkAntiQuarkNotPair"); //10
NamesOfPlots.push_back("Quark Quark And AntiQuark AntiQuark"); //11
NamesOfPlots.push_back("Broken");
map<string, TH1*> AllPlots;
AllPlots[NamesOfPlots[0]] = new TH1D(NamesOfPlots[0].c_str(), NamesOfPlots[0].c_str(), nphistar, phistarBins);
AllPlots[NamesOfPlots[1]] = new TH1D(NamesOfPlots[1].c_str(), NamesOfPlots[1].c_str(), nphistar, phistarBins);
AllPlots[NamesOfPlots[2]] = new TH1D(NamesOfPlots[2].c_str(), NamesOfPlots[2].c_str(), nphistar, phistarBins);
AllPlots[NamesOfPlots[3]] = new TH1D(NamesOfPlots[3].c_str(), NamesOfPlots[3].c_str(), nphistar, phistarBins);
AllPlots[NamesOfPlots[4]] = new TH1D(NamesOfPlots[4].c_str(), NamesOfPlots[4].c_str(), nphistar, phistarBins);
AllPlots[NamesOfPlots[5]] = new TH1D(NamesOfPlots[5].c_str(), NamesOfPlots[5].c_str(), nphistar, phistarBins);
AllPlots[NamesOfPlots[6]] = new TH1D(NamesOfPlots[6].c_str(), NamesOfPlots[6].c_str(), nphistar, phistarBins);
AllPlots[NamesOfPlots[7]] = new TH1D(NamesOfPlots[7].c_str(), NamesOfPlots[7].c_str(), nphistar, phistarBins); //Two quarks
AllPlots[NamesOfPlots[8]] = new TH1D(NamesOfPlots[8].c_str(), NamesOfPlots[8].c_str(), nphistar, phistarBins); //Two Anti quarks
AllPlots[NamesOfPlots[9]] = new TH1D(NamesOfPlots[9].c_str(), NamesOfPlots[9].c_str(), nphistar, phistarBins); //
AllPlots[NamesOfPlots[10]] = new TH1D(NamesOfPlots[10].c_str(), NamesOfPlots[10].c_str(), nphistar, phistarBins);
AllPlots[NamesOfPlots[11]] = new TH1D(NamesOfPlots[11].c_str(), NamesOfPlots[11].c_str(), nphistar, phistarBins);
AllPlots[NamesOfPlots[12]] = new TH1D(NamesOfPlots[12].c_str(), NamesOfPlots[12].c_str(), nphistar, phistarBins);
map<string, TH1*> RatioPlots; //using normalized versions of the pairs to see shape changes
cout << "test 1" << endl;
//Vector<TH1*> YplotsFromParents;
//YplotsFromParents.push_back(new TH1D("YSeperatedUpQuarkPair", "UpQuarkPair", nY, yBins));
//YplotsFromParents.push_back(new TH1D("YSeperatedDownQuarkPair", "DownQuarkPair", nY, yBins));
//YplotsFromParents.push_back(new TH1D("YSeperatedStrangeQuarkPair", "StrangeQuarkPair", nY, yBins));
//YplotsFromParents.push_back(new TH1D("YSeperatedCharmQuarkPair", "CharmQuarkPair", nY, yBins));
//YplotsFromParents.push_back(new TH1D("YSeperatedBottomQuarkPair", "BottomQuarkPair", nY, yBins));
//YplotsFromParents.push_back(new TH1D("YSeperatedGluonQuarkPair", "GluonQuarkPair", nY, yBins));
//YplotsFromParents.push_back(new TH1D("YSeperatedGluon", "Gluon", nY, yBins));
//YplotsFromParents.push_back(new TH1D("YSeperatedUnmatchingQuarks", "UnmatchingQuarks", nY, yBins));
//TH2D* Parents = new TH2D("ParentsPDGId", "Parents PDGID", 28, -6.5, 21.5, 28, -6.5, 21.5);
TH2D* ProductionVsY = new TH2D("ProductionVsY", "ProductionVsY", 7, 0, 7, 6, yBins);
for (int i = 0; i < tree->GetEntries(); i++) {
tree->GetEntry(i);
if(PhiStar->GetValue()==-1)continue;
if (fabs(MomOrPenUltimateMom1->GetValue()) == 1 && -MomOrPenUltimateMom1->GetValue() == MomOrPenUltimateMom2->GetValue()) {
AllPlots["QuarkAntiQuarkPair"]->Fill(PhiStar->GetValue());
AllPlots["UpQuarkPair"]->Fill(PhiStar->GetValue());
ProductionVsY->Fill(0.1, Z_YBorn->GetValue()
);
} else if (fabs(MomOrPenUltimateMom1->GetValue()) == 2 && -MomOrPenUltimateMom1->GetValue() == MomOrPenUltimateMom2->GetValue()) {
AllPlots["QuarkAntiQuarkPair"]->Fill(PhiStar->GetValue());
AllPlots["DownQuarkPair"]->Fill(PhiStar->GetValue());
ProductionVsY->Fill(1.1, Z_YBorn->GetValue());
} else if (fabs(MomOrPenUltimateMom1->GetValue()) == 3 && -MomOrPenUltimateMom1->GetValue() == MomOrPenUltimateMom2->GetValue()) {
AllPlots["QuarkAntiQuarkPair"]->Fill(PhiStar->GetValue());
AllPlots["StrangeQuarkPair"]->Fill(PhiStar->GetValue());
ProductionVsY->Fill(2.1, Z_YBorn->GetValue());
} else if (fabs(MomOrPenUltimateMom1->GetValue()) == 4 && -MomOrPenUltimateMom1->GetValue() == MomOrPenUltimateMom2->GetValue()) {
AllPlots["QuarkAntiQuarkPair"]->Fill(PhiStar->GetValue());
AllPlots["CharmQuarkPair"]->Fill(PhiStar->GetValue());
ProductionVsY->Fill(3.1, Z_YBorn->GetValue());
} else if (fabs(MomOrPenUltimateMom1->GetValue()) == 5 && -MomOrPenUltimateMom1->GetValue() == MomOrPenUltimateMom2->GetValue()) {
AllPlots["QuarkAntiQuarkPair"]->Fill(PhiStar->GetValue());
AllPlots["BottomQuarkPair"]->Fill(PhiStar->GetValue());
ProductionVsY->Fill(4.1, Z_YBorn->GetValue());
} else if ((MomOrPenUltimateMom1->GetValue() == 21 && fabs(MomOrPenUltimateMom2->GetValue()) < 7) || (MomOrPenUltimateMom2->GetValue() == 21 && fabs(MomOrPenUltimateMom1->GetValue()) < 7)) {
AllPlots["SingleQuark"]->Fill(PhiStar->GetValue());
ProductionVsY->Fill(6.1, Z_YBorn->GetValue());
//.........这里部分代码省略.........
示例9: macroanalysis
int macroanalysis(char* filename)
{
// char* filename = "combined.root";
// Read in the file
TFile* f = new TFile(filename);
// TDirectory* hists = f->GetDirectory("hists;1");
// TDirectory* tuples = f->GetDirectory("tuples;1");
TTree* accum = (TTree*) f->GetObjectUnchecked("AccumulatedEnergy;1");
TLeaf* einit = (TLeaf*) accum->GetLeaf("Einit");
TLeaf* edepo = (TLeaf*) accum->GetLeaf("Edep");
TTree* edeps = (TTree*) f->GetObjectUnchecked("EnergyDepositions;1");
TLeaf* individualdepos = (TLeaf*) edeps->GetLeaf("Edep");
TTree* secs = (TTree*) f->GetObjectUnchecked("SecondarySpectrum;1");
TLeaf* secsenergy = (TLeaf*) secs->GetLeaf("KineticEnergy");
double ein = 0;
double eout = 0;
int nevents = accum->GetEntries();
for (int ii = 0; ii<nevents; ii++)
{
accum->GetEntry(ii);
ein+=einit->GetValue();
eout+=edepo->GetValue();
}
int ndepos = edeps->GetEntries();
double deposum = 0;
for (int ii = 0; ii<ndepos; ii++)
{
edeps->GetEntry(ii);
deposum+=individualdepos->GetValue();
}
int nsecs = secs->GetEntries();
double secsum = 0;
for (int ii = 0; ii<nsecs; ii++)
{
secs->GetEntry(ii);
secsum+=secsenergy->GetValue();
}
cout << "Making Summary\n";
FILE* summary = fopen("macro_summ.txt", "a+");
time_t t = time(NULL);
char* c_time_string = std::ctime(&t);
char mytime[20];
std::strncpy(mytime, c_time_string, 19);
mytime[ std::strlen(mytime) - 1 ] = '\0';
std::fprintf(summary, "%s,%s,%i,%e,%e,%i,%e,%i,%e\n", mytime, filename,
nevents, ein, eout, ndepos, deposum, nsecs, secsum);
fclose(summary);
cout << "Making Histogram\n";
nevents = secs->GetEntries();
TH1F* secondarieslow = new TH1F("secondarieslow", "Secondary Electrons <1 keV", 900, 0.000100, 0.001000);
TH1F* secondariesmid = new TH1F("secondariesmid", "Secondary Electrons 1<E<10 keV", 900, 0.001, 0.010);
TH1F* secondarieshigh = new TH1F("secondarieshigh", "Secondary Electrons 10<E<100 keV", 900, 0.010, 0.100);
TH1F* secondariesveryhigh = new TH1F("secondariesveryhigh", "Secondary Electrons 100keV<E<3 MeV", 2902, 0.100, 3.002);
for (int ii = 0; ii<nevents; ii++)
{
secs->GetEntry(ii);
double en = secsenergy->GetValue();
if (en < 0.001) secondarieslow->Fill(en, 1);
else if (en < 0.01) secondariesmid->Fill(en, 0.1);
else if (en < 0.1) secondarieshigh->Fill(en, 0.01);
else secondariesveryhigh->Fill(en, 0.001);
}
char suffix[] = ".secondaryhisto";
cout << "Making Filenames\n";
char* outfilename = (char*) malloc(std::strlen(filename) + std::strlen(suffix) + 1);
std::strcpy(outfilename, filename);
std::strcat(outfilename, suffix);
std::printf("Saving Histogram: %s \n", outfilename);
h12ascii(secondarieslow, secondariesmid, secondarieshigh, secondariesveryhigh, outfilename);
return 0;
}
示例10: main
int main(int argc, char* argv[])
{
vector<vector<double> >* voltages = new vector<vector<double> >;
vector<vector<double> >* currents = new vector<vector<double> >;
voltages->resize(52);
currents->resize(52);
TChain* chain = loadChain(argc, argv);
int entries = chain->GetEntries();
cout << entries/2 << " files\n";
for(int i=0; i<entries; i++)
{
chain->GetEvent(i);
for(int slot=0; slot<16; slot++)
{
TLeaf* vleaf = chain->GetLeaf(("VHS_"+target_card[slot]+".VM."+target_channel[slot]).c_str());
voltages->at(slot).push_back(vleaf->GetValue(0));
TLeaf* ileaf = chain->GetLeaf(("VHS_"+target_card[slot]+".IM."+target_channel[slot]).c_str());
currents->at(slot).push_back(ileaf->GetValue(0));
}
for(int slot=0; slot<36; slot++)
{
if(veto_card[slot]=="4_3")
{
voltages->at(slot+16).push_back(-1);
currents->at(slot+16).push_back(-1);
}
else
{
TLeaf* vleaf = chain->GetLeaf(("VHS_"+veto_card[slot]+".VM."+veto_channel[slot]).c_str());
voltages->at(slot+16).push_back(vleaf->GetValue(0));
TLeaf* ileaf = chain->GetLeaf(("VHS_"+veto_card[slot]+".IM."+veto_channel[slot]).c_str());
currents->at(slot+16).push_back(ileaf->GetValue(0));
}
}
}
const double allowed_dv = 100;
const double allowed_di = 50e-06;
vector<bool> pmt_flags_v;
vector<bool> pmt_flags_i;
pmt_flags_v.resize(52,0);
pmt_flags_i.resize(52,0);
for( auto pmt = voltages->begin();
pmt!=voltages->end(); ++pmt )
{
double meanvalue = mean(*pmt);
double deviation = std_dev(*pmt);
//cout << "Mean: " << meanvalue << " Dev: " << deviation << endl;
for(auto it2 = (*pmt).begin();
it2!=(*pmt).end(); ++it2)
{
//cout << distance((*it).begin(), it2) << " ";
if( abs(*it2-meanvalue) > allowed_dv )
pmt_flags_v.at( distance(voltages->begin(), pmt) ) = true;
}
}
for( auto pmt = currents->begin();
pmt!=currents->end(); ++pmt )
{
double meanvalue = mean(*pmt);
double deviation = std_dev(*pmt);
for(auto it2 = (*pmt).begin();
it2!=(*pmt).end(); ++it2)
if( abs(*it2-meanvalue) > allowed_di )
pmt_flags_i.at( distance(currents->begin(), pmt) ) = true;
}
bool error = false;
// Now if we managed to pick up some flags lets say so
for(auto it = pmt_flags_v.begin();
it!=pmt_flags_v.end(); ++it)
if(*it==true)
{
cout << "PMT: " << distance(pmt_flags_v.begin(), it) << " varied VOLTAGE more than "
<< allowed_dv << " from its mean value" << endl;
error = true;
}
for(auto it = pmt_flags_i.begin();
it!=pmt_flags_i.end(); ++it)
if(*it==true)
{
cout << "PMT: " << distance(pmt_flags_i.begin(), it) << " varied CURRENT more than "
<< allowed_di << " from its mean value" << endl;
error = true;
}
if(error == true)
{
cout << ">>> See error.txt for full report <<<" << endl;
writeReport(voltages, pmt_flags_v, currents, pmt_flags_i);
}
delete currents;
//.........这里部分代码省略.........
示例11: CacheTrendingProductions
/// Cache MC production information
void CacheTrendingProductions(TString dataType){
AliExternalInfo info;
info.fLoadMetadata=kFALSE;
TObjArray* periodList = NULL, *idList=NULL;
//
TTree * tree = info.GetTree("MonALISA.ProductionCycle","","");
Int_t nProd=tree->GetEntries();
periodList = new TObjArray(nProd);
idList= new TObjArray(nProd);
TLeaf *leafTag = tree->GetLeaf("Tag");
TLeaf *leafID = tree->GetLeaf("ID");
for (Int_t iProd=0; iProd<nProd; iProd++){
tree->GetEntry(iProd);
TString prodName=((char*)leafTag->GetValuePointer());
TString idName =TString::Format("%d",TMath::Nint(leafID->GetValue()));
if (prodName.Contains("LHC")==0) continue;
periodList->AddAt(new TObjString(prodName),iProd);
idList->AddAt(new TObjString(idName),iProd);
}
delete tree;
//
for (Int_t iPeriod=0; iPeriod<periodList->GetEntriesFast(); iPeriod++) {
TObjString * pName= (TObjString*)idList->At(iPeriod);
if (pName==NULL) continue;
TTree* treeP = info.GetTreeProdCycleByID(idList->At(iPeriod)->GetName());
if (treeP==NULL) continue;
TLeaf *leafOutput = treeP->GetLeaf("outputdir");
Int_t nRuns= treeP->GetEntries();
treeP->GetEntry(0);
TString path=((char*)leafOutput->GetValuePointer());
TObjArray *pArray = path.Tokenize("/");
if (pArray==NULL) continue;
Int_t nElems=pArray->GetEntries();
if (nElems<4) continue;
TString aperiod=pArray->At(3)->GetName();
TString apass =pArray->At(nElems-1)->GetName();
delete pArray;
::Info("CacheTrendingProductions","%s\t%s\t%s\t%s\t%d",idList->At(iPeriod)->GetName(),path.Data(), aperiod.Data(),apass.Data(),nRuns);
delete treeP;
TTree* treeQA = info.GetTree(dataType.Data(),aperiod.Data(),apass.Data());
if (treeQA){
Int_t entries=treeQA->Draw("run","1","goff");
TString sInfo=aperiod;
sInfo+="\t";
sInfo+=apass;
sInfo+="\t";
sInfo+=dataType;
sInfo+="\t";
sInfo+=TString::Format("%d\t",entries);
sInfo+=TString::Format("%d\t",nRuns);
for (Int_t j=0; j<entries; j++) {
sInfo+=TString::Format("%2.0f,",treeQA->GetV1()[j]);
::Info("CacheTrendingProductionsRun:","%s\t%s\t%s\t%d\t%d\t%2.0f",aperiod.Data(),apass.Data(),dataType.Data(),entries,nRuns,treeQA->GetV1()[j]);
}
sInfo+="0";
::Info("CacheTrendingProductionsPeriod:","%s\n",sInfo.Data());
delete treeQA;
}else{
::Error("CacheTrendingProductionsPeriod:","%s\t%s\t%s\t-1\t%d\t0",aperiod.Data(),apass.Data(), dataType.Data(),nRuns);
}
}
}