Пример #1
0
	void Dis_mxc1(MIPSOpcode op, char *out)
	{
		int fs = _FS;
		int rt = _RT;
		const char *name = MIPSGetName(op);
		sprintf(out, "%s\t%s, %s",name,RN(rt),FN(fs));
	}
Пример #2
0
	void Dis_Cache(MIPSOpcode op, char *out)
	{
		int imm = (s16)(op & 0xFFFF);
		int rs = _RS;
		int func = (op >> 16) & 0x1F;
		sprintf(out, "%s\tfunc=%i, %s(%s)", MIPSGetName(op), func, RN(rs), SignedHex(imm));
	}
Пример #3
0
	void Dis_FPULS(MIPSOpcode op, char *out)
	{
		int offset = (signed short)(op&0xFFFF);
		int ft = _FT;
		int rs = _RS;
		const char *name = MIPSGetName(op);
		sprintf(out, "%s\t%s, %s(%s)",name,FN(ft),SignedHex(offset),RN(rs));
	}
Пример #4
0
void Dis_FPULS(u32 op, char *out)
{
    int offset = (signed short)(op&0xFFFF);
    int ft = _FT;
    int rs = _RS;
    const char *name = MIPSGetName(op);
    sprintf(out, "%s\t%s, %d(%s)",name,FN(ft),offset,RN(rs));
}
Пример #5
0
	void Dis_RelBranch(MIPSOpcode op, char *out)
	{
		u32 off = disPC;
		int imm = (signed short)(op&0xFFFF)<<2;
		int rs = _RS;
		off += imm + 4;

		const char *name = MIPSGetName(op);
		sprintf(out, "%s\t%s, ->$%08x",name,RN(rs),off);
	}
Пример #6
0
       void TwisterVM::dispatch ()
       {
             STRING s_aux1;
	 STRING s_aux2;
	 char *ch_aux1;
	 STRING input_s;
	 NUMBER input_d;
	 Instruction executing;

      static const void
      *label_targets[] = {
	     &&LOP_ABS_N, &&LOP_ACOS_N, &&LOP_ADD_N, &&LOP_ASIN_N, &&LOP_ATAN_N, &&LOP_CEIL_N, &&LOP_COS_N, &&LOP_DEC_N, &&LOP_DIV_N, &&LOP_FLOOR_N, &&LOP_INC_N, &&LOP_LOG_N, &&LOP_MOD_N, &&LOP_MULT_N, &&LOP_NEG_N, &&LOP_POW_N, &&LOP_SIN_N, &&LOP_SQRT_N, &&LOP_SUB_N, &&LOP_TAN_N, &&LOP_RAND_N, &&LOP_GOTO, &&LOP_HALT, &&LOP_NOP, &&LOP_SYSTEM_S, &&LOP_GETENV_S, &&LOP_INPUT_N, &&LOP_INPUT_S, &&LOP_PRINT_N, &&LOP_PRINT_S, &&LOP_PUT_N, &&LOP_PUT_S, &&LOP_MOV_N, &&LOP_MOV_S, &&LOP_STORE_N, &&LOP_STORE_S, &&LOP_CONCAT_S, &&LOP_CHARAT_S, &&LOP_LT_S, &&LOP_GT_S, &&LOP_LTE_S, &&LOP_GTE_S, &&LOP_EQ_S, &&LOP_LT_N, &&LOP_GT_N, &&LOP_LTE_N, &&LOP_GTE_N, &&LOP_EQ_N, &&LOP_NOT_LT_S, &&LOP_NOT_GT_S, &&LOP_NOT_LTE_S, &&LOP_NOT_GTE_S, &&LOP_NOT_EQ_S, &&LOP_NOT_LT_N, &&LOP_NOT_GT_N, &&LOP_NOT_LTE_N, &&LOP_NOT_GTE_N, &&LOP_NOT_EQ_N, &&LOP_ZERO_N, &&LOP_NOT_ZERO_N, 
      };
            executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];

LOP_ABS_N: {
	 #ifdef DEBUG
	 puts ("abs_n");
	 #endif
	 RN (executing.A, fabs (RN (executing.A)));
	 current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_ACOS_N: {
	 #ifdef DEBUG
	 puts ("acos_n");
	 #endif
	 RN (executing.C, acos (RN (executing.A)));
	 current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_ADD_N: {
	 #ifdef DEBUG
	 puts ("add_n");
	 #endif
	 RN (executing.C,
		 RN (executing.A) +
		 RN (executing.B));
	 current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_ASIN_N: {
	 #ifdef DEBUG
	 puts ("asin_n");
	 #endif
	 RN (executing.C, asin (RN (executing.A)));
	 current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_ATAN_N: {
	 #ifdef DEBUG
	 puts ("atan_n");
	 #endif
	 RN (executing.C, atan (RN (executing.A)));
	 current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_CEIL_N: {
	 #ifdef DEBUG
	 puts ("ceil_n");
	 #endif
	 RN (executing.C, ceil (RN (executing.A)));
	 current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_COS_N: {
	 #ifdef DEBUG
	 puts ("cos_n");
	 #endif
	 RN (executing.C, cos (RN (executing.A)));
	 current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_DEC_N: {
	 #ifdef DEBUG
	 puts ("dec_n");
	 #endif
	 RN (executing.A, (RN (executing.A) - 1));
	 current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_DIV_N: {
	 #ifdef DEBUG
	 puts ("div_n");
	 #endif
	 /* Colocar como exception */
	 if (RN (executing.B) == 0)
		{
		  error_emitter.emit (ZERO_DIVISION);
		  abort ();
		}
	 RN (executing.C,
		 RN (executing.A) /
		 RN (executing.B));
	 current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_FLOOR_N: {
	 #ifdef DEBUG
	 puts ("floor_n");
	 #endif
	 RN (executing.C, floor (RN (executing.A)));
	 current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_INC_N: {
	 #ifdef DEBUG
	 puts ("inc_n");
	 #endif
	 RN (executing.A, (RN (executing.A) + 1));
	 current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_LOG_N: {
	 #ifdef DEBUG
	 puts ("log_n");
	 #endif
	 RN (executing.C, log (RN (executing.A)));
	 current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_MOD_N: {
	 #ifdef DEBUG
	 puts ("mod_n");
	 #endif
	 RN (executing.C,
		 static_cast<int>(RN (executing.A)) %
		 static_cast<int>(RN (executing.B)));
	 current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_MULT_N: {
	 #ifdef DEBUG
	 puts ("mult_n");
	 #endif
	 RN (executing.C,
		 RN (executing.A) *
		 RN (executing.B));
	 current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_NEG_N: {
	 #ifdef DEBUG
	 puts ("neg_n");
	 #endif
	 RN (executing.A, -RN (executing.A));
	 current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_POW_N: {
	 #ifdef DEBUG
	 puts ("pow_n");
	 #endif
	 RN (executing.C, pow (RN (executing.A),
								 RN (executing.B)));
	 current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_SIN_N: {
	 #ifdef DEBUG
	 puts ("sin_n");
	 #endif
	 RN (executing.C, sin (RN (executing.A)));
	 current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_SQRT_N: {
	 #ifdef DEBUG
	 puts ("sqrt_n");
	 #endif
	 RN (executing.C, sqrt (RN (executing.A)));
	 current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_SUB_N: {
	 #ifdef DEBUG
	 puts ("mult_n");
	 #endif
	 RN (executing.C,
		 RN (executing.A) -
		 RN (executing.B));
	 current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_TAN_N: {
	 #ifdef DEBUG
	 puts ("tan_n");
	 #endif
	 RN (executing.C, tan (RN (executing.A)));
	 current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_RAND_N: {
	 #ifdef DEBUG
	 puts ("rand_n");
	 #endif
	 srand (time (0));
	 RN (executing.C, rand ());
	 current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_GOTO: {
	 #ifdef DEBUG
	 puts ("goto");
	 #endif
	 current_context->pc = executing.A;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_HALT: {
	 #ifdef DEBUG
	 puts ("halt");
	 #endif
	 exit (0);                /* sai normalmente */
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_NOP: {
	 #ifdef DEBUG
	 puts ("nop");
	 #endif
	 current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_SYSTEM_S: {
	 #ifdef DEBUG
	 puts ("system_s");
	 #endif
	 system (RS (executing.A).c_str ());
	 current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_GETENV_S: {
	 #ifdef DEBUG
	 puts ("getenv_s");
	 #endif
	 ch_aux1 = getenv (RS (executing.A).c_str ());
	 if (ch_aux1 == NULL)
		error_emitter.emit (ENV_NOT_FOUND);
	 else
		RS (executing.C, STRING (ch_aux1));
	 current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_INPUT_N: {
	 #ifdef DEBUG
	 puts ("input_n");
	 #endif
	 read_num (input_d);
	 RN (executing.C, input_d);
	 current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_INPUT_S: {
	 #ifdef DEBUG
	 puts ("input_s");
	 #endif
	 read_string (input_s);
	 RS (executing.C, input_s);
	 current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_PRINT_N: {
	 #ifdef DEBUG
	 puts ("print_n");
	 #endif
	 print_num (RN (executing.A), false);
	 current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_PRINT_S: {
	 #ifdef DEBUG
	 puts ("print_s");
	 #endif
	 print_string (RS (executing.A), false);
	 current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_PUT_N: {
	 #ifdef DEBUG
	 puts ("put_n");
	 #endif
	 print_num (RN (executing.A), true);
	 current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_PUT_S: {
	 #ifdef DEBUG
	 puts ("put_s");
	 #endif
	 print_string (RS (executing.A), true);
	 current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_MOV_N: {
	 #ifdef DEBUG
	 puts ("mov_n");
	 #endif
	 RN (executing.C, RN (executing.A));
	 current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_MOV_S: {
	 #ifdef DEBUG
	 puts ("mov_s");
	 #endif
	 RS (executing.C, RS (executing.A));
	 current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_STORE_N: {
	 #ifdef DEBUG
	 puts ("store_n");
	 #endif
	 RN (executing.C,
		 current_context->get_num (executing.A));
	 current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_STORE_S: {
	 #ifdef DEBUG
	 puts ("store_s");
	 #endif
	 RS (executing.C,
		 STRING (current_context->get_string(executing.A)));
	 current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_CONCAT_S: {
	 #ifdef DEBUG
	 puts ("concat_s");
	 #endif
	 s_aux1 = RS (executing.A);
	 s_aux2 = RS (executing.B);
	 RS (executing.C, s_aux1 + s_aux2);
	 current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_CHARAT_S: {
	 #ifdef DEBUG
	 puts ("charat_s");
	 #endif
	 s_aux1 = RS (executing.A);
	 ch_aux1 = new char[2];

	 try {
		/* converte caractere inteiro em char * */
		sprintf (ch_aux1, "%c", s_aux1.at(executing.B));
	 }
	 catch (out_of_range e) {
		error_emitter.emit (OUT_OF_RANGE);
		current_context->pc++;
	 }

	 RS (executing.C, STRING (ch_aux1));
	 current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_LT_S: {
	 #ifdef DEBUG
	 puts ("lt_s");
	 #endif
	 if (RS (executing.A) <
		  RS (executing.B))
		  current_context->pc = executing.C;
	 else
		  current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_GT_S: {
	 #ifdef DEBUG
	 puts ("gt_s");
	 #endif
	 if (RS (executing.A) >
		  RS (executing.B))
		  current_context->pc = executing.C;
	 else
		  current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_LTE_S: {
	 #ifdef DEBUG
	 puts ("lte_s");
	 #endif
	 if (RS (executing.A) <=
		  RS (executing.B))
		  current_context->pc = executing.C;
	 else
		  current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_GTE_S: {
	 #ifdef DEBUG
	 puts ("gte_s");
	 #endif
	 if (RS (executing.A) >=
		  RS (executing.B))
		  current_context->pc = executing.C;
	 else
		  current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_EQ_S: {
	 #ifdef DEBUG
	 puts ("eq_s");
	 #endif
	 if (RS (executing.A) ==
		  RS (executing.B))
		  current_context->pc = executing.C;
	 else
		  current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_LT_N: {
	 #ifdef DEBUG
	 puts ("lt_n");
	 #endif
	 if (RN (executing.A) <
		  RN (executing.B))
		  current_context->pc = executing.C;
	 else
		  current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_GT_N: {
	 #ifdef DEBUG
	 puts ("gt_n");
	 #endif
	 if (RN (executing.A) >
		  RN (executing.B))
		  current_context->pc = executing.C;
	 else
		  current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_LTE_N: {
	 #ifdef DEBUG
	 puts ("lte_n");
	 #endif
	 if (RN (executing.A) <=
		  RN (executing.B))
		  current_context->pc = executing.C;
	 else
		  current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_GTE_N: {
	 #ifdef DEBUG
	 puts ("gte_n");
	 #endif
	 if (RN (executing.A) >=
		  RN (executing.B))
		  current_context->pc = executing.C;
	 else
		  current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_EQ_N: {
	 #ifdef DEBUG
	 puts ("eq_n");
	 #endif
	 /* cout << RN (executing.A) << endl; */
	 /* cout << RN (4) << endl; */
	 /* cout << executing.B << endl; */
	 if (RN (executing.A) ==
		  RN (executing.B))
		  current_context->pc = executing.C;
	 else
		  current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_NOT_LT_S: {
	 #ifdef DEBUG
	 puts ("not_lt_s");
	 #endif
	 if (RS (executing.A) >=
		  RS (executing.B))
		  current_context->pc = executing.C;
	 else
		  current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_NOT_GT_S: {
	 #ifdef DEBUG
	 puts ("not_gt_s");
	 #endif
	 if (RS (executing.A) <=
		  RS (executing.B))
		  current_context->pc = executing.C;
	 else
		  current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_NOT_LTE_S: {
	 #ifdef DEBUG
	 puts ("not_lte_s");
	 #endif
	 if (RS (executing.A) >
		  RS (executing.B))
		  current_context->pc = executing.C;
	 else
		  current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_NOT_GTE_S: {
	 #ifdef DEBUG
	 puts ("not_gte_s");
	 #endif
	 if (RS (executing.A) <
		  RS (executing.B))
		  current_context->pc = executing.C;
	 else
		  current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_NOT_EQ_S: {
	 #ifdef DEBUG
	 puts ("not_eq_s");
	 #endif
	 if (RS (executing.A) !=
		  RS (executing.B))
		  current_context->pc = executing.C;
	 else
		  current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_NOT_LT_N: {
	 #ifdef DEBUG
	 puts ("not_lt_n");
	 #endif
	 if (RN (executing.A) >=
		  RN (executing.B))
		  current_context->pc = executing.C;
	 else
		  current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_NOT_GT_N: {
	 #ifdef DEBUG
	 puts ("not_gt_n");
	 #endif
	 if (RN (executing.A) <=
		  RN (executing.B))
		  current_context->pc = executing.C;
	 else
		  current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_NOT_LTE_N: {
	 #ifdef DEBUG
	 puts ("not_lte_n");
	 #endif
	 if (RN (executing.A) >
		  RN (executing.B))
		  current_context->pc = executing.C;
	 else
		  current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_NOT_GTE_N: {
	 #ifdef DEBUG
	 puts ("not_gte_n");
	 #endif
	 if (RN (executing.A) <
		  RN (executing.B))
		  current_context->pc = executing.C;
	 else
		  current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_NOT_EQ_N: {
	 #ifdef DEBUG
	 puts ("not_eq_n");
	 #endif
	 if (RN (executing.A) !=
		  RN (executing.B))
		  current_context->pc = executing.C;
	 else
		  current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_ZERO_N: {
	 #ifdef DEBUG
	 puts ("zero_n");
	 #endif
	 if (RN (executing.A) == 0)
		  current_context->pc = executing.C;
	 else
		  current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
LOP_NOT_ZERO_N: {
	 #ifdef DEBUG
	 puts ("zero_n");
	 #endif
	 if (RN (executing.A) != 0)
		  current_context->pc = executing.C;
	 else
		  current_context->pc++;
      executing = current_context->code_section[current_context->pc];
      goto *label_targets[executing.opcode];
}
}
Пример #7
0
int main(int argc, const char** argv){
  bool ReDoCuts=false;

  TCut TwelveCut = "gamma_CL>0.1&&BDT_response>0.36&&piplus_MC12TuneV3_ProbNNpi>0.2&&piminus_MC12TuneV3_ProbNNpi>0.2&&Kaon_MC12TuneV3_ProbNNk>0.4";
  TCut ElevenCut = "gamma_CL>0.1&&BDT_response>0.30&&piplus_MC12TuneV3_ProbNNpi>0.2&&piminus_MC12TuneV3_ProbNNpi>0.2&&Kaon_MC12TuneV3_ProbNNk>0.4";
  
  //______________________________MAKE CUT FILE FOR 2012___________________________________
  if(ReDoCuts){
    DataFile MCA(std::getenv("BUKETAPMCBDTRESPROOT"),MC,Twel,MagAll,buketap,"BDTApplied_SampleA");
    
    DataFile MCB(std::getenv("BUKETAPMCBDTRESPROOT"),MC,Twel,MagAll,buketap,"BDTApplied_SampleB");
  
    TreeReader* MC12Reader=  new TreeReader("DecayTree");
    MC12Reader->AddFile(MCA);
    MC12Reader->AddFile(MCB);
    MC12Reader->Initialize();
    
    TFile* MC12Cut = new TFile("CutFile12.root","RECREATE");
    TTree* MC12CutTree=MC12Reader->CopyTree(TwelveCut,-1,"DecayTree");
    TRandom3 *MCRand = new TRandom3(224);
    TH1I * MCnCands12= new TH1I("MCnCands12","MCnCands12",10,0,10);
    TTree*MC12SingleTree=HandyFunctions::GetSingleTree(MCRand,MC12CutTree,MCnCands12,NULL);
    MCnCands12->Write();
    MC12SingleTree->Write();
    MC12Cut->Close();
    
    //________________________________MAKE CUT FILE FOR 2011__________________________________
    
    DataFile MC11A(std::getenv("BUKETAPMCBDTRESPROOT"),MC,Elev,MagAll,buketap,"BDTApplied_SampleA");
    
    DataFile MC11B(std::getenv("BUKETAPMCBDTRESPROOT"),MC,Elev,MagAll,buketap,"BDTApplied_SampleB");
    
    TreeReader* MC11Reader= new TreeReader("DecayTree");
    MC11Reader->AddFile(MC11A);
    MC11Reader->AddFile(MC11B);
    MC11Reader->Initialize();
    
    TFile* MC11Cut = new TFile("CutFile11.root","RECREATE");
    TTree* MC11CutTree=MC11Reader->CopyTree(ElevenCut,-1,"DecayTree");

    TH1I * MCnCands11= new TH1I("MCnCands11","MCnCands11",10,0,10);
    TTree* MC11SingleTree=HandyFunctions::GetSingleTree(MCRand,MC11CutTree,MCnCands11,NULL);
    MCnCands11->Write();
    MC11SingleTree->Write();
    MC11Cut->Close();
  //_________________________________ MAKE FLAT TREES  ____________________________________
  
    TFile* MC12Input = new TFile("CutFile12.root");
    TTree* MC12InputTree=(TTree*)MC12Input->Get("DecayTree");
    Float_t MCEta_Mass12[20]; MC12InputTree->SetBranchAddress("Bu_DTFNoFix_eta_prime_M",&MCEta_Mass12);
    Int_t isSingle12; MC12InputTree->SetBranchAddress("isSingle",&isSingle12);
    
    TFile* MC12FlatOut = new TFile("MCMinimalFile12.root","RECREATE");
    TTree* MC12FlatTree = MC12InputTree->CloneTree(0);
    Double_t MCBu_DTFNoFix_eta_Prime_MF12; MC12FlatTree->Branch("Bu_DTFNoFix_eta_prime_MF",&MCBu_DTFNoFix_eta_Prime_MF12,"Bu_DTFNoFix_eta_prime_MF/D");
    
    Long64_t Entries12=MC12InputTree->GetEntries();
    
    for(int i=0;i<Entries12;++i){
      MC12InputTree->GetEntry(i);
      if(isSingle12==0)continue;
      MCBu_DTFNoFix_eta_Prime_MF12=MCEta_Mass12[0];
      MC12FlatTree->Fill();
    }
    
    MC12FlatTree->Write();
    MC12FlatOut->Close();
    
    TFile* MC11Input = new TFile("CutFile11.root");
    TTree* MC11InputTree=(TTree*)MC11Input->Get("DecayTree");
    Float_t MCEta_Mass11[20]; MC11InputTree->SetBranchAddress("Bu_DTFNoFix_eta_prime_M",&MCEta_Mass11);
    Int_t isSingle11; MC11InputTree->SetBranchAddress("isSingle",&isSingle11);
    
    TFile* MC11FlatOut = new TFile("MCMinimalFile11.root","RECREATE");
    TTree* MC11FlatTree = MC11InputTree->CloneTree(0);
    Double_t MCBu_DTFNoFix_eta_Prime_MF11; MC11FlatTree->Branch("Bu_DTFNoFix_eta_prime_MF",&MCBu_DTFNoFix_eta_Prime_MF11,"Bu_DTFNoFix_eta_prime_MF/D");
    
    Long64_t Entries11=MC11InputTree->GetEntries();
    
    for(int i=0;i<Entries11;++i){
      MC11InputTree->GetEntry(i);
      if(isSingle11==0)continue;
      MCBu_DTFNoFix_eta_Prime_MF11=MCEta_Mass11[0];
      MC11FlatTree->Fill();
    }
    
    MC11FlatTree->Write();
    MC11FlatOut->Close();
  }
  
  //_____________________________________________LOAD ROODATASETS___________________________________

  TFile* MCFlatInput12= new TFile("MCMinimalFile12.root");
  TTree* MCFlatInputTree12=(TTree*)MCFlatInput12->Get("DecayTree");

  TFile* MCFlatInput11= new TFile("MCMinimalFile11.root");
  TTree* MCFlatInputTree11=(TTree*)MCFlatInput11->Get("DecayTree");

  RooRealVar MCBMass("Bu_DTF_MF","Bu_DTF_MF",5000.0,5600.0);
  RooRealVar MCEtaMass("eta_prime_MM","eta_prime_MM",700.0,1200.0);
  RooRealVar BDT_response("BDT_response","BDT_response",-1.0,1.0);
  RooRealVar gamma_CL("gamma_CL","gamma_CL",0.1,1.0);
  RooArgSet Args(MCBMass,MCEtaMass,BDT_response,gamma_CL);

  RooDataSet* MCData12 = new RooDataSet("MCData12","MCData12",Args,Import(*MCFlatInputTree12));
  
  std::cout <<" Data File 12 Loaded"<<std::endl;
  
  RooDataSet* MCData11 = new RooDataSet("MCData11","MCData11",Args,Import(*MCFlatInputTree11));

  std::cout<<" Data File 11 loaded"<<std::endl;

  RooDataSet* MCDataAll= new RooDataSet("MCDataAll","MCDataAll",Args);

  MCDataAll->append(*MCData12);
  MCDataAll->append(*MCData11);
  
  RooPlot* massFrame = MCBMass.frame(Title("Data Import Check"),Bins(50));
  MCDataAll->plotOn(massFrame);
  
  RooPlot *BDTFrame = BDT_response.frame(Title("BDT Cut Check"),Bins(50));
  MCDataAll->plotOn(BDTFrame);
  TCanvas C;
  C.Divide(2,1);
  C.cd(1);
  massFrame->Draw();
  C.cd(2);
  BDTFrame->Draw();
  C.SaveAs("ImportChecks.eps");

  //________________________________MAKE MCROODATACATEGORIES__________________________________

  RooDataSet* MCBData=(RooDataSet*)MCDataAll->reduce(RooArgSet(MCBMass));
  MCBData->Print("v");
  
  RooDataSet* MCEtaData=(RooDataSet*)MCDataAll->reduce(RooArgSet(MCEtaMass));
  MCEtaData->Print("v");

  RooCategory MCMassType("MCMassType","MCMassType") ;
  MCMassType.defineType("B") ;
  MCMassType.defineType("Eta") ;
  
  // Construct combined dataset in (x,sample)
  RooDataSet MCcombData("MCcombData","MC combined data",Args,Index(MCMassType),Import("B",*MCBData),Import("Eta",*MCEtaData));

  
  //=============================================== MC FIT MODEL===================================
  
  RooRealVar Mean("Mean","Mean",5279.29,5276.0,5284.00);
  RooRealVar Sigma("Sigma","Sigma",20.54,17.0,24.8);
  RooRealVar LAlpha("LAlpha","LAlpha",-1.064,-2.5,0.0);
  RooRealVar RAlpha("RAlpha","RAlpha",1.88,0.0,5.0);
  RooRealVar LN("LN","LN",13.0,0.0,40.0);
  RooRealVar RN("RN","RN",2.56,0.0,6.0);

  RooCBShape CBLeft("CBLeft","CBLeft",MCBMass,Mean,Sigma,LAlpha,LN);
  
  RooCBShape CBRight("CBRight","CBRight",MCBMass,Mean,Sigma,RAlpha,RN);

  RooRealVar FitFraction("FitFraction","FitFraction",0.5,0.0,1.0);
  RooAddPdf DCB("DCB","DCB",RooArgList(CBRight,CBLeft),FitFraction);

  RooRealVar SignalYield("SignalYield","SignalYield",4338.0,500.0,10000.0);
  //  RooExtendPdf ExtDCB("ExtDCB","ExtDCB",DCB,SignalYield);
  
  //==============================ETA DCB ++++++++++++++++++++++++++++++
  
  RooRealVar MCEtamean("MCEtamean","MCEtamean",958.0,955.0,960.0);
  RooRealVar MCEtasigma("MCEtasigma","MCEtasigma",9.16,8.0,14.0);
  RooRealVar EtaLAlpha("EtaLAlpha","EtaLAlpha",-1.45,-5.0,1.0);
  RooRealVar EtaRAlpha("EtaRAlpha","EtaRAlpha",1.76,0.0,4.0);
  RooRealVar EtaLN("EtaLN","EtaLN",0.1,0.0,20.0);
  RooRealVar EtaRN("EtaRN","EtaRN",0.1,0.0,20.0);

  RooCBShape EtaCBLeft("EtaCBLeft","EtaCBLeft",MCEtaMass,MCEtamean,MCEtasigma,EtaLAlpha,EtaLN);
  
  RooCBShape EtaCBRight("EtaCBRight","EtaCBRight",MCEtaMass,MCEtamean,MCEtasigma,EtaRAlpha,EtaRN);

  RooRealVar EtaFitFraction("EtaFitFraction","EtaFitFraction",0.22,0.1,1.0);
  RooAddPdf EtaDCB("EteaDCB","EtaDCB",RooArgList(EtaCBRight,EtaCBLeft),EtaFitFraction);

  RooProdPdf MCSignalPdf("MCSignalPdf","MCSignalPdf",RooArgSet(EtaDCB,DCB));
  
  RooExtendPdf ExtendedMCSignalPdf("ExtendedMCSignalPdf","ExtendedMCSignalPdf",MCSignalPdf,SignalYield);

  RooSimultaneous MCsimPdf("MCsimPdf","MC simultaneous pdf",MCMassType) ;
  //  MCsimPdf.addPdf(ExtDCB,"B");
  //  MCsimPdf.addPdf(ExtendedMCEtaDCB,"Eta"); 

  //============================== DO the MC FIT =======================================
  //MCsimPdf.fitTo(MCcombData,Extended(kTRUE),Minos(kTRUE));
  //ExtendedMCEtaDCB.fitTo(*MCEtaData,Extended(kTRUE),Minos(kTRUE));
  //ExtDCB.fitTo(*MCBData,Extended(
  ExtendedMCSignalPdf.fitTo(*MCDataAll,Extended(kTRUE),Minos(kTRUE));
  
  RooPlot* MCframe1 = MCBMass.frame(Range(5100.0,5500.0),Bins(50),Title("B mass projection"));
  MCDataAll->plotOn(MCframe1);
  ExtendedMCSignalPdf.plotOn(MCframe1);
  ExtendedMCSignalPdf.paramOn(MCframe1);
  
  RooPlot* MCframe2 = MCEtaMass.frame(Range(880.0,1020.0),Bins(50),Title("Eta mass projection")) ;
  MCDataAll->plotOn(MCframe2);
  ExtendedMCSignalPdf.plotOn(MCframe2);
  ExtendedMCSignalPdf.paramOn(MCframe2);
  
  TCanvas* MCc = new TCanvas("rf501_simultaneouspdf","rf403_simultaneouspdf",1200,1000) ;
  gPad->SetLeftMargin(0.15) ; MCframe1->GetYaxis()->SetTitleOffset(1.4) ; MCframe1->Draw() ;
  MCc->SaveAs("MCSimulCanvas.pdf");

  TCanvas* MCcEta = new TCanvas(" Eta Canvas","Eta Canvas",1200,1000);
  gPad->SetLeftMargin(0.15) ; MCframe2->GetYaxis()->SetTitleOffset(1.4) ; MCframe2->Draw() ;
  MCcEta->SaveAs("MCEtaCanvas.pdf");

  TFile* MCFits= new TFile("MCFitResult.root","RECREATE");
  //  TCanvas* DecMCB=HandyFunctions::DecoratePlot(MCframe1);
  //  TCanvas* DecMCEta=HandyFunctions::DecoratePlot(MCframe2);
  //DecMCEta->Write();
  //  DecMCB->Write();
  MCc->Write();
  MCcEta->Write();

  std::cout<<"MC Eta Chi2 = "<<MCframe2->chiSquare()<<std::endl;
  std::cout<<"MC B Chi2 = "<<MCframe1->chiSquare()<<std::endl;

  //___________________________________ CUT DOWN COLLISION DATA ______________________________
  if(ReDoCuts){
    DataFile TwelveA(std::getenv("BUKETAPDATABDTRESPROOT"),Data,Twel,MagAll,buketap,"BDTApplied_SampleA");

    DataFile TwelveB(std::getenv("BUKETAPDATABDTRESPROOT"),Data,Twel,MagAll,buketap,"BDTApplied_SampleB");
  
    DataFile ElevenA(std::getenv("BUKETAPDATABDTRESPROOT"),Data,Elev,MagAll,buketap,"BDTApplied_SampleA");

    DataFile ElevenB(std::getenv("BUKETAPDATABDTRESPROOT"),Data,Elev,MagAll,buketap,"BDTApplied_SampleB");		

    TRandom3* DataRand= new TRandom3(224);
    TH1I* DataNCand12= new TH1I("DataNCand12","DataNCand12",10,0,10);
    TH1I* DataNCand11= new TH1I("DataNCand11","DataNCand11",10,0,10);
    
    TreeReader* UncutDataReader12= new TreeReader("DecayTree");
    UncutDataReader12->AddFile(TwelveA);
    UncutDataReader12->AddFile(TwelveB);
    UncutDataReader12->Initialize();
    
    TFile* CutDataFile12 = new TFile("CutDataFile12.root","RECREATE");
    TTree* CutDataTree12 = UncutDataReader12->CopyTree(TwelveCut,-1,"DecayTree");
    TTree* SingleCutDataTree12=HandyFunctions::GetSingleTree(DataRand,CutDataTree12,DataNCand12,NULL);
    SingleCutDataTree12->Write();
    CutDataFile12->Close();
    
    TreeReader* UncutDataReader11= new TreeReader("DecayTree");
    UncutDataReader11->AddFile(ElevenB);
    UncutDataReader11->AddFile(ElevenA);
    UncutDataReader11->Initialize();
    
    TFile* CutDataFile11 = new TFile("CutDataFile11.root","RECREATE");
    TTree* CutDataTree11 = UncutDataReader11->CopyTree(ElevenCut,-1,"DecayTree");
    TTree* SingleCutDataTree11=HandyFunctions::GetSingleTree(DataRand,CutDataTree11,DataNCand11,NULL);
    SingleCutDataTree11->Write();
    CutDataFile11->Close();
  

    TFile* DataInput12 = new TFile("CutDataFile12.root");
    TTree* DataInputTree12=(TTree*)DataInput12->Get("DecayTree");
    DataInputTree12->SetBranchStatus("*",0);
    DataInputTree12->SetBranchStatus("Bu_DTF_MF",1);
    DataInputTree12->SetBranchStatus("Bu_DTFNoFix_eta_prime_M",1);
    DataInputTree12->SetBranchStatus("eta_prime_MM",1);
    DataInputTree12->SetBranchStatus("isSingle",1);
    Float_t Eta_Mass12[20]; DataInputTree12->SetBranchAddress("Bu_DTFNoFix_eta_prime_M",&Eta_Mass12);
    Int_t isSingle12; DataInputTree12->SetBranchAddress("isSingle",&isSingle12);
    
    TFile* MinimalDataFile12 = new TFile("MinimalDataFile12.root","RECREATE");
    TTree* MinimalDataTree12= DataInputTree12->CloneTree(0);
    Double_t Bu_DTFNoFix_eta_prime_MF12; MinimalDataTree12->Branch("Bu_DTFNoFix_eta_prime_MF",&Bu_DTFNoFix_eta_prime_MF12,"Bu_DTFNoFix_eta_prime_MF/D");
    
    Long64_t Entries12=DataInputTree12->GetEntries();
    
    for(int i=0;i<Entries12;++i){
      DataInputTree12->GetEntry(i);
      if(isSingle12==0)continue;
      Bu_DTFNoFix_eta_prime_MF12=Eta_Mass12[0];
      MinimalDataTree12->Fill();
    }
    
    MinimalDataTree12->Write();
    MinimalDataFile12->Close();
    
    TFile* DataInput11 = new TFile("CutDataFile11.root");
    TTree* DataInputTree11=(TTree*)DataInput11->Get("DecayTree");
    DataInputTree11->SetBranchStatus("*",0);
    DataInputTree11->SetBranchStatus("Bu_DTF_MF",1);
    DataInputTree11->SetBranchStatus("Bu_DTFNoFix_eta_prime_M",1);
    DataInputTree11->SetBranchStatus("eta_prime_MM",1);
    DataInputTree11->SetBranchStatus("isSingle",1);
    Float_t Eta_Mass11[20]; DataInputTree11->SetBranchAddress("Bu_DTFNoFix_eta_prime_M",&Eta_Mass11);
    Int_t isSingle11; DataInputTree11->SetBranchAddress("isSingle",&isSingle11);
    
    TFile* MinimalDataFile11 = new TFile("MinimalDataFile11.root","RECREATE");
    TTree* MinimalDataTree11= DataInputTree11->CloneTree(0);
    Double_t Bu_DTFNoFix_eta_prime_MF11; MinimalDataTree11->Branch("Bu_DTFNoFix_eta_prime_MF",&Bu_DTFNoFix_eta_prime_MF11,"Bu_DTFNoFix_eta_prime_MF/D");
    
    Long64_t Entries11=DataInputTree11->GetEntries();
    
    for(int i=0;i<Entries11;++i){
    DataInputTree11->GetEntry(i);
    if(isSingle11==0)continue;
    Bu_DTFNoFix_eta_prime_MF11=Eta_Mass11[0];
    MinimalDataTree11->Fill();
    }
    MinimalDataTree11->Write();
    MinimalDataFile11->Close();
  }

  //___________________________________ LOAD DATA TO ROODATASET____________________________________
  
  RooRealVar BMass("Bu_DTF_MF","Bu_DTF_MF",5000.0,5600.0);
  RooRealVar EtaMass("eta_prime_MM","eta_prime_MM",870.0,1050.0);
  RooArgSet MassArgs(BMass,EtaMass);

  TFile* Data12File = new TFile("MinimalDataFile12.root");
  TTree* DataTree12=(TTree*)Data12File->Get("DecayTree");

  RooDataSet* Data12 = new RooDataSet("Data12","Data12",MassArgs,Import(*DataTree12));

  TFile* Data11File = new TFile("MinimalDataFile11.root");
  TTree* DataTree11=(TTree*)Data11File->Get("DecayTree");

  RooDataSet* Data11 = new RooDataSet("Data11","Data11",MassArgs,Import(*DataTree11));
  
  RooDataSet* AllData = new RooDataSet("AllData","AllData",MassArgs);
  AllData->append(*Data12);
  AllData->append(*Data11);
  TCanvas ImportC;
  RooPlot* ImportCheck = BMass.frame(Title("ImportCheck"),Bins(50));
  AllData->plotOn(ImportCheck);
  ImportCheck->Draw();
  ImportC.SaveAs("Alldataimport.pdf");

  std::cout<<" Data Loaded, Total Entries = "<<AllData->numEntries()<<std::endl;

  AllData->Print("v");

  RooDataSet* BData=(RooDataSet*)AllData->reduce(RooArgSet(BMass));
  BData->Print("v");

  RooDataSet* EtaData=(RooDataSet*)AllData->reduce(RooArgSet(EtaMass));
  EtaData->Print("v");

  //___________________________________Fit to Eta_Prime in BMass Sidebands______________________

  RooDataSet* BSidebands=(RooDataSet*)AllData->reduce(Cut("(Bu_DTF_MF>5000.0&&Bu_DTF_MF<5179.0)||(Bu_DTF_MF>5379.0&&Bu_DTF_MF<5800.0)"));

  TCanvas BSidebandCanvas;
  RooPlot* BSidebandPlot = EtaMass.frame(Title("B sidebands"),Bins(30));
  BSidebands->plotOn(BSidebandPlot);
  BSidebandPlot->Draw();
  BSidebandCanvas.SaveAs("BSidebandDataCheck.pdf");

  
  RooRealVar BsbMean(" Mean","BsbMean",958.0,900.0,1020.0);
  RooRealVar BsbSigma(" Sigma","BsbSigma",19.8,10.0,40.8);
  RooRealVar BsbLAlpha(" Alpha","BsbLAlpha",-1.63,-10.0,0.0);
  //  RooRealVar BsbRAlpha("BsbRAlpha","BsbRAlpha",1.47,0.0,10.0);
  RooRealVar BsbLN(" N","BsbLN",0.1,0.0,20.0);
  //  RooRealVar BsbRN("BsbRN","BsbRN",0.1,0.0,20.0);

  RooCBShape BsbCBLeft("BsbCBLeft","BsbCBLeft",EtaMass,BsbMean,BsbSigma,BsbLAlpha,BsbLN);
  
  //  RooCBShape BsbCBRight("BsbCBRight","BsbCBRight",EtaMass,BsbMean,BsbSigma,BsbRAlpha,BsbRN);

  //  RooRealVar BsbFitFraction("BsbFitFraction","BsbFitFraction",0.5,0.0,1.0);
  //  RooAddPdf BsbDCB("BsbDCB","BsbDCB",RooArgList(BsbCBRight,BsbCBLeft),BsbFitFraction);
  RooRealVar Bsbslope("Bsbslope","Bsbslope",0.5,0.0,1.0);
  RooRealVar BsbP2("BsbP2","BsbP2",-0.5,-1.0,0.0);
  RooChebychev BsbLinear("BsbLinear","BsbLinear",EtaMass,RooArgSet(Bsbslope,BsbP2));

  RooRealVar BsbFitFraction("BsbFitFraction","BsbFitFraction",0.2,0.0,1.0);

  RooAddPdf BsbBackground("BsbBackground","BsbBackground",RooArgList(BsbLinear,BsbCBLeft),BsbFitFraction);
  
  RooRealVar BsbYield(" Yield","BsbYield",500.0,0.0,1000.0);
  RooExtendPdf BsbExtDCB("BsbExtDCB","BsbExtDCB",BsbCBLeft,BsbYield);

  BsbExtDCB.fitTo(*BSidebands,Extended(kTRUE),Minos(kTRUE));
  TCanvas BSBFitCanvas;
  RooPlot* BSBFitPlot = EtaMass.frame(Title("Eta fit in B Sidebands"),Bins(30));
  BSidebands->plotOn(BSBFitPlot);
  BsbExtDCB.plotOn(BSBFitPlot);
  BsbExtDCB.paramOn(BSBFitPlot);
  BSBFitPlot->Draw();
  BSBFitCanvas.SaveAs("BSidebandFit.pdf");
  TFile * SidebandFitFile= new TFile("SidebandFit.root","RECREATE");
  BSBFitCanvas.Write();
  SidebandFitFile->Close();
  
  //___________________________________DO THE 2D FIT TO DATA___________________________________


  const double PDGBMass= 5279.26;
  BMass.setRange("SignalWindow",PDGBMass-(3*Sigma.getVal()),PDGBMass+(3*Sigma.getVal()));
  RooRealVar DSignalYield("DSignalYield","DSignalYield",4000.0,0.0,10000.0);

  //================================= B MASS SIGNAL PDF==============================
  RooRealVar DMean("Mean","DMean",5279.29,5270.0,5290.00);
  RooRealVar DSigma("Sigma","DSigma",19.8,10.0,40.8);
  RooRealVar DLAlpha("DLAlpha","DLAlpha",LAlpha.getVal());
  RooRealVar DRAlpha("DRAlpha","DRAlpha",RAlpha.getVal());
  RooRealVar DLN("DLN","DLN",LN.getVal());
  RooRealVar DRN("DRN","DRN",RN.getVal());

  RooCBShape DCBLeft("DCBLeft","DCBLeft",BMass,DMean,DSigma,DLAlpha,DLN);
  
  RooCBShape DCBRight("DCBRight","DCBRight",BMass,DMean,DSigma,DRAlpha,DRN);

  RooRealVar DFitFraction("FitFraction","DFitFraction",0.5,0.0,1.0);
  RooAddPdf DDCB("DDCB","DDCB",RooArgList(DCBRight,DCBLeft),DFitFraction);
  
  //==============================B MASS BKG PDF==============================
  RooRealVar slope("slope","slope",-0.5,-1.0,0.0);
  RooChebychev bkg("bkg","Background",BMass,RooArgSet(slope));
  
  //==============================Eta mass signal pdf================================
  RooRealVar DEtamean("Etamean","DEtamean",958.0,945.0,980.0) ;
  RooRealVar DEtasigma("Etasigma","DEtasigma",15.0,5.0,65.0) ;
  RooRealVar DEtaLAlpha("DEtaLAlpha","DEtaLAlpha",EtaLAlpha.getVal());
  RooRealVar DEtaRAlpha("DEtaRAlpha","DEtaRAlpha",EtaRAlpha.getVal());
  RooRealVar DEtaLN("DEtaLN","DEtaLN",EtaLN.getVal());
  RooRealVar DEtaRN("DEtaRN","DEtaRN",EtaRN.getVal());
  
  RooCBShape EtaDCBLeft("EtaDCBLeft","EtaDCBLeft",EtaMass,DEtamean,DEtasigma,DEtaLAlpha,DEtaLN);
  
  RooCBShape EtaDCBRight("EtaDCBRight","EtaDCBRight",EtaMass,DEtamean,DEtasigma,DEtaRAlpha,DEtaRN);
  
  RooRealVar DEtaFitFraction("EtaFitFraction","DEtaFitFraction",0.5,0.0,1.0);
  RooAddPdf EtaDDCB("EtaDDCB","EtaDDCB",RooArgList(EtaDCBRight,EtaDCBLeft),DEtaFitFraction);

  RooProdPdf DSignalPdf("DSignalPdf","DSignalPdf",RooArgList(EtaDDCB,DDCB));
  
  RooExtendPdf DExtSignalPdf("DExtSignalPdf","DExtSignalPdf",DSignalPdf,DSignalYield);

  //=============================== Eta mass bkg pdf==================================
  
  RooRealVar EtaBkgMean("EtaBkgMean","EtaBkgMean",958.0,900.0,1020.0);
  RooRealVar EtaBkgSigma("EtaBkgSigma","EtaBkgSigma",19.8,10.0,40.8);
  RooRealVar EtaBkgLAlpha("EtaBkgLAlpha","EtaBkgLAlpha",BsbLAlpha.getVal());
  //  RooRealVar EtaBkgRAlpha("EtaBkgRAlpha","EtaBkgRAlpha",BsbRAlpha.getVal());
  RooRealVar EtaBkgLN("EtaBkgLN","EtaBkgLN",BsbLN.getVal());
  //  RooRealVar EtaBkgRN("EtaBkgRN","EtaBkgRN",BsbRN.getVal());

  RooCBShape EtaBkgCBLeft("EtaBkgCBLeft","EtaBkgCBLeft",EtaMass,DEtamean,EtaBkgSigma,EtaBkgLAlpha,EtaBkgLN);
  
  //  RooCBShape EtaBkgCBRight("EtaBkgCBRight","EtaBkgCBRight",EtaMass,DEtamean,EtaBkgSigma,EtaBkgRAlpha,EtaBkgRN);
  
  //  RooRealVar EtaBkgFitFraction("EtaBkgFitFraction","EtaBkgFitFraction",0.5,0.0,1.0);
  //  RooAddPdf EtaBkgDCB("EtaBkgDCB","EtaBkgDCB",RooArgList(EtaBkgCBRight,EtaBkgCBLeft),EtaBkgFitFraction);
  
  RooProdPdf DataBackgroundPDF("DataBackgroundPDF","DataBackgroundPDF",RooArgList(EtaBkgCBLeft,bkg));
  
  RooRealVar DataBackgroundYield("BackgroundYield","DataBackgroundYield",500.0,0.0,10000.0);
  
  RooExtendPdf ExtDataBackgroundPDF("ExtDataBackgroundPDF","ExtDataBackgroundPDF",DataBackgroundPDF,DataBackgroundYield);

  RooAddPdf TotalPDF("TotalPDF","TotalPDF",RooArgList(ExtDataBackgroundPDF,DExtSignalPdf));
  std::cout<<"Dependents = "<<std::endl;
  RooArgSet* Dependents=TotalPDF.getDependents(AllData);
  Dependents->Print("v");
  std::cout<<"parameters= "<<std::endl;
  RooArgSet* parameters=TotalPDF.getParameters(AllData);
  parameters->Print("v");
  RooCategory MassType("MassType","MassType") ;
  MassType.defineType("B") ;
  MassType.defineType("Eta") ;
  
  // Construct combined dataset in (x,sample)
  RooDataSet combData("combData","combined data",MassArgs,Index(MassType),Import("B",*BData),Import("Eta",*EtaData));

  RooSimultaneous simPdf("simPdf","simultaneous pdf",MassType) ;

  // Associate model with the physics state and model_ctl with the control state
  //  simPdf.addPdf(WholeFit,"B");
  //  simPdf.addPdf(WholeEtaFit,"Eta"); 

  //  simPdf.fitTo(combData,Extended(kTRUE)/*,Minos(kTRUE)*/);
  
  TotalPDF.fitTo(*AllData,Extended(kTRUE),Minos(kTRUE));

  RooPlot* frame1 = BMass.frame(Bins(50),Title("B mass projection"));
  AllData->plotOn(frame1);
  TotalPDF.plotOn(frame1,Components(ExtDataBackgroundPDF),LineStyle(kDashed),LineColor(kRed));
  TotalPDF.plotOn(frame1);
  TotalPDF.paramOn(frame1);
  
  // The same plot for the control sample slice
  RooPlot* frame2 = EtaMass.frame(Bins(50),Title("Eta mass projection")) ;
  AllData->plotOn(frame2);
  TotalPDF.plotOn(frame2,Components(ExtDataBackgroundPDF),LineStyle(kDashed),LineColor(kRed));
  TotalPDF.plotOn(frame2);
  TotalPDF.paramOn(frame2);
  TCanvas* DecoratedCanvas =HandyFunctions::DecoratePlot(frame2);

  
  TCanvas* DataBC= new TCanvas("BCanvas","BCanvas",1200,1000) ;
  gPad->SetLeftMargin(0.15) ; frame1->GetYaxis()->SetTitleOffset(1.4) ; frame1->Draw() ;
  TCanvas* EtaBC= new TCanvas("EtaCanvas","EtaCanvas",1200,1000) ;
  gPad->SetLeftMargin(0.15) ; frame2->GetYaxis()->SetTitleOffset(1.4) ; frame2->Draw() ;
  DataBC->SaveAs("DataBC.pdf");
  EtaBC->SaveAs("EtaBC.pdf");
  
  TFile * DataSimulFit = new TFile("DataSimulFit.root","RECREATE");
  DataBC->Write();
  EtaBC->Write();
  DecoratedCanvas->Write();

  
		 
		  

  
}
Пример #8
0
int main()
{
	TFIM test[N];
	Regulation Hope;
	Hope.readName(test);
	Hope.fullFill();
	//Calculate xinyu;
	//xinyu.Network_1(Hope.originalMatrix,166);
	//xinyu.Network_2(Hope.originalMatrix,166);
	//cout<<xinyu.nong[90];
	int A,C;
	string B;
	FILE *fp;
	//FILE *fp1;
	//fp=fopen("DNA","w");
	/*for(int i=160;i<Hope.getGeneAmount();i++)
	{
		test[i].getGeneInformation(fp);
		cout<<i<<endl;
		//cout<<test[i].getGeneSequence()<<endl;
	}
	fclose(fp);*/
	//ReadDNA read[100];
	ReadDNA luck[N];
	Sequence good[N];
	fp=fopen("DNA","r");
	//fp1=fopen("AAS","w");
	//ofstream data("AAS");
	for(int i=0;i<Hope.getGeneAmount();i++)
	{
		//test[i].getGeneInformation(fp);
		luck[i].fetch(fp);
		A=luck[i].getNumber();
		B=luck[i].getSequence();
		C=luck[i].getLength();
		//B=test[i].getGeneSequence();
		//C=B.length();
		good[i].initializeGeneSequence(B,A,C);
		good[i].translation();
		B=good[i].aminoAcidSequence;
		//cout<<A<<"	"<<B<<endl;
	}
	fclose(fp);
	//data.close();
	ofstream RN("newGRN");
	string insertGene="MSKGEELFTGVVPILVELDGDVNGHKFSVSGEGEGDATYGKLTLKFICTTGKLPVPWPTLVTTFAYGVQCFSRYPDHMKRHDFFKSAMPEGYVQERTIFFKDDGNYKTRAEVKFEGDTLVNRIELKGIDFKEDGNILGHKLEYNYNSHNVYIMADKQKNGIKVNFKIRHNIEDGSVQLADHYQQNTPIGDGPVLLPDNHYLSTQSVLSKDPNEKRDHMVLLEFVTAAGITHGMDELYK";
	GRN newGRN;
	newGRN.initializeGRN(Hope.originalMatrix,Hope.getGeneAmount());
	good[166].getNewASS(insertGene);
	newGRN.constructNewGRN(good);
	for(int j=0;j<N;j++)
	{
		for(int i=0;i<N;i++)
		{
			RN<<newGRN.newGRNCorrelation[j][i]<<"	";
		}
		RN<<endl;
	}
	//test[30].getGeneInformation();
	//test[31].getGeneInformation();
	//int a;
	//a=test[31].getRNA();
	//a=test[30].getRNA();
	getchar();
}