Changeset 9144 for trunk


Ignore:
Timestamp:
10/23/08 14:23:28 (16 years ago)
Author:
hoehne
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r9143 r9144  
    1818
    1919                                                 -*-*- END OF LINE -*-*-
     20
     21 2008/10/23 Daniel Hoehne-Moench
     22
     23   * datacenter/macros/fillcamera.C:
     24     - added and changed some parameters
     25
     26   * datacenter/scripts/fillcamera:
     27     - rewritten
     28
     29
    2030
    2131 2008/10/14 Thomas Bretz
  • 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    {
  • trunk/MagicSoft/Mars/datacenter/scripts/fillcamera

    r8759 r9144  
    1818#
    1919#
    20 #   Author(s): Daniel Hoehne  09/2007 <mailto:hoehne@astro.uni-wuerzburg.de>
    21 #
    22 #   Copyright: MAGIC Software Development, 2000-2007
     20#   Author(s): Daniel Hoehne  06/2008 <mailto:hoehne@astro.uni-wuerzburg.de>
     21#
     22#   Copyright: MAGIC Software Development, 2000-2008
    2323#
    2424#
     
    4444#mccampath=$mcpath/camera
    4545mccampath=/magic/montecarlo/camera
    46 cameradirs=`find $mccampath -maxdepth 1 -mindepth 1 -type d`
     46#workaround
     47cameradirs=`find /magic/montecarlo/camera -maxdepth 4 -mindepth 2 -type d ! -name Gamma ! -name Muon ! -name Proton ! -name Spot_?.?`
     48#cameradirs=`find /magic/montecarlo/camera -maxdepth 3 -mindepth 2 -type d ! -name Gamma ! -name Muon ! -name Proton`
     49#cameradirs=`find $mccampath -maxdepth 1 -mindepth 1 -type d`
    4750echo "camera dirs: "${cameradirs[@]}  >> $scriptlog 2>&1
    4851echo "" >> $scriptlog 2>&1
     
    5558   printprocesslog "INFO inserting information for all root camera files in $cameradir"
    5659   cam=`basename $cameradir`
     60   spot=`echo $cameradir | cut -d/ -f7` #spotsize
     61   par=`echo $cameradir | cut -d/ -f6` #particle name
     62   if [ $cam = "Cal_and_Ped" ]
     63   then
     64      par=""
     65      spot=""
     66   fi
     67   epo=`echo $cameradir | cut -d/ -f5` #epoch
    5768   echo "dir: "$cameradir >> $scriptlog 2>&1
    5869   fillcamerapath=$logpath/$program
    5970   makedir $fillcamerapath >> $scriptlog 2>&1
    60    fillcameralog=$fillcamerapath/$program-$cam.log
     71   fillcameralog=$fillcamerapath/$program-$epo-$par-$spot-$cam.log
    6172   
    6273   check0=`root -q -b $macrospath/fillcamera.C+\("\"$cameradir\""\,kFALSE\) | tee $fillcameralog | intgrep`
     74#   check0=`root -q -b $macrospath/fillcamera.C+\("\"$cameradir\""\,kTRUE\) | tee $fillcameralog | intgrep`
    6375   case $check0 in
    6476      1)   echo "check0=$check0 -> everything ok " >> $scriptlog 2>&1
     
    7789   echo "linking cal and ped files" >> $scriptlog 2>&1
    7890   
    79    epo=`basename $cameradir` #filename
    80    pedfile=`find $cameradir/Cal_and_Ped -name *_P_*.root`
    81    calfile=`find $cameradir/Cal_and_Ped -name *_C_*.root`
    82    
    83    echo "calfile for epoch $epo : " $calfile >> $scriptlog 2>&1
    84    echo "pedfile for epoch $epo : " $pedfile >> $scriptlog 2>&1
    85    
    86    #check number of files
    87    numfiles=`echo $pedfile $calfile | wc -w`
    88    
    89    if [ "$numfiles" != "2" ]
     91   if [ $cam = "Cal_and_Ped" ];
    9092   then
    91       echo "too many files in the directory $epoch/Cal_and_Ped -> exit" >> $scriptlog 2>&1
    92       rm -v $lockfile >> $scriptlog 2>&1
    93       exit
    94       printprocesslog "ERROR too many ped and cal files found in $epoch/Cal_and_Ped"
    95       finish >> $scriptlog 2>&1
    96    fi
    97    
    98 
    99    user="test"
    100    db="TestMonteCarlo"
    101    pw="Ics+eaTD"
    102    cquery=" select fRunNumber from MCRunProcessStatus where fFileName=\"$calfile\" "
    103    pquery=" select fRunNumber from MCRunProcessStatus where fFileName=\"$pedfile\" "
    104 
    105    crun=`mysql -ss -u $user --password=$pw --host=vela $db -e " $cquery "`
    106    prun=`mysql -ss -u $user --password=$pw --host=vela $db -e " $pquery "`
    107    cnum=`printf %08d $crun`
    108    pnum=`printf %08d $prun`
    109    echo "calrun number: " $cnum >> $scriptlog 2>&1
    110    echo "pedrun number: " $pnum >> $scriptlog 2>&1
    111    #get all directories in the linked structure for the epoch
    112 #   dirs=`find $mcrawpath/ -mindepth 3 -maxdepth 3 -type d`
    113    files=`find $mcrawpath/ -lname *$epo*.root`
    114 
    115    for file in ${files[@]}
    116    do
    117       dir=`dirname $file`
    118       date=`echo $file | cut -c 28-31,33,34,36,37`
    119      
    120       if ls $dir | grep MonteCarlo | grep $pnum
    121       then
    122 #         echo "P run already there, do nothing" >> $scriptlog 2>&1
    123          continue
    124       else
    125          echo "linking P run for epoch $epo" >> $scriptlog 2>&1
    126          newpedfile="${dir}/${date}_${pnum}_P_MonteCarlo_E.root"
    127          ln -sv $pedfile $newpedfile >> $scriptlog 2>&1
     93      echo "Cal_and_Ped folder, no cal and ped files will be linked" >> $scriptlog 2>&1
     94   else
     95
     96      epo=`echo $cameradir | cut -d/ -f5` #filename
     97      #epo=`basename $cameradir` #filename
     98      pedfile=`find $mccampath/$epo/Cal_and_Ped -name *_P_*.root`
     99      calfile=`find $mccampath/$epo/Cal_and_Ped -name *_C_*.root`
     100   
     101      echo "calfile for epoch $epo : " $calfile >> $scriptlog 2>&1
     102      echo "pedfile for epoch $epo : " $pedfile >> $scriptlog 2>&1
     103   
     104      #check number of files
     105      numfiles=`echo $pedfile $calfile | wc -w`
     106   
     107      if [ "$numfiles" != "2" ]
     108      then
     109        echo "too many or too less files in the directory $epo/Cal_and_Ped -> exit" >> $scriptlog 2>&1
     110        rm -v $lockfile >> $scriptlog 2>&1
     111        exit
     112        printprocesslog "ERROR too many ped and cal files found in $epo/Cal_and_Ped"
     113        finish >> $scriptlog 2>&1
    128114      fi
    129115     
    130       if ls $dir | grep MonteCarlo | grep $cnum
    131       then
    132 #         echo "C run already there, do nothing" >> $scriptlog 2>&1
    133          continue
    134       else
    135          echo "linking C run for epoch $epo" >> $scriptlog 2>&1
     116     
     117      #   user="test"
     118      #   db="TestMonteCarlo"
     119      #   pw="Ics+eaTD"
     120      user="operator"
     121      db="MyMagicMonteCarlo"
     122      pw="Ics+eMM!"
     123      cquery=" select fRunNumber from MCRunProcessStatus where fFileName=\"$calfile\" "
     124      pquery=" select fRunNumber from MCRunProcessStatus where fFileName=\"$pedfile\" "
     125     
     126      crun=`mysql -ss -u $user --password=$pw --host=vela $db -e " $cquery "`
     127      prun=`mysql -ss -u $user --password=$pw --host=vela $db -e " $pquery "`
     128      cnum=`printf %08d $crun`
     129      pnum=`printf %08d $prun`
     130      echo "calrun number: " $cnum >> $scriptlog 2>&1
     131      echo "pedrun number: " $pnum >> $scriptlog 2>&1
     132      #get all directories in the linked structure for the epoch
     133      #dirs=`find $mcrawpath/ -mindepth 3 -maxdepth 3 -type d`
     134      files=`find $mcrawpath/ -lname *$epo*.root`
     135   
     136      for file in ${files[@]}
     137      do
     138         dir=`dirname $file`
     139         #datacenter
     140         date=`echo $file | cut -c 28-31,33,34,36,37`
     141         #for tests
     142         #date=`echo $file | cut -c 57-60,62,63,65,66`
     143         
     144         newpedfile="${dir}/${date}_${pnum}_P_MonteCarlo_E.root"
    136145         newcalfile="${dir}/${date}_${cnum}_C_MonteCarlo_E.root"
    137          ln -sv $calfile $newcalfile >> $scriptlog 2>&1
    138       fi
    139 
    140    done
     146         pupdate=" update MCRunProcessStatus set fRunLinked=Now(), fLinkName=\"$newpedfile\" where fRunNumber=\"$prun\" "
     147         cupdate=" update MCRunProcessStatus set fRunLinked=Now(), fLinkName=\"$newcalfile\" where fRunNumber=\"$crun\" "
     148         if ls $dir | grep MonteCarlo | grep $pnum
     149         then
     150            echo "P run already there, do mysql update" >> $scriptlog 2>&1
     151   #         continue
     152            mysql -ss -u $user --password=$pw --host=vela $db -e " $pupdate "
     153         else
     154            echo "linking P run for epoch $epo" >> $scriptlog 2>&1
     155            ln -sv $pedfile $newpedfile >> $scriptlog 2>&1
     156            mysql -ss -u $user --password=$pw --host=vela $db -e " $pupdate "
     157         fi
     158         
     159         if ls $dir | grep MonteCarlo | grep $cnum
     160         then
     161            echo "C run already there, do mysql update" >> $scriptlog 2>&1
     162   #         continue
     163            mysql -ss -u $user --password=$pw --host=vela $db -e " $cupdate "
     164         else
     165            echo "linking C run for epoch $epo" >> $scriptlog 2>&1
     166            ln -sv $calfile $newcalfile >> $scriptlog 2>&1
     167            mysql -ss -u $user --password=$pw --host=vela $db -e " $cupdate "
     168         fi
     169   
     170      done
     171   
     172   fi
    141173
    142174done
     
    145177
    146178# observation epochs
    147 epochs=("" "After January 07 (new MUX)," "From April 06 to January 07," "Before April 06")
     179epochs=("" "After January 07 (MUX FADCs)," "From April 06 to January 07 (Siegen FADCs with splitters)," "Before April 06 (Siegen FADCs)")
    148180
    149181# print information and explanation of structure into README.txt
     
    156188echo "YYYY represents 19zbin" >> $readme 2>&1
    157189echo "MM represents the epoch" >> $readme 2>&1
    158 echo "DD represents the psf in mm" >> $readme 2>&1
     190echo "DD represents the additional spot size in mm" >> $readme 2>&1
    159191echo "" >> $readme 2>&1
    160192echo "explanation of the epochs" >> $readme 2>&1
     
    180212echo "<P/C/D> indicates the run type" >> $readme 2>&1
    181213echo "<Particle>: Gamma, Proton, Muon, MonteCarlo (for P,C runs)" >> $readme 2>&1
    182 echo "<Spectrum>: empty or HE, depending on the simulated MC spectrum" >> $readme 2>&1
    183 echo "<ObservationMode>: empty (On), W1/W2 (Wobble), FW1/FW2 (Fake Wobble), Diff (Diffuse)" >> $readme 2>&1
    184 echo "" >> $readme 2>&1
    185 echo "Run numbers for Cal and Ped files are linked depending on the epoch:" >> $readme 2>&1
    186 echo "MC_old:           P=1, C=2" >> $readme 2>&1
    187 echo "MC_up_to_April06: P=1, C=2" >> $readme 2>&1
    188 echo "MC_April_May06:   P=3, C=4" >> $readme 2>&1
    189 echo "MC_post_June06:   P=3, C=4" >> $readme 2>&1
    190 echo "MC_MuxFADCs:      P=5, C=6" >> $readme 2>&1
    191 echo "MC_MuxFADCs_NEW:  P=5, C=6" >> $readme 2>&1
     214echo "<Spectrum>: 'empty' or HE, depending on the simulated MC spectrum" >> $readme 2>&1
     215echo "<ObservationMode>: 'empty' (On), W1/W2 (Wobble), FW (Fake Wobble), Diff (Diffuse)" >> $readme 2>&1
    192216echo "" >> $readme 2>&1
    193217
Note: See TracChangeset for help on using the changeset viewer.