Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

TMarSyst.C

Go to the documentation of this file.
00001 
00002 // Class TMarSyst
00003 //
00004 // Author     : F. Cassol Brunner
00005 // Created    : 15/1/2004
00006 // Last update: 
00007 //          by: 
00008 // Comment: Class to handle the study of systematic errors
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;       // energy electron scale up
00023    MapPossibleScales["E_EM_DOWN"]=-1;     // energy electron scale down
00024    MapPossibleScales["THE_EM_UP"]=+2;     // theta electron scale up
00025    MapPossibleScales["THE_EM_DOWN"]=-2;   // theta electron scale down
00026    MapPossibleScales["E_JET_UP"]=+3;      // energy jet scale up
00027    MapPossibleScales["E_JET_DOWN"]=-3;    // energy jet scale down
00028    MapPossibleScales["THE_JET_UP"]=+4;    // theta jet scale up
00029    MapPossibleScales["THE_JET_DOWN"]=-4;  // theta jet scale down
00030    MapPossibleScales["PT_MU_UP"]=+5;      // pt mu scale up
00031    MapPossibleScales["PT_MU_DOWN"]=-5;    // pt mu scale down
00032    MapPossibleScales["THE_MU_UP"]=+6;     // theta mu scale up
00033    MapPossibleScales["THE_MU_DOWN"]=-6;   // theta mu scale down
00034    MapPossibleScales["THE_ALL_UP"]=+7;    // theta electron,jet,mu scale up
00035    MapPossibleScales["THE_ALL_DOWN"]=-7;  // theta electron,jet,mu scale down
00036    MapPossibleScales["E_ALL_UP"]=+8;      // energy electron,jet and pt mu scale up
00037    MapPossibleScales["E_ALL_DOWN"]=-8;    // energy electron,jet and pt mu scale down
00038    MapPossibleScales["ID_EM_UP"]=+9;     // identification electron scale up
00039    MapPossibleScales["ID_EM_DOWN"]=-9;   // identification electron scale down
00040    MapPossibleScales["ID_JET_UP"]=+10;     // identification jet scale up
00041    MapPossibleScales["ID_JET_DOWN"]=-10;   // identification jet scale down
00042    MapPossibleScales["ID_MU_UP"]=+11;     // identification muon scale up
00043    MapPossibleScales["ID_MU_DOWN"]=-11;   // identification muon scale down
00044    MapPossibleScales["ID_PHO_UP"]=+12;     // identification electron scale up
00045    MapPossibleScales["ID_PHO_DOWN"]=-12;   // identification electron scale down
00046    
00047    MapPossibleScales["TRIGGER_UP"]=+13;      // trigger up
00048    MapPossibleScales["TRIGGER_DOWN"]=-13;    // trigger down
00049    MapPossibleScales["USERSEL_UP"]=+14;      // related to user selection up
00050    MapPossibleScales["USERSEL_DOWN"]=-14;    // related to user selection down
00051    MapPossibleScales["HFSNOISE_UP"]=+15;      // related to user selection up
00052    MapPossibleScales["HFSNOISE_DOWN"]=-15;    // related to user selection down
00053 
00054 //---- for separation between correlated/uncorrelated parts (mainly NC/CC analysis)
00055    MapPossibleScales["E_EM_UP_COR"]=+16;       // energy electron scale up
00056    MapPossibleScales["E_EM_DOWN_COR"]=-16;     // energy electron scale down
00057    MapPossibleScales["E_EM_UP_UNCOR"]=+17;       // energy electron scale up
00058    MapPossibleScales["E_EM_DOWN_UNCOR"]=-17;     // energy electron scale down
00059    MapPossibleScales["E_JET_UP_COR"]=+18;      // energy jet scale up
00060    MapPossibleScales["E_JET_DOWN_COR"]=-18;    // energy jet scale down
00061    MapPossibleScales["E_JET_UP_UNCOR"]=+19;      // energy jet scale up
00062    MapPossibleScales["E_JET_DOWN_UNCOR"]=-19;    // energy jet scale down
00063 
00064 //--- tau identification
00065    MapPossibleScales["ID_TAU_UP"]=+20;     // identification muon scale up
00066    MapPossibleScales["ID_TAU_DOWN"]=-20;   // identification muon scale down
00067 
00068 //--- Forward detectors
00069    MapPossibleScales["EFF_FMD_UP"]=+21;     // Fmd efficiency up
00070    MapPossibleScales["EFF_FMD_DOWN"]=-21;   // Fmd efficiency down
00071    MapPossibleScales["EFF_PRT_UP"]=+22;     // PRT efficiency up
00072    MapPossibleScales["EFF_PRT_DOWN"]=-22;   // PRT efficiency down
00073    MapPossibleScales["EFF_PLUG_UP"]=+23;     // Plug efficiency up
00074    MapPossibleScales["EFF_PLUG_DOWN"]=-23;   // Plug efficiency down
00075 
00076 //--- MC weighting errors
00077    MapPossibleScales["W_XPOM_UP"]=+24;     // MC xpomeron weighting  up
00078    MapPossibleScales["W_XPOM_DOWN"]=-24;   // MC xpomeron weighting  down
00079    MapPossibleScales["W_BETA_UP"]=+25;     // MC Beta weighting  up
00080    MapPossibleScales["W_BETA_DOWN"]=-25;   // MC Beta weighting  down
00081    MapPossibleScales["W_T_UP"]=+26;     // MC T weighting  up
00082    MapPossibleScales["W_T_DOWN"]=-26;   // MC T weighting  down
00083    MapPossibleScales["W_Q2_UP"]=+27;     // MC Q2 weighting up
00084    MapPossibleScales["W_Q2_DOWN"]=-27;   // MC Q2 weighting down
00085 
00086 
00087 
00088 //... default:
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 //... set the type and sign of the scale
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 //... prepare the pointer for the next scale
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 //... syst. on energy scale (see. thesis of B. Heinemann)
00176 //... Move scale from 0.7-3% depending on zCluster (theta)
00177 //... If up-correction use factors 1.007..1.03
00178 //... Correlation is used to separe it into one correlated and uncorrelated part
00179 //... 0 = all, 1 = correlated, 2 = uncorrelated
00180 
00181   Float_t Corr90E    = 0.007;    // 0.7% in energy scale  z<20cm
00182   Float_t Corr40E    = 0.015;     // 1.5% in energy scale   20<z<100
00183   Float_t Corr0E     = 0.03;     // 3% in energy scale    z>100
00184   Float_t CorrESpacal = 0.01;    // 1% in energy scale  for spacal
00185   Float_t CorrE;
00186 
00187 //--- systematics for Hera-2 data
00188   if(RunYear==TMarEvent::Y0304||RunYear==TMarEvent::Y05) {
00189         Corr90E    = 0.015;      // 1.5% in energy scale  z<20cm
00190         Corr40E    = 0.015;       // 1.5% in energy scale   20<z<100
00191         Corr0E     = 0.03;       // 3% in energy scale  z>100
00192   }
00193   if(Correlation==2) { //--- uncorrelated error
00194         Corr90E    = 0.005;      
00195         Corr40E    = 0.005;      
00196         Corr0E     = 0.005;
00197   }
00198   
00199   
00200 //... list of modified electrons
00201   
00202   Float_t zCluster=0;
00203   Double_t NewE=0;
00204   Double_t NewPt=0;
00205 
00206 //... loop over all PartEm
00207   for(vector<TMarBody>::iterator body=PartList.begin();body!=PartList.end();body++) {
00208 
00209     
00210 //... find the cluster position
00211     zCluster=100.5/atan(body->GetTheta())+Zvtx;
00212 
00213 //... define the correction to be applied if electron in LAr
00214     if (zCluster<20)
00215       CorrE = Corr90E;
00216     else if (zCluster>20 && zCluster<100)
00217       CorrE = Corr40E;
00218     else 
00219       CorrE = Corr0E;
00220 
00221 //... For spacal electron: up to now crude theta angle definition
00222     if(body->GetTheta()*MYR2D>153.) CorrE = CorrESpacal;      
00223 
00224 //... correct energy and Pt
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;   // 3 mrad in theta
00240   const Float_t CorrDiffTheSpacal= 0.001;   // 1 mrad in theta for spacal (if BDC, best is 0.5 mrad)
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 //... loop over all PartEm
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 //     NewThe = acos(cos(body->GetTheta()+Sign*CorrDiffThe));
00263     
00264     NewEta = -log(tan(NewThe/2));
00265     NewPt = body->GetE()*TMath::Sin(NewThe);
00266 
00267 //... correct Eta et Pt
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 //... Correlation is used to separe it into one correlated and uncorrelated part
00280 //... 0 = all, 1 = correlated, 2 = uncorrelated
00281 //... Pth is used to check if jet calibration is applied or not 
00282 //                      (ie: at low Q2: 5% systematic error is used)
00283 
00284 //... scale factor
00285   Float_t CorrE    = 0.02;
00286   Float_t CorrESpacal    = 0.07;   //--- 7% if spacal hadrons
00287   if(Correlation==1) CorrE = 0.017; //--- correlated part
00288   if(Correlation==2) CorrE = 0.01; //--- uncorrelated part
00289   if((HadNoJetVec+HadJetVec).Pt()<8) CorrE = 0.05; //--- 5% applied at low Pt
00290 
00291 //... initialize variables
00292   Float_t NewE=0;  
00293   Float_t NewPt=0;
00294   HadJetVec.SetPtEtaPhiE(0,0,0,0);
00295 
00296 //... loop over all PartJet
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 //... correct energy and Pt
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 //... scale no also the hfs not in jets
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 //... scale factor
00321   const Float_t CorrDiffTheC= 0.010; // Diff de 10 mrad central
00322   const Float_t CorrDiffTheF= 0.005; // Diff de 5 mrad forward
00323 
00324 //... initialize variables
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 //... loop over all PartJet
00333   for(vector<TMarBody>::iterator body=PartList.begin();body!=PartList.end();body++) {
00334  
00335     OldThe=body->GetTheta();
00336 
00337 //... Define Error on thetajet
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 //     NewThe = acos(cos(OldThe+Sign*CorrDiffThe));
00350      
00351     NewEta = -log(tan(NewThe/2));
00352     NewPt = body->GetE()*TMath::Sin(NewThe);
00353 
00354 //... correct Eta et Pt
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 //... scale factor
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 //... correct energy and Pt
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 //... scale factor
00388   Float_t CorrDiffThe= 0.003; // Diff de 3 mrad central
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 //... loop over all PartJet
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 //     NewThe = acos(cos(OldThe+Sign*CorrDiffThe));
00408      
00409     NewEta = -log(tan(NewThe/2));
00410     NewPt = body->GetE()*TMath::Sin(NewThe);
00411 
00412 //... correct Eta et Pt
00413     
00414     body->SetEta(NewEta);
00415     body->SetPt(NewPt);
00416 
00417   }
00418 
00419 }
00420 
00421 void TMarSyst::ScaleNoiseHFS(TLorentzVector& HadNoJetVec)
00422 {
00423 //      Shift the part of the hfs with no jets by 4-vector of the removed 
00424 //      noise to calculate systematic error comming from the noise substraction
00425         
00426 //... scale factor
00427   const Float_t CorrNoise  = 0.10; //--- 25% of syst error on noise reduction, 10% now (Benji,8/07/04)
00428 
00429  static H1FloatPtr PtrNoisePt("HfsClusNoisePt");   
00430  static H1FloatPtr PtrNoiseTheta("HfsClusNoiseTheta");   
00431  static H1FloatPtr PtrNoisePhi("HfsClusNoisePhi");   
00432  static H1FloatPtr PtrNoiseE("HfsClusNoiseE");  
00433 
00434 
00435 //--- Get the noise 4-vector from Hat
00436  TLorentzVector NoiseVec(0.,0.,0.,0.);
00437  NoiseVec.SetPtEtaPhiE(*PtrNoisePt,-TMath::Log(tan(*PtrNoiseTheta/2)),*PtrNoisePhi,*PtrNoiseE);
00438 
00439 //... scale no also the hfs not in jets
00440   HadNoJetVec=HadNoJetVec+Sign*CorrNoise*NoiseVec;
00441 
00442 
00443 }

Generated on Thu Jul 28 11:48:52 2005 for SFHMarana by doxygen 1.3.2