作业3.2¶

将dssd1/2/3中,没有相邻条影响的y~x事件保存到d1/2/3xy.root文件¶

- 1. 在x和y一重hit的条件下选出两侧能量关联的大致范围(参见3.4 In[8]),存成 cut1/2/3.C
- 2. 按照下面程序结构,编写完整代码,将所有满足条件的x-y组合存到ROOT文件

//check whether d1x[i]/d1y[j] satisfies the condition of no adjacent strip sharing
bool IsNoAdjacentSharing(int dxe[32], int dye[32], int ix, int iy) {

    ...
}


//input ROOT file
TFile *fin = new TFile("data_16C.root");
TTree *tree =(TTree *)fin->Get("tree");

Int_t d1x[32], d2x[32], d3x[32];
Int_t d1y[32], d2y[32], d3y[32];

tree->SetBranchAddress("d1x", &d1x);
...

//output ROOT file
int ix, iy;
Int_t xe, ye;
TFile *fout = new TFile("d1dxy.root","recreate");
fout->cd();
TTree *tout = new TTree("tree","x-y");
tout->Branch("ix", &ix, "ix/I");//strip number
tout->Branch("iy", &iy, "iy/I");
tout->Branch("xe", &xe, "xe/I");//energy
tout->Branch("ye", &ye, "ye/I");

...

for (Long64_t jentry = 0; jentry < nentries; jentry++) {
    tree->GetEntry(jentry);
    bool bcut;
    for (int i = 0; i < 32; i++) {
        for (int j = 0; j < 32; j++) {
            bcut = cut1->IsInside(d1x[i], d1y[j]);
            bcut *= IsNoAdjacentSharing(d1x,d1y,i,j);
            if (!bcut) continue;
            ix = i;
            iy = j;
            xe = d1x[i];
            ye = d1y[j];
            tout->Fill();
        }
    }
    if (jentry % 10000 == 0 ) cout << ".";

} 
cout<<endl;   
fout->cd();
tout->Write();
fout->Close();
fin->Close();

预期结果¶

In [1]:
TCanvas *c1 = new TCanvas("c1","c1");
TFile *fin = new TFile("./data/d1xy.root");
TTree *tree =(TTree *)fin->Get("tree");
In [3]:
tree->Draw("ye:xe>>(4000,0,8000,4000,0,8000)","","colz");
c1->SetLogz();
c1->Draw();
In [5]:
tree->Scan("iy:ix:ye:xe","","",10,1);
************************************************************
*    Row   *        iy *        ix *        ye *        xe *
************************************************************
*        1 *        23 *         4 *       501 *       629 *
*        2 *         7 *        10 *       611 *       471 *
*        3 *        23 *        10 *       501 *       471 *
*        4 *        18 *         3 *      1171 *      1178 *
*        5 *        14 *         8 *       507 *       498 *
*        6 *        23 *        26 *      1387 *      1351 *
*        7 *        21 *        29 *       459 *       444 *
*        8 *        20 *        25 *       445 *       491 *
*        9 *        27 *        25 *       484 *       491 *
*       10 *        20 *        27 *       445 *       437 *
************************************************************