本文整理汇总了C++中TList::Delete方法的典型用法代码示例。如果您正苦于以下问题:C++ TList::Delete方法的具体用法?C++ TList::Delete怎么用?C++ TList::Delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TList
的用法示例。
在下文中一共展示了TList::Delete方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testMergeCont
void testMergeCont()
{
// Macro to test merging of containers.
gROOT->LoadMacro("$ROOTSYS/tutorials/hsimple.C");
TList *list = (TList *)GetCollection();
TList *inputs = new TList();
for (Int_t i=0; i<10; i++) {
inputs->AddAt(GetCollection(),0);
list->Merge(inputs);
inputs->Delete();
f->Close();
}
delete inputs;
TH1F *hpx = (TH1F*)(((TList*)list->At(1))->At(0));
printf("============================================\n");
printf("Total hpx: %d entries\n", (int)hpx->GetEntries());
hpx->Draw();
list->Delete();
delete list;
}
示例2: ClearSelection
void KVNameValueList::ClearSelection(TRegexp& sel)
{
// Remove from list all parameters whose name matches the regular expression
// Examples:
// remove all parameters starting with "toto": TRegexp sel("^toto")
// remove all parameters with "toto" in name: TRegexp sel("toto")
TList toBeRemoved;
Int_t np1 = GetNpar();
for (Int_t ii = 0; ii < np1; ii += 1) {
TString name = GetParameter(ii)->GetName();
if (name.Contains(sel)) toBeRemoved.Add(new TNamed(name.Data(), ""));
}
if (toBeRemoved.GetEntries()) {
TIter next(&toBeRemoved);
TNamed* tbr;
while ((tbr = (TNamed*)next())) RemoveParameter(tbr->GetName());
toBeRemoved.Delete();
}
}
示例3: AnalyzeData
//.........这里部分代码省略.........
}
cout << "Draw Data - Pedestals Subtracted" << endl;
TString Title = "Average Charge - Pedestal subtracted";
TCanvas *csubdata = new TCanvas("csubdata", Title, 1000, 1000);
csubdata->Divide(3,3);
for(h = 0; h < DOMINO_NCH; h++) {
csubdata->cd(h+1);
TString title = "DataSub channel ";
title += h;
TH1F *hCellDataSub = new TH1F(title, title, 100, -20, 20);
grDataSub = (TGraphErrors *) grDataSubList->At(h);
for(ch = 0; ch < DOMINO_NCELL; ch++) {
grDataSub->GetPoint(ch, x, y);
hCellDataSub->Fill(y);
}
hCellDataSub->Fit("gaus", "Q");
hCellDataSub->GetXaxis()->SetTitle("ADC Counts");
hCellDataSub->GetFunction("gaus")->SetLineColor(4);
hCellDataSub->DrawCopy();
}
cout << "breakpoint" << endl;
TCanvas *csubdata2 = new TCanvas("csubdata2", "DataSub for every channel", 1000, 1000);
TString title = "DataSub every channel ";
TH1F *hCellChDataSubTot = new TH1F(title, title, 100, -20, 20);
for(h = 0; h < DOMINO_NCH; h++) {
grDataSub = (TGraphErrors *) grDataSubList->At(h);
for(ch = 0; ch < DOMINO_NCELL; ch++) {
grDataSub->GetPoint(ch, x, y);
hCellChDataSubTot->Fill(y);
}
hCellChDataSubTot->Fit("gaus", "Q");
hCellChDataSubTot->GetXaxis()->SetTitle("ADC Counts");
hCellChDataSubTot->GetFunction("gaus")->SetLineColor(4);
hCellChDataSubTot->Draw();
}
cout << "Draw Pedestals" << endl;
TString Title = "Pedestals";
TCanvas *c2 = new TCanvas("c2", Title, 1050, 780);
c2->SetBorderMode(0);
c2->SetBorderSize(0.);
c2->Divide(1, 8);
// gStyle->SetCanvasBorderMode(0.);
// gStyle->SetCanvasBorderSize(0.);
Double_t x, y;
for (int h = 0; h < DOMINO_NCH; h++) {
c2->cd(h + 1);
grPed = ((TGraphErrors *) grPedList->At(h));
grPed->SetMarkerStyle(20);
grPed->SetMarkerSize(0.5);
grPed->GetYaxis()->SetLabelSize(0.12);
grPed->GetXaxis()->SetLabelSize(0.12);
// cout << " err:" << grPed->GetErrorY(102) << " " ;
// cout << x << "--" << y << endl;
grPed->Draw("APE");
}
cout << "Draw Data - Average charge" << endl;
TString Title = "Average_Charge";
TCanvas *cdata = new TCanvas("cdata", Title, 1050, 780);
cdata->Divide(1, 8);
Double_t x, y;
for (int h = 0; h < DOMINO_NCH; h++) {
cdata->cd(h + 1);
grData = ((TGraphErrors *) grDataList->At(h));
grData->SetMarkerStyle(20);
grData->SetMarkerSize(0.3);
grData->GetYaxis()->SetLabelSize(0.12);
grData->GetXaxis()->SetLabelSize(0.12);
grData->GetPoint(10, x, y);
// cout << x << "-" << y << endl;
grData->Draw("APE");
}
cout << "Draw Data - Pedestals Subtracted" << endl;
TString Title = "Average Charge - Pedestal subtracted";
TCanvas *csubdata = new TCanvas("csubdata", Title, 1200, 780);
csubdata->Divide(1, 8);
TF1 *fsin = new TF1("fsin", sigSin, 0., 1024., 4);
TH1D *resDist = new TH1D("resDist", "Residuals Signal", 100, -100., 100.);
cout << "Draw Data - Pedestals Subtracted" << endl;
TString Title = "Residuals";
TCanvas *residuals = new TCanvas("residuals", Title, 1200, 780);
resDist->DrawCopy();
}
fclose(fdata);
hCellList->Delete();
hCellSubList->Delete();
hRMSList->Delete();
hRMSFitList->Delete();
}
示例4: addhistoEmc
void addhistoEmc(const char* list="list.txt", char *newname=0)
{
// Add histograms from a set of files listed in file list
// and write the result into a new file.
char SumName[20];
if (!newname) {
sprintf(SumName,"Sum_All_Emc.root");
newname=SumName;
printf("\n === Default output file name is %s ===\n",newname);
}
TFile *f=NULL;
TH1F* hst[5][64][56];
TH1F* hadd=NULL;
char hnam[80];
char htit[80];
TList* hlist = 0;
char fpath[80];
int ifscanf=0;
Int_t ifile=0;
for(Int_t iMod=0; iMod<5; iMod++) {
for(Int_t iX=0; iX<64; iX++) {
for(Int_t iZ=0; iZ<56; iZ++) {
sprintf(hnam,"%d_%d_%d",iMod,iX,iZ);
sprintf(htit,"Two-gamma inv. mass for mod %d, cell (%d,%d)",iMod,iX,iZ);
hst[iMod][iX][iZ] = new TH1F(hnam,htit,100,0.,300.);
}
}
}
TH1F* hmgg = new TH1F("hmgg","2-cluster invariant mass",100,0.,300.);
FILE* fd = fopen(list,"r");
while( ifscanf = fscanf(fd,"%s",fpath) != EOF) {
f=new TFile(fpath);
hlist = (TList*)f->Get("histos");
for(Int_t iList=0; iList<hlist->GetEntries(); iList++) {
hadd = (TH1F*)hlist->At(iList);
const char* str = hadd->GetName();
int md,X,Z;
if (sscanf(str,"%d_%d_%d",&md,&X,&Z)) {
hst[md][X][Z]->Add(hadd);
//printf("Added hst[%d][%d][%d]\n",md,X,Z);
}
else {
printf("Trying to add histogram %s to hmgg.\n",hadd->GetName());
hmgg->Add(hadd);
}
}
printf("Deleting list..\n");
hlist->Delete();
printf("OK!\n");
ifile++;
printf("File %s processed.\n",fpath);
if(f) delete f;
}
printf("%d processed.\n",ifile);
TFile outfile(newname,"recreate");
for(Int_t iMod=0; iMod<5; iMod++) {
for(Int_t iX=0; iX<64; iX++) {
for(Int_t iZ=0; iZ<56; iZ++) {
if(hst[iMod][iX][iZ]->GetEntries()) hst[iMod][iX][iZ]->Print();
hst[iMod][iX][iZ]->Write();
}
}
}
hmgg->Write();
outfile.Close();
}
示例5: main
int main(int argc, char *argv[])
{
if (argc != 3 && argc != 4 && argc != 7) {
cout << "Usage: quickDraw path drawstring [selection [nbins xmin xmax]]" << endl;
cout << " will create a file histogram.pdf from the given files" << endl
<< endl;
cout << "path points to a directory containing ROOT files" << endl;
cout << "drawstring is a string usable in TTree::Draw()" << endl;
cout << "selection e.g. (muo_n>0)&&(jet_n>0) or 1. if no selection" << endl;
cout << "nbins number of bins in histogram" << endl;
cout << "xmin low x edge of histogram" << endl;
cout << "xmax high x edge of histogram" << endl;
cout << endl;
cout << "Example: quickDraw ~/data \"muo_pt[0]\" \"(jet_n>2)\" 100 0 1000" << endl;
cout << " will draw muo_pt of the leading muon (index 0) for all events" << endl;
cout << " that contain at least three jets in a histogram with 100 bins," << endl;
cout << " ranging from 0 to 1000 GeV" << endl;
cout << endl;
cout << "Example: quickDraw ~/data vtx_n global_weight" << endl;
cout << " will draw vtx_n for all events in an automatically binned histogram " << endl;
cout << " The histogram weight will be taken from the leaf global_weight for each event" << endl;
exit (1);
}
// Loop over all files in directory <path> and fill
// root file names into list <filelist>
Text_t lpath[strlen(argv[1])+8];
sprintf(lpath, "%s", argv[1]);
Text_t * basepath = gSystem->ExpandPathName(lpath); // delete it later...
void * dirhandle = gSystem->OpenDirectory(basepath);
const Text_t * basename;
if (gLogLevel)
cout << "Reading file names from directory " << basepath << endl;
TList * filelist = new TList;
while ((basename = gSystem->GetDirEntry(dirhandle))) {
// Skip non-ROOT files
if (!strstr(basename, ".root"))
continue;
Text_t * fullname = new Text_t[strlen(basepath)+strlen(basename)+2];
strcpy(fullname, basepath);
strcat(fullname, "/");
strcat(fullname, basename);
filelist->Add(new TObjString(fullname));
delete fullname;
}
// check if we have read some files
if (filelist->GetSize() < 1) {
cerr << "ERR: No *.root files available in " << basepath << " Exiting. " << endl;
exit(EXIT_FAILURE);
}
// Add all root files to a TChain
if (gLogLevel)
cout << "Adding files to TChain" << endl;
TChain * chain = new TChain("ACSkimAnalysis/allData");
TIter next(filelist);
while (TObjString * obj = (TObjString *) next()) {
chain->Add(obj->GetString());
if (gLogLevel > 3)
cout << "FILE: " << obj->GetString() << " added to TChain" << endl;
}
// Delete all filelist elements and the list itself
// (They are not deleted automatically when the TList is deleted!!!)
filelist->Delete();
delete filelist;
delete basepath;
long int events_from_tree = chain->GetEntries();
cout << "Found a total of " << events_from_tree << " events in chain" << endl;
gROOT->SetBatch();
TCanvas * c1 = new TCanvas();
TFile * f = new TFile("histo.root", "RECREATE");
Int_t nbins = 200;
double xmin = 0;
double xmax = 1;
if (argc == 7) {
nbins = atoi(argv[4]);
xmin = atof(argv[5]);
xmax = atof(argv[6]);
}
TH1D * h1 = new TH1D("h1", argv[2], nbins, xmin, xmax);
if (argc < 5) {
h1->SetBit(TH1::kCanRebin);
}
const char * selection = "1.";
if (argc >= 4)
selection = argv[3];
chain->Draw(Form("%s>>h1", argv[2]), selection);
h1->Draw();
c1->Print("histo.pdf");
f->Write();
f->Close();
delete f;
return 0;
}
示例6: scanDirectory
void scanDirectory(const char *dirname)
{
TDirectoryIter iter(dirname);
const char *filename = 0;
TString ent;
TString file;
TString html;
html.Form(gPreamble,dirname,dirname);
TList dirList;
TList fileList;
while( (filename=iter.Next()) )
{
if (filename[0]!='.') {
ent.Form("%s/%s", dirname, filename);
FileStat_t st;
gSystem->GetPathInfo(ent.Data(), st);
if (R_ISDIR(st.fMode)) {
//fprintf(stderr,"Seeing directory %s\n",ent.Data());
scanDirectory(ent.Data());
dirList.Add(new TObjString(filename));
} else {
size_t len = strlen(filename);
if (len > 8 && strncmp(filename,"pt_",3)==0 && strncmp(filename+len-5,".root",5)==0) {
//fprintf(stderr,"Seeing file %s\n",ent.Data());
file = filename;
file[len-5]='\0';
fileList.Add(new TObjString(file));
}
}
}
}
dirList.Sort();
fileList.Sort();
TIter next(&dirList);
TObjString *obj;
html += "<table width=\"500\">\n";
html += gLine;
html += gParentDir;
while ( (obj = (TObjString*)next()) ) {
html += TString::Format(gDirFmt,obj->GetName(),obj->GetName());
}
html += gLine;
if (!fileList.IsEmpty()) {
next = &fileList;
while ( (obj = (TObjString*)next()) ) {
html += "<tr>";
html += TString::Format(gFiles,obj->GetName(),obj->GetName(),obj->GetName(),obj->GetName());
obj = (TObjString*)next();
if (obj) {
html += TString::Format(gFiles,obj->GetName(),obj->GetName(),obj->GetName(),obj->GetName());
} else {
html += "<td></td></tr>";
break;
}
}
html += gLine;
}
html += "</table>\n";
dirList.Delete();
fileList.Delete();
html += "</body>\n";
html += "</html>\n";
ent.Form("%s/pt_index.html",dirname);
FILE *output = fopen(ent.Data(),"w");
fprintf(output,"%s",html.Data());
fclose(output);
}
示例7: CalibrateData
//.........这里部分代码省略.........
for (int j = 0; j < 1; j++) {
fread((void *) &event_data, 1, sizeof(event_data), fdata);
p = (struct channel_struct *) &event_data.ch[0]; // read bunch of data
p += anaChannel;
for (ch = 0; ch < DOMINO_NCELL; ch++) {
grPedData->GetPoint(ch, itmp, PedVal);
reftmp = TMath::Abs((Double_t)(p->data[ch])-PedVal);
if (reftmp > 0.8* refval)
refval = 0.2*reftmp+0.8*refval;
// cout << ch << " " <<p->data[ch] << " " <<reftmp << " " << refval <<endl ;
}
}
cout << "refval="<< refval<<endl;
rewind(fdata);
Int_t ievt = 1;
// go to first event (startEv)
while (ievt < startEv) {
fread((void *) &event_data, 1, sizeof(event_data), fdata);
if (feof(fdata))
break;
ievt++;
}
ievt = 1;
Int_t iTrig = 0;
Int_t flagEnd = 0;
Double_t chtmp, chtrig;
Double_t ratio;
Double_t mean, rms;
// loop on events
while (ievt <= nevt && !flagEnd) {
fread((void *) &event_data, 1, sizeof(event_data), fdata);
if (feof(fdata))
flagEnd = 1;
p = (struct channel_struct *) &event_data.ch[0]; // read bunch of data
dep = (struct channel_struct *) &event_data.ch[1]; // read bunch of data
//now anaChannel analysis
p += anaChannel;
// read data, subtract pedestals values and fill hCellCalibList.
for (int ch = 0; ch < DOMINO_NCELL; ch++) {
// Read pedestal value for this cell
grPedData->GetPoint(ch, itmp, PedVal);
chtmp = (Double_t)(p->data[ch]); // data value
chtmp = chtmp - PedVal;
//if (TMath::Abs(chtmp) > 0.9 * refval)
((TH1 *) hCellCalibList->At(iFile*DOMINO_NCELL+ch))->Fill(chtmp);
//cout << ch << " " << iFile << " " << chtmp << endl;
}
gProgress->Increment(1);
gSystem->DispatchOneEvent(kTRUE);
ievt++; // next event
}
TH1 *hCellTmp;
for(ch = 0; ch < DOMINO_NCELL;ch++) {
hCellTmp = ((TH1 *) hCellCalibList->At(iFile*DOMINO_NCELL+ch));
//hCellTmp->Fit("gaus", "Q");
//mean = (hCellTmp->GetFunction("gaus"))->GetParameter(1);
//rms = (hCellTmp->GetFunction("gaus"))->GetParameter(2);
mean = hCellTmp->GetMean();
rms = hCellTmp->GetRMS();
((TGraphErrors *) (grCellCalibList->At(ch)))->SetPoint(iFile, (Double_t) mV[iFile], mean);
((TGraphErrors *) (grCellCalibList->At(ch)))->SetPointError(iFile, 0., rms);
}
ctest->cd(iFile + 1);
hCellTmp = ((TH1 *) hCellCalibList->At(567 + iFile*DOMINO_NCELL));
hCellTmp->Fit("gaus","Q");
hCellTmp->DrawCopy();
}
TString OutFile = "CalibrationDataNew";
OutFile += nevt;
OutFile += "events.root";
TFile *f = new TFile(OutFile, "RECREATE");
for (int ch = 0; ch < DOMINO_NCELL; ch++) {
TString key = "CalibDataCell";
key += ch;
((TGraphErrors*) grCellCalibList->At(ch))->Write(key);
}
f->Close();
hCellCalibList->Delete();
((TGMainFrame *) gProgress->GetParent())->CloseWindow();
fclose(fdata);
}