Ignore:
Timestamp:
05/20/05 11:59:31 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mjobs
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mjobs/MJCalibration.cc

    r7054 r7069  
    14851485
    14861486  MCalibrationHiLoCam hilocam;
    1487  
    1488   *fLog << all << "Initializing High gain vs. Low gain intercalibration from " << fHiLoCalibFile << endl;
    1489   *fLog << all << endl;
    1490 
    14911487  if (hilocam.Read()<=0)
    14921488  {
     
    15001496      return kFALSE;
    15011497  }
     1498
     1499  *fLog << all << "Hi-/Lo-Gain intercalibration constants read from " << fHiLoCalibFile << endl << endl;
    15021500
    15031501  if (fCalibrationCam.GetSize() < 1)
  • trunk/MagicSoft/Mars/mjobs/MJPedestal.cc

    r7043 r7069  
    822822}
    823823
     824Bool_t MJPedestal::PulsePosCheck(const MParList &plist) const
     825{
     826    if (fIsPixelCheck)
     827    {
     828        MHPedestalCam *hcam = (MHPedestalCam*)plist.FindObject("MHPedestalCam");
     829        if (hcam)
     830        {
     831            MHPedestalPix &pix1 = (MHPedestalPix&)(*hcam)[fCheckedPixId];
     832            pix1.DrawClone("");
     833        }
     834    }
     835
     836    if (!fIsPulsePosCheck)
     837        return kTRUE;
     838
     839    Int_t numhigainsamples = 0;
     840    Int_t numlogainsamples = 0;
     841
     842    Float_t meanpulsetime  = 0.;
     843    Float_t rmspulsetime   = 0.;
     844
     845    if (IsUseMC())
     846    {
     847        //
     848        // FIXME:
     849        // The MC cannot run over the first 2000 pedestal events since almost all
     850        // events are empty, therefore a pulse pos. check is not possible, either.
     851        // For the moment, have to fix the problem hardcoded...
     852        //
     853        //            MMcEvt *evt = (MMcEvt*)plist.FindObject("MMcEvt");
     854        //            const Float_t meanpulsetime = evt->GetFadcTimeJitter();
     855        meanpulsetime = 4.5;
     856        rmspulsetime  = 1.0;
     857
     858        numhigainsamples = 15;
     859        numlogainsamples = 15;
     860
     861    }
     862    else
     863    {
     864        if (fIsPixelCheck)
     865        {
     866            MHCalibrationPulseTimeCam *hcam = (MHCalibrationPulseTimeCam*)plist.FindObject("MHCalibrationPulseTimeCam");
     867            if (!hcam)
     868            {
     869                *fLog << err << "MHCalibrationPulseTimeCam not found... abort." << endl;
     870                return kFALSE;
     871            }
     872            hcam->DrawClone();
     873            gPad->SaveAs(Form("%s/PulsePosTest_all.root",fPathOut.Data()));
     874
     875            MHCalibrationPix &pix = (*hcam)[fCheckedPixId];
     876            pix.DrawClone();
     877            gPad->SaveAs(Form("%s/PulsePosTest_Pixel%04d.root",fPathOut.Data(),fCheckedPixId));
     878        }
     879
     880        MCalibrationPulseTimeCam *cam = (MCalibrationPulseTimeCam*)plist.FindObject("MCalibrationPulseTimeCam");
     881        if (!cam)
     882        {
     883            *fLog << err << "MCalibrationPulseTimeCam not found... abort." << endl;
     884            return kFALSE;
     885        }
     886
     887        meanpulsetime = cam->GetAverageArea(0).GetHiGainMean();
     888        rmspulsetime  = cam->GetAverageArea(0).GetHiGainRms();
     889
     890        MRawEvtData *data = (MRawEvtData*)plist.FindObject("MRawEvtData");
     891        if (!data)
     892        {
     893            *fLog << err << "MRawEvtData not found... abort." << endl;
     894            return kFALSE;
     895        }
     896
     897        numhigainsamples = data->GetNumHiGainSamples();
     898        numlogainsamples = data->GetNumLoGainSamples();
     899    }
     900
     901    *fLog << all << "Mean pulse time (" << (IsUseMC()?"MC":"cosmics") << "): ";
     902    *fLog << meanpulsetime << "+-" << rmspulsetime << endl;
     903
     904    const MExtractTimeAndCharge *ext = dynamic_cast<MExtractTimeAndCharge*>(fExtractor);
     905
     906    //
     907    // Get the ranges for the new extractor setting
     908    //
     909    const Int_t newfirst = TMath::Nint(meanpulsetime-fExtractWinLeft);
     910
     911    Int_t wshigain = ext ? ext->GetWindowSizeHiGain() : 6;
     912    if (wshigain > 6)
     913        wshigain = 6;
     914
     915    Int_t wslogain = ext ? ext->GetWindowSizeLoGain() : 4;
     916    if (wslogain > 4)
     917        wslogain = 4;
     918
     919    const Int_t newlast  = TMath::Nint(meanpulsetime+fExtractWinRight);
     920
     921    *fLog << underline;
     922    *fLog << "Try to set new range limits: (" << newfirst << "," << newlast;
     923    *fLog << "+" << wshigain << "," << newfirst-1 << "," << newlast << "+";
     924    *fLog << wslogain << ")" << endl;
     925
     926    //
     927    // Check the ranges for the new extractor setting
     928    //
     929    if (newfirst < 0)
     930    {
     931        *fLog << err << "Pulse is too much to the left, cannot go below 0!" << endl;
     932        return kFALSE;
     933
     934    }
     935    if (newlast+wshigain > numhigainsamples+numlogainsamples-1)
     936    {
     937        *fLog << err << "Pulse is too much to the right, cannot go beyond limits: ";
     938        *fLog << numhigainsamples << "+" << numlogainsamples << "-1" << endl;
     939        *fLog << " Cannot extract at all!" << endl;
     940        return kFALSE;
     941    }
     942    if (newlast+wslogain > numlogainsamples)
     943    {
     944        *fLog << err << "Pulse is too much to the right, cannot go beyond logain limits!" << endl;
     945        *fLog << endl;
     946        *fLog << "Try to use a different extractor (e.g. with a window size of only 4 sl.) or:" << endl;
     947        *fLog << "Set the limit to a lower value (callisto.rc):" << endl;
     948        *fLog << "    MJPedestalY2:ExtractWinRight: 4.5" << endl;
     949        *fLog << "(ATTENTION, you will lose late cosmics pulses!)" << endl;
     950        *fLog << endl;
     951        return kFALSE;
     952    }
     953
     954    //
     955    // Set and store the new ranges
     956    //
     957    const Int_t hi0 = newfirst;
     958    const Int_t hi1 = newlast+wshigain;
     959
     960    const Int_t lo0 = newfirst>0 ? newfirst-1 : newfirst;
     961    const Int_t lo1 = numlogainsamples-1;
     962
     963    fExtractor->SetRange(hi0, hi1, lo0, lo1);
     964    return kTRUE;
     965}
     966
    824967Bool_t MJPedestal::Process()
    825968{
     
    9891132    }
    9901133   
    991     if (fIsUseHists)
     1134    if (fIsUseHists && fExtractor)
    9921135      {
    9931136        if (fExtractor->InheritsFrom("MExtractTimeAndCharge"))
     
    10211164    if (fExtractor)
    10221165    {
     1166      fExtractor->SetPedestals(&fPedestalCamIn);
    10231167
    10241168      if (fExtractionType!=kFundamental)
     
    10651209        *fLog << "windows." << endl;
    10661210    }
    1067    
    1068     /*
    1069     switch (fExtractType)
    1070     {
    1071     case kUseData:
    1072         *fLog << all << "TYPE: USEDATA " << fExtractor << endl;
    1073         taskenv.SetDefault(&pedlogain);
    1074         tlist.AddToList(&taskenv);
    1075 
    1076         if (!SetupExtractor(plist, pedlogain))
    1077         {
    1078             *fLog << all <<  "SETTING TO: " << fExtractor << " " << fExtractor->GetNumHiGainSamples() << endl;
    1079             fExtractor->Print();
    1080             pedlogain.SetExtractWindow(15, (Int_t)TMath::Nint(fExtractor->GetNumHiGainSamples()));
    1081         }
    1082         break;
    1083 
    1084     case kUsePedRun:
    1085         *fLog << all <<  "TYPE: USEPEDRUN " << fExtractor << endl;
    1086         taskenv.SetDefault(&pedcalc);
    1087         tlist.AddToList(&taskenv);
    1088 
    1089         if (!SetupExtractor(plist, pedcalc))
    1090             pedcalc.SetExtractWindow(fExtractor->GetHiGainFirst(), TMath::Nint(fExtractor->GetNumHiGainSamples()));
    1091         break;
    1092 
    1093     case kUseHists:
    1094         if (!fExtractor)
    1095         {
    1096             *fLog << err << GetDescriptor() << " - ERROR: ";
    1097             *fLog << "Extraction Type is kUseHists, but no extractor was set" << endl;
    1098             return kFALSE;
    1099         }
    1100 
    1101         tlist.AddToList(fExtractor);
    1102         tlist.AddToList(&fillped);
    1103         break;
    1104     } */
    1105 
    1106     /*
    1107     if (!fPathIn.IsNull())
    1108     {
    1109         delete fExtractor;
    1110         fExtractor = 0;
    1111     }
    1112     */
    1113 
    11141211
    11151212    //
     
    11351232    tlist.PrintStatistics();
    11361233
    1137     if (fIsPixelCheck)
    1138       {
    1139         MHPedestalCam *hcam = (MHPedestalCam*)plist.FindObject("MHPedestalCam");
    1140         if (hcam)
    1141           {
    1142             MHPedestalPix &pix1 = (MHPedestalPix&)(*hcam)[fCheckedPixId];
    1143             pix1.DrawClone("");
    1144           }
    1145       }
    1146    
    11471234    if (fDisplayType!=kDisplayNone)
    11481235        DisplayResult(plist);
     
    11511238        return kFALSE;
    11521239
    1153     if (fIsPulsePosCheck)
    1154       {
    1155        
    1156         Int_t numhigainsamples = 0;
    1157         Int_t numlogainsamples = 0;
    1158         Float_t meanpulsetime  = 0.;
    1159         Float_t rmspulsetime   = 0.;
    1160 
    1161         if (IsUseMC())
    1162           {
    1163             //
    1164             // FIXME:
    1165             // The MC cannot run over the first 2000 pedestal events since almost all
    1166             // events are empty, therefore a pulse pos. check is not possible, either.
    1167             // For the moment, have to fix the problem hardcoded...
    1168             //
    1169             //            MMcEvt *evt = (MMcEvt*)plist.FindObject("MMcEvt");
    1170             //            const Float_t meanpulsetime = evt->GetFadcTimeJitter();
    1171             meanpulsetime = 4.5;
    1172             rmspulsetime  = 1.0;
    1173 
    1174             *fLog << all << "Mean pulse time (MC): " << meanpulsetime << "+-" << rmspulsetime << endl;
    1175 
    1176             numhigainsamples = 15;
    1177             numlogainsamples = 15;
    1178 
    1179           }
    1180         else
    1181           {
    1182             MHCalibrationPulseTimeCam *hcam = (MHCalibrationPulseTimeCam*)plist.FindObject("MHCalibrationPulseTimeCam");
    1183             if (fIsPixelCheck)
    1184               {
    1185                 hcam->DrawClone();
    1186                 gPad->SaveAs(Form("%s/PulsePosTest_all.root",fPathOut.Data()));
    1187                 MHCalibrationPix &pix = (*hcam)[fCheckedPixId];
    1188                 pix.DrawClone();
    1189                 gPad->SaveAs(Form("%s/PulsePosTest_Pixel%04d.root",fPathOut.Data(),fCheckedPixId));
    1190               }
    1191            
    1192             MCalibrationPulseTimeCam *cam = (MCalibrationPulseTimeCam*)plist.FindObject("MCalibrationPulseTimeCam");
    1193             if (!cam)
    1194               {
    1195                 *fLog << err << "Could not determine mean pulse position, abort... " << endl;
    1196                 return kFALSE;
    1197               }
    1198            
    1199             meanpulsetime = cam->GetAverageArea(0).GetHiGainMean();
    1200             rmspulsetime  = cam->GetAverageArea(0).GetHiGainRms();
    1201 
    1202             *fLog << all << "Mean pulse time (cosmics): " << meanpulsetime << "+-" << rmspulsetime << endl;
    1203 
    1204             MRawEvtData *data = (MRawEvtData*)plist.FindObject("MRawEvtData");
    1205 
    1206             numhigainsamples = data->GetNumHiGainSamples();
    1207             numlogainsamples = data->GetNumLoGainSamples();
    1208           }
    1209        
    1210         //
    1211         // Get the ranges for the new extractor setting
    1212         //
    1213         const Int_t newfirst = TMath::Nint(meanpulsetime-fExtractWinLeft);
    1214         Int_t wshigain = fExtractor->InheritsFrom("MExtractTimeAndCharge")
    1215           ?  ((MExtractTimeAndCharge*)fExtractor)->GetWindowSizeHiGain()
    1216           : 6;
    1217 
    1218         if (wshigain > 6)
    1219           wshigain = 6;
    1220 
    1221         Int_t wslogain = fExtractor->InheritsFrom("MExtractTimeAndCharge")
    1222           ? ((MExtractTimeAndCharge*)fExtractor)->GetWindowSizeLoGain()
    1223           : 6;
    1224         if (wslogain > 4)
    1225           wslogain = 4;
    1226 
    1227         const Int_t newlast  = TMath::Nint(meanpulsetime+fExtractWinRight);
    1228 
    1229         *fLog << all << underline
    1230               << "Try to set new range limits: ("<<newfirst<<","<<newlast<<"+"<<wshigain
    1231               <<","<<newfirst-1<<","<<newlast<<"+"<<wslogain<<")"<<endl;
    1232         //
    1233         // Check the ranges for the new extractor setting
    1234         //
    1235         if (newfirst < 0)
    1236           {
    1237             *fLog << err << "Pulse is too much to the left, cannot go below 0! " << endl;
    1238             return kFALSE;
    1239           }
    1240         if (newlast+wshigain > numhigainsamples+numlogainsamples-1)
    1241           {
    1242             *fLog << err << "Pulse is too much to the right, cannot go beyond limits: "
    1243                   << numhigainsamples << "+" << numlogainsamples << "-1" << endl;
    1244             *fLog << " Cannot extract at all! ... " << endl;
    1245             return kFALSE;
    1246           }
    1247         if (newlast+wslogain > numlogainsamples)
    1248           {
    1249             *fLog << err << "Pulse is too much to the right, cannot go beyond logain limits! " << endl;
    1250             *fLog << endl;
    1251             *fLog << "Try to use a different extractor (e.g. with a window size of only 4 sl.) or:" << endl;
    1252             *fLog << "Set the limit to a lower value (callisto.rc: line 329): " << endl;
    1253             *fLog << "    MJPedestalY2:ExtractWinRight: 4.5           " << endl;
    1254             *fLog << "(ATTENTION, you will lose late cosmics pulses!)" << endl;
    1255             *fLog << endl;
    1256             return kFALSE;
    1257           }
    1258         //
    1259         // Set and store the new ranges
    1260         //
    1261         fExtractor->SetRange(newfirst,newlast+wshigain,
    1262                              newfirst>0?newfirst-1:newfirst,numlogainsamples-1);
    1263       }
    1264    
     1240    if (!PulsePosCheck(plist))
     1241        return kFALSE;
    12651242
    12661243    *fLog << all << GetDescriptor() << ": Done." << endl;
  • trunk/MagicSoft/Mars/mjobs/MJPedestal.h

    r7043 r7069  
    2626{
    2727private:
    28 
    2928    static const TString  fgReferenceFile;    //! default for fReferenceFile ("pedestalref.rc")
    3029    static const TString  fgBadPixelsFile;    //! default for fBadPixelsFile ("badpixels_0_559.rc")
     
    8382    void   DisplayOutliers(TH1D *hist) const;
    8483    void   FixDataCheckHist(TH1D *hist) const;
     84    Bool_t PulsePosCheck(const MParList &plist) const;
    8585
    8686    Bool_t CheckEnvLocal();
Note: See TracChangeset for help on using the changeset viewer.