00001
00002
00003
00004
00005
00006
00007
00008
00010
00011 #include "Marana/TMarSyst.h"
00012 #include "Marana/TMarEvent.h"
00013
00014 TMarSyst::TMarSyst()
00015 {
00016 Sign=0;
00017 Type=0;
00018 Name="/";
00019 Scale_now=NULL;
00020
00021 MapPossibleScales["/"]=0;
00022 MapPossibleScales["E_EM_UP"]=+1;
00023 MapPossibleScales["E_EM_DOWN"]=-1;
00024 MapPossibleScales["THE_EM_UP"]=+2;
00025 MapPossibleScales["THE_EM_DOWN"]=-2;
00026 MapPossibleScales["E_JET_UP"]=+3;
00027 MapPossibleScales["E_JET_DOWN"]=-3;
00028 MapPossibleScales["THE_JET_UP"]=+4;
00029 MapPossibleScales["THE_JET_DOWN"]=-4;
00030 MapPossibleScales["PT_MU_UP"]=+5;
00031 MapPossibleScales["PT_MU_DOWN"]=-5;
00032 MapPossibleScales["THE_MU_UP"]=+6;
00033 MapPossibleScales["THE_MU_DOWN"]=-6;
00034 MapPossibleScales["THE_ALL_UP"]=+7;
00035 MapPossibleScales["THE_ALL_DOWN"]=-7;
00036 MapPossibleScales["E_ALL_UP"]=+8;
00037 MapPossibleScales["E_ALL_DOWN"]=-8;
00038 MapPossibleScales["ID_EM_UP"]=+9;
00039 MapPossibleScales["ID_EM_DOWN"]=-9;
00040 MapPossibleScales["ID_JET_UP"]=+10;
00041 MapPossibleScales["ID_JET_DOWN"]=-10;
00042 MapPossibleScales["ID_MU_UP"]=+11;
00043 MapPossibleScales["ID_MU_DOWN"]=-11;
00044 MapPossibleScales["ID_PHO_UP"]=+12;
00045 MapPossibleScales["ID_PHO_DOWN"]=-12;
00046
00047 MapPossibleScales["TRIGGER_UP"]=+13;
00048 MapPossibleScales["TRIGGER_DOWN"]=-13;
00049 MapPossibleScales["USERSEL_UP"]=+14;
00050 MapPossibleScales["USERSEL_DOWN"]=-14;
00051 MapPossibleScales["HFSNOISE_UP"]=+15;
00052 MapPossibleScales["HFSNOISE_DOWN"]=-15;
00053
00054
00055 MapPossibleScales["E_EM_UP_COR"]=+16;
00056 MapPossibleScales["E_EM_DOWN_COR"]=-16;
00057 MapPossibleScales["E_EM_UP_UNCOR"]=+17;
00058 MapPossibleScales["E_EM_DOWN_UNCOR"]=-17;
00059 MapPossibleScales["E_JET_UP_COR"]=+18;
00060 MapPossibleScales["E_JET_DOWN_COR"]=-18;
00061 MapPossibleScales["E_JET_UP_UNCOR"]=+19;
00062 MapPossibleScales["E_JET_DOWN_UNCOR"]=-19;
00063
00064
00065 MapPossibleScales["ID_TAU_UP"]=+20;
00066 MapPossibleScales["ID_TAU_DOWN"]=-20;
00067
00068
00069 MapPossibleScales["EFF_FMD_UP"]=+21;
00070 MapPossibleScales["EFF_FMD_DOWN"]=-21;
00071 MapPossibleScales["EFF_PRT_UP"]=+22;
00072 MapPossibleScales["EFF_PRT_DOWN"]=-22;
00073 MapPossibleScales["EFF_PLUG_UP"]=+23;
00074 MapPossibleScales["EFF_PLUG_DOWN"]=-23;
00075
00076
00077 MapPossibleScales["W_XPOM_UP"]=+24;
00078 MapPossibleScales["W_XPOM_DOWN"]=-24;
00079 MapPossibleScales["W_BETA_UP"]=+25;
00080 MapPossibleScales["W_BETA_DOWN"]=-25;
00081 MapPossibleScales["W_T_UP"]=+26;
00082 MapPossibleScales["W_T_DOWN"]=-26;
00083 MapPossibleScales["W_Q2_UP"]=+27;
00084 MapPossibleScales["W_Q2_DOWN"]=-27;
00085
00086
00087
00088
00089 ScalesToBeDone.push_back("/");
00090 };
00091
00092 istream& operator>>(istream& in, TMarSyst& Syst){
00093 Int_t num=0, out=1;
00094 char nom[10];
00095
00096 string tag;
00097
00098
00099 in >> nom;
00100 out= sscanf(nom,"%d",&num);
00101
00102 if(!out){
00103 Error("TMarSyst::istream","Wrong input card format (systematics:). Exit");
00104 exit(1);
00105 }
00106
00107 for (Int_t i=0;i<num;i++){
00108 in >> tag;
00109
00110 if(Syst.MapPossibleScales.find(tag)!=Syst.MapPossibleScales.end())Syst.ScalesToBeDone.push_back(tag);
00111 else {
00112 Error("TMarSyst::istream","Warning Scale '%s' not known. Exit",tag.c_str());
00113 exit(1);
00114 }
00115
00116 }
00117
00118
00119
00120 return in;
00121 };
00122 TMarSyst::~TMarSyst(){
00123
00124 ScalesToBeDone.clear();
00125 MapPossibleScales.clear();
00126
00127 }
00128 ostream& operator<<(ostream& out, TMarSyst& Syst){
00129
00130 for(list<string>::iterator i=Syst.ScalesToBeDone.begin();i!=Syst.ScalesToBeDone.end();i++)
00131 {
00132 out << " " << (*i);
00133 }
00134 out << endl;
00135
00136 return out;
00137 };
00138
00139
00140 TMarSyst& TMarSyst::operator= (const TMarSyst& other)
00141 {
00142 Sign=other.Sign;
00143 Type=other.Type;
00144 Name=other.Name;
00145 MapPossibleScales=other.MapPossibleScales;
00146 ScalesToBeDone=other.ScalesToBeDone;
00147 return *this;
00148
00149 };
00150 Int_t TMarSyst::Next()
00151 {
00152
00153 if(ScalesToBeDone.size()<=1)return 0;
00154
00155 if(Scale_now==NULL||Scale_now==ScalesToBeDone.end())Scale_now=ScalesToBeDone.begin();
00156
00157
00158
00159 Name=(*Scale_now);
00160
00161 int scale=MapPossibleScales[Name];
00162 Type=abs(scale);
00163 if(Type!=0)Sign=Type/(scale);
00164 else Sign=0;
00165
00166
00167 Scale_now++;
00168
00169 return Type;
00170 }
00171
00172 void TMarSyst::ScaleEnergyPartEm(vector<TMarBody>& PartList, const Double_t& Zvtx,const Int_t RunYear
00173 ,const Int_t Correlation){
00174
00175
00176
00177
00178
00179
00180
00181 Float_t Corr90E = 0.007;
00182 Float_t Corr40E = 0.015;
00183 Float_t Corr0E = 0.03;
00184 Float_t CorrESpacal = 0.01;
00185 Float_t CorrE;
00186
00187
00188 if(RunYear==TMarEvent::Y0304||RunYear==TMarEvent::Y05) {
00189 Corr90E = 0.015;
00190 Corr40E = 0.015;
00191 Corr0E = 0.03;
00192 }
00193 if(Correlation==2) {
00194 Corr90E = 0.005;
00195 Corr40E = 0.005;
00196 Corr0E = 0.005;
00197 }
00198
00199
00200
00201
00202 Float_t zCluster=0;
00203 Double_t NewE=0;
00204 Double_t NewPt=0;
00205
00206
00207 for(vector<TMarBody>::iterator body=PartList.begin();body!=PartList.end();body++) {
00208
00209
00210
00211 zCluster=100.5/atan(body->GetTheta())+Zvtx;
00212
00213
00214 if (zCluster<20)
00215 CorrE = Corr90E;
00216 else if (zCluster>20 && zCluster<100)
00217 CorrE = Corr40E;
00218 else
00219 CorrE = Corr0E;
00220
00221
00222 if(body->GetTheta()*MYR2D>153.) CorrE = CorrESpacal;
00223
00224
00225
00226 NewE = body->GetE()*(1+(Sign*CorrE));
00227 NewPt = NewE*TMath::Sin(body->GetTheta());
00228
00229 body->SetE(NewE);
00230 body->SetPt(NewPt);
00231 }
00232
00233 return ;
00234 }
00235
00236 void TMarSyst::ScaleThetaPartEm(vector<TMarBody>& PartList,const Int_t RunYear){
00237
00238
00239 Float_t CorrDiffThe= 0.003;
00240 const Float_t CorrDiffTheSpacal= 0.001;
00241
00242 if(RunYear==TMarEvent::Y0304||RunYear==TMarEvent::Y05) {
00243 CorrDiffThe= 0.005;
00244 }
00245
00246
00247 Float_t NewThe=0;
00248 Float_t NewEta=0;
00249 Float_t NewPt=0;
00250
00251
00252 for(vector<TMarBody>::iterator body=PartList.begin();body!=PartList.end();body++) {
00253
00254 Float_t ThisCorrDiffThe=CorrDiffThe;
00255 if(body->GetTheta()*MYR2D>153.) ThisCorrDiffThe = CorrDiffTheSpacal;
00256
00257 if(body->GetTheta()*MYR2D>90.0)
00258 NewThe = acos(cos(body->GetTheta()-Sign*ThisCorrDiffThe));
00259 else
00260 NewThe = acos(cos(body->GetTheta()+Sign*ThisCorrDiffThe));
00261
00262
00263
00264 NewEta = -log(tan(NewThe/2));
00265 NewPt = body->GetE()*TMath::Sin(NewThe);
00266
00267
00268
00269 body->SetEta(NewEta);
00270 body->SetPt(NewPt);
00271 }
00272
00273 return;
00274 }
00275
00276 void TMarSyst::ScaleEnergyPartJet(vector<TMarBody>& PartList,TLorentzVector& HadJetVec
00277 ,TLorentzVector& HadNoJetVec,const Int_t RunYear,const Int_t Correlation)
00278 {
00279
00280
00281
00282
00283
00284
00285 Float_t CorrE = 0.02;
00286 Float_t CorrESpacal = 0.07;
00287 if(Correlation==1) CorrE = 0.017;
00288 if(Correlation==2) CorrE = 0.01;
00289 if((HadNoJetVec+HadJetVec).Pt()<8) CorrE = 0.05;
00290
00291
00292 Float_t NewE=0;
00293 Float_t NewPt=0;
00294 HadJetVec.SetPtEtaPhiE(0,0,0,0);
00295
00296
00297 for(vector<TMarBody>::iterator body=PartList.begin();body!=PartList.end();body++) {
00298
00299 Float_t ThisCorrE=CorrE;
00300 if(body->GetTheta()*MYR2D>153.) ThisCorrE=CorrESpacal;
00301
00302
00303
00304 NewE = body->GetE()*(1+(Sign*ThisCorrE));
00305 NewPt = NewE*TMath::Sin(body->GetTheta());
00306
00307 body->SetE(NewE);
00308 body->SetPt(NewPt);
00309
00310 HadJetVec+=body->GetFourVector();
00311 }
00312
00313 if(HadNoJetVec.Theta()*MYR2D>153.) CorrE=CorrESpacal;
00314 HadNoJetVec=(1+(Sign*CorrE))*HadNoJetVec;
00315
00316
00317 }
00318 void TMarSyst::ScaleThetaPartJet(vector<TMarBody>& PartList,TLorentzVector& HadJetVec){
00319
00320
00321 const Float_t CorrDiffTheC= 0.010;
00322 const Float_t CorrDiffTheF= 0.005;
00323
00324
00325 Float_t CorrDiffThe = 0.0;
00326 Float_t NewThe=0;
00327 Float_t NewPt=0;
00328 Float_t NewEta=0;
00329 Float_t OldThe=0;
00330 HadJetVec.SetPtEtaPhiE(0,0,0,0);
00331
00332
00333 for(vector<TMarBody>::iterator body=PartList.begin();body!=PartList.end();body++) {
00334
00335 OldThe=body->GetTheta();
00336
00337
00338 if (OldThe*MYR2D>20.0){
00339 CorrDiffThe = CorrDiffTheC;
00340 }
00341 else{
00342 CorrDiffThe = CorrDiffTheF;
00343 }
00344
00345 if(OldThe*MYR2D>90.0)
00346 NewThe = acos(cos(OldThe-Sign*CorrDiffThe));
00347 else
00348 NewThe = acos(cos(OldThe+Sign*CorrDiffThe));
00349
00350
00351 NewEta = -log(tan(NewThe/2));
00352 NewPt = body->GetE()*TMath::Sin(NewThe);
00353
00354
00355
00356 body->SetEta(NewEta);
00357 body->SetPt(NewPt);
00358
00359 HadJetVec+=body->GetFourVector();
00360 }
00361
00362 }
00363 void TMarSyst::ScalePtPartMuon(vector<TMarBody>& PartList){
00364
00365
00366 const Float_t CorrPt = 0.05;
00367
00368 Float_t NewE=0;
00369 Float_t NewPt=0;
00370
00371
00372 for(vector<TMarBody>::iterator body=PartList.begin();body!=PartList.end();body++) {
00373
00374
00375
00376 NewPt = body->GetPt()*(1+(Sign*CorrPt));
00377 NewE = NewPt/TMath::Sin(body->GetTheta());
00378
00379
00380 body->SetPt(NewPt);
00381 body->SetE(NewE);
00382 }
00383
00384 }
00385 void TMarSyst::ScaleThetaPartMuon(vector<TMarBody>& PartList,const Int_t RunYear){
00386
00387
00388 Float_t CorrDiffThe= 0.003;
00389 if(RunYear==TMarEvent::Y0304||RunYear==TMarEvent::Y05) {
00390 CorrDiffThe= 0.005;
00391 }
00392
00393 Float_t NewThe=0;
00394 Float_t NewPt=0;
00395 Float_t NewEta=0;
00396 Float_t OldThe=0;
00397
00398
00399 for(vector<TMarBody>::iterator body=PartList.begin();body!=PartList.end();body++) {
00400
00401 OldThe=body->GetTheta();
00402
00403 if(OldThe*MYR2D>90.0)
00404 NewThe = acos(cos(OldThe-Sign*CorrDiffThe));
00405 else
00406 NewThe = acos(cos(OldThe+Sign*CorrDiffThe));
00407
00408
00409 NewEta = -log(tan(NewThe/2));
00410 NewPt = body->GetE()*TMath::Sin(NewThe);
00411
00412
00413
00414 body->SetEta(NewEta);
00415 body->SetPt(NewPt);
00416
00417 }
00418
00419 }
00420
00421 void TMarSyst::ScaleNoiseHFS(TLorentzVector& HadNoJetVec)
00422 {
00423
00424
00425
00426
00427 const Float_t CorrNoise = 0.10;
00428
00429 static H1FloatPtr PtrNoisePt("HfsClusNoisePt");
00430 static H1FloatPtr PtrNoiseTheta("HfsClusNoiseTheta");
00431 static H1FloatPtr PtrNoisePhi("HfsClusNoisePhi");
00432 static H1FloatPtr PtrNoiseE("HfsClusNoiseE");
00433
00434
00435
00436 TLorentzVector NoiseVec(0.,0.,0.,0.);
00437 NoiseVec.SetPtEtaPhiE(*PtrNoisePt,-TMath::Log(tan(*PtrNoiseTheta/2)),*PtrNoisePhi,*PtrNoiseE);
00438
00439
00440 HadNoJetVec=HadNoJetVec+Sign*CorrNoise*NoiseVec;
00441
00442
00443 }