MUST2 SAMURAI_2018 S3-LEB-LPC SUPERNEMO MUGAST EXPAND SCALP GALATRON HiCARI VELO
  MUGAST  Not logged in MUGAST
Message ID: 4416     Entry time: Tue Apr 16 23:38:04 2019
Author: Fairouz Jaromir 
ExpNbr: e744s 
Type: RUN 
Category: Software 
Status: Fixed 
Target-Source:  
Subject: Script to watch efficiency CATS and VAMOS offline hour by hour 
do

lpcgrit

in directory
/home/mugast/analysis/nptool/Projects/MUGAST

root offline/root_vamos/run_xxx.root
.x macros/EffCheck_fhjm.C
Attachment 1: EffCheck_fhjm.C  4 kB  Uploaded Wed Apr 17 00:43:46 2019  | Hide | Hide all
void chkef( ULong64_t low, ULong64_t high,   ULong64_t n ){
  cout<<endl;
  cout<< "=========================================================\n" ;
  cout<<"i... HOUR: "<<n<<endl; //"     "<<low<<" "<<high<<endl;
  string sep = "----------------------------\n" ;



  TTree *t1 = (TTree*) gROOT->FindObject("AD");

  TH1F * hc = new TH1F("hc","hc",2000,0.1,50);
  TH1F * ht = new TH1F("ht","ht",2000,0.1,50);


  TString cond=  Form("(((RTS<<32)+(VTS<<16)+LTS)>=%lld)&&(((RTS<<32)+(VTS<<16)+LTS)<%lld)",low,high);
  TString condad=Form("&&( (((RTS<<32)+(VTS<<16)+LTS)>=%lld)&&(((RTS<<32)+(VTS<<16)+LTS)<%lld) )",low,high);


  // cout<<cond<<endl<<condad<<endl;



      cout << "Forward (condition by before)" << endl; 
  for(int i =0; i<1;i++)
    {
      t1->Draw("T_FPMW_HF_C:T_FPMW_CATS2_C",cond.Data(),"goff"); 
      long long a=AD->GetSelectedRows();

      t1->Draw("T_FPMW_HF_C:T_FPMW_CATS2_C",Form("T_FPMW_CATS2_C<1 && T_FPMW_HF_C>2 && %s",cond.Data() ),"goff");
      long long b=AD->GetSelectedRows();

	cout << "CATS lost efficiency with resect to VAMOS" << 100.*b/a  << "%" << endl;

    }

  cout << sep ;




      cout << "Forward (condition by before)" << endl; 
  for(int i =0; i<4;i++)
    {
      t1->Draw(Form("IC[%d]>>ht",i+1),cond.Data() ,"goff");
      t1->Draw(Form("IC[%d]>>hc",i+1),Form("IC[%d]>0.1 %s",i,condad.Data() ),"goff");
      cout << "IC " << i << " " << hc->Integral()/ht->Integral()*100. << "%"<< endl;

    }

  cout << sep ;


  cout << "Backward  (condition by after)" << endl; 

  for(int i =0; i<4;i++)
    {
      t1->Draw(Form("IC[%d]>>ht",i),cond.Data() ,"goff");
      t1->Draw(Form("IC[%d]>>hc",i),Form("IC[%d]>0.1 %s",i+1,  condad.Data() ),"goff");
      cout << "IC " << i+1 << " " << hc->Integral()/ht->Integral()*100. << "%"<< endl;

    }
cout << sep ;

 cout << "DC  (condition by IC[0])" << endl; 

  for(int i =0; i<4;i++)
    {
      t1->Draw(Form("IC[0]>>ht"),cond.Data(),"goff");
      t1->Draw(Form("IC[0]>>hc"),Form("EWIRE_%d>100 %s",i, condad.Data() ),"goff");
      cout << "DC WIRE " << i << " " << hc->Integral()/ht->Integral()*100. << "%"<< endl;

    }
cout << sep ;

cout << "DC X  (condition by IC[0])" << endl; 

  for(int i =0; i<4;i++)
    {
      t1->Draw(Form("IC[0]>>ht"),cond.Data(),"goff");
      t1->Draw(Form("IC[0]>>hc"),Form("DC%d_X>-1500  %s",i, condad.Data() ),"goff");
      cout << "DCX" << i << " " << hc->Integral()/ht->Integral()*100. << "%"<< endl;

    }

cout << sep ;


cout << "Xf  (condition by IC[0])" << endl; 

      t1->Draw(Form("IC[0]>>ht"),cond.Data() ,"goff");
      t1->Draw(Form("IC[0]>>hc"),Form("Xf>-1500 %s", condad.Data() ),"goff");
      cout << "Xf " << hc->Integral()/ht->Integral()*100. << "%"<< endl;


cout << sep ;


 delete hc;
 delete ht;
}
//==============================================================end





/*
ORIGINAL NAME but  now the original code for VAMOS eff is above
 */
void EffCheck_fhjm()
{

  ULong64_t hour;
  ULong64_t LTSmin=-1;
  ULong64_t LTSmax=-1;
  ULong64_t LTS,VTS,RTS, tmin,tmax,tmp;
 
  cout<< "============================================================\n" ;
  cout<<"          "<<gFile->GetName()<<endl;
  cout<< "============================================================\n" ;


  cout<<"Looking for min and max time stamp... very slow"<<endl;
  TTree *tree= (TTree*)gDirectory->Get("AD");
  tree->SetBranchAddress("LTS",&LTS);
  tree->SetBranchAddress("VTS",&VTS);
  tree->SetBranchAddress("RTS",&RTS);
  
  
 for (int i=1;i<tree->GetEntries();i++){
   tree->GetEntry(i);
   tmp=(RTS<<32)+(VTS<<16)+LTS;
   if ((LTS>0)&&(tmp>1e+14)){  //================== kill some low values?
     if ((LTSmin>tmp) || (LTSmin==-1)){
       LTSmin=tmp;
     }
     if ((LTSmax<tmp) || (LTSmax==-1)){
       LTSmax=tmp;
     }
   }
 }


 //tree->Draw("(RTS<<32)+(VTS<<16)+LTS>>h(10000)","","");
 //  Long64_t LTSmin=AD->GetV1()[0];
 //  AD->Draw("RTS<<32+VTS<<16+LTS","LTS>0","goff", 1, AD->GetEntries()-1 );
 //  Long64_t LTSmax=AD->GetV1()[0];
 cout<<"min    "<<LTSmin<<" "<<endl;
 cout<<"max    "<<LTSmax<<" "<< endl;
 cout<<"delta  "<<LTSmax-LTSmin<<endl;
 cout<<"delta  "<<(LTSmax-LTSmin)/100/1e+6/3600/282162*4.3<<" hours  EMPIRICAL RUN LENGHT"<<endl;
 hour=143567947269965277/6.0775;
 cout<<"1hour=="<<hour<<endl<<endl<<endl;
 //==========================================================================================
//   MAIN LOOP OVER TIME STEPS
 ULong64_t n=0;
 int hourstep=2;
 for (ULong64_t i=LTSmin; i<LTSmax; i+=hour*hourstep){
   n=n+1;
   chkef( i, i+hour , n*hourstep);
 }

  return NULL;




}

ELOG Home Page