/[PAMELA software]/YodaProfiler/src/PamelaDBOperations.cpp
ViewVC logotype

Diff of /YodaProfiler/src/PamelaDBOperations.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.21 by mocchiut, Mon Nov 27 14:25:35 2006 UTC revision 1.22 by pam-fi, Wed Nov 29 18:12:02 2006 UTC
# Line 3092  Int_t PamelaDBOperations::insertTRK_CALI Line 3092  Int_t PamelaDBOperations::insertTRK_CALI
3092      pkt1 = ph1->GetCounter();        pkt1 = ph1->GetCounter();  
3093      fromtime = this->GetAbsTime(ph1->GetOrbitalTime());        fromtime = this->GetAbsTime(ph1->GetOrbitalTime());  
3094      //      //
3095      valid = 1;  //     valid = 1;
3096      //  //     //
3097      if ( caltrk1->unpackError != 0 && caltrk1->good0 == 0 ) valid = 0;// CONDITIONS ON THE GOODNESS OF THE CALIBRATION PKT1  //     if ( caltrk1->unpackError != 0 && caltrk1->good0 == 0 ) valid = 0;// CONDITIONS ON THE GOODNESS OF THE CALIBRATION PKT1
3098      //      //
3099      //      //
3100      if ( this->PKT(pkt1) >= this->PKT(pktfirst) && this->OBT(obt1) >= this->OBT(obtfirst) ){      if ( this->PKT(pkt1) >= this->PKT(pktfirst) && this->OBT(obt1) >= this->OBT(obtfirst) ){
3101        //        //
3102        if ( IsDebug() ) printf(" Trk calibration1 at time %i obt %i pkt %i \n",fromtime,obt1,pkt1);        if ( IsDebug() ) printf(" Trk calibration1 at time %i obt %i pkt %i \n",fromtime,obt1,pkt1);
3103          //      
3104          valid = ValidateTrkCalib( caltrk1, eh1 );
3105          if ( IsDebug() ) cout << " pkt1 validation --> "<<valid<<endl;
3106        //        //
3107        // Do we have the second calibration packet?        // Do we have the second calibration packet?
3108        //        //
# Line 3116  Int_t PamelaDBOperations::insertTRK_CALI Line 3119  Int_t PamelaDBOperations::insertTRK_CALI
3119            obt2 = ph2->GetOrbitalTime();              obt2 = ph2->GetOrbitalTime();  
3120            pkt2 = ph2->GetCounter();              pkt2 = ph2->GetCounter();  
3121            //            //
3122            if ( caltrk2->unpackError != 0 || caltrk2->good0 == 0 ) valid = 0; // CONDITIONS ON THE GOODNESS OF THE CALIBRATION PKT2  //        if ( caltrk2->unpackError != 0 || caltrk2->good0 == 0 ) valid = 0; // CONDITIONS ON THE GOODNESS OF THE CALIBRATION PKT2
3123            //                  //      
3124          } else {          } else {
3125            //            //
# Line 3147  Int_t PamelaDBOperations::insertTRK_CALI Line 3150  Int_t PamelaDBOperations::insertTRK_CALI
3150          //          //
3151          if ( IsDebug() ) printf(" The trk calibration2 at obt %i pkt %i t2 is %i is good \n",obt2,pkt2,t2);          if ( IsDebug() ) printf(" The trk calibration2 at obt %i pkt %i t2 is %i is good \n",obt2,pkt2,t2);
3152          //          //
3153            UInt_t valid2 = ValidateTrkCalib( caltrk2, eh2 );
3154            if ( IsDebug() ) cout << " pkt2 validation --> "<<valid2<<endl;
3155            valid = valid & valid2;
3156            //
3157          // Handle good calib          // Handle good calib
3158          //          //
3159          this->HandleTRK_CALIB(true,true);          this->HandleTRK_CALIB(true,true);
# Line 4415  void PamelaDBOperations::RemoveCALIBS(){ Line 4422  void PamelaDBOperations::RemoveCALIBS(){
4422      //      //
4423    };    };
4424  };  };
4425    /**
4426     *
4427     * Rearrange calibration tables
4428     *
4429     **/
4430    UInt_t PamelaDBOperations::ValidateTrkCalib( CalibTrk1Event* caltrk, EventHeader *eh ){
4431    
4432        Int_t vorder[]={5,5,3,3,4,4,2,2,1,1,0,0};
4433        UInt_t timeaftercalib=120000; //2000;
4434    //  ----------
4435    //  Check CRCs
4436    //  ----------
4437        for(Int_t ipkt=0; ipkt<6; ipkt++){
4438            if( caltrk->crc_hcal[ipkt] )return 0; // :-(
4439            for(Int_t ilad=0; ilad<3; ilad++)if( caltrk->crc_cal[ipkt][ilad] )return 0; // :-(
4440        }
4441    //  -----------------------
4442    //  Check missing packets:
4443    //  -----------------------
4444    //    Readout order:
4445    //    ------------------
4446    //    DSP   packet board
4447    //    ------------------
4448    //    12    0      1
4449    //    10    1      1
4450    //     8    2      1
4451    //     4    3      1
4452    //     6    4      1
4453    //     2    5      1
4454    //    ------------------
4455    //    11    0      2
4456    //     9    1      2
4457    //     7    2      2
4458    //     3    3      2
4459    //     5    4      2
4460    //     1    5      2
4461    //    ------------------
4462    //  -------------------------------------------------
4463    //  Check if it is first or second calibration packet
4464    //  -------------------------------------------------
4465        UInt_t build=0;
4466        TString classname = caltrk->GetName();
4467        UInt_t base=0;
4468        UInt_t mask=0;
4469        if(classname.Contains("CalibTrk1Event")){
4470            base=12;
4471            mask=0x03F000;
4472        }
4473        if(classname.Contains("CalibTrk2Event")){
4474            base=18;
4475            mask=0xFC0000;
4476        }
4477    //  -------------------------------------------------
4478    //  Count number of packets and set build variable
4479    //  -------------------------------------------------
4480        Int_t  npkts=0;
4481        for(Int_t ipkt=0; ipkt<6; ipkt++){
4482            if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){
4483                npkts++;
4484                build = build | ( 1<<(base+vorder[caltrk->DSPnumber[ipkt]-1]) );
4485            }
4486        }
4487    //    if( npkts==6 )return 1; // :-)
4488    
4489    //    cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime()<<endl;
4490    
4491    //  -----------------------------------------------
4492    //  If missing packets: check the acq configuration
4493    //  (some DSPs might be excluded from acquisition)
4494    //  -----------------------------------------------
4495    
4496    //  -----------------------------------------------
4497    //  retrieve the first run header after calib
4498    //  -----------------------------------------------
4499         PacketType *pctp;
4500         EventCounter *cod;
4501         cod = eh->GetCounter();
4502         Int_t irun = cod->Get(pctp->RunHeader);
4503         TTree *rh=(TTree*)file->Get("RunHeader");
4504         if ( !rh || rh->IsZombie() ) throw -17;
4505         if( rh->GetEntries() == irun ){
4506              if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (1)  -- cannot validate :-( "<<endl;
4507             return 0; // :-(
4508         }
4509    
4510         RunHeaderEvent *run  = 0;
4511         EventHeader    *hrun = 0;
4512         rh->SetBranchAddress("RunHeader", &run);
4513         rh->SetBranchAddress("Header", &hrun);
4514         rh->GetEntry(irun);
4515    //     cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime() << " Run " << hrun->GetPscuHeader()->GetOrbitalTime() <<endl;
4516    
4517         if( OBT(hrun->GetPscuHeader()->GetOrbitalTime()) < OBT(eh->GetPscuHeader()->GetOrbitalTime())){
4518              if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (2) -- cannot validate :-( "<<endl;
4519             return 0; // :-(
4520         }
4521        
4522         if( !run->RM_ACQ_AFTER_CALIB ){
4523              if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) RM_ACQ_AFTER_CALIB=0    -- cannot validate :-( "<<endl;
4524             return 0; // :-(
4525         }
4526    
4527         UInt_t dtime = OBT(hrun->GetPscuHeader()->GetOrbitalTime()) - OBT(eh->GetPscuHeader()->GetOrbitalTime());
4528         if( dtime > timeaftercalib ){
4529             if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) run after calib too far ( "<<dtime<<"ms ) -- cannot validate :-( "<<endl;
4530             return 0; // :-(
4531         }
4532        
4533    
4534    
4535         if( (run->ACQ_BUILD_INFO & mask) != build ){
4536             if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) ACQ_BUILD_INFO= >>> "<<hex << (run->ACQ_BUILD_INFO&mask) << " != "<< build << dec<<endl;
4537             return 0; // :-(
4538         }
4539         return 1; // :-)
4540    
4541    }

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.22

  ViewVC Help
Powered by ViewVC 1.1.23