Try:
{
const char *file_name = "digTrk200.root";
const int first_run = 100001855;
const int last_run = 100001855;
const int first_event = 90;
const int last_event = 205;
const bool show_stats = kTRUE; // kTRUE ... or ... kFALSE
gStyle->SetPalette(55);
// https://root-forum.cern.ch/t/ttree-draw-integral-depends-on-number-bins-bug/21203/7
TDirectory *cwd = gDirectory; // we create histograms "here"
TH3F *track3d = new TH3F("track3d", "track3d", 12, -6, 6, 12, -6, 6, 12, -6, 6);
track3d->SetStats(show_stats);
TFile *noMaskDigitFile = TFile::Open(file_name);
TTree *noMaskDigits; noMaskDigitFile->GetObject("tracks", noMaskDigits);
noMaskDigits->SetMarkerStyle(20);
cwd->cd(); // go to the directory where histograms are
TCanvas *c1 = new TCanvas("c1", "c1");
for (int run = first_run; run <= last_run; run++)
{
std::cout << "////// event tracks for run: " << run << " ////////" << std::endl;
for (int eventID = first_event; eventID <= last_event; eventID++)
{
TString individ_eventCut =
TString::Format("fitType==5&&run==%d&&eventID==%d", run, eventID);
track3d->SetTitle(individ_eventCut + ";dig_x;dig_y;dig_z");
// https://root-forum.cern.ch/t/problem-with-tree-and-histogram/21240/12
track3d->Reset("M"); // make sure it's "clean"
if (!(track3d->TestBit(TH1::kNoStats))) {
noMaskDigits->Project("track3d", "dig_z:dig_y:dig_x", individ_eventCut, "");
((TArrayF *)track3d)->Reset(); // "reset" histogram's bins' contents
}
noMaskDigits->Draw("dig_z:dig_y:dig_x:dig_adc>>+track3d", individ_eventCut, "col");
c1->SetTheta(40);
c1->Modified(); c1->Update();
c1->SaveAs(TString::Format("run%d_eventID%d.png", run, eventID));
}
}
std::cout << std::endl << "Incredible, isn't it." << std::endl << std::endl;
}
BTW. Another example can be found in this thread. For "e1:e2"
draw expressions, which produce unbinned 2-d scatter-plots (TGraph), there is this thread.