Script for sorting data.
//******************************************* //******************************************* sortLedTw( TString outName="hv0-A01", int timeStamp=1097898850) { printf("outName=%s, timeStamp=%d\n",outName, timeStamp); // return; watchDog(100000,"runCgood",1,12,1,0,timeStamp,"/star/data05/scratch/bulling/","outLed/timeC/"+outName); } //******************************************* //******************************************* //******************************************* //******************************************* watchDog(int mxEve=1000, char *runL=" R5028090", int firstSec=1, int lastSec=12, int convMode=2, int oflTrigId=0, int timeS=0, TString iPath="/star/data04/sim/balewski/daq/ezTree/", TString outPixels="out/pi" ) { TString outCrates="outLed/cr"; // runL=" R5011048 R5011050 R5011051 R5011054 R5011055 R5011056"; char *libL[]={ "StRoot/StDbLib/StDbLib.so", "StRoot/StEEmcDbMaker/libEEmcDbMaker.so", "StRoot/StEEmcUtil/EEfeeRaw/libEEfeeRaw.so", "EEmcDb/libEEmcDb.so", "EEwatchDog/libEEwatchDog.so" }; int i; for(i=0;iLoad(libL[i])); } printf("loaded %d libraries\n",i); //........... sorters .......... EEwdPixels *wdPixels=new EEwdPixels; wdPixels->setLimits(0,4095);// range for histos switch(convMode) { case 1: wdPixels->doRawAdc();// converions mode break; case 2: wdPixels->doPedSub();// converions mode break; case 3: wdPixels->doPedAndGain(); // break; default: assert(2==3); } // ......... input event file ......... TChain *chain = new TChain("ezstar"); char *run=strtok(runL," "); // init 'strtok' int i=0; do { printf("add run %d '%s' \n",i++,run); TString fullName=iPath+run+".ez.root"; chain->Add(fullName); } while(run=strtok(0," ")); // advance by one nam EEfeeRawEvent *eFee=0; EEmcEventHeader *eHead =0; EEstarTrig *eTrig=0; chain->SetBranchAddress("eemc",&eFee); chain->SetBranchAddress("head",&eHead); chain->SetBranchAddress("trig",&eTrig); chain->GetEntry(0);// read first event long timeStamp=eHead->getTimeStamp(); // timeStamp= 1077690022+5;//tmp printf("run timeStamp=%d=%s\n" ,timeStamp,ctime((const time_t *)&timeStamp)); //............ DB-reader ................. EEmcDb *db=new EEmcDb() ; db->setThreshold(2.0); // might wanna choose a flavour: // db->setPreferredFlavor("test","eemcADCconf"); //db->setDbg(4); db->setPreferredFlavor("onlped","eemcPMTped"); db->requestDataBase(timeStamp,firstSec,lastSec); // range of sectors // dump current DB content // db->exportAscii("dbDump.dat"); return; // might wanna scale some gains for a MAPMT (g_new=g_old*fac) //db->scaleGain("05S3-01",10.0); wdPixels->initHisto(db); // use DB-info in sorting int nEntries = (Int_t)chain->GetEntries(); printf("Sort %d of total Events %d, use trigId=%d\n",mxEve, nEntries,oflTrigId); int nEve=0; int nAcc=0; int t1=time(0); long int told=0; for(nEve=0; nEve GetEntry(nEve); long int timeStp=eHead->getProcessingTime(); if(timeStp!=told) told=timeStp; //printf("new t=%d\n",told);} if(timeStp<=timeS) continue; if(timeStp>timeS+23) break; if(nEve%200==0)printf("in %d, acc %d\n",nEve,nAcc); if(oflTrigId>0 && ! eTrig->isTrigID(oflTrigId) )continue; nAcc++; int nCr=eFee->maskWrongCrates(timeStamp,eHead->getToken(),EEfeeRawEvent::headVer3); //printf("n good Cr=%d\n",nCr); // eFee->print(0); break; wdPixels->sort(eFee); } printf("sorting done, nEve=%d of %d\n",nEve, nEntries); int t2=time(0); float rate=1.*nEve/(t2-t1); printf("sorting done acc %d of nEve=%d, CPU rate=%.1f Hz\n",nAcc,nEve,rate); wdPixels->saveHisto(outPixels); }
Shell script for running sorting program. This shell script needs a file that has two columns one with high-voltage time slot name and one with the timestamp associated with the START of that high voltage. To run: 'bigSort.sh < timeA.lis' (where bigSort.sh for example is the shell script name and timeA.lis is the file containing time slot name and time stamp info.
#!/bin/sh # reads from stdinp nf=0 while [ true ]; do read line if [ $? -ne 0 ];then break; fi tower=`echo $line | cut -f1 -d\ ` timeStamp=`echo $line | cut -f2 -d\ ` # echo "LINE IS " $line nf=$[$nf +1] echo "test $nf: $tower $timeStamp" root.exe -b <
Script from making 12 by 12 plots above.void plotLedTw( int pl=3,int sector=1, char sub='A' ){ TFile *fd=0; TCanvas *c; class TPad; TPad *pad=0; c=new TCanvas("ledTower","led data",800,700); gROOT->Reset(); gStyle->SetPalette(1,0); c->SetBorderMode(0); // c->Range(0,0,1,1); TPad *pad0 = new TPad("pad0", "apd0",0.0,0.95,1.,1.); pad0->Draw(); pad0->cd(); TPaveText *pt = new TPaveText(0,0.,1,1,"br"); pt->Draw(); TDatime dt; TString txt2=" "; txt2+=dt.AsString(); pt->AddText(txt2); int MxEta = 12; int MxTimeSlot = 12; char nameb[100]; char outdir[100]; char fullpath[200]; sprintf(outdir,"outLed/timeC/hv2-"); printf("outdir %s\n",outdir); txt2=" 12 towers for subsector "; txt2+=sector; txt2+="T"; txt2+=sub; pt->AddText(txt2); txt2="--"; pt->AddText(txt2); c->cd(); pad = new TPad("pad1", "apd1",0.0,0.0,1,.95); pad->Draw(); gStyle->SetOptStat(11111 ); pad->Divide(12,12); //Loop over time slot hist.root files for(int j=0; jIsOpen()) { printf("NOT found file=%s, STOP\n",fullpath); return; } assert(fd->IsOpen()); //Loop over 12 eta for(int i =0;i cd((12*j)+i+1); TH1* h = (TH1*)fd->Get(namea); assert(h); h->Draw(); h->SetAxisRange(1,4000); gPad->SetLogy(); gPad->SetLogx(); } } c->cd(); char tit[100]; //automatically generate .gif or .ps according to pl and name according //to sector and subsector (1 for .ps; 2 for .gif; 3 for both) if(pl&1) { sprintf(tit,"%02dT%c.ps",sector,sub); c->Print(tit); } if(pl&2) { sprintf(tit,"%02dT%c.gif",sector,sub); c->Print(tit); } return; }
Shell script for looping through plotLedTw and sending the appropriate variables.#!/bin/sh # reads from stdinp nf=0 for sec in 12 01 02 ; do for sub in A B C D E ; do nf=$[$nf +1] echo "sec $sec sub $sub $nf " #continue root.exe << EOF .x plotLedTw.C(3,$sec,'$sub') .q EOF done done echo "info: $nf muDst tested" exit