Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

LIGainCurve.cxx

Go to the documentation of this file.
00001 #define LIGainCurve_cxx
00002 
00003 #include <LIGainCurve.h>
00004 #include <TF1.h>
00005 #include <TMath.h>
00006 
00007 #include <Validity/VldContext.h>
00008 #include <Plex/PlexStripEndId.h>
00009 #include <Conventions/Detector.h>
00010 #include <Conventions/StripEnd.h>
00011 
00012 using namespace std;
00013 
00014 static const Short_t MASTERMAX  = 20;
00015 static const Short_t MINDERMAX  = 8;
00016 static const Short_t MENUMAX    = 16;
00017 
00018 static const Short_t VARCMAX    = 3;
00019 static const Short_t VMMMAX     = 6;
00020 static const Short_t VFBMAX     = 2;
00021 static const Short_t VAMAX      = 3;
00022 static const Short_t CHANNELMAX = 22;
00023 
00024 Bool_t LIGainCurve::fCheckDB = true;
00025 
00026 
00027 CVSID("$Id: LIGainCurve.cxx,v 1.11 2007/11/11 08:00:53 rhatcher Exp $");
00028 
00029 
00030 //-------------------------------------------------
00031 
00032 LIGainCurve::LIGainCurve() {
00033 
00034   fInTree = 0;
00035   fInFile = 0;
00036 
00037   gErrorIgnoreLevel=1;
00038 
00039   gStyle->SetOptFit(0111);
00040   gStyle->SetOptStat(0); //iourmen
00041 
00042 
00043   //
00044   // Input File -> A file with a TTree with the GainCurve information.
00045   // LI-TTree obtained from LIReco.C
00046   fFileNameIn = "~/DATA/Comp2003/LI_data/LIDataC00071335_0023.root";
00047 
00048   // Output file:
00049   fFileNameOut = getenv("SRT_PRIVATE_CONTEXT");
00050   fFileNameOut += "/LISummary/liGainCurveOutput/LIGainCurveOut.ps";
00051 
00052   //
00053   //Initialised Analysis objects:
00054   //
00055 
00056   //HG
00057   fSlopeND_HG_h     = new TH1F("fSlopeND_HG_h","",100,0,0.5);
00058   fSlopeFD_HG_h     = new TH1F("fSlopeFD_HG_h","",100,0,0.5);
00059   fInterceptND_HG_h = new TH1F("fInterceptND_HG_h","",100,-75,25);
00060   fInterceptFD_HG_h = new TH1F("fInterceptFD_HG_h","",100,-75,25);
00061 
00062   fResponseND_HG_p = new TProfile("fResponseND_HG_p","",120,0,12000);
00063   fResponseFD_HG_p = new TProfile("fResponseFD_HG_p","",120,0,12000);
00064   fResponseND_HG_h = new TH2F("fResponseND_HG_h","",120,0,12000,100,0,500);
00065   fResponseFD_HG_h = new TH2F("fResponseFD_HG_h","",120,0,12000,100,0,500);
00066 
00067   //LG
00068   fSlopeND_LG_h     = new TH1F("fSlopeND_LG_h","",100,0,0.5);
00069   fSlopeFD_LG_h     = new TH1F("fSlopeFD_LG_h","",100,0,0.5);
00070   fInterceptND_LG_h = new TH1F("fInterceptND_LG_h","",100,-75,25);
00071   fInterceptFD_LG_h = new TH1F("fInterceptFD_LG_h","",100,-75,25);
00072 
00073   fResponseND_LG_p = new TProfile("fResponseND_LG_p","",120,0,12000);
00074   fResponseFD_LG_p = new TProfile("fResponseFD_LG_p","",120,0,12000);
00075   fResponseND_LG_h = new TH2F("fResponseND_LG_h","",120,0,12000,125,0,250);
00076   fResponseFD_LG_h = new TH2F("fResponseFD_LG_h","",120,0,12000,125,0,250);
00077 
00078   //Response per LED:
00079   fResponseND_LG1_p = new TProfile("fResponseND_LG1_p","",40,0,4000);
00080   fResponseFD_LG1_p = new TProfile("fResponseFD_LG1_p","",40,0,4000);
00081   fResponseND_LG2_p = new TProfile("fResponseND_LG2_p","",40,0,4000);
00082   fResponseFD_LG2_p = new TProfile("fResponseFD_LG2_p","",40,0,4000);
00083   fResponseND_LG3_p = new TProfile("fResponseND_LG3_p","",40,0,4000);
00084   fResponseFD_LG3_p = new TProfile("fResponseFD_LG3_p","",40,0,4000);
00085   fResponseND_LG4_p = new TProfile("fResponseND_LG4_p","",40,0,4000);
00086   fResponseFD_LG4_p = new TProfile("fResponseFD_LG4_p","",40,0,4000);
00087   fResponseND_LG5_p = new TProfile("fResponseND_LG5_p","",40,0,4000);
00088   fResponseFD_LG5_p = new TProfile("fResponseFD_LG5_p","",40,0,4000);
00089   fResponseND_LG6_p = new TProfile("fResponseND_LG6_p","",40,0,4000);
00090   fResponseFD_LG6_p = new TProfile("fResponseFD_LG6_p","",40,0,4000);
00091 
00092   //Response per LED:
00093   fResponseND_HG1_p = new TProfile("fResponseND_HG1_p","",50,0,10000);
00094   fResponseFD_HG1_p = new TProfile("fResponseFD_HG1_p","",50,0,10000);
00095   fResponseND_HG2_p = new TProfile("fResponseND_HG2_p","",50,0,10000);
00096   fResponseFD_HG2_p = new TProfile("fResponseFD_HG2_p","",50,0,10000);
00097   fResponseND_HG3_p = new TProfile("fResponseND_HG3_p","",50,0,10000);
00098   fResponseFD_HG3_p = new TProfile("fResponseFD_HG3_p","",50,0,10000);
00099   fResponseND_HG4_p = new TProfile("fResponseND_HG4_p","",50,0,10000);
00100   fResponseFD_HG4_p = new TProfile("fResponseFD_HG4_p","",50,0,10000);
00101   fResponseND_HG5_p = new TProfile("fResponseND_HG5_p","",50,0,10000);
00102   fResponseFD_HG5_p = new TProfile("fResponseFD_HG5_p","",50,0,10000);
00103   fResponseND_HG6_p = new TProfile("fResponseND_HG6_p","",50,0,10000);
00104   fResponseFD_HG6_p = new TProfile("fResponseFD_HG6_p","",50,0,10000);
00105 
00106 
00107 
00108   //Residuals:
00109   fResidualND_p = new TProfile("fResidualND_p","",50,0,100);
00110   fResidualFD_p = new TProfile("fResidualFD_p","",50,0,100);
00111   fResidualFDPMT_p = new TProfile("fResidualFDPMT_p","",50,0,100);
00112 
00113   fResidualFD300_p = new TProfile("fResidualFD300_p","",150,0,300);
00114   fResidualND300_p = new TProfile("fResidualND300_p","",150,0,300);
00115   fResidualFD300PMT_p = new TProfile("fResidualFD300PMT_p","",150,0,300);
00116 
00117   fResidualFDADC_p = new TProfile("fResidualFDADC_p","",150,0,15000);
00118   fResidualNDADC_p = new TProfile("fResidualNDADC_p","",150,0,25000);
00119   fResidualFDADCPMT_p = new TProfile("fResidualFDADCPMT_p","",150,0,15000);
00120 
00121   fResidualND_h = new TH2F("fResidualND_h","",300,0,300,100,-0.3,0.1);
00122   fResidualFD_h = new TH2F("fResidualFD_h","",300,0,300,100,-0.3,0.1);
00123   fResidualFDPMT_h = new TH2F("fResidualFDPMT_h","",300,0,300,100,-0.15,0.1);
00124 
00125   //fResidualN_F_p = new TH1D("fResidualN-F_p","",55,0,1100);
00126   fResidualN_F_p = new TProfile("fResidualN_F_p","",150,0,300);
00127   //fResidualN_F_h = new TH2F("fResidualN_F_h","",200,0,200,100,-0.3,0.1);
00128 
00129 
00130   fResVsGainND_p = new TProfile("fResVsGainND_p","",25,30,130);
00131   fResVsGainFD_p = new TProfile("fResVsGainFD_p","",25,30,130);
00132 }
00133 
00134 //-------------------------------------------------
00135 
00136 LIGainCurve::~LIGainCurve() {
00137 
00138   ;
00139 }
00140 
00141 //-------------------------------------------------
00142 
00143 void LIGainCurve::ExecuteMe(Int_t nentries) {
00144 
00145   //cout << "Size (empty)" << mapLinResp.size() << endl;
00146   //mapLinResp[4];
00147   //LinResp* t = new LinResp();
00148   //t->addressKey = 40;
00149   //mapLinResp[4] = t;
00150   //cout << "Size (one guy!)" << mapLinResp.size() << endl;
00151 
00152   Bool_t success = true;
00153 
00154 
00155   MSG("LIGainCurve",Msg::kInfo) << "\tLoading TTree from input file" << endl;
00156 
00157   success = this->LoadTreeLI();
00158 
00159   MSG("LIGainCurve",Msg::kInfo) << "\tAdquiring data from TTree" << endl;
00160 
00161   if(success) success = this->GetData(nentries);
00162 
00163   MSG("LIGainCurve",Msg::kInfo) << "\n\tProcessing the data" << endl;
00164 
00165   if(success) success = this->ProcessData();
00166 
00167   MSG("LIGainCurve",Msg::kInfo) << "\tPlotting results" << endl;
00168 
00169   if(success) this->PlotData();
00170 
00171   if(!success)
00172     MSG("LIGainCurve",Msg::kFatal) << "There was an error somewhere!" << endl;
00173 
00174   return;
00175 }
00176 
00177 //-------------------------------------------------
00178 
00179 Bool_t LIGainCurve::LoadTreeLI() {
00180   
00181   if(!fInTree) {
00182 
00183     if(!fFileNameIn.empty()) {
00184 
00185       fInFile = TFile::Open( fFileNameIn.c_str() );
00186       fInTree = static_cast<TTree*>( fInFile->Get("li_tree") );
00187     }
00188     else {
00189 
00190       cerr << endl
00191            << "\tThe Input file name was not given in the ROOT macro 'makeLIGainCurve.C'"
00192            << endl;
00193       return false;
00194     }
00195     
00196     if(!fInTree) {
00197 
00198       cerr << "ERROR: TTree is still empty" << endl;
00199       return false;
00200     }
00201 
00202     //fInTree->SetBranchAddress("ashtray",&ashtray);
00203     //fInTree->SetBranchAddress("calibPoint",&calibPoint);
00204     //fInTree->SetBranchAddress("calibType",&calibType);
00205     //fInTree->SetBranchAddress("chAdd",&chAdd);
00206     fInTree->SetBranchAddress("channel",&channel);
00207     fInTree->SetBranchAddress("chip",&va);
00208     fInTree->SetBranchAddress("correlatedHit",&correlatedHit);
00209     fInTree->SetBranchAddress("crate",&crate);
00210     //fInTree->SetBranchAddress("detectorType",&detectorType);
00211     fInTree->SetBranchAddress("eastWest",&eastWest);
00212     fInTree->SetBranchAddress("elecType",&elecType);
00213     //fInTree->SetBranchAddress("farLed",&farLed);
00214     //fInTree->SetBranchAddress("farPulserBox",&farPulserBox);
00215     fInTree->SetBranchAddress("geoAdd",&master);
00216     //fInTree->SetBranchAddress("inRack",&inRack);
00217     fInTree->SetBranchAddress("led",&led);
00218     fInTree->SetBranchAddress("masterCh",&minder);
00219     fInTree->SetBranchAddress("mean",&mean);
00220     fInTree->SetBranchAddress("minderCh",&menu);
00221     fInTree->SetBranchAddress("nearLed",&nearLed);
00222     fInTree->SetBranchAddress("nearPulserBox",&nearPulserBox);
00223     fInTree->SetBranchAddress("numEntries",&numEntries);
00224     //fInTree->SetBranchAddress("numericMuxBox",&numericMuxBox);
00225     //fInTree->SetBranchAddress("pe",&pe);
00226     //fInTree->SetBranchAddress("period",&period);
00227     fInTree->SetBranchAddress("pinGain",&pinGain);
00228     //fInTree->SetBranchAddress("pinInBox",&pinInBox);
00229     //fInTree->SetBranchAddress("pixel",&pixel);
00230     fInTree->SetBranchAddress("plane",&plane);
00231     fInTree->SetBranchAddress("pulseHeight",&pulseHeight);
00232     fInTree->SetBranchAddress("pulserBox",&pulserBox);
00233     //fInTree->SetBranchAddress("pulses",&pulses);
00234     fInTree->SetBranchAddress("pulseWidth",&pulseWidth);
00235     //fInTree->SetBranchAddress("rackBay",&rackBay);
00236     //fInTree->SetBranchAddress("rackLevel",&rackLevel);
00237     fInTree->SetBranchAddress("readoutType",&readoutType);
00238     fInTree->SetBranchAddress("rms",&rms);
00239     //fInTree->SetBranchAddress("runNumber",&runNumber);
00240     //fInTree->SetBranchAddress("runNumberSub",&runNumberSub);
00241     //fInTree->SetBranchAddress("runType",&runType);
00242     fInTree->SetBranchAddress("strip",&strip);
00243     fInTree->SetBranchAddress("stripEnd",&stripEnd);
00244     //fInTree->SetBranchAddress("summaryCounter",&summaryCounter);
00245     fInTree->SetBranchAddress("timestamp",&timestamp);
00246     fInTree->SetBranchAddress("varc",&varc);
00247     fInTree->SetBranchAddress("vfb",&vfb);
00248     fInTree->SetBranchAddress("vmm",&vmm);
00249 
00250   }
00251   else MSG("LIGainCurve",Msg::kError) << "What's wrong with it? Just continue!" << endl;
00252 
00253   return true;
00254 }
00255 
00256 //-------------------------------------------------
00257 
00258 Int_t LIGainCurve::EncryptMeKey(const Int_t crate,
00259                             const Int_t varc,
00260                             const Int_t vmm,
00261                             const Int_t vfb,
00262                             const Int_t va,
00263                             const Int_t channel) {
00264 
00265   Int_t key = CHANNELMAX*va+channel;
00266   key      += CHANNELMAX*VAMAX*vfb;
00267   key      += CHANNELMAX*VAMAX*VFBMAX*vmm;
00268   key      += CHANNELMAX*VAMAX*VFBMAX*VMMMAX*varc;
00269   key      += CHANNELMAX*VAMAX*VFBMAX*VMMMAX*VARCMAX*crate;
00270   
00271   return key;
00272 }
00273 
00274 //-------------------------------------------------
00275 
00276 Int_t LIGainCurve:: EncryptMeKey(const Int_t crate,
00277                              const Int_t master,
00278                              const Int_t minder,
00279                              const Int_t menu ) {
00280 
00281   Int_t key = MENUMAX*minder+menu;
00282   key      += MENUMAX*MINDERMAX*master;
00283   key      += MENUMAX*MINDERMAX*MASTERMAX*crate;
00284   key      += 2500; //offset
00285     
00286   return key;
00287 }
00288 
00289 //-------------------------------------------------
00290 
00291 Bool_t LIGainCurve::GetData(Int_t nentries) {
00292 
00293   if (nentries == -1) 
00294     nentries = Int_t(fInTree->GetEntries());
00295  
00296   //LOOP over TTree entries:
00297   for (Int_t jentry=0; jentry<nentries; jentry++) {
00298 
00299     Int_t ientry = fInTree->GetEntry(jentry);
00300 
00301     if (ientry < 0) {
00302 
00303       cerr  << endl << "ERROR with the TChain entry" << endl;
00304       break;
00305     }
00306 
00307     //
00308     //Collect data into the map of LILinResp's:
00309     //
00310     if( correlatedHit == 1           //in agreement with the PLEX
00311         &&
00312         pulserBox==nearPulserBox     //Make sure the pulser box is the correcte one
00313         &&
00314         led == nearLed ) {           //make sure we use the near LED only
00315 
00316 
00317       //
00318       //PMT data - channels connected to strip-ends:
00319       //
00320       if( readoutType == 0x0001 ) {
00321 
00322         PlexStripEndId* seid = 0;
00323         Int_t key = -1;
00324 
00325         //My local pointer to a LILinResp object 
00326         //(to be stored in map) 
00327         LILinResp* myLR = 0;
00328 
00329         //create iter. Initialise to end of map (was =0 but that's
00330         //not ansi c++ and gcc 4.1 compile fails) This should work ok...
00331         map<Int_t,LILinResp*>::iterator iter = mapLinResp.end();
00332 
00333         //FD
00334         if(crate == 0) {
00335           
00336           if(!seid) {
00337             seid = new PlexStripEndId(Detector::kCalDet,plane,strip,StripEnd::kNegative);
00338 
00339             key = this->EncryptMeKey(crate,varc,vmm,vfb,va,channel);
00340 
00341             //Check this channel has already been added or not:
00342             //if(mapLinResp.size()>0) 
00343             iter = mapLinResp.find(key);
00344 
00345             //if((*iter).second == 0) {
00346             if(iter == mapLinResp.end()) {
00347 
00348               myLR = new LILinResp();
00349 
00350               //Give address:
00351               myLR->typeFEE    = ElecType::kVA;
00352               myLR->addressKey = key;
00353               //LED: link to corresponding PIN:
00354               myLR->led        = led;
00355             }
00356             else {
00357 
00358               myLR = (*iter).second;
00359             }
00360 
00361             if(!myLR) cerr << "This should not happen!" << endl;
00362           }
00363           else cerr << "This should not happen!" << endl;
00364         }
00365         //ND
00366         else {
00367           
00368           if(!seid) {
00369             seid = new PlexStripEndId(Detector::kCalDet,plane,strip,StripEnd::kPositive);
00370 
00371             key = this->EncryptMeKey(crate,master,minder,menu);
00372 
00373             //Check this channel has already been added or not:
00374             //if(mapLinResp.size()>0) 
00375             iter = mapLinResp.find(key);
00376 
00377             //if((*iter).second == 0) {
00378             if(iter == mapLinResp.end()) {
00379 
00380               myLR = new LILinResp();
00381 
00382               //Once created initialised:
00383               //Address:
00384               myLR->addressKey = key;
00385               myLR->typeFEE    = ElecType::kQIE;
00386               //LED: link to corresponding PIN:
00387               myLR->led        = led;
00388             }
00389             else {
00390 
00391               myLR = (*iter).second;
00392             }
00393 
00394             if(!myLR) cerr << "This should not happen!" << endl;
00395           }
00396           else cerr << "This should not happen!" << endl;
00397         }
00398         
00399         //
00400         // RMS:
00401         // 
00402         //  saturation effects on the VA FEE->
00403         //  RMS seems ok until pulseHeight ~400.
00404         // 
00405         //  QIE's RMS looks ok all the time.
00406         //
00407         //
00408                 
00409         //if(key==6218) continue;
00410 
00411         //Get drifted gain of PMT -> PE:
00412         if(seid) {
00413           
00414           Float_t meanCal = 0;
00415           Float_t mean_e  = rms / sqrt( Float_t(numEntries) );
00416           
00417           //cout << jentry << "\t" << key << "\t" << led << "\t" << mapLinResp.size() << endl;
00418 
00419           Float_t gain  = -1;
00420           Float_t drift = -1;
00421           
00422           //If values still not stored into LinResp object -> get them.
00423           if( (*myLR).gain == -1 && (*myLR).drift == -1 ) {
00424             
00425             if(crate == 0 )
00426               gain = 65;    //(PE/ADC) As measured at CalDet
00427             if(crate > 0 )
00428               gain  = 81.;  //(PE/ADC) As measured at CalDet
00429 
00430             //No drift:
00431             drift = 1.;
00432 
00433             //
00434             // There was a time that I did all this calculation with the real gains: that was not right!
00435             //
00436 
00437             //Store into the LinResp objects:
00438             myLR->gain  = gain;
00439             myLR->drift = drift;
00440           }
00441           else {
00442             gain  = myLR->gain;
00443             drift = myLR->drift;
00444           }
00445 
00446           //Get charge in PEs taken into account the drift:
00447           if(gain != -1 && drift != -1 )
00448             meanCal = mean * drift / gain * numEntries/2000.; //Note the total number of entries expected is hardwire here
00449           else
00450             MSG("LIGainCurve",Msg::kError) << "No gain/drift numbers available!" << endl;
00451 
00452           //Correct for attenuation of each view:
00453           //NIY
00454 
00455           
00456 
00457           if(key>-1) {
00458           
00459             //Sanity check (>90% of entries):
00460             if( numEntries > 1800 ) {
00461               
00462               myLR->fX.push_back(meanCal);
00463               myLR->fX_error.push_back(mean_e);
00464             }
00465             //Data should not be used -> label with -1 and then removed.
00466             else {
00467               
00468               myLR->fX.push_back(-1);
00469               myLR->fX_error.push_back(-1);
00470             }
00471             mapLinResp[key] = myLR;
00472           }
00473         }
00474 
00475         delete seid;
00476       }
00477     
00478       //
00479       //PIN data:
00480       //
00481       if( readoutType == 0x0002 ) {
00482         
00483         //NOTE:*******************************************
00484         //
00485         //HERE the link between LED <--> PIN is hard-wired 
00486         //************************************************
00487         //
00488         // @ CALDET 2003:
00489         //
00490         // LED  |  VMM  |  VFB
00491         //  1   |   0   |   0
00492         //  2   |   0   |   1
00493         //  3   |   1   |   
00494         //  4   |   2   |   
00495         //  5   |   4   |   
00496         //  6   |   3   |   
00497         //
00498 
00499         MSG("LIGainCurve",Msg::kDebug) << crate << "\t"
00500                                    << varc << "\t"
00501                                    << vmm << "\t"
00502                                    << vfb << "\t"
00503                                    << va << "\t"
00504                                    << channel << "\t"
00505                                    << pinGain << "\t"
00506                                    << led << "\t"
00507                                    << nearLed << "\t" 
00508                                    << numEntries << "\t"
00509                                    << mean << "\t" 
00510                                    << endl;
00511         
00512 
00513         //This swich account for the mapping of the PINs in FEE-space:
00514         switch(vmm) {
00515         case 0:
00516           if(vfb==0) {
00517             if( numEntries > 1800 ) {
00518               //cout << "led 1" << endl; 
00519               if(va==0) LILinResp::fXrefPINLG1.push_back(mean);
00520               if(va==1) LILinResp::fXrefPINHG1.push_back(mean);
00521             }
00522             //Data should not be used:
00523             else {
00524               //cout << "led 1" << endl; 
00525               if(va==0) LILinResp::fXrefPINLG1.push_back(-1);
00526               if(va==1) LILinResp::fXrefPINHG1.push_back(-1);
00527             }
00528           }
00529           else{
00530             if( numEntries > 1800 ) {
00531               //cout << "led 2" << endl; 
00532               if(va==0) LILinResp::fXrefPINLG2.push_back(mean);
00533               if(va==1) LILinResp::fXrefPINHG2.push_back(mean);
00534             }
00535             //Data should not be used:
00536             else {
00537               //cout << "led 2" << endl; 
00538               if(va==0) LILinResp::fXrefPINLG2.push_back(-1);
00539               if(va==1) LILinResp::fXrefPINHG2.push_back(-1);
00540             }
00541           }
00542           break;
00543         case 1:
00544           if( numEntries > 1800 ) {
00545               //cout << "led 3" << endl; 
00546             if(va==0) LILinResp::fXrefPINLG3.push_back(mean);
00547             if(va==1) LILinResp::fXrefPINHG3.push_back(mean);
00548           }
00549           //Data should not be used:
00550           else {
00551               //cout << "led 3" << endl; 
00552             if(va==0) LILinResp::fXrefPINLG3.push_back(-1);
00553             if(va==1) LILinResp::fXrefPINHG3.push_back(-1);
00554           }
00555           break;
00556         case 2:
00557           if( numEntries > 1800 ) {
00558               //cout << "led 4" << endl; 
00559             if(va==0) LILinResp::fXrefPINLG4.push_back(mean);
00560             if(va==1) LILinResp::fXrefPINHG4.push_back(mean);
00561           }
00562           //Data should not be used:
00563         else {
00564               //cout << "led 4" << endl; 
00565           if(va==0) LILinResp::fXrefPINLG4.push_back(-1);
00566           if(va==1) LILinResp::fXrefPINHG4.push_back(-1);
00567         }
00568           break;
00569         case 3:
00570           if( numEntries > 1800 ) {
00571               //cout << "led 6" << endl; 
00572             if(va==0) LILinResp::fXrefPINLG6.push_back(mean);
00573             if(va==1) LILinResp::fXrefPINHG6.push_back(mean);
00574           }
00575           //Data should not be used:
00576           else {
00577               //cout << "led 6" << endl; 
00578             if(va==0) LILinResp::fXrefPINLG6.push_back(-1);
00579             if(va==1) LILinResp::fXrefPINHG6.push_back(-1);
00580           }
00581           break;
00582         case 4:
00583           if( numEntries > 1800 ) {
00584               //cout << "led 5" << endl; 
00585             if(va==0) LILinResp::fXrefPINLG5.push_back(mean);
00586             if(va==1) LILinResp::fXrefPINHG5.push_back(mean);
00587           }
00588           //Data should not be used:
00589           else {
00590               //cout << "led 5" << endl; 
00591             if(va==0) LILinResp::fXrefPINLG5.push_back(-1);
00592             if(va==1) LILinResp::fXrefPINHG5.push_back(-1);
00593           }
00594           break;
00595         }
00596       }
00597       
00598     } //End of IF => selected response
00599 
00600     else {
00601 
00602       MSG("LILinResp",Msg::kVerbose) << crate << "\t"
00603                                    << numEntries << "\t"
00604                                    << correlatedHit << "\t"
00605                                    << led << "\t"
00606                                    << nearLed << "\t" 
00607                                    << channel << "\t"
00608                                    << endl;
00609     }
00610 
00611   } //End of LOOP over Input TTREE
00612   
00613 
00614   MSG("LILinResp",Msg::kInfo) << "\t\t\t\t...Number of LILinResp created: " << mapLinResp.size() << endl;
00615 
00616   //fInFile->Close();
00617 
00618   return true;
00619 }
00620 
00621 
00622 //-------------------------------------------------
00623 
00624 
00625 Bool_t LIGainCurve::ProcessData() {
00626 
00627   //Int_t count  = 0;
00628 
00629   Bool_t success = false;
00630   map<Int_t,LILinResp*>::iterator linRespIter = mapLinResp.begin();
00631 
00632   //
00633   //LOOP over the map of LinResp
00634   //
00635   while( linRespIter != mapLinResp.end() ) {
00636     
00637     //Tell LinResp to estimate their linearity
00638     success = (*linRespIter).second->GetLinearity();
00639 
00640     //(*linRespIter).second->PrintMe();
00641 
00642     if(success) {
00643 
00644       //
00645       //Fill GLOBAL histograms with slopes & intercepts:
00646       //
00647 
00648       if((*linRespIter).second->typeFEE == ElecType::kQIE) {
00649 
00650         //HG
00651         fSlopeND_HG_h->Fill( (*linRespIter).second->slopeHG );
00652         fInterceptND_HG_h->Fill( (*linRespIter).second->interceptHG );
00653         //LG
00654         fSlopeND_LG_h->Fill( (*linRespIter).second->slopeLG );
00655         fInterceptND_LG_h->Fill( (*linRespIter).second->interceptLG );
00656       }
00657       else {
00658 
00659         //HG
00660         fSlopeFD_HG_h->Fill( (*linRespIter).second->slopeHG );
00661         fInterceptFD_HG_h->Fill( (*linRespIter).second->interceptHG );
00662         //LG
00663         fSlopeFD_LG_h->Fill( (*linRespIter).second->slopeLG );
00664         fInterceptFD_LG_h->Fill( (*linRespIter).second->interceptLG );
00665       }
00666 
00667       //
00668       // Iterate over the vectors in each LinResp to get residuals
00669       //
00670 
00671       vector<Float_t>* X    = (*linRespIter).second->GetX();
00672       //vector<Float_t>* X_e  = (*linRespIter).second->GetX_e();
00673       vector<Float_t>* Res     = (*linRespIter).second->GetResiduals();
00674       vector<Float_t>* ResPMT  = (*linRespIter).second->GetPMTResiduals();
00675 
00676       vector<Float_t>* XrefPINHG = 0;
00677       vector<Float_t>* XrefPINLG = 0;
00678 
00679       //Ask each channel for what LED should be injected by.
00680       //Once the LED is known -> use the LED to find the corresponding Xref.
00681       switch( (*linRespIter).second->led ) {
00682       case 1:
00683         XrefPINHG = ( &LILinResp::fXrefPINHG1 );
00684         XrefPINLG = ( &LILinResp::fXrefPINLG1 );
00685         break;
00686       case 2:
00687         XrefPINHG = ( &LILinResp::fXrefPINHG2 );
00688         XrefPINLG = ( &LILinResp::fXrefPINLG2 );
00689         break;
00690       case 3:
00691         XrefPINHG = ( &LILinResp::fXrefPINHG3 );
00692         XrefPINLG = ( &LILinResp::fXrefPINLG3 );
00693         break;
00694       case 4:
00695         XrefPINHG = ( &LILinResp::fXrefPINHG4 );
00696         XrefPINLG = ( &LILinResp::fXrefPINLG4 );
00697         break;
00698       case 5:
00699         XrefPINHG = ( &LILinResp::fXrefPINHG5 );
00700         XrefPINLG = ( &LILinResp::fXrefPINLG5 );
00701         break;
00702       case 6:
00703         XrefPINHG = ( &LILinResp::fXrefPINHG6 );
00704         XrefPINLG = ( &LILinResp::fXrefPINLG6 );
00705         break;
00706       }
00707 
00708       vector<Float_t>::iterator xIter    = X->begin();
00709       //vector<Float_t>::iterator xeIter   = X_e->begin();
00710       vector<Float_t>::iterator resIter     = Res->begin();
00711       vector<Float_t>::iterator resIterPMT  = ResPMT->begin();
00712       vector<Float_t>::iterator xRefPINHGIter = XrefPINHG->begin();
00713       vector<Float_t>::iterator xRefPINLGIter = XrefPINLG->begin();
00714 
00715 
00716       //
00717       //LOOP over the responses of each LinResp object:
00718       //
00719       while( xIter != X->end() ) {
00720 
00721         if( (*xIter) != -1 && (*xRefPINHGIter) != -1 && (*xRefPINLGIter) != -1 && (*resIter) != -1 ) {
00722 
00723           if( (*linRespIter).second->typeFEE == ElecType::kQIE ) {
00724             
00725             if( (*linRespIter).second->led <= 3 ) {
00726 
00727               //Fill GLOBAL histograms with linearity
00728               //HG:       
00729               fResponseND_HG_p->Fill( (*xRefPINHGIter),(*xIter) );
00730               fResponseND_HG_h->Fill( (*xRefPINHGIter),(*xIter) );
00731               
00732               //LG:
00733               fResponseND_LG_p->Fill( (*xRefPINLGIter),(*xIter) );
00734               fResponseND_LG_h->Fill( (*xRefPINLGIter),(*xIter) );
00735               
00736               
00737               switch( (*linRespIter).second->led ) {
00738               case 1:
00739                 fResponseND_LG1_p->Fill( (*xRefPINLGIter),(*xIter) );
00740                 fResponseND_HG1_p->Fill( (*xRefPINHGIter),(*xIter) );
00741                 break;
00742               case 2:
00743                 fResponseND_LG2_p->Fill( (*xRefPINLGIter),(*xIter) );
00744                 fResponseND_HG2_p->Fill( (*xRefPINHGIter),(*xIter) );
00745                 break;
00746               case 3:
00747                 fResponseND_LG3_p->Fill( (*xRefPINLGIter),(*xIter) );
00748                 fResponseND_HG3_p->Fill( (*xRefPINHGIter),(*xIter) );
00749                 break;
00750               case 4:
00751                 fResponseND_LG4_p->Fill( (*xRefPINLGIter),(*xIter) );
00752                 fResponseND_HG4_p->Fill( (*xRefPINHGIter),(*xIter) );
00753                 break;
00754               case 5:
00755                 fResponseND_LG5_p->Fill( (*xRefPINLGIter),(*xIter) );
00756                 fResponseND_HG5_p->Fill( (*xRefPINHGIter),(*xIter) );
00757                 break;
00758               case 6:
00759                 fResponseND_LG6_p->Fill( (*xRefPINLGIter),(*xIter) );
00760                 fResponseND_HG6_p->Fill( (*xRefPINHGIter),(*xIter) );
00761                 break;
00762               }
00763               
00764               
00765               //HGPIN was not used
00766               Float_t xLinearised = (*linRespIter).second->slopeLG * (*xRefPINLGIter) + (*linRespIter).second->interceptLG;
00767 
00768               //Float_t xLinearised = (*linRespIter).second->slopeHG * (*xRefPINHGIter) + (*linRespIter).second->interceptHG;
00769               
00770 
00771               //Fill GLOBAL histograms with residuals
00772               if(xLinearised>5 //Low charge structure not necesarily very well describe with GainCurve, there cut, not affect fit for parametrisation
00773                  && 
00774                  (*linRespIter).second->slopeLG > 0 
00775                  &&
00776                  (*linRespIter).second->slopeLG < 0.3 
00777                  && 
00778                  TMath::Abs( (*resIter) ) < 0.2 ) { //For some reason the are some entries screwed up! -> to be investigated
00779                 //fResidualND_p->Fill( (*xIter),(*resIter) );
00780                 //fResidualND_h->Fill( (*xIter),(*resIter) );
00781                 fResidualND_p->Fill( xLinearised,(*resIter) );
00782                 fResidualND_h->Fill( xLinearised,(*resIter) );
00783                 fResidualND300_p->Fill( xLinearised,(*resIter) );
00784                 fResidualNDADC_p->Fill( xLinearised*(*linRespIter).second->gain,(*resIter) );
00785               }
00786               
00787               if(xLinearised > 140 && xLinearised < 160)
00788                 fResVsGainND_p->Fill( (*linRespIter).second->gain, (*resIter) );
00789             }
00790           }
00791           else {
00792           
00793             //Fill GLOBAL histograms with linearity
00794             //HG:
00795             fResponseFD_HG_p->Fill( (*xRefPINHGIter),(*xIter) );
00796             fResponseFD_HG_h->Fill( (*xRefPINHGIter),(*xIter) );
00797           
00798             //LG:
00799             fResponseFD_LG_p->Fill( (*xRefPINLGIter),(*xIter) );
00800             fResponseFD_LG_h->Fill( (*xRefPINLGIter),(*xIter) );
00801           
00802 
00803             switch( (*linRespIter).second->led ) {
00804             case 1:
00805               fResponseFD_LG1_p->Fill( (*xRefPINLGIter),(*xIter) );
00806               fResponseFD_HG1_p->Fill( (*xRefPINHGIter),(*xIter) );
00807               break;
00808             case 2:
00809               fResponseFD_LG2_p->Fill( (*xRefPINLGIter),(*xIter) );
00810               fResponseFD_HG2_p->Fill( (*xRefPINHGIter),(*xIter) );
00811               break;
00812             case 3:
00813               fResponseFD_LG3_p->Fill( (*xRefPINLGIter),(*xIter) );
00814               fResponseFD_HG3_p->Fill( (*xRefPINHGIter),(*xIter) );
00815               break;
00816             case 4:
00817               fResponseFD_LG4_p->Fill( (*xRefPINLGIter),(*xIter) );
00818               fResponseFD_HG4_p->Fill( (*xRefPINHGIter),(*xIter) );
00819               break;
00820             case 5:
00821               fResponseFD_LG5_p->Fill( (*xRefPINLGIter),(*xIter) );
00822               fResponseFD_HG5_p->Fill( (*xRefPINHGIter),(*xIter) );
00823               break;
00824             case 6:
00825               fResponseFD_LG6_p->Fill( (*xRefPINLGIter),(*xIter) );
00826               fResponseFD_HG6_p->Fill( (*xRefPINHGIter),(*xIter) );
00827               break;
00828             }
00829 
00830 
00831             //HGPIN was not used
00832             Float_t xLinearised = (*linRespIter).second->slopeLG * (*xRefPINLGIter) + (*linRespIter).second->interceptLG;
00833             //Float_t xLinearised = (*linRespIter).second->slopeHG * (*xRefPINHGIter) + (*linRespIter).second->interceptHG;
00834 
00835 
00836             //Fill GLOBAL histograms with residuals
00837             if(xLinearised>5 //Low charge structure not necesarily very well describe with GainCurve, there cut, not affect fit for parametrisation
00838                && 
00839                (*linRespIter).second->slopeLG > 0 
00840                &&
00841                (*linRespIter).second->slopeLG < 0.3 
00842                && 
00843                TMath::Abs( (*resIter) ) < 0.4 ) { //For some reason the are some entries screwed up! -> to be investigated
00844 
00845               //fResidualFD_p->Fill( (*xIter),(*resIter) );
00846               //fResidualFD_h->Fill( (*xIter),(*resIter) );
00847               fResidualFD_p->Fill( xLinearised,(*resIter) );
00848               fResidualFD_h->Fill( xLinearised,(*resIter) );
00849               fResidualFD300_p->Fill( xLinearised,(*resIter) );
00850               fResidualFDADC_p->Fill( xLinearised*(*linRespIter).second->gain,(*resIter) );
00851 
00852               if(xLinearised <=220) {
00853                 fResidualFDPMT_p->Fill( xLinearised,(*resIterPMT) );
00854                 fResidualFDPMT_h->Fill( xLinearised,(*resIterPMT) );
00855                 fResidualFD300PMT_p->Fill( xLinearised,(*resIterPMT) );
00856                 fResidualFDADCPMT_p->Fill( xLinearised*(*linRespIter).second->gain,(*resIterPMT) );
00857               }
00858             }
00859 
00860             if(xLinearised > 140 && xLinearised < 160)
00861               fResVsGainFD_p->Fill( (*linRespIter).second->gain, (*resIter) );
00862           }
00863         }
00864 
00865         xIter++;
00866         resIter++;
00867         resIterPMT++;
00868         xRefPINLGIter++;
00869         xRefPINHGIter++;
00870       }
00871     }
00872 
00873     //count ++;
00874     linRespIter++;
00875   }
00876 
00877   //
00878   //Residuals' difference:
00879   //
00880   fResidualN_F_p->Add(fResidualND300_p,       
00881                       fResidualFD300_p,
00882                       1,-1);
00883 
00884   //Clear map - not needed any more!
00885   mapLinResp.clear();
00886 
00887   return true;
00888 }
00889 
00890 //-------------------------------------------------
00891 
00892 void LIGainCurve::PlotData() {
00893 
00894   //Plot the Summaries:
00895   Int_t plotCounter = 0;
00896 
00897   fplotFile_c = new TCanvas("plotFile_c","",1200,800);
00898 
00899   string fFileOutStart = fFileNameOut + "(";
00900   string fFileOutEnd   = fFileNameOut + ")";
00901 
00902   fplotFile_c->cd();
00903   fplotFile_c->Clear();
00904   fplotFile_c->Print(fFileOutStart.c_str());
00905 
00906   //
00907   //Response:
00908   //
00909 
00910   //ND & HG:
00911   fplotFile_c->cd();
00912   fplotFile_c->Divide(2,1);
00913   fplotFile_c->cd(1);
00914   gPad->SetLogz(1);
00915   fResponseND_HG_h->SetXTitle("X_{referece HG}");
00916   fResponseND_HG_h->SetYTitle("MEAN ND [PE]");
00917   fResponseND_HG_h->Draw("colz");
00918   fplotFile_c->cd(2);
00919   gPad->SetLogz(0);
00920   fResponseND_HG_p->SetXTitle("X_{referece HG}");
00921   fResponseND_HG_p->SetYTitle("<MEAN ND [PE]>");
00922   fResponseND_HG_p->SetLineColor(9);
00923   fResponseND_HG_p->SetLineWidth(4);
00924   fResponseND_HG_p->Draw();
00925   fplotFile_c->cd();
00926   fplotFile_c->Update();
00927   fplotFile_c->Print(fFileNameOut.c_str());
00928   plotCounter++;
00929   fplotFile_c->Clear();
00930 
00931 
00932   //ND & LG:
00933   fplotFile_c->cd();
00934   fplotFile_c->Divide(2,1);
00935   fplotFile_c->cd(1);
00936   gPad->SetLogz(1);
00937   fResponseND_LG_h->SetXTitle("X_{referece LG}");
00938   fResponseND_LG_h->SetYTitle("MEAN ND [PE]");
00939   fResponseND_LG_h->Draw("colz");
00940   fplotFile_c->cd(2);
00941   gPad->SetLogz(0);
00942   fResponseND_LG_p->SetXTitle("X_{referece LG}");
00943   fResponseND_LG_p->SetYTitle("<MEAN ND [PE]>");
00944   fResponseND_LG_p->SetLineColor(9);
00945   fResponseND_LG_p->SetLineWidth(4);
00946   fResponseND_LG_p->Draw();
00947   fplotFile_c->cd();
00948   fplotFile_c->Update();
00949   fplotFile_c->Print(fFileNameOut.c_str());
00950   plotCounter++;
00951   fplotFile_c->Clear();
00952 
00953 
00954 
00955   //FD & HG:
00956   fplotFile_c->cd();
00957   fplotFile_c->Divide(2,1);
00958   fplotFile_c->cd(1);
00959   gPad->SetLogz(1);
00960   fResponseFD_HG_h->SetXTitle("X_{referece HG}");
00961   fResponseFD_HG_h->SetYTitle("MEAN FD [PE]");
00962   fResponseFD_HG_h->Draw("colz");
00963   fplotFile_c->cd(2);
00964   gPad->SetLogz(0);
00965   fResponseFD_HG_p->SetXTitle("X_{referece HG}");
00966   fResponseFD_HG_p->SetYTitle("<MEAN FD [PE]>");
00967   fResponseFD_HG_p->SetLineColor(9);
00968   fResponseFD_HG_p->SetLineWidth(4);
00969   fResponseFD_HG_p->Draw();
00970   fplotFile_c->cd();
00971   fplotFile_c->Update();
00972   fplotFile_c->Print(fFileNameOut.c_str());
00973   plotCounter++;
00974   fplotFile_c->Clear();
00975 
00976 
00977   //FD & LG:
00978   fplotFile_c->cd();
00979   fplotFile_c->Divide(2,1);
00980   fplotFile_c->cd(1);
00981   gPad->SetLogz(1);
00982   fResponseFD_LG_h->SetXTitle("X_{referece LG}");
00983   fResponseFD_LG_h->SetYTitle("MEAN FD [PE]");
00984   fResponseFD_LG_h->Draw("colz");
00985   fplotFile_c->cd(2);
00986   gPad->SetLogz(0);
00987   fResponseFD_LG_p->SetXTitle("X_{referece LG}");
00988   fResponseFD_LG_p->SetYTitle("<MEAN FD [PE]>");
00989   fResponseFD_LG_p->SetLineColor(9);
00990   fResponseFD_LG_p->SetLineWidth(4);
00991   fResponseFD_LG_p->Draw();
00992   fplotFile_c->cd();
00993   fplotFile_c->Update();
00994   fplotFile_c->Print(fFileNameOut.c_str());
00995   plotCounter++;
00996   fplotFile_c->Clear();
00997 
00998 
00999 
01000   //ND & LG:
01001   fplotFile_c->cd();
01002   fplotFile_c->Divide(2,3);
01003   //
01004   fplotFile_c->cd(1);
01005   gPad->SetLogz(0);
01006   fResponseND_LG1_p->SetXTitle("X_{referece LG}(1)");
01007   fResponseND_LG1_p->SetYTitle("<MEAN ND [PE]>");
01008   fResponseND_LG1_p->Draw();
01009   //
01010   fplotFile_c->cd(2);
01011   gPad->SetLogz(0);
01012   fResponseND_LG2_p->SetXTitle("X_{referece LG}(2)");
01013   fResponseND_LG2_p->SetYTitle("<MEAN ND [PE]>");
01014   fResponseND_LG2_p->Draw();
01015   //
01016   fplotFile_c->cd(3);
01017   gPad->SetLogz(0);
01018   fResponseND_LG3_p->SetXTitle("X_{referece LG}(3)");
01019   fResponseND_LG3_p->SetYTitle("<MEAN ND [PE]>");
01020   fResponseND_LG3_p->Draw();
01021   //
01022   fplotFile_c->cd(4);
01023   gPad->SetLogz(0);
01024   fResponseND_LG4_p->SetXTitle("X_{referece LG}(4)");
01025   fResponseND_LG4_p->SetYTitle("<MEAN ND [PE]>");
01026   fResponseND_LG4_p->Draw();
01027   //
01028   fplotFile_c->cd(5);
01029   gPad->SetLogz(0);
01030   fResponseND_LG5_p->SetXTitle("X_{referece LG}(5)");
01031   fResponseND_LG5_p->SetYTitle("<MEAN ND [PE]>");
01032   fResponseND_LG5_p->Draw();
01033   //
01034   fplotFile_c->cd(6);
01035   gPad->SetLogz(0);
01036   fResponseND_LG6_p->SetXTitle("X_{referece LG}(6)");
01037   fResponseND_LG6_p->SetYTitle("<MEAN ND [PE]>");
01038   fResponseND_LG6_p->Draw();
01039 
01040   fplotFile_c->cd();
01041   fplotFile_c->Update();
01042   fplotFile_c->Print(fFileNameOut.c_str());
01043   plotCounter++;
01044   fplotFile_c->Clear();
01045 
01046 
01047 
01048   //FD & LG:
01049   fplotFile_c->cd();
01050   fplotFile_c->Divide(2,3);
01051   //
01052   fplotFile_c->cd(1);
01053   gPad->SetLogz(0);
01054   fResponseFD_LG1_p->SetXTitle("X_{referece LG}(1)");
01055   fResponseFD_LG1_p->SetYTitle("<MEAN FD [PE]>");
01056   fResponseFD_LG1_p->Draw();
01057   //
01058   fplotFile_c->cd(2);
01059   gPad->SetLogz(0);
01060   fResponseFD_LG2_p->SetXTitle("X_{referece LG}(2)");
01061   fResponseFD_LG2_p->SetYTitle("<MEAN FD [PE]>");
01062   fResponseFD_LG2_p->Draw();
01063   //
01064   fplotFile_c->cd(3);
01065   gPad->SetLogz(0);
01066   fResponseFD_LG3_p->SetXTitle("X_{referece LG}(3)");
01067   fResponseFD_LG3_p->SetYTitle("<MEAN FD [PE]>");
01068   fResponseFD_LG3_p->Draw();
01069   //
01070   fplotFile_c->cd(4);
01071   gPad->SetLogz(0);
01072   fResponseFD_LG4_p->SetXTitle("X_{referece LG}(4)");
01073   fResponseFD_LG4_p->SetYTitle("<MEAN FD [PE]>");
01074   fResponseFD_LG4_p->Draw();
01075   //
01076   fplotFile_c->cd(5);
01077   gPad->SetLogz(0);
01078   fResponseFD_LG5_p->SetXTitle("X_{referece LG}(5)");
01079   fResponseFD_LG5_p->SetYTitle("<MEAN FD [PE]>");
01080   fResponseFD_LG5_p->Draw();
01081   //
01082   fplotFile_c->cd(6);
01083   gPad->SetLogz(0);
01084   fResponseFD_LG6_p->SetXTitle("X_{referece LG}(6)");
01085   fResponseFD_LG6_p->SetYTitle("<MEAN FD [PE]>");
01086   fResponseFD_LG6_p->Draw();
01087 
01088   fplotFile_c->cd();
01089   fplotFile_c->Update();
01090   fplotFile_c->Print(fFileNameOut.c_str());
01091   plotCounter++;
01092   fplotFile_c->Clear();
01093 
01094 
01095 
01096 
01097   //ND & HG:
01098   fplotFile_c->cd();
01099   fplotFile_c->Divide(2,3);
01100   //
01101   fplotFile_c->cd(1);
01102   gPad->SetLogz(0);
01103   fResponseND_HG1_p->SetXTitle("X_{referece HG}(1)");
01104   fResponseND_HG1_p->SetYTitle("<MEAN ND [PE]>");
01105   fResponseND_HG1_p->Draw();
01106   //
01107   fplotFile_c->cd(2);
01108   gPad->SetLogz(0);
01109   fResponseND_HG2_p->SetXTitle("X_{referece HG}(2)");
01110   fResponseND_HG2_p->SetYTitle("<MEAN ND [PE]>");
01111   fResponseND_HG2_p->Draw();
01112   //
01113   fplotFile_c->cd(3);
01114   gPad->SetLogz(0);
01115   fResponseND_HG3_p->SetXTitle("X_{referece HG}(3)");
01116   fResponseND_HG3_p->SetYTitle("<MEAN ND [PE]>");
01117   fResponseND_HG3_p->Draw();
01118   //
01119   fplotFile_c->cd(4);
01120   gPad->SetLogz(0);
01121   fResponseND_HG4_p->SetXTitle("X_{referece HG}(4)");
01122   fResponseND_HG4_p->SetYTitle("<MEAN ND [PE]>");
01123   fResponseND_HG4_p->Draw();
01124   //
01125   fplotFile_c->cd(5);
01126   gPad->SetLogz(0);
01127   fResponseND_HG5_p->SetXTitle("X_{referece HG}(5)");
01128   fResponseND_HG5_p->SetYTitle("<MEAN ND [PE]>");
01129   fResponseND_HG5_p->Draw();
01130   //
01131   fplotFile_c->cd(6);
01132   gPad->SetLogz(0);
01133   fResponseND_HG6_p->SetXTitle("X_{referece HG}(6)");
01134   fResponseND_HG6_p->SetYTitle("<MEAN ND [PE]>");
01135   fResponseND_HG6_p->Draw();
01136 
01137   fplotFile_c->cd();
01138   fplotFile_c->Update();
01139   fplotFile_c->Print(fFileNameOut.c_str());
01140   plotCounter++;
01141   fplotFile_c->Clear();
01142 
01143 
01144 
01145   //FD & HG:
01146   fplotFile_c->cd();
01147   fplotFile_c->Divide(2,3);
01148   //
01149   fplotFile_c->cd(1);
01150   gPad->SetLogz(0);
01151   fResponseFD_HG1_p->SetXTitle("X_{referece HG}(1)");
01152   fResponseFD_HG1_p->SetYTitle("<MEAN FD [PE]>");
01153   fResponseFD_HG1_p->Draw();
01154   //
01155   fplotFile_c->cd(2);
01156   gPad->SetLogz(0);
01157   fResponseFD_HG2_p->SetXTitle("X_{referece HG}(2)");
01158   fResponseFD_HG2_p->SetYTitle("<MEAN FD [PE]>");
01159   fResponseFD_HG2_p->Draw();
01160   //
01161   fplotFile_c->cd(3);
01162   gPad->SetLogz(0);
01163   fResponseFD_HG3_p->SetXTitle("X_{referece HG}(3)");
01164   fResponseFD_HG3_p->SetYTitle("<MEAN FD [PE]>");
01165   fResponseFD_HG3_p->Draw();
01166   //
01167   fplotFile_c->cd(4);
01168   gPad->SetLogz(0);
01169   fResponseFD_HG4_p->SetXTitle("X_{referece HG}(4)");
01170   fResponseFD_HG4_p->SetYTitle("<MEAN FD [PE]>");
01171   fResponseFD_HG4_p->Draw();
01172   //
01173   fplotFile_c->cd(5);
01174   gPad->SetLogz(0);
01175   fResponseFD_HG5_p->SetXTitle("X_{referece HG}(5)");
01176   fResponseFD_HG5_p->SetYTitle("<MEAN FD [PE]>");
01177   fResponseFD_HG5_p->Draw();
01178   //
01179   fplotFile_c->cd(6);
01180   gPad->SetLogz(0);
01181   fResponseFD_HG6_p->SetXTitle("X_{referece HG}(6)");
01182   fResponseFD_HG6_p->SetYTitle("<MEAN FD [PE]>");
01183   fResponseFD_HG6_p->Draw();
01184 
01185   fplotFile_c->cd();
01186   fplotFile_c->Update();
01187   fplotFile_c->Print(fFileNameOut.c_str());
01188   plotCounter++;
01189   fplotFile_c->Clear();
01190 
01191 
01192   //
01193   //Residuals:
01194   //
01195 
01196   //ND:
01197   fplotFile_c->cd();
01198   gPad->SetLogz(1);
01199   gPad->SetGrid();
01200   //fResidualND_h->SetMaximum(0.1);
01201   //fResidualND_h->SetStats(0);
01202   fResidualND_h->SetXTitle("Linearised Scale (PE)");
01203   fResidualND_h->SetYTitle("(NonLinear - Linear) / Linear [ND]");
01204   fResidualND_h->Draw("colz");
01205   fplotFile_c->Update();
01206   fplotFile_c->Print(fFileNameOut.c_str());
01207   plotCounter++;
01208   fplotFile_c->Clear();
01209 
01210 
01211 
01212   TF1* lin = new TF1("lin","[0]+[1]*x+[2]*x**2+[3]*x**3+[4]*x**4+[5]*x**5");
01213   //lin->FixParameter(0,0);
01214   lin->SetParameter(0,0);
01215   lin->SetParameter(1,0);
01216   lin->SetParameter(2,0);
01217   lin->SetParameter(3,0);
01218   lin->SetParameter(4,0);
01219   lin->SetParameter(5,0);
01220 
01221 
01222   TF1* lin2 = new TF1("lin2","[0]+[1]*x");
01223   lin2->SetParameter(0,0);
01224   lin2->SetParameter(1,0);
01225 
01226 
01227   //fResidualND300_p->Fit(lin,"Q","",0,300);
01228 
01229 
01230   fplotFile_c->cd();
01231   gPad->SetLogy(0);
01232   gPad->SetGrid();
01233   //fResidualND_p->SetStats(0);
01234   fResidualND_p->SetXTitle("Linearised Scale (PE)");
01235   fResidualND_p->SetYTitle("(NonLinear - Linear) / Linear [ND]");
01236   fResidualND_p->SetLineColor(4);
01237   fResidualND_p->SetMarkerColor(4);
01238   fResidualND_p->SetLineWidth(4);
01239   fResidualND_p->Draw();
01240   lin->Draw("same");
01241   fplotFile_c->Update();
01242   fplotFile_c->Print(fFileNameOut.c_str());
01243   fplotFile_c->Print("ND_nonLin-LI.C");
01244   plotCounter++;
01245   fplotFile_c->Clear();
01246 
01247 
01248   fplotFile_c->cd();
01249   gPad->SetLogy(0);
01250   gPad->SetGrid();
01251   //fResidualND300_p->SetStats(0);
01252   //fResidualND300_p->Fit(lin,"Q","",0,300);
01253   fResidualND300_p->SetXTitle("Linearised Scale (PE)");
01254   fResidualND300_p->SetYTitle("(NonLinear - Linear) / Linear [ND]");
01255   fResidualND300_p->SetLineColor(4);
01256   fResidualND300_p->SetMarkerColor(4);
01257   fResidualND300_p->SetLineWidth(4);
01258   fResidualND300_p->Draw();
01259   //lin1->Draw("same");
01260   //lin2->Draw("same");
01261   fplotFile_c->Update();
01262   fplotFile_c->Print(fFileNameOut.c_str());
01263   fplotFile_c->Print("ND300_nonLin-LI.C");
01264   plotCounter++;
01265   fplotFile_c->Clear();
01266 
01267 
01268   fplotFile_c->cd();
01269   gPad->SetLogy(0);
01270   gPad->SetGrid();
01271   //fResidualNDADC_p->SetStats(0);
01272   fResidualNDADC_p->Fit(lin2,"Q","",2500,25000);
01273   fResidualNDADC_p->Fit(lin,"Q","",0,5000);
01274   fResidualNDADC_p->SetXTitle("Linearised Scale (ADC)");
01275   fResidualNDADC_p->SetYTitle("(NonLinear - Linear) / Linear [ND]");
01276   fResidualNDADC_p->SetLineColor(4);
01277   fResidualNDADC_p->SetMarkerColor(4);
01278   fResidualNDADC_p->SetLineWidth(4);
01279   fResidualNDADC_p->Draw();
01280   lin->Draw("same");
01281   lin2->Draw("same");
01282   fplotFile_c->Update();
01283   fplotFile_c->Print(fFileNameOut.c_str());
01284   fplotFile_c->Print("NDADC_nonLin-LI.C");
01285   plotCounter++;
01286   fplotFile_c->Clear();
01287 
01288 
01289   delete lin;
01290   lin=0;
01291 
01292   //FD:
01293   fplotFile_c->cd();
01294   gPad->SetLogz(1);
01295   gPad->SetGrid();
01296   //fResidualFD_h->SetMaximum(0.1);
01297   fResidualFD_h->SetStats(0);
01298   fResidualFD_h->SetXTitle("Linearised Scale (PE)");
01299   fResidualFD_h->SetYTitle("(NonLinear - Linear) / Linear [FD]");
01300   fResidualFD_h->Draw("colz");
01301   fplotFile_c->Update();
01302   fplotFile_c->Print(fFileNameOut.c_str());
01303   plotCounter++;
01304   fplotFile_c->Clear();
01305 
01306 
01307   //FD M16 parametrisation (Mike's)
01308   TF1* g = new TF1("f","(5e-2-1.4e-3*x+5.6e-6*x*x-7.5e-9*x*x*x)",0,300);
01309   g->SetLineColor(6);
01310 
01311 
01312 
01313   if(!lin) lin = new TF1("lin","[0]+[1]*x+[2]*x**2+[3]*x**3+[4]*x**4+[5]*x**5");
01314   lin->FixParameter(0,0);
01315   lin->SetParameter(1,0);
01316   lin->SetParameter(2,0);
01317   lin->SetParameter(3,0);
01318   lin->SetParameter(4,0);
01319   lin->SetParameter(5,0);
01320 
01321 
01322   fplotFile_c->cd();
01323   gPad->SetLogy(0);
01324   gPad->SetGrid();
01325   //fResidualFD_p->SetStats(0);
01326   //fResidualFD_h->SetMinimum(-0.12);
01327   //fResidualFD_p->Fit(lin,"Q","",0,300);
01328   fResidualFD_p->SetXTitle("Linearised Scale (PE)");
01329   fResidualFD_p->SetYTitle("(NonLinear - Linear) / Linear [FD]");
01330   fResidualFD_p->SetLineColor(4);
01331   fResidualFD_p->SetMarkerColor(4);
01332   fResidualFD_p->SetLineWidth(4);
01333   fResidualFD_p->Draw();
01334   //g->Draw("same");
01335   fplotFile_c->Update();
01336   fplotFile_c->Print(fFileNameOut.c_str());
01337   fplotFile_c->Print("FD_nonLin-LI.C");
01338   plotCounter++;
01339   fplotFile_c->Clear();
01340 
01341 
01342 
01343   fplotFile_c->cd();
01344   gPad->SetLogy(0);
01345   gPad->SetGrid();
01346   //fResidualFD300_p->SetStats(0);
01347   //fResidualFD300_h->SetMinimum(-0.12);
01348   //fResidualFD300_p->Fit(lin,"Q","",0,300);
01349   fResidualFD300_p->SetXTitle("Linearised Scale (PE)");
01350   fResidualFD300_p->SetYTitle("(NonLinear - Linear) / Linear [FD]");
01351   fResidualFD300_p->SetLineColor(4);
01352   fResidualFD300_p->SetMarkerColor(4);
01353   fResidualFD300_p->SetLineWidth(4);
01354   fResidualFD300_p->Draw();
01355   //g->Draw("same");
01356   fplotFile_c->Update();
01357   fplotFile_c->Print(fFileNameOut.c_str());
01358   fplotFile_c->Print("FD300_nonLin-LI.C");
01359   plotCounter++;
01360   fplotFile_c->Clear();
01361 
01362 
01363 
01364   fplotFile_c->cd();
01365   gPad->SetLogy(0);
01366   gPad->SetGrid();
01367   //fResidualFDADC_p->SetStats(0);
01368   //fResidualFDADC_h->SetMinimum(-0.12);
01369   fResidualFDADC_p->Fit(lin,"Q","",0,15000);
01370   fResidualFDADC_p->SetXTitle("Linearised Scale (ADC)");
01371   fResidualFDADC_p->SetYTitle("(NonLinear - Linear) / Linear [FD]");
01372   fResidualFDADC_p->SetLineColor(4);
01373   fResidualFDADC_p->SetMarkerColor(4);
01374   fResidualFDADC_p->SetLineWidth(4);
01375   fResidualFDADC_p->Draw();
01376   //g->Draw("same");
01377   fplotFile_c->Update();
01378   fplotFile_c->Print(fFileNameOut.c_str());
01379   fplotFile_c->Print("FDADC_nonLin-LI.C");
01380   plotCounter++;
01381   fplotFile_c->Clear();
01382 
01383 
01384 
01385   delete lin;
01386   lin = 0;
01387 
01388   //
01389   //
01390   //PMT non linearity: M16
01391   //
01392   //
01393 
01394 
01395   //FD:
01396   fplotFile_c->cd();
01397   gPad->SetLogz(1);
01398   gPad->SetGrid();
01399   fResidualFDPMT_h->SetStats(0);
01400   fResidualFDPMT_h->SetXTitle("Linearised Scale (PE)");
01401   fResidualFDPMT_h->SetYTitle("(NonLinear - Linear) / Linear [FD]");
01402   //fResidualFDPMT_h->SetMinimum(-0.15);
01403   fResidualFDPMT_h->Draw("colz");
01404   fplotFile_c->Update();
01405   fplotFile_c->Print(fFileNameOut.c_str());
01406   plotCounter++;
01407   fplotFile_c->Clear();
01408 
01409 
01410   //
01411   //FD M16 parametrisation (Mike's)
01412   //TF1* g = new TF1("f","(5e-2-1.4e-3*x+5.6e-6*x*x-7.5e-9*x*x*x)",0,300);
01413   //g->SetLineColor(6);
01414 
01415 
01416 
01417   if(!lin) lin = new TF1("lin","[0]+[1]*x"); //+[2]*x**2+[3]*x**3+[4]*x**4+[5]*x**5");
01418   //lin->FixParameter(0,0);
01419   lin->SetParameter(0,0);
01420   lin->SetParameter(1,0);
01421   //lin->SetParameter(2,0);
01422   //lin->SetParameter(3,0);
01423   //lin->SetParameter(4,0);
01424   //lin->SetParameter(5,0);
01425 
01426 
01427   fplotFile_c->cd();
01428   gPad->SetLogy(0);
01429   gPad->SetGrid();
01430   //fResidualFDPMT_p->SetStats(0);
01431   //fResidualFDPMT_p->Fit(lin,"Q","",55,200);
01432   fResidualFDPMT_p->SetXTitle("Linearised Scale (PE)");
01433   fResidualFDPMT_p->SetYTitle("(NonLinear - Linear) / Linear [FD]");
01434   fResidualFDPMT_p->SetLineColor(4);
01435   fResidualFDPMT_p->SetMarkerColor(4);
01436   fResidualFDPMT_p->SetLineWidth(4);
01437   fResidualFDPMT_p->Draw();
01438   //g->Draw("same");
01439   fplotFile_c->Update();
01440   fplotFile_c->Print(fFileNameOut.c_str());
01441   fplotFile_c->Print("M16_nonLin-LI.C");
01442   plotCounter++;
01443   fplotFile_c->Clear();
01444 
01445 
01446 
01447   fplotFile_c->cd();
01448   gPad->SetLogy(0);
01449   gPad->SetGrid();
01450   //fResidualFD300PMT_p->SetStats(0);
01451   //fResidualFD300PMT_p->Fit(lin,"Q","",55,200);
01452   fResidualFD300PMT_p->SetXTitle("Linearised Scale (PE)");
01453   fResidualFD300PMT_p->SetYTitle("(NonLinear - Linear) / Linear [FD]");
01454   fResidualFD300PMT_p->SetLineColor(4);
01455   fResidualFD300PMT_p->SetMarkerColor(4);
01456   fResidualFD300PMT_p->SetLineWidth(4);
01457   fResidualFD300PMT_p->Draw();
01458   //g->Draw("same");
01459   fplotFile_c->Update();
01460   fplotFile_c->Print(fFileNameOut.c_str());
01461   fplotFile_c->Print("M16-300_nonLin-LI.C");
01462   plotCounter++;
01463   fplotFile_c->Clear();
01464 
01465 
01466   fplotFile_c->cd();
01467   gPad->SetLogy(0);
01468   gPad->SetGrid();
01469   //fResidualFDADCPMT_p->SetStats(0);
01470   fResidualFDADCPMT_p->Fit(lin,"Q","",3600,13000);
01471   fResidualFDADCPMT_p->SetXTitle("Linearised Scale (ADC)");
01472   fResidualFDADCPMT_p->SetYTitle("(NonLinear - Linear) / Linear [FD]");
01473   fResidualFDADCPMT_p->SetLineColor(4);
01474   fResidualFDADCPMT_p->SetMarkerColor(4);
01475   fResidualFDADCPMT_p->SetLineWidth(4);
01476   fResidualFDADCPMT_p->Draw();
01477   //g->Draw("same");
01478   fplotFile_c->Update();
01479   fplotFile_c->Print(fFileNameOut.c_str());
01480   fplotFile_c->Print("M16-ADC_nonLin-LI.C");
01481   plotCounter++;
01482   fplotFile_c->Clear();
01483 
01484 
01485 
01486   delete lin;
01487   lin = 0;
01488 
01489 
01490   //
01491   //Both in the same plot:
01492   //
01493 
01494 
01495   fplotFile_c->cd();
01496   gPad->SetLogy(0);
01497   gPad->SetGrid();
01498   fResidualND300_p->SetStats(0);
01499   fResidualFD300PMT_p->SetStats(0);
01500   fResidualND300_p->Draw();
01501   fResidualFD300PMT_p->Draw("same");
01502   fplotFile_c->Update();
01503   fplotFile_c->Print(fFileNameOut.c_str());
01504   fplotFile_c->Print("PMT-300_nonLin-LI.C");
01505   plotCounter++;
01506   fplotFile_c->Clear();
01507 
01508 
01509 
01510   fplotFile_c->cd();
01511   gPad->SetLogy(0);
01512   gPad->SetGrid();
01513   fResidualND300_p->SetStats(0);
01514   fResidualFD300_p->SetStats(0);
01515   fResidualND300_p->Draw();
01516   fResidualFD300_p->Draw("same");
01517   fplotFile_c->Update();
01518   fplotFile_c->Print(fFileNameOut.c_str());
01519   plotCounter++;
01520   fplotFile_c->Clear();
01521 
01522 
01523 
01524 
01525   //
01526   //Difference between ND and FD:
01527   //
01528 
01529   if(!lin) lin = new TF1("lin","[0]+[1]*x+[2]*x**2+[3]*x**3+[4]*x**4+[5]*x**5");
01530   lin->SetParameter(0,0);
01531   lin->SetParameter(1,0);
01532   lin->SetParameter(2,0);
01533   lin->SetParameter(3,0);
01534   lin->SetParameter(4,0);
01535   lin->SetParameter(5,0);
01536 
01537 
01538   fplotFile_c->cd();
01539   gPad->SetLogy(0);
01540   gPad->SetGrid();
01541   fResidualN_F_p->SetXTitle("Linearised Scale (PE)");
01542   fResidualN_F_p->SetYTitle("<ND - FD>");
01543   fResidualN_F_p->SetAxisRange(0,150,"X");
01544   fResidualN_F_p->Fit(lin,"Q","",0,150);
01545   fResidualN_F_p->Draw();
01546   fplotFile_c->Update();
01547   fplotFile_c->Print(fFileNameOut.c_str());
01548   fplotFile_c->Print("RelNonLin-LI.C");
01549   plotCounter++;
01550   fplotFile_c->Clear();
01551   //TF1* g = new TF1("f","-4.*(-3.63e-4*x*4+1.67e-5*pow(x*4,2)-2.27e-7*pow(x*4,3)+1.30e-9*pow(x*4,4)-3.02e-12*pow(x*4,5))",0,200);
01552 
01553 
01554 
01555   fplotFile_c->cd();
01556   gPad->SetLogy(0);
01557   gPad->SetGrid();
01558   fResVsGainFD_p->SetXTitle("Gain (PE/ADC)");
01559   //fResVsGainND_p->SetXTitle("");
01560   fResVsGainFD_p->SetYTitle("(NonLinear - Linear) / Linear [@ 150PE]");
01561   fResVsGainFD_p->SetMinimum(-0.1);
01562   fResVsGainFD_p->SetLineColor(2);
01563   fResVsGainND_p->SetLineColor(4);
01564   fResVsGainFD_p->SetMarkerColor(2);
01565   fResVsGainND_p->SetMarkerColor(4);
01566   fResVsGainFD_p->Draw();
01567   fResVsGainND_p->Draw("same");
01568   fplotFile_c->Update();
01569   fplotFile_c->Print(fFileNameOut.c_str());
01570   plotCounter++;
01571   fplotFile_c->Clear();
01572 
01573 
01574 
01575 
01576   //
01577   //Slopes & Intercepts:
01578   //
01579 
01580 
01581   //ND & HG:
01582   fplotFile_c->cd();
01583   gPad->SetLogy(0);
01584   fSlopeND_HG_h->SetXTitle("Response Slope ND");
01585   fSlopeND_HG_h->Draw();
01586   fplotFile_c->Update();
01587   fplotFile_c->Print(fFileNameOut.c_str());
01588   plotCounter++;
01589   fplotFile_c->Clear();
01590 
01591   fplotFile_c->cd();
01592   gPad->SetLogy(0);
01593   fInterceptND_HG_h->SetXTitle("Response Intercept ND");
01594   fInterceptND_HG_h->Draw();
01595   fplotFile_c->Update();
01596   fplotFile_c->Print(fFileNameOut.c_str());
01597   plotCounter++;
01598   fplotFile_c->Clear();
01599 
01600 
01601   //ND & LG:
01602   fplotFile_c->cd();
01603   gPad->SetLogy(0);
01604   fSlopeND_LG_h->SetXTitle("Response Slope ND");
01605   fSlopeND_LG_h->Draw();
01606   fplotFile_c->Update();
01607   fplotFile_c->Print(fFileNameOut.c_str());
01608   plotCounter++;
01609   fplotFile_c->Clear();
01610 
01611   fplotFile_c->cd();
01612   gPad->SetLogy(0);
01613   fInterceptND_LG_h->SetXTitle("Response Intercept ND");
01614   fInterceptND_LG_h->Draw();
01615   fplotFile_c->Update();
01616   fplotFile_c->Print(fFileNameOut.c_str());
01617   plotCounter++;
01618   fplotFile_c->Clear();
01619 
01620 
01621   //FD & HG:
01622   fplotFile_c->cd();
01623   gPad->SetLogy(0);
01624   fSlopeFD_HG_h->SetXTitle("Response Slope FD");
01625   fSlopeFD_HG_h->Draw();
01626   fplotFile_c->Update();
01627   fplotFile_c->Print(fFileNameOut.c_str());
01628   plotCounter++;
01629   fplotFile_c->Clear();
01630 
01631   fplotFile_c->cd();
01632   gPad->SetLogy(0);
01633   fInterceptFD_HG_h->SetXTitle("Response Intercept FD");
01634   fInterceptFD_HG_h->Draw();
01635   fplotFile_c->Update();
01636   fplotFile_c->Print(fFileNameOut.c_str());
01637   plotCounter++;
01638   fplotFile_c->Clear();
01639 
01640 
01641   //FD & LG:
01642   fplotFile_c->cd();
01643   gPad->SetLogy(0);
01644   fSlopeFD_LG_h->SetXTitle("Response Slope FD");
01645   fSlopeFD_LG_h->Draw();
01646   fplotFile_c->Update();
01647   //fplotFile_c->Print(fFileNameOut.c_str());
01648   plotCounter++;
01649   fplotFile_c->Clear();
01650 
01651   fplotFile_c->cd();
01652   gPad->SetLogy(0);
01653   fInterceptFD_LG_h->SetXTitle("Response Intercept FD");
01654   fInterceptFD_LG_h->Draw();
01655   fplotFile_c->Update();
01656   fplotFile_c->Print(fFileOutEnd.c_str());
01657   //fplotFile_c->Print(fFileNameOut.c_str());
01658   plotCounter++;
01659   fplotFile_c->Clear();
01660 
01661 
01662   //Close the Booklet:
01663   fplotFile_c->cd();
01664   fplotFile_c->Clear();
01665   fplotFile_c->Update();
01666   //fplotFile_c->Print(fFileOutEnd.c_str());
01667 
01668   delete fplotFile_c;
01669  
01670   return; 
01671 }
01672 
01673 //-------------------------------------------------
01674 
01675 //EOF

Generated on Mon Feb 15 11:06:51 2010 for loon by  doxygen 1.3.9.1