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

TMarCutMC.C

Go to the documentation of this file.
00001 
00002 // Class TMarCutMC
00003 //
00004 // Author     : F. Cassol Brunner
00005 // Created    : 21/10/2002
00006 // Last update: 
00007 //          by: 
00008 // Comment: Class to handle cut on generated particles
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 /*TMarCutMC& TMarCutMC::operator= (const TMarCutMC& other) 
00088 {
00089    Variable=other.GetVariable();
00090    CutMin=other.GetCutMin();
00091    CutMax=other.GetCutMax();
00092    Valid=other.GetValid();
00093    Value=other.GetValue();
00094    Weight=other.GetWeight();
00095 
00096    return *this;
00097 
00098 };*/
00099 
00100 // bool TMarCutMC::Evaluate(Float_t value)
00101 // {
00102 // 
00103 // //... set Valid to true if the cut is passed
00104 // 
00105 //    Value=value;
00106 //    Valid=false;
00107 //    for (unsigned int i=0;i<CutMin.size();i++){
00108 // 
00109 //      if (value>CutMin[i] && value<CutMax[i]){
00110 //        Valid=true;
00111 //        return Valid;
00112 //      }
00113 // 
00114 //    }
00115 //    return Valid;
00116 // };
00117 
00118 Double_t TMarCutMC::Evaluate(Double_t value)
00119 {
00120   
00121 //... set Valid to true if the cut is passed
00122   for (unsigned int i=0;i<CutMin.size();i++){
00123 //      printf("evaluate cut %d min=%f max=%f w=%f \n",i,CutMin[i],CutMax[i],Weight[i]);
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 };

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