[BLAST_SHIFTS] programs to study detector efficiencies

From: zhangchi (zhangchi@general.lns.mit.edu)
Date: Sat Oct 26 2002 - 04:37:01 EDT


Hi all,

in the last few months, Chris and I deviced some small but interesting
software utilities and I think it is time to do some advertising and lure
people to make use of them.

Following is two macros I wrote this morning to study TOF and CC
efficiencies. They make use of the TBLCut classes I checked into
BlastLib2. My hope is that this is going to make cuts simple and self
explaining. They will save you much typing and once offsects, pedestals of
the detectors are calibrated and written into blast.sc_cal, the cuts such
as adc higher than pedestal will be automatically implemented.

The condition they can be used is that ntuple.C is run first on the run
and "ntp" is filled and written into commis-????.root.

It incorperates the script init.C by Chris which provides almost infinite
flexibility.

They macros are infact short enough for cut and paste:

tof_ef.C:
{
   gROOT->Reset();
   gEnv->SetValue("ntuple", "ntp");// look for events in ntuple named ntp
   gROOT->ProcessLine(".x init.C"); // takes care of everything

   gSystem->Load("libBlast.so");
   TBLCut::Init((TTree*)chain[0]); // tell TBLCut what tree to cut on

   TBLCut denom1(TOF_HIT('l', 4) & TOF_HIT('l',15) & CC_HIT('l', 0));
   TBLCut denom2(TOF_HIT('l', 5) & TOF_HIT('l',15) & CC_HIT('l', 0));
   TBLCut denom3(TOF_HIT('l', 6) & TOF_HIT('l',15) & CC_HIT('l', 0));
   TBLCut denom4(TOF_HIT('l', 7) & TOF_HIT('l',15) & CC_HIT('l', 0));
   //hope the syntax explains themselves
   
   TBLCut num1(denom1 & TOF_HIT('l', 0));
   TBLCut num2(denom2 & TOF_HIT('l', 1));
   TBLCut num3(denom3 & TOF_HIT('l', 2));
   TBLCut num4(denom4 & TOF_HIT('l', 3));

   //denom1.Examine(); // can look at the content in the Cut
   //num1.Examine();

   // efficeincy = #of entries with cut num1/#of entries with cut denom1
   TCanvas *c1 = new TCanvas("c1", "c1", 10, 10, 1200, 600);
   c1->Divide(4, 2);

   c1->cd(1);
   chain[0]->Draw("(ttl0t+ttl0b)/2.", denom1);
   c1->cd(2);
   chain[0]->Draw("(ttl0t+ttl0b)/2.", num1);

   c1->cd(3);
   chain[0]->Draw("(ttl1t+ttl1b)/2.", denom2);
   c1->cd(4);
   chain[0]->Draw("(ttl1t+ttl1b)/2.", num2);

   c1->cd(5);
   chain[0]->Draw("(ttl2t+ttl2b)/2.", denom3);
   c1->cd(6);
   chain[0]->Draw("(ttl2t+ttl2b)/2.", num3);

   c1->cd(7);
   chain[0]->Draw("(ttl2t+ttl2b)/2.", denom4);
   c1->cd(8);
   chain[0]->Draw("(ttl2t+ttl2b)/2.", num4);
}

cc_eff.C
{
   gROOT->Reset();
   gEnv->SetValue("ntuple", "ntp");// look for events in ntuple named ntp
   gROOT->ProcessLine(".x init.C"); // takes care of everything

   gSystem->Load("libBlast.so");
   TBLCut::Init((TTree*)chain[0]); // tell TBLCut what tree to cut on

   TBLCut denom1(TOF_HIT('l', 4) & TOF_HIT('l',15) & TOF_HIT('l', 0));
   TBLCut denom2(TOF_HIT('l', 5) & TOF_HIT('l',15) & TOF_HIT('l', 1));
   TBLCut denom3(TOF_HIT('l', 6) & TOF_HIT('l',15) & TOF_HIT('l', 2));
   TBLCut denom4(TOF_HIT('l', 7) & TOF_HIT('l',15) & TOF_HIT('l', 3));
   // TOF_HIT(0, 4) is also OK. so yoTOF_HIT(i, j);

   TBLCut num1(denom1 & CC_HIT('l', 0));
   TBLCut num2(denom2 & CC_HIT('l', 1));
   TBLCut num3(denom3 & CC_HIT('l', 2));
   TBLCut num4(denom4 & CC_HIT('l', 3));

   //denom1.Examine();
   //num1.Examine();

   TBLCut denom(denom1 | denom3 | denom4);
   TBLCut num(num1 | num3 | num4);

   TCanvas *c1 = new TCanvas("c1", "c1", 10, 10, 1200, 600);
   c1->Divide(4, 2);

   c1->cd(1);
   chain[0]->Draw("acl0", denom); // total for box 0
   c1->cd(2);
   chain[0]->Draw("acl0", num);

   c1->cd(3);
   chain[0]->Draw("acl0", denom1);
   c1->cd(4);
   chain[0]->Draw("acl0", num1);

   c1->cd(5);
   chain[0]->Draw("acl0", denom3);
   c1->cd(6);
   chain[0]->Draw("acl0", num3);

   c1->cd(7);
   chain[0]->Draw("acl0", denom4);
   c1->cd(8);
   chain[0]->Draw("acl0", num4);
}

I hope it will be useful to people as now every student is taking detector
calibration shifts.

Chi



This archive was generated by hypermail 2.1.2 : Mon Feb 24 2014 - 14:07:28 EST