#include "TString.h" #include "StructDef.h" Bool_t CurrRateHd(Int_t iDet = 0, Int_t iDetectorIndex = 0, Double_t dTimeOffset = 0.0, Double_t dScaleFactor = 1.0) { if(2 < iDet) { cout<<" not a possible detector number "<IsOpen() ) { cout<< Form("Input file %s cannot be opened.", sInputFilenameScal.Data())<Get("cbmsim"); if(!tInputTreeScal) { cout<<"No CbmSim tree inside the input file for scalers."<GetEntries(); // Obtain pointers on the branches where the TRIGLOG and scaler data are stored TClonesArray* tArrayTriglog(NULL); TClonesArray* tArrayScal(NULL); // Branch pointer for Triglog TBranch* tBranchEventTriglog = tInputTreeScal->GetBranch( "TofTriglog" ); if(!tBranchEventTriglog) { cout<<"No branch TofTriglog in input tree."<SetAddress(&tArrayTriglog); // Branch pointer for Scalers TBranch* tBranchEventScal = tInputTreeScal->GetBranch( "TofCalibScaler" ); if(!tBranchEventScal) { cout<<"No branch TofCalibScaler in input tree."<SetAddress(&tArrayScal); // Switch back current directory to gROOT so that new object are created in memory, not in file gROOT->cd(); // TTofCalibScaler* tEventScal(0); cout<GetEntry(iFirstGoodMbsEvent); fTriglogBoard = (TTofTriglogBoard*) tArrayTriglog->ConstructedAt(0); // Always only 1 TRIGLOG board! if( 0 < fTriglogBoard->GetMbsTimeSec() ) break; } // for( iFirstGoodMbsEvent = 0; iFirstGoodMbsEvent < uNTreeEntriesScal; iFirstGoodMbsEvent ++) tInputTreeScal->GetEntry(iFirstGoodMbsEvent); fTriglogBoard = (TTofTriglogBoard*) tArrayTriglog->ConstructedAt(0); // Always only 1 TRIGLOG board! fCalTrloBoard = (TTofCalibScaler*) tArrayScal->ConstructedAt(0); // TRIGLOG board always first! // Use TTimeStamp as an example, this give access to date and time in nice format // Direct use of the time is also possible! TTimeStamp tTimeFirstMbsEvent; tTimeFirstMbsEvent.SetSec( fTriglogBoard->GetMbsTimeSec() ); tTimeFirstMbsEvent.SetNanoSec( fTriglogBoard->GetMbsTimeMilliSec() * 1000000 ); Double_t dFirstMbsTime = (Double_t)(tTimeFirstMbsEvent.GetSec()) + (Double_t)(tTimeFirstMbsEvent.GetNanoSec())/1e9; // Get time for MBS ending point tInputTreeScal->GetEntry(uNTreeEntriesScal-1); fTriglogBoard = (TTofTriglogBoard*) tArrayTriglog->ConstructedAt(0); // Always only 1 TRIGLOG board! fCalTrloBoard = (TTofCalibScaler*) tArrayScal->ConstructedAt(0); // TRIGLOG board always first! TTimeStamp tTimeLastMbsEvent; tTimeLastMbsEvent.SetSec( fTriglogBoard->GetMbsTimeSec() ); tTimeLastMbsEvent.SetNanoSec( fTriglogBoard->GetMbsTimeMilliSec() * 1000000 ); Int_t iTimeIntervalSecClk = (Int_t)(fCalTrloBoard->GetTimeToFirst()) + 1; cout<<"Time first MBS event: "<GetEntry(0); Double_t dFirstMbsTime = (Double_t)(tTimeFirstMbsEvent.GetSec()) + (Double_t)(tTimeFirstMbsEvent.GetNanoSec())/1e9; // Loop over MBS events UInt_t uMbsEvtIndex = 0; Double_t dRateKhzCm = 0; for( uMbsEvtIndex = iFirstGoodMbsEvent; uMbsEvtIndex < uNTreeEntriesScal; uMbsEvtIndex ++) { // Get the event data tInputTreeScal->GetEntry( uMbsEvtIndex ); // Get the TRIGLOG and SCALER object we want from the arrays fTriglogBoard = (TTofTriglogBoard*) tArrayTriglog->ConstructedAt(0); // Always only 1 TRIGLOG board! fCalTrloBoard = (TTofCalibScaler*) tArrayScal->ConstructedAt(0); // TRIGLOG board always first! // Calculate current MBS time (use directly the time, knowing the date is not so important here) Double_t dCurrMbsTime = (Double_t)(fTriglogBoard->GetMbsTimeSec()) + (Double_t)(fTriglogBoard->GetMbsTimeMilliSec())/1e3; // Calculate rate per cm2 dRateKhzCm = fCalTrloBoard->GetScalerValue(iDetId[iDet]) / 1000.0 / dDetArea[iDet]; // back HD PMT (4cmx11cm) // if( 0 < fCalTrloBoard->GetTimeToLast() ) if( 1e-5 < fCalTrloBoard->GetTimeToLast() ) // avoid too low reference clock counts // if( 5e-5 < fCalTrloBoard->GetTimeToLast() ) // avoid too low reference clock counts { // Scale rate with time since last event for averaging //hRateEvoScalMbs0->Fill( dCurrMbsTime - dFirstMbsTime, dRateKhzCm1, fCalTrloBoard->GetTimeToLast() ); hRateEvoScalMbs->Fill( dCurrMbsTime - dFirstMbsTime, dRateKhzCm, fCalTrloBoard->GetTimeToLast()); hRateEvoScalMbsw->Fill( dCurrMbsTime - dFirstMbsTime, dRateKhzCm, fCalTrloBoard->GetTimeToLast()); } } // for( uMbsEvtIndex = 0; uMbsEvtIndex < uNTreeEntriesScal; uMbsEvtIndex ++) // Looking for RPC currents const Int_t kiNbBoardsUsed = 6; Int_t kiSlotIndex[kiNbBoardsUsed] = { 0, 4, 2, 6, 13, 14}; Int_t kiSlotSzOff[kiNbBoardsUsed] = { 0, 0, 0, 0, 2, 2}; TString sFileName[kiNbBoardsUsed]; fstream * fInputFile[kiNbBoardsUsed]; std::streampos fSizeFile[kiNbBoardsUsed]; if( iDetectorIndex < 0 || 0 == iDate || -1 == iTime ) { cout<<"Please provide a detector index, a data and a time as input!!!!"<fail() ) { cout<<"************************************************************************"<seekg( 0, std::ios::end ); fSizeFile[iBoardIndex] = fInputFile[iBoardIndex]->tellg(); fInputFile[iBoardIndex]->seekg( 0, std::ios::beg ); } // for( Int_t iBoardIndex = 0; iBoardIndex < kiNbBoardsUsed; iBoardIndex++) Bool_t bAllSameSize = kTRUE; for( Int_t iBoardIndex = 1; iBoardIndex < kiNbBoardsUsed; iBoardIndex++) if( (fSizeFile[0] + kiSlotSzOff[iBoardIndex]) != fSizeFile[iBoardIndex] ) { cout<<" Warning!!!! the file for board "<eof() ) //while( iNbLinesRead < 5) { Bool_t bEndReachedInOne = kFALSE; for( Int_t iBoardIndex = 0; iBoardIndex < kiNbBoardsUsed; iBoardIndex++) { // Read a line of the HV file and set the iterator automatically to the next line sLine[iBoardIndex].ReadLine( *(fInputFile[iBoardIndex]) , kFALSE); if( 0 == sLine[iBoardIndex].Length() ) { bEndReachedInOne = kTRUE; break; } // if( 0 == sLine[iBoardIndex].Length() ) // Extract the fields as sub-strings pValuesArray[iBoardIndex] = sLine[iBoardIndex].Tokenize( ";" ); } // If at least one file is over, stop! if( kTRUE == bEndReachedInOne ) break; // Extract RPC data as numbers for( Int_t iRpcIndex = 0; iRpcIndex < kiNbRpc; iRpcIndex++) { TObjString* subString; // Take readout time from negative voltage board subString = (TObjString*)pValuesArray[ iSlotRpcNeg[iRpcIndex] ]->At(0); TString sHour = subString->GetString(); TString sMin = sHour(3,2); TString sSec = sHour(6,2); TString sMilSec = sHour(9,2); sHour = sHour(0,2); if (-1 == iFirstHour) iFirstHour = sHour.Atoi(); else if ( sHour.Atoi() < iFirstHour) { iNewDay ++; iFirstHour = sHour.Atoi(); } // else if ( sHour.Atoi() < iFirstHour) tTempTime.Set( sYearString.Atoi(), // Year sMonthString.Atoi(), // Month sDayString.Atoi() +iNewDay, // Day sHour.Atoi(), // Hour sMin.Atoi(), // Minutes sSec.Atoi(), // Seconds sMilSec.Atoi() * 10000000, // Nanoseconds kFALSE, // Not in UTC iSecOffset ); stRpcValArray[iRpcIndex].iTimeSec = tTempTime.GetSec(); //Extract seconds stRpcValArray[iRpcIndex].iTimeMilliSec = tTempTime.GetNanoSec()/1000000; //Extract milliseconds //cout<close(); // Now need to be displayed TCanvas* tCanvasA = new TCanvas("tCanvasA","Rate evolution: two case",0,0,2000,1000); tCanvasA->SetFillColor(0); tCanvasA->SetGridx(0); tCanvasA->SetGridy(0); tCanvasA->SetTopMargin(0); tCanvasA->SetRightMargin(0); tCanvasA->SetBottomMargin(0); tCanvasA->SetLeftMargin(0); //tCanvasA->Divide(2,1); tCanvasA->cd(1); gPad->SetTopMargin(0.15); gPad->SetRightMargin(0.15); gPad->SetBottomMargin(0.15); gPad->SetLeftMargin(0.15); hCurrent->SetLineColor(kRed); hCurrent->SetMarkerColor(kRed); hCurrent->SetMarkerSize(1.); hCurrent->SetMarkerStyle(20); hCurrent->Draw("P"); hCurrent->GetYaxis()->SetTitleOffset(1.5); hRateEvoScalMbs->SetFillColor(kGreen); hRateEvoScalMbs->SetFillStyle(3003); hRateEvoScalMbs->SetLineColor(kBlack); hRateEvoScalMbs->Scale(dScaleFactor); hRateEvoScalMbs->Draw("HIST,SAME"); leg = new TLegend(0.1,0.8,0.4,0.9); //leg->SetHeader("The Legend Title"); leg->AddEntry(hRateEvoScalMbs, Form("Incident particle flux on the %s counter x %.1f", iDetName[iDet].Data(), dScaleFactor),"f"); leg->AddEntry(hCurrent, Form("%s RPC current", sChNameRpc[iDetectorIndex].Data())); leg->Draw(); //tCanvasA->cd(2); //gPad->SetTopMargin(0.15); //gPad->SetRightMargin(0.15); //gPad->SetBottomMargin(0.15); //gPad->SetLeftMargin(0.15); //hRateEvoScalMbsw->SetLineColor(kBlack); //hRateEvoScalMbsw->Draw("HIST"); //hRateEvoScalMbsw->GetYaxis()->SetTitleOffset(1.5); fInputFileScal->Close(); return kTRUE; }