Ignore:
Timestamp:
10/23/08 14:23:28 (16 years ago)
Author:
hoehne
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/datacenter/macros/fillcamera.C

    r8996 r9144  
    1818!   Author(s): Thomas Bretz, 06/2007 <mailto:tbretz@astro.uni-wuerzburg.de>
    1919!   Author(s): Daniela Dorner, 11/2005 <mailto:dorner@astro.uni-wuerzburg.de>
    20 !   Author(s): Daniel Hoehne, 10/2007 <mailto:hoehne@astro.uni-wuerzburg.de>
     20!   Author(s): Daniel Hoehne, 06/2008 <mailto:hoehne@astro.uni-wuerzburg.de>
    2121!
    22 !   Copyright: MAGIC Software Development, 2000-2007
     22!   Copyright: MAGIC Software Development, 2000-2008
    2323!
    2424!
     
    3737//
    3838// Make sure, that database and password are corretly set in a resource
    39 // file called mcsql.rc and the resource file is found.
     39// file called sql.rc and the resource file is found.
     40// In order not to confuse the MC processing with the data processing,
     41// both branches will be processed in two different Mars directories,
     42// e.g. Mars-2.0 for data and Mars.MC for MCs.
    4043//
    4144// Returns 2 in case of failure and 1 in case of success.
     
    171174    Double_t point        = runheader2->GetPointSpread();
    172175    Double_t pointspreadx = runheader2->GetPointSpreadX();
     176    Double_t addspotsize;
     177    if (pointspreadx < 0.25)
     178    {
     179        addspotsize = 0;
     180    }
     181    else
     182    {
     183        addspotsize = TMath::Sqrt(pointspreadx*pointspreadx - 0.25);
     184    }
     185    Double_t realpsf      = TMath::Sqrt(pointspreadx*pointspreadx + 0.25);
    173186    Double_t pointspready = runheader2->GetPointSpreadY();
    174187    Double_t coneai       = runheader1->GetViewconeAngleInner();
     
    184197
    185198    // some calculations: round the given values
    186     pointspreadx=TMath::Floor(pointspreadx*100+0.5)/100;
    187     pointspready=TMath::Floor(pointspready*100+0.5)/100;
    188     point=TMath::Floor(point*10+0.5)/10;
    189     coneai=TMath::Floor(coneai*10+0.5)/10;
    190     coneao=TMath::Floor(coneao*10+0.5)/10;
    191     spectrum=TMath::Floor(spectrum*10+0.5)/10;
     199    pointspreadx = TMath::Floor(pointspreadx*100+0.5)/100;
     200    addspotsize  = TMath::Floor(addspotsize*100+0.5)/100;
     201    realpsf      = TMath::Floor(realpsf*100+0.5)/100;
     202    pointspready = TMath::Floor(pointspready*100+0.5)/100;
     203    point        = TMath::Floor(point*10+0.5)/10;
     204    coneai       = TMath::Floor(coneai*10+0.5)/10;
     205    coneao       = TMath::Floor(coneao*10+0.5)/10;
     206    spectrum     = TMath::Floor(spectrum*10+0.5)/10;
    192207
    193208    // Definition of strings
     209    TString numslices = Form("%5.0i", rawheader->GetNumSamplesHiGain());
    194210    TString elow      = Form("%5.1f", runheader1->GetELowLim());
    195211    TString eupp      = Form("%5.1f", runheader1->GetEUppLim());
     
    202218    TString psf       = Form("%5.1f", point);
    203219    TString psfx      = Form("%5.2f", pointspreadx);
     220    TString addspot   = Form("%5.2f", addspotsize);
     221    TString rpsf      = Form("%5.2f", realpsf);
    204222    TString psfy      = Form("%5.2f", pointspready);
    205223    TString psfadd    = Form("%5.2f", TMath::Hypot(runheader2->GetPointSpreadX(), runheader2->GetPointSpread()));
     
    247265
    248266    //get the psf value for the path for linking
    249     Float_t pointsfuncx=pointspreadx*10;
    250     pointsfuncx=TMath::Floor(pointsfuncx*10+0.5)/10;
    251     Int_t pointsfx = TMath::Nint(pointsfuncx);
     267    Float_t pointsfuncx = pointspreadx*10;
     268    pointsfuncx         = TMath::Floor(pointsfuncx*10+0.5)/10;
     269    Int_t pointsfx      = TMath::Nint(pointsfuncx);
     270
     271    Float_t aspotsize   = addspotsize*10;
     272    aspotsize           = TMath::Floor(aspotsize*10+0.5)/10;
     273    Int_t ass           = TMath::Nint(aspotsize);
     274
     275    Float_t realpointsf = realpsf*10;
     276    realpointsf         = TMath::Floor(realpointsf*10+0.5)/10;
     277    Int_t rpointsf = TMath::Nint(realpointsf);
     278
    252279
    253280    // Get zbin
     
    264291    Int_t amplfadckey;
    265292    Int_t psfkey;
     293    Int_t spotsizekey;
    266294    Int_t viewconeangleokey;
    267295    Int_t spectrumkey;
     
    299327        cout << "ElecNoise       " << enoise    << endl;
    300328        cout << "DigiNoise       " << dnoise    << endl;
     329        cout << "Num HiGainSlices " << numslices << endl;
    301330        cout << "PhiMin          " << pmin      << endl;
    302331        cout << "PhiMax          " << pmax      << endl;
     
    312341        cout << "CamVer          " << camvers     << " -> " << "n/a" <<endl;
    313342        cout << "PointSpreadX    " << psfx        << " -> " << "0" <<endl;
     343        cout << "Add. SpotSize   " << addspot     << " -> " << "0" <<endl;
     344        cout << "Real PSF        " << rpsf        << " -> " << "0" <<endl;
    314345        cout << "PointSpreadY    " << psfy        << " -> " << "0" <<endl;
    315346        cout << "MispointingX    " << misx        << " -> " << "0" <<endl;
     
    319350        cout << endl;
    320351
    321         corsikakey=1;
    322         reflectorkey=1;
    323         camerakey=1;
    324         observationkey=1;
    325         particlekey = 1;
    326         atmomodelkey = serv.QueryKeyOfName("AtmosphericModel", atmomodel.Data());
    327         amplfadckey = serv.QueryKeyOfName("AmplFadc", amplfadc.Data());
     352        corsikakey     = 1;
     353        reflectorkey   = 1;
     354        camerakey      = 1;
     355        observationkey = 1;
     356        particlekey    = 1;
     357        atmomodelkey   = serv.QueryKeyOfName("AtmosphericModel", atmomodel.Data());
     358        amplfadckey    = serv.QueryKeyOfName("AmplFadc", amplfadc.Data());
    328359        viewconeangleokey = serv.QueryKeyOfName("ViewconeAngleO", coneangleo.Data());
    329         spectrumkey = 1;
    330         psfkey = 1;
     360        spectrumkey    = 1;
     361        psfkey         = 1;
     362        spotsizekey    = 1;
    331363
    332364        if (corsvers==0)
     
    355387        }
    356388
    357         cout << "corsikakey: " << corsikakey << endl;
    358         cout << "reflectorkey: " << reflectorkey << endl;
    359         cout << "camerakey: " << camerakey << endl;
     389        cout << "corsikakey:     " << corsikakey << endl;
     390        cout << "reflectorkey:   " << reflectorkey << endl;
     391        cout << "camerakey:      " << camerakey << endl;
    360392        cout << "observationkey: " << observationkey << endl;
    361         cout << "particlekey: " << particlekey << endl;
    362         cout << "atmomodelkey: " << atmomodelkey << endl;
    363         cout << "amplfadckey: " << amplfadckey << endl;
    364         cout << "psfkey: " << psfkey << endl;
    365         cout << "coneangleokey: " << viewconeangleokey << endl;
    366         cout << "spectrumkey: " << spectrumkey << endl;
     393        cout << "particlekey:    " << particlekey << endl;
     394        cout << "atmomodelkey:   " << atmomodelkey << endl;
     395        cout << "amplfadckey:    " << amplfadckey << endl;
     396        cout << "psfkey:         " << psfkey << endl;
     397        cout << "spotsizekey:    " << spotsizekey << endl;
     398        cout << "coneangleokey:  " << viewconeangleokey << endl;
     399        cout << "spectrumkey:    " << spectrumkey << endl;
    367400        cout << endl;
    368401
    369402        // For ped/cal: fixed values for psf and mispointing
    370         vars = Form("fPointSpreadX=0, fPointSpreadY=0, fMissPointingX=0, fMissPointingY=0, ");
     403        vars = Form("fPointSpreadX=0, fAdditionalSpotSize=0, fRealPointSpread=0, fPointSpreadY=0, fMissPointingX=0, fMissPointingY=0, ");
    371404
    372405    }
     
    387420        cout << "CamVer          " << camera    << endl;
    388421        cout << "ParticleId      " << partid    << endl;
    389         cout << "ParticleName    "  << partname  << endl;
     422        cout << "ParticleName    " << partname  << endl;
    390423        cout << "PointSpread     " << psf       << endl;
    391424        cout << "PointSpreadX    " << pointspreadx << endl;
     425        cout << "Add. SpotSize   " << addspot   << endl;
     426        cout << "Real PSF        " << rpsf      << endl;
    392427        cout << "PointSpreadXY   " << psfx      << " /" << psfy << endl;
    393428//        cout << "AdditionPSF     " << psfadd << endl;
     
    407442        cout << "ElecNoise       " << enoise    << endl;
    408443        cout << "DigiNoise       " << dnoise    << endl;
     444        cout << "Num HiGainSlices " << numslices << endl;
    409445        cout << "PhiMin          " << pmin      << endl;
    410446        cout << "PhiMax          " << pmax      << endl;
     
    418454        cout << endl;
    419455
    420         corsikakey=1;
    421         reflectorkey=1;
    422         camerakey=1;
     456        corsikakey     = 1;
     457        reflectorkey   = 1;
     458        camerakey      = 1;
    423459        observationkey = serv.QueryKeyOfName("ObservationMode", wobblemod.Data());
    424         particlekey = serv.QueryKeyOfName("MCParticle", partname.Data());
    425         atmomodelkey = serv.QueryKeyOfName("AtmosphericModel", atmomodel.Data());
    426         amplfadckey = serv.QueryKeyOfName("AmplFadc", amplfadc.Data());
     460        particlekey    = serv.QueryKeyOfName("MCParticle", partname.Data());
     461        atmomodelkey   = serv.QueryKeyOfName("AtmosphericModel", atmomodel.Data());
     462        amplfadckey    = serv.QueryKeyOfName("AmplFadc", amplfadc.Data());
    427463        viewconeangleokey = serv.QueryKeyOfName("ViewconeAngleO", coneangleo.Data());
    428         psfkey = serv.QueryKeyOfName("PSF", psfx);
    429         spectrumkey = serv.QueryKeyOfName("Spectrum", slope);
     464        psfkey         = serv.QueryKeyOfName("PSF", rpsf);
     465        spotsizekey    = serv.QueryKeyOfName("AddSpotSize", addspot);
     466        spectrumkey    = serv.QueryKeyOfName("Spectrum", slope);
    430467
    431468        if (corsvers==0)
     
    454491        }
    455492
    456         cout << "corsikakey: " << corsikakey << endl;
    457         cout << "reflectorkey: " << reflectorkey << endl;
    458         cout << "camerakey: " << camerakey << endl;
     493        cout << "corsikakey:     " << corsikakey << endl;
     494        cout << "reflectorkey:   " << reflectorkey << endl;
     495        cout << "camerakey:      " << camerakey << endl;
    459496        cout << "observationkey: " << observationkey << endl;
    460         cout << "particlekey: " << particlekey << endl;
    461         cout << "atmomodelkey: " << atmomodelkey << endl;
    462         cout << "amplfadckey: " << amplfadckey << endl;
    463         cout << "psfkey: " << psfkey << endl;
    464         cout << "coneangleokey: " << viewconeangleokey << endl;
    465         cout << "spectrumkey: " << spectrumkey << endl;
     497        cout << "particlekey:    " << particlekey << endl;
     498        cout << "atmomodelkey:   " << atmomodelkey << endl;
     499        cout << "amplfadckey:    " << amplfadckey << endl;
     500        cout << "psfkey:         " << psfkey << endl;
     501        cout << "spotsizekey:    " << spotsizekey << endl;
     502        cout << "coneangleokey:  " << viewconeangleokey << endl;
     503        cout << "spectrumkey:    " << spectrumkey << endl;
    466504        cout << endl;
    467505
    468506        // For data runs the values are taken from the file
    469         vars = Form("fPointSpreadX=%5.2f, fPointSpreadY=%5.2f, fMissPointingX=%s, fMissPointingY=%s, ",
    470                     pointspreadx, pointspready, misx.Data(), misy.Data());
     507        vars = Form("fPointSpreadX=%5.2f, fAdditionalSpotSize=%5.2f, fRealPointSpread=%5.2f, fPointSpreadY=%5.2f, fMissPointingX=%s, fMissPointingY=%s, ",
     508                    pointspreadx, addspotsize, realpsf, pointspready, misx.Data(), misy.Data());
    471509
    472510    }
     
    488526    TSQLRow *row = 0;
    489527    row = res->Next();
     528    if (!row)
     529        return 2;
    490530    TString num=(*row)[0];
    491531    Int_t RunNum=atoi(num.Data());
     
    518558                 "fThetaMax=%s, fPointSpread=%s, "
    519559                 "fPedesMean=%s, fLow2HighGain=%s, "
    520                  "fAmplFadc=%s, fAmplFadcOuter=%s, ",
     560                 "fAmplFadcInner=%s, fAmplFadcOuter=%s, ",
    521561                 elow.Data(), eupp.Data(), spectrum,
    522562                 imax.Data(), numsimshow, numevents,
     
    528568            Form("fElectricNoise=%s, "
    529569                 "fDigitalNoise=%s, fRunNumber=%d, "
    530                  "fCorsikaVersionKEY =%d, "
     570                 "fNumSlices=%s, fCorsikaVersionKEY=%d, "
    531571                 "fReflectorVersionKEY=%d, fCameraVersionKEY=%d, "
    532572                 "fObservationModeKEY=%d, fMCParticleKEY=%d, "
    533573                 "fSequenceFirst=0, fNumTriggers=%d, fViewconeAngleInner=%5.2f, fViewconeAngleOuter=%5.2f, "
    534                  "fAtmosphericModelKEY=%d, fAmplFadcKEY=%d, "
     574                 "fAtmosphericModelKEY=%d, fAmplFadcKEY=%d, fAddSpotSizeKEY=%d, "
    535575                 "fPSFKEY=%d, fViewconeAngleOKEY=%d, fSpectrumKEY=%d ",
    536576                 enoise.Data(),
    537577                 dnoise.Data(), RunNum,
    538                  corsikakey,
     578                 numslices.Data(), corsikakey,
    539579                 reflectorkey, camerakey,
    540580                 observationkey, particlekey,
    541581                 ntrig, coneai, coneao,
    542                  atmomodelkey, amplfadckey,
     582                 atmomodelkey, amplfadckey, spotsizekey,
    543583                 psfkey, viewconeangleokey, spectrumkey);
    544584
     
    588628                     "fThetaMax=%s, fPointSpread=%s, "
    589629                     "fPedesMean=%s, fLow2HighGain=%s, "
    590                      "fAmplFadc=%s, fAmplFadcOuter=%s, ",
     630                     "fAmplFadcInner=%s, fAmplFadcOuter=%s, ",
    591631                     elow.Data(), eupp.Data(), spectrum,
    592632                     imax.Data(), numsimshow, numevents,
     
    598638                Form("fElectricNoise=%s, "
    599639                     "fDigitalNoise=%s, fRunNumber=%d, "
    600                      "fCorsikaVersionKEY =%d, "
     640                     "fNumSlices=%s, fCorsikaVersionKEY =%d, "
    601641                     "fReflectorVersionKEY=%d, fCameraVersionKEY=%d, "
    602642                     "fObservationModeKEY=%d, fMCParticleKEY=%d, "
    603643                     "fSequenceFirst=0, fNumTriggers=%d, fViewconeAngleInner=%5.2f, fViewconeAngleOuter=%5.2f, "
    604                      "fAtmosphericModelKEY=%d, fAmplFadcKEY=%d, "
     644                     "fAtmosphericModelKEY=%d, fAmplFadcKEY=%d, fAddSpotSizeKEY=%d, "
    605645                     "fPSFKEY=%d, fViewconeAngleOKEY=%d, fSpectrumKEY=%d ",
    606646                     enoise.Data(),
    607647                     dnoise.Data(), RunNum,
    608                      corsikakey,
     648                     numslices.Data(), corsikakey,
    609649                     reflectorkey, camerakey,
    610650                     observationkey, particlekey,
    611651                     ntrig, coneai, coneao,
    612                      atmomodelkey, amplfadckey,
     652                     atmomodelkey, amplfadckey, spotsizekey,
    613653                     psfkey, viewconeangleokey, spectrumkey);
    614654
     
    656696    TString query3(Form("SELECT fMCParticleName, fSpectrum FROM MCRunData "
    657697                        "LEFT JOIN MCParticle USING (fMCParticleKEY) "
     698//                        "LEFT JOIN ON MCRunData.fMCParticleKEY=MCParticle.fMCParticleKEY "
    658699                        "LEFT JOIN Spectrum USING (fSpectrumKEY) "
     700//                        "LEFT JOIN Spectrum ON Spectrum.fSpectrumKEY=MCRunData.fSpectrumKEY "
    659701                        "WHERE MCRunData.fRunNumber=%d;", RunNum));
    660702    res = serv.Query(query3);
     
    666708
    667709    row = res->Next();
     710    if (!row)
     711        return 2;
     712
    668713
    669714    // Definition of variables for linking the file
     
    675720    TString mkdir;
    676721    TString link;
     722    TString linkname;
    677723    TString RunNumber=Form("%08d",RunNum);
    678724
    679725    delete res;
    680     rawpath = Form("/magic/montecarlo/rawfiles/19%02d/%02d/%02d", zBin2, amplfadckey, pointsfx);
    681 //    rawpath = Form("/home/hoehne/Analyse/TestMonteCarlo/montecarlo/rawfiles/19%02d/%02d/%02d", zBin2, amplfadckey, pointsfx);
     726    rawpath = Form("/magic/montecarlo/rawfiles/19%02d/%02d/%02d", zBin2, amplfadckey, ass);
     727//    rawpath = Form("/home/hoehne/Analyse/TestMonteCarlo/montecarlo/rawfiles/19%02d/%02d/%02d", zBin2, amplfadckey, ass);
    682728    mkdir = Form("mkdir -p -v %s", rawpath.Data());
    683729
     
    732778    }
    733779
    734     if (obsmode!=1)
    735     {
    736         link = Form("ln -sv %s %s/19%02d%02d%02d_%s_%s_%s%s%s_E.root", fname.Data(), rawpath.Data(), zBin2, amplfadckey, pointsfx, RunNumber.Data(), type.Data(), particle.Data(), spec.Data(), obsmode.Data());
     780    if (observationkey!=1)
     781    {
     782        link = Form("ln -sv %s %s/19%02d%02d%02d_%s_%s_%s%s%s_E.root", fname.Data(), rawpath.Data(), zBin2, amplfadckey, ass, RunNumber.Data(), type.Data(), particle.Data(), spec.Data(), obsmode.Data());
     783        linkname = Form("%s/19%02d%02d%02d_%s_%s_%s%s%s_E.root", rawpath.Data(), zBin2, amplfadckey, ass, RunNumber.Data(), type.Data(), particle.Data(), spec.Data(), obsmode.Data());
    737784
    738785        if (dummy==kFALSE)
     
    740787            gSystem->Exec(mkdir);
    741788            gSystem->Exec(link);
     789
     790            TString vars3 =
     791                Form("fRunLinked=Now(), fLinkName=\"%s\", fRunNumber=%d ",
     792                     linkname.Data(), RunNum);
     793
     794            if (!serv.ExistStr("fRunNumber", "MCRunProcessStatus", Form("%d", RunNum)))
     795            {
     796                if (!serv.Insert("MCRunProcessStatus", vars3))
     797                    return 2;
     798            }
     799            else
     800                if (!serv.Update("MCRunProcessStatus", vars3, Form("fRunNumber=%d", RunNum)))
     801                    return 2;
     802
    742803        }
    743804        else
     
    753814    {
    754815        cout << "" << endl;
    755         cout << "Linking will be done by fillcamera script" << endl;
     816        cout << "P/C Linking will be done by fillcamera script" << endl;
    756817        cout << "" << endl;
    757818    }
    758819
    759     delete runheader1;
    760     delete runheader2;
    761     delete runheader3;
    762     delete fadcheader;
    763     delete rawheader;
    764     delete evtbasic;
     820//    delete runheader1;
     821//    delete runheader2;
     822//    delete runheader3;
     823//    delete fadcheader;
     824//    delete rawheader;
     825//    delete evtbasic;
    765826
    766827
     
    772833int fillcamera(TString fname, Bool_t dummy=kTRUE)
    773834{
    774     MSQLMagic serv("sql.rc");
     835    TEnv env("sql.rc");
     836
     837    MSQLMagic serv(env);
    775838    if (!serv.IsConnected())
    776839    {
     
    794857int fillcamera(TString path="/magic/montecarlo/camera", Bool_t dummy=kTRUE)
    795858{
    796     MSQLMagic serv("mcsql.rc");
     859//    TEnv env("mcsql.rc");
     860//    TEnv env("sql.rc");
     861
     862//    MSQLMagic serv(env);
     863    MSQLMagic serv("sql.rc");
    797864    if (!serv.IsConnected())
    798865    {
Note: See TracChangeset for help on using the changeset viewer.