00001
00002
00003
00004
00005
00006
00007
00008
00010
00011 #include "TMarCutMC.h"
00012
00013 TMarCutMC::TMarCutMC()
00014 {
00015 Variable="none";
00016 Valid=false;
00017
00018 };
00019
00020 istream& operator>>(istream& in, TMarCutMC& CutMC){
00021
00022 int n_cut,out=1;
00023 float Min,Max;
00024 double Lumi;
00025 char nom[20];
00026
00027 in >> CutMC.Variable >> nom;
00028
00029 if(CutMC.Variable!="MELEPHO"&&
00030 CutMC.Variable!="MMUMU"&&
00031 CutMC.Variable!="Q2"&&
00032 CutMC.Variable!="RAPQ2"&&
00033 CutMC.Variable!="Y"&&
00034 CutMC.Variable!="RAPY"&&
00035 CutMC.Variable!="PHAT")
00036 {
00037 Error("TMarCutMC::istream","Wrong CutMC.Variable '%s' in card 'genCut'. Exit",CutMC.Variable.c_str());
00038 exit(1);
00039 }
00040
00041
00042 out= sscanf(nom,"%d",&n_cut);
00043
00044 if(!out){
00045 error:;
00046 Error("TMarCutMC::istream","Wrong input format (card 'genCut'). Exit");
00047 exit(1);
00048 }
00049
00050 for(Int_t i=0;i<n_cut;i++){
00051 in >> nom;
00052 out= sscanf(nom,"%f",&Min);
00053 if(!out)goto error;
00054
00055 in >> nom;
00056 out= sscanf(nom,"%f",&Max);
00057 if(!out)goto error;
00058
00059 in >> nom;
00060 out= sscanf(nom,"%lf",&Lumi);
00061 if(!out)goto error;
00062
00063
00064 CutMC.CutMin.push_back(Min);
00065 CutMC.CutMax.push_back(Max);
00066
00067 if(Lumi!=0)CutMC.Weight.push_back(1/Lumi);
00068 else CutMC.Weight.push_back(0) ;
00069 }
00070
00071
00072
00073 return in;
00074 };
00075
00076 ostream& operator<<(ostream& out, TMarCutMC& CutMC){
00077
00078 out << "variable= " << CutMC.Variable;
00079 for (unsigned int i=0;i<CutMC.CutMin.size();i++){
00080 out << " min= " << CutMC.CutMin[i]
00081 << " max= " << CutMC.CutMax[i] << " weight= "<< CutMC.Weight[i] ;
00082 }
00083 return out;
00084 };
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118 Double_t TMarCutMC::Evaluate(Double_t value)
00119 {
00120
00121
00122 for (unsigned int i=0;i<CutMin.size();i++){
00123
00124 if (value>CutMin[i] && value<CutMax[i]){
00125
00126 return Weight[i];
00127 }
00128
00129 }
00130 return 0;
00131 };
00132
00133
00134 istream& operator>>(istream& in, TMarCutMCList& List){
00135
00136 int n_cut,out=1;
00137 char nom[20];
00138 in >> nom;
00139
00140 out= sscanf(nom,"%d",&n_cut);
00141
00142 if(!out){
00143 Error("TMarCutMCList::istream","Wrong input format (card 'genCut'). Exit");
00144 exit(1);
00145 }
00146 for(Int_t i=0;i<n_cut;i++){
00147
00148 TMarCutMC newCut;
00149 in >> newCut;
00150 List.CutList.push_back(newCut);
00151
00152 }
00153 return in;
00154 };
00155
00156 ostream& operator<<(ostream& out, TMarCutMCList& List){
00157
00158 out << "Cuts lists: "<< endl;
00159 for (list<TMarCutMC>::iterator it= List.CutList.begin();it != List.CutList.end(); it++)
00160 {
00161
00162 out << *it<< endl;
00163 }
00164 return out;
00165 };