void plotDelay(const int istation=1, const int nbinsX = 60, const float minX = 110.5, const float maxX = 170.5, const char *fname="resultDelay160.root" ) { TFile *inFile = TFile::Open(fname); const int debug = 0; // constants for arrays const int kNChan = 32; const int kNQR = 26; const int kNVRef = 6; const int kNACurr = 5; const int kNSync = 8; TTree *tree = (TTree*) inFile->Get("tree"); //Declaration of leaves types //Declaration of leaves types Char_t filename[200]; Char_t datetime[100]; Char_t cQR[kNQR]; Int_t iChip; Int_t iSta; Float_t fVRef[kNVRef]; Float_t fVCurr[kNACurr]; Float_t fACurr[kNACurr]; Float_t fGain20mV[32]; Float_t fGain30mV[32]; Float_t fGainRT20mV[32]; Float_t fGainRT30mV[32]; Float_t fRT20mV[32]; Float_t fRT30mV[32]; Float_t fPed20mV[32]; Float_t fPed30mV[32]; Float_t fRms20mV[32]; Float_t fRms30mV[32]; Float_t fPedAna20mV[32]; Float_t fPedAna30mV[32]; Float_t fRmsAna20mV[32]; Float_t fRmsAna30mV[32]; Float_t fX20mVeven; Float_t fX20mVodd; Float_t fX30mVeven; Float_t fX30mVodd; Int_t iSync[kNSync]; Int_t iDFT; Int_t iJtag; Int_t iMem; Float_t fRingOsc; Int_t i2cErr; Int_t iErrCode; Int_t iRCode; // Set branch addresses. tree->SetBranchAddress("filename",filename); tree->SetBranchAddress("datetime",datetime); tree->SetBranchAddress("cQR",&cQR); tree->SetBranchAddress("iChip",&iChip); tree->SetBranchAddress("iSta",&iSta); tree->SetBranchAddress("fVRef",fVRef); tree->SetBranchAddress("fVCurr",fVCurr); tree->SetBranchAddress("fACurr",fACurr); tree->SetBranchAddress("fGain20mV",fGain20mV); tree->SetBranchAddress("fGain30mV",fGain30mV); tree->SetBranchAddress("fGainRT20mV",fGainRT20mV); tree->SetBranchAddress("fGainRT30mV",fGainRT30mV); tree->SetBranchAddress("fRT20mV",fRT20mV); tree->SetBranchAddress("fRT30mV",fRT30mV); tree->SetBranchAddress("fPed20mV",fPed20mV); tree->SetBranchAddress("fPed30mV",fPed30mV); tree->SetBranchAddress("fRms20mV",fRms20mV); tree->SetBranchAddress("fRms30mV",fRms30mV); tree->SetBranchAddress("fPedAna20mV",fPedAna20mV); tree->SetBranchAddress("fPedAna30mV",fPedAna30mV); tree->SetBranchAddress("fRmsAna20mV",fRmsAna20mV); tree->SetBranchAddress("fRmsAna30mV",fRmsAna30mV); tree->SetBranchAddress("fX20mVeven",&fX20mVeven); tree->SetBranchAddress("fX20mVodd",&fX20mVodd); tree->SetBranchAddress("fX30mVeven",&fX30mVeven); tree->SetBranchAddress("fX30mVodd",&fX30mVodd); tree->SetBranchAddress("iSync",iSync); tree->SetBranchAddress("iDFT",&iDFT); tree->SetBranchAddress("iJtag",&iJtag); tree->SetBranchAddress("iMem",&iMem); tree->SetBranchAddress("fRingOsc",&fRingOsc); tree->SetBranchAddress("i2cErr",&i2cErr); tree->SetBranchAddress("iErrCode",&iErrCode); tree->SetBranchAddress("iRCode",&iRCode); // This is the loop skeleton // To read only selected branches, Insert statements like: // tree->SetBranchStatus("*",0); // disable all branches // TTreePlayer->SetBranchStatus("branchname",1); // activate branchname Long64_t nentries = tree->GetEntries(); // histos: gain20, gain30, rt20, rt30: even & odd const int kNHistMax = 4*2; TProfile *hp[kNHistMax]; TH2F *h2[kNHistMax]; int nbinsY[kNHistMax] = { 300 }; float minY[kNHistMax] = { 30.0 }; float maxY[kNHistMax] = { 33.0 }; // vector hTitle; vector hFill; int nHists = 0; hTitle.push_back("Gain20 Even (mV/fC)"); nbinsY[nHists] = 300; minY[nHists] = 19.5; maxY[nHists] = 22.5; hFill.push_back("fGain20mVEven"); nHists++; hTitle.push_back("Gain30 Even (mV/fC)"); nbinsY[nHists] = 300; minY[nHists] = 30; maxY[nHists] = 33; hFill.push_back("fGain30mVEven"); nHists++; hTitle.push_back("RiseTime20mV Even (ns)"); nbinsY[nHists] = 300; minY[nHists] = 60; maxY[nHists] = 75; hFill.push_back("fRT20mVEven"); nHists++; hTitle.push_back("RiseTime30mV Even (ns)"); nbinsY[nHists] = 300; minY[nHists] = 60; maxY[nHists] = 75; hFill.push_back("fRT30mVEven"); nHists++; hTitle.push_back("Gain20 Odd (mV/fC)"); nbinsY[nHists] = 300; minY[nHists] = 19.5; maxY[nHists] = 22.5; hFill.push_back("fGain20mVOdd"); nHists++; hTitle.push_back("Gain30 Odd (mV/fC)"); nbinsY[nHists] = 300; minY[nHists] = 30; maxY[nHists] = 33; hFill.push_back("fGain30mVOdd"); nHists++; hTitle.push_back("RiseTime20mV Odd (ns)"); nbinsY[nHists] = 300; minY[nHists] = 60; maxY[nHists] = 75; hFill.push_back("fRT20mVOdd"); nHists++; hTitle.push_back("RiseTime30mV Odd (ns)"); nbinsY[nHists] = 300; minY[nHists] = 60; maxY[nHists] = 75; hFill.push_back("fRT30mVOdd"); nHists++; if (debug>1) cout << " nHists " << nHists << endl; // Print Strings stored in Vector if (debug>0) { for (int ii=0; ii1) cout << " nentries " << nentries << endl; for (Long64_t i=0; i1) cout << " get entry i " << i << endl; nbytes += tree->GetEntry(i); if (debug>1) cout << " entry i " << i << " iSta " << iSta << endl; int delay = iChip; if (iSta == istation) { // selected station if (debug>1) cout << " selected entry i " << i << " iSta " << iSta << endl; int nSyncFail = 0; int nSyncOK = 0; for (k=0; k1) cout << " nSyncOK " << nSyncOK << endl; if ( nSyncOK == kNSync ) { if (debug>1) cout << " ok entry for station " << iSta << endl; // need to fill histos in the same order as they were declared above j=0; if (debug>1) cout << " line " << __LINE__ << " j " << j << endl; // all histos with entries per channel int oddOffset = 0; for (int ichan=0; ichan<32; ichan++) { if (debug>1) cout << " ichan " << ichan << endl; oddOffset = (ichan % 2) * 4; j = oddOffset; h2[j]->Fill(delay, fGain20mV[ichan]); j++; h2[j]->Fill(delay, fGain30mV[ichan]); j++; h2[j]->Fill(delay, fRT20mV[ichan]); j++; h2[j]->Fill(delay, fRT30mV[ichan]); j++; j = oddOffset; hp[j]->Fill(delay, fGain20mV[ichan]); j++; hp[j]->Fill(delay, fGain30mV[ichan]); j++; hp[j]->Fill(delay, fRT20mV[ichan]); j++; hp[j]->Fill(delay, fRT30mV[ichan]); j++; } if (j != nHists) cerr << " line " << __LINE__ << " mismatch! j " << j << " nHists " << nHists << endl; } // OK event (Sync) } // station } gStyle->SetOptStat(0); // third, create all plots, and check cut info if (debug>1) cout << " create canvas " << endl; TCanvas *c1 = new TCanvas("c1","c1"); if (debug>1) cout << " canvas created " << endl; for (j = 0; j1) cout << " line " << __LINE__ << " j " << j << endl; c1->cd(1); h2[j]->Draw("colz"); c1->Modified(); sprintf(id, "png/delay/sta%d_%s.png", istation, hFill[j].c_str()); c1->SaveAs(id); c1->cd(1); hp[j]->Draw(); c1->Modified(); sprintf(id, "png/delay/sta%d_prof_%s.png", istation, hFill[j].c_str()); c1->SaveAs(id); } }