ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/andersj/HcalPlotter/scripts/PlotAllDisplay.C
Revision: 1.1
Committed: Wed Jul 20 11:34:58 2011 UTC (13 years, 9 months ago) by andersj
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Log Message:
inital version

File Contents

# User Rev Content
1 andersj 1.1 #include "HcalVisualSelector.h"
2     #include "HcalElectronicsSelector.h"//k*^
3     #include "PlotAllDisplay.h"
4    
5     class PlotAllAdapter : public HcalVisualSelector::Callbacks {
6     public:
7     PlotAllAdapter(PlotAllDisplay* disp, int evtType, int flavType) :
8     m_disp(disp), m_evtType(evtType), m_flavType(flavType){
9     }
10     virtual void plot(const MyHcalDetId& id) {
11     m_disp->displayOne(id,m_evtType,m_flavType);
12     }
13     virtual MyHcalSubdetector getSubdet(int ieta, int depth) {
14     return m_disp->getSubDetector(ieta,depth);
15     }
16     private:
17     PlotAllDisplay* m_disp;
18     int m_evtType, m_flavType;
19     };
20    
21    
22     class PlotAllElecAdapter : public HcalElectronicsSelector::Callbacks {
23     public:
24     PlotAllElecAdapter(PlotAllDisplay* disp, int evtType, int flavType) :
25     m_disp(disp), m_evtType(evtType), m_flavType(flavType){
26     }
27     virtual void plot(const MyElectronicsId& id) {
28     m_disp->displayElecOne(id,m_evtType,m_flavType);
29     }
30    
31     private:
32     PlotAllDisplay* m_disp;
33     int m_evtType, m_flavType;
34     };
35    
36     //===========================================================================
37    
38     std::vector<MyHcalDetId>
39     PlotAllDisplay::spatialFilter(int ieta,
40     int iphi,
41     const std::vector<MyHcalDetId>& inputs)
42     {
43     std::vector<MyHcalDetId> retval;
44     std::vector<MyHcalDetId>::const_iterator ii;
45     for (ii=inputs.begin(); ii!=inputs.end(); ii++) {
46     if (iphi!=0 && ii->iphi!=iphi) continue;
47     if (ieta!=0 && ii->ieta!=ieta) continue;
48     retval.push_back(*ii);
49     }
50     return retval;
51     }
52    
53     //===========================================================================
54    
55     TH1* PlotAllDisplay::bookMasterHistogram(DisplaySetupStruct& ss,
56     const std::string& basename, int lo,
57     int hi)
58     {
59     char name[120];
60     TH1* retval=0;
61     if (ss.iphi!=0) {
62     sprintf(name,"%s:%s-%s IPHI=%d",
63     ss.eventTypeStr.c_str(),ss.flavTypeStr.c_str(),
64     basename.c_str(),ss.iphi);
65     retval=new TH1F(name,name, hi-lo+1, lo-0.5, hi+0.5);
66     retval->GetXaxis()->SetTitle("IETA");
67     } else {
68     sprintf(name,"%s:%s-%s IETA=%d",
69     ss.eventTypeStr.c_str(),ss.flavTypeStr.c_str(),
70     basename.c_str(),ss.ieta);
71     retval=new TH1F(name,name, hi-lo+1, lo-0.5, hi+0.5);
72     retval->GetXaxis()->SetTitle("IPHI");
73     }
74     retval->SetDirectory(0);
75     retval->SetStats(0);
76     return retval;
77     }
78    
79     //===========================================================================
80    
81     MyHcalSubdetector PlotAllDisplay::getSubDetector(int ieta, int depth)
82     {
83     MyHcalSubdetector retval=HcalEmpty;
84     int aieta = abs(ieta);
85    
86     if(aieta<=16 && depth<=2) retval=HcalBarrel;
87     if(aieta<=15 && depth==4) retval=HcalOuter;
88     if( (aieta==16&&depth==3)||(aieta>16&&aieta<29) ) retval=HcalEndcap;
89     if(aieta>28) retval=HcalForward;
90    
91     // NOTE: based on above, HE29 is not plottable!
92    
93     if(retval==HcalEmpty) printf("Bad detector coordinates!\n");
94    
95     return retval;
96     }
97    
98     //===========================================================================
99    
100     void PlotAllDisplay::displaySummary(int ieta, int iphi,
101     int evtType, int flavType)
102     {
103     HistoManager::EventType et=(HistoManager::EventType)evtType;
104     HistoManager::HistType ht=(HistoManager::HistType)flavType;
105     DisplaySetupStruct setup;
106     setup.ieta=ieta;
107     setup.iphi=iphi;
108     setup.eventTypeStr=HistoManager::nameForEvent(et);
109     setup.flavTypeStr=HistoManager::nameForFlavor(ht);
110    
111     std::vector<MyHcalDetId> KeyIds = histKeys.getDetIdsForType(ht,et);
112     std::vector<MyHcalDetId> ids = spatialFilter(ieta,iphi,KeyIds);
113    
114     if (ids.size()==0) {
115     printf("The iphi or ieta value entered was not found!\n");
116     printf("Make sure the correct event type is selected and the correct ieta/iphi values are entered.\n");
117     return;
118     }
119    
120     std::vector<MyHcalDetId>::const_iterator ii;
121    
122     std::cout << "Summing channels" << std::flush;
123    
124     // Sum of all channels
125     TH1* sum=0;
126     for (ii=ids.begin(); ii!=ids.end(); ii++) {
127     std::cout << '.' << std::flush;
128     TH1* h=histKeys.GetAHistogram(*ii,ht,et);
129     if (h==0) continue;
130     if (sum==0) {
131     sum=(TH1*)h->Clone("All");
132     sum->SetDirectory(0);
133     char name[120];
134     sprintf(name,"All %s:%s",
135     setup.eventTypeStr.c_str(),setup.flavTypeStr.c_str());
136     sum->SetTitle(name);
137     } else sum->Add(h);
138     }
139    
140     TCanvas* c=new TCanvas("All","All",60,60,800,600);
141     c->cd();
142     sum->Draw();
143     sum->Draw("SAMEHIST");
144    
145     std::cout << "done." << std::endl;
146    
147     if (ht==HistoManager::PULSE) return;
148    
149     // profile of an ieta or iphi
150    
151     if (iphi!=0 || ieta!=0) {
152     TH1* meanSummary[5];
153     TH1* RMSSummary[5];
154    
155     std::cout << "Compiling eta/phi profiles";
156    
157     int range_lo=100000, range_hi=-100000;
158     for(ii=ids.begin(); ii!=ids.end(); ii++) {
159     int ibin=(iphi!=0)?(ii->ieta):(ii->iphi);
160     if (ibin>range_hi) range_hi=ibin;
161     if (ibin<range_lo) range_lo=ibin;
162     }
163    
164     meanSummary[0]=bookMasterHistogram(setup,"MEAN",range_lo,range_hi);
165     RMSSummary[0]=bookMasterHistogram(setup,"RMS",range_lo,range_hi);
166     for (int j=1; j<5; j++) {
167     std::cout << '.' << std::flush;
168     int marker=j+23;
169     if (j==4) marker=30;
170    
171     char aname[120];
172     sprintf(aname,"Mean_Depth%d",j);
173     meanSummary[j]=new TH1F(aname,aname,(range_hi-range_lo)+1,
174     range_lo-0.5,range_hi+0.5);
175     meanSummary[j]->SetDirectory(0);
176     meanSummary[j]->SetMarkerStyle(marker);
177     meanSummary[j]->SetMarkerColor(j);
178    
179     sprintf(aname,"RMS_Depth%d",j);
180     RMSSummary[j]=new TH1F(aname,aname,(range_hi-range_lo)+1,
181     range_lo-0.5,range_hi+0.5);
182     RMSSummary[j]->SetDirectory(0);
183     RMSSummary[j]->SetMarkerStyle(marker);
184     RMSSummary[j]->SetMarkerColor(j);
185     }
186    
187     for(ii=ids.begin(); ii!=ids.end(); ii++) {
188     std::cout << '.' << std::flush;
189     TH1* h=histKeys.GetAHistogram(*ii,ht,et);
190     if (h==0) continue;
191     double bin=(iphi!=0)?(ii->ieta*1.0):(ii->iphi*1.0);
192     meanSummary[ii->depth]->Fill(bin, h->GetMean());
193     RMSSummary[ii->depth]->Fill(bin, h->GetRMS());
194     }
195    
196     double ml=1e16,mh=-1e16;
197     for (int j=1; j<5; j++) {
198     std::cout << '.' << std::flush;
199     for (int jj=1; jj<=meanSummary[j]->GetNbinsX(); jj++)
200     if (meanSummary[j]->GetBinError(jj)==0.0)
201     meanSummary[j]->SetBinContent(jj,-1e6);
202     else {
203     if (meanSummary[j]->GetBinContent(jj)<ml)
204     ml=meanSummary[j]->GetBinContent(jj);
205     if (meanSummary[j]->GetBinContent(jj)>mh)
206     mh=meanSummary[j]->GetBinContent(jj);
207     }
208     }
209     meanSummary[0]->SetMaximum(mh+(mh-ml)*0.05);
210     meanSummary[0]->SetMinimum(ml-(mh-ml)*0.05);
211    
212     ml=1e16,mh=-1e16;
213     for (int j=1; j<5; j++) {
214     std::cout << '.' << std::flush;
215     for (int jj=1; jj<=RMSSummary[j]->GetNbinsX(); jj++)
216     if (RMSSummary[j]->GetBinError(jj)==0.0)
217     RMSSummary[j]->SetBinContent(jj,-1e6);
218     else {
219     if (RMSSummary[j]->GetBinContent(jj)<ml)
220     ml=RMSSummary[j]->GetBinContent(jj);
221     if (RMSSummary[j]->GetBinContent(jj)>mh)
222     mh=RMSSummary[j]->GetBinContent(jj);
223     }
224     }
225     RMSSummary[0]->SetMaximum(mh+(mh-ml)*0.05);
226     RMSSummary[0]->SetMinimum(ml-(mh-ml)*0.05);
227    
228    
229     TCanvas* myplot=new TCanvas(setup.eventTypeStr.c_str(),
230     setup.eventTypeStr.c_str(),
231     20,20,800,600);
232     myplot->Divide(1,2);
233    
234     myplot->cd(1);
235     meanSummary[0]->Draw("P");
236     for (int j=1; j<5; j++)
237     meanSummary[j]->Draw("SAMEP");
238     myplot->cd(2);
239     RMSSummary[0]->Draw("P");
240     for (int j=1; j<5; j++)
241     RMSSummary[j]->Draw("SAMEP");
242    
243     std::cout << "done." << std::endl;
244     }
245    
246     // global distributions
247    
248     {
249     std::cout << "Compiling global distributions" << std::flush;
250    
251     double mean_lo=1e160, mean_hi=-1e160;
252     double RMS_lo=1e160, RMS_hi=-1e160;
253     for (ii=ids.begin(); ii!=ids.end(); ii++) {
254     std::cout << '.' << std::flush;
255     TH1* h=histKeys.GetAHistogram(*ii,ht,et);
256     if (h==0) continue;
257     double mean=h->GetMean();
258     double RMS=h->GetRMS();
259     if (mean<mean_lo) mean_lo=mean;
260     if (mean>mean_hi) mean_hi=mean;
261     if (RMS<RMS_lo) RMS_lo=RMS;
262     if (RMS>RMS_hi) RMS_hi=RMS;
263     }
264    
265     //adjust range to include endpoints
266     mean_lo = mean_lo - 0.05*(mean_hi-mean_lo);
267     mean_hi = mean_hi + 0.05*(mean_hi-mean_lo);
268     RMS_lo = RMS_lo - 0.05*(RMS_hi-RMS_lo);
269     RMS_hi = RMS_hi + 0.05*(RMS_hi-RMS_lo);
270    
271     TH1* means=new TH1F("MEANS","MEANS",50,mean_lo,mean_hi);
272     means->SetDirectory(0);
273    
274     TH1* RMSs=new TH1F("RMSs","RMSs",50,RMS_lo,RMS_hi);
275     RMSs->SetDirectory(0);
276    
277     for (ii=ids.begin(); ii!=ids.end(); ii++) {
278     std::cout << '.' << std::flush;
279     TH1* h=histKeys.GetAHistogram(*ii,ht,et);
280     if (h==0) continue;
281     means->Fill(h->GetMean());
282     RMSs->Fill(h->GetRMS());
283     }
284    
285     TCanvas * myplot = new TCanvas("Statistics","Statistics",
286     40,40,800,600);
287    
288     myplot->Divide(1,2);
289    
290     myplot->cd(1);
291     means->Draw();
292     myplot->cd(2);
293     RMSs->Draw();
294    
295     std::cout << "done." << std::endl;
296     }
297     }
298    
299     //===========================================================================
300    
301     void PlotAllDisplay::displayOne(int ieta, int iphi, int depth,
302     int evtType, int flavType)
303     {
304     MyHcalSubdetector subDet = getSubDetector(ieta,depth);
305    
306     if (subDet != HcalEmpty) {
307     MyHcalDetId id = {subDet,ieta,iphi,depth};
308     displayOne(id,evtType,flavType);
309     }
310     }
311    
312     //===========================================================================
313    
314     void PlotAllDisplay::displayOne(const MyHcalDetId& id,
315     int evtType, int flavType)
316     {
317     HistoManager::EventType et=(HistoManager::EventType)evtType;
318     HistoManager::HistType ht=(HistoManager::HistType)flavType;
319    
320     TH1* h=histKeys.GetAHistogram(id,ht,et);
321    
322     if (h==0) {
323     printf("The ieta and/or iphi values were not found!\n");
324     printf("Make sure the correct event type is selected and the correct iphi/ieta values are entered.\n");
325     return;
326     }
327    
328     if (m_movie==0) {
329     m_movie=new TCanvas("Selected","Selected",50,50,800,600);
330     m_movie->Divide(3,2);
331     }
332    
333     n_movie=(n_movie%6)+1;
334     m_movie->cd(n_movie);
335    
336     if (ht==HistoManager::PULSE)
337     h->Draw("HIST");
338     else
339     h->Draw();
340     m_movie->Flush();
341     m_movie->Update();
342     m_movie->Paint();
343     }
344    
345     //===========================================================================
346    
347     void PlotAllDisplay::displaySelector(int evtType, int flavType,
348     int plotStatType)
349     {
350     HistoManager::EventType et=(HistoManager::EventType)evtType;
351     HistoManager::HistType ht=(HistoManager::HistType)flavType;
352    
353     std::vector<MyHcalDetId> KeyIds = histKeys.getDetIdsForType(ht,et);
354    
355     if (KeyIds.empty()) {
356     printf("No histograms found for specified event type and flavor type\n");
357     return;
358     }
359    
360     int ieta_lo=10000;
361     int ieta_hi=-10000;
362     int iphi_lo=10000;
363     int iphi_hi=-10000;
364     for(std::vector<MyHcalDetId>::iterator jj=KeyIds.begin();
365     jj!=KeyIds.end();
366     jj++) {
367     if( jj->ieta>ieta_hi ) ieta_hi=jj->ieta;
368     if( jj->ieta<ieta_lo ) ieta_lo=jj->ieta;
369     if( jj->iphi>iphi_hi ) iphi_hi=jj->iphi;
370     if( jj->iphi<iphi_lo ) iphi_lo=jj->iphi;
371     }
372    
373     // printf("eta_lo=%d eta_hi=%d phi_lo=%d phi_hi=%d\n",
374     // ieta_lo,ieta_hi,iphi_lo,iphi_hi);
375    
376     HcalVisualSelector* vs=
377     new HcalVisualSelector(new PlotAllAdapter(this,evtType,flavType),
378     ieta_lo,ieta_hi,iphi_lo,iphi_hi);
379    
380     for (std::vector<MyHcalDetId>::iterator ii=KeyIds.begin();
381     ii!=KeyIds.end();
382     ii++) {
383     TH1* h=histKeys.GetAHistogram(*ii,ht,et);
384     if (h==0) {
385     printf("ieta=%d, iphi=%d not found\n", ii->ieta, ii->iphi);
386     continue;
387     }
388     if (!plotStatType)
389     vs->fill(*ii,h->GetMean());
390     else
391     vs->fill(*ii,h->GetRMS());
392     }
393    
394     vs->Update();
395     }
396    
397    
398    
399     std::vector<MyElectronicsId> PlotAllDisplay::electronicsFilter(int fiber,int fiberChan,int crate,int Slot,int tb,
400     const std::vector<MyElectronicsId>& inputs)
401     {
402     std::vector<MyElectronicsId> retval;
403     std::vector<MyElectronicsId>::const_iterator ii;
404     for (ii=inputs.begin(); ii!=inputs.end(); ii++) {
405     if ((fiber!=-1 && ii->fiber!=fiber)&&(fiberChan!=-1 && ii->fiberChan!=fiberChan)) continue;
406     if (crate!=-1 && ii->crate!=crate) continue;
407     if (Slot!=-1 && ii->Slot!=Slot) continue;
408     if(tb!=-1 && ii->tb!=tb) continue;
409     retval.push_back(*ii);
410     }
411     return retval;
412     }
413    
414    
415     TH1* PlotAllDisplay::bookMasterHistogram(DisplayElecSetup& ss,
416     const std::string& basename, int lo,
417     int hi)
418     {
419     char name[120];
420     TH1* retval=0;
421     char bt = (ss.tb==1)?('t'):('b');
422    
423     sprintf(name,"%s:%s-%s Crate=%d FPGA=%d%c",
424     ss.eventTypeStr.c_str(),ss.flavTypeStr.c_str(),basename.c_str(),ss.crate,ss.Slot,bt);
425     retval=new TH1F(name,name, hi-lo+1, lo-0.5, hi+0.5);
426     retval->GetXaxis()->SetTitle("HTR Channel");
427    
428     retval->SetDirectory(0);
429     retval->SetStats(0);
430     return retval;
431     }
432    
433    
434     void PlotAllDisplay::displayElecSummary(int crate,int Slot,int tb, int evtType, int flavType) {
435     HistoManager::EventType et=(HistoManager::EventType)evtType;
436     HistoManager::HistType ht=(HistoManager::HistType)flavType;
437     DisplayElecSetup setup;
438     setup.fiber=-1;
439     setup.fiberChan=-1;
440     setup.crate=crate;
441     setup.Slot=Slot;
442     setup.tb=tb;
443     setup.eventTypeStr=HistoManager::nameForEvent(et);
444     setup.flavTypeStr=HistoManager::nameForFlavor(ht);
445    
446     std::vector<MyElectronicsId> KeyIds = histKeys.getElecIdsForType(ht,et);
447     std::vector<MyElectronicsId> ids = electronicsFilter(-1,-1,crate,Slot,tb,KeyIds);
448    
449     if (ids.size()==0) {
450     printf("The fiber/fiber channel/crate/slot values were not found!\n");
451     printf("Make sure the correct event type is selected and the correct fiber/fiber channel/crate/slot values are entered.\n");
452     return;
453     } //else printf("I found %d histograms.\n",ids.size());
454    
455     std::vector<MyElectronicsId>::const_iterator ii;
456    
457     // Sum of all channels
458     TH1* sum=0;
459     for (ii=ids.begin(); ii!=ids.end(); ii++) {
460     TH1* h=histKeys.GetAHistogram(*ii,ht,et);
461     if (h==0) continue;
462     if (sum==0) {
463     sum=(TH1*)h->Clone("All");
464     sum->SetDirectory(0);
465     char name[120];
466     sprintf(name,"All %s:%s",setup.eventTypeStr.c_str(),setup.flavTypeStr.c_str());
467     sum->SetTitle(name);
468     } else sum->Add(h);
469     }
470    
471     TCanvas* c=new TCanvas("All","All",60,60,800,600);
472     c->cd();
473     sum->Draw();
474     sum->Draw("SAMEHIST");
475    
476     if (ht==HistoManager::PULSE) return;
477    
478    
479     TH1* meanSummary;
480     TH1* RMSSummary;
481    
482     int range_lo=100000, range_hi=-100000;
483     for(ii=ids.begin(); ii!=ids.end(); ii++) {
484     int ibin=(ii->fiber-1)*3+ii->fiberChan+1;
485     if (ibin>range_hi) range_hi=ibin;
486     if (ibin<range_lo) range_lo=ibin;
487    
488     }
489    
490     meanSummary=bookMasterHistogram(setup,"MEAN",range_lo,range_hi);
491     RMSSummary=bookMasterHistogram(setup,"RMS",range_lo,range_hi);
492    
493    
494     int marker=24;
495    
496     meanSummary->SetMarkerStyle(marker);
497     RMSSummary->SetMarkerStyle(marker);
498    
499    
500     for(ii=ids.begin(); ii!=ids.end(); ii++) {
501     TH1* h=histKeys.GetAHistogram(*ii,ht,et);
502     if (h==0) continue;
503     double bin=(ii->fiber-1)*3+ii->fiberChan+1;
504     meanSummary->Fill(bin, h->GetMean());
505     RMSSummary->Fill(bin, h->GetRMS());
506     // printf("%d %d %f %f %f \n",ii->fiber,ii->fiberChan,bin, h->GetMean(),h->GetRMS());
507     }
508    
509     double ml=1e16,mh=-1e16;
510    
511     for (int jj=1; jj<=meanSummary->GetNbinsX(); jj++)
512     if (meanSummary->GetBinError(jj)==0.0){
513     //meanSummary->SetBinContent(jj,-1e6);
514     } else {
515     if (meanSummary->GetBinContent(jj)<ml)
516     ml=meanSummary->GetBinContent(jj);
517     if (meanSummary->GetBinContent(jj)>mh)
518     mh=meanSummary->GetBinContent(jj);
519     }
520    
521     meanSummary->SetMaximum(mh+(mh-ml)*0.05);
522     meanSummary->SetMinimum(ml-(mh-ml)*0.05);
523    
524     ml=1e16,mh=-1e16;
525    
526     for (int jj=1; jj<=RMSSummary->GetNbinsX(); jj++)
527     if (RMSSummary->GetBinError(jj)==0.0){
528     // RMSSummary->SetBinContent(jj,-1e6);
529     } else {
530     if (RMSSummary->GetBinContent(jj)<ml)
531     ml=RMSSummary->GetBinContent(jj);
532     if (RMSSummary->GetBinContent(jj)>mh)
533     mh=RMSSummary->GetBinContent(jj);
534     }
535    
536     RMSSummary->SetMaximum(mh+(mh-ml)*0.05);
537     RMSSummary->SetMinimum(ml-(mh-ml)*0.05);
538    
539    
540     TCanvas* myplot=new TCanvas(setup.eventTypeStr.c_str(),
541     setup.eventTypeStr.c_str(),
542     20,20,800,600);
543     myplot->Divide(1,2);
544    
545     myplot->cd(1);
546     meanSummary->Draw("P");
547    
548     myplot->cd(2);
549     RMSSummary->Draw("P");
550    
551    
552     // global distributions
553    
554    
555     double mean_lo=1e160, mean_hi=-1e160;
556     double RMS_lo=1e160, RMS_hi=-1e160;
557     for (ii=ids.begin(); ii!=ids.end(); ii++) {
558     TH1* h=histKeys.GetAHistogram(*ii,ht,et);
559     if (h==0) continue;
560     double mean=h->GetMean();
561     double RMS=h->GetRMS();
562     if (mean<mean_lo) mean_lo=mean;
563     if (mean>mean_hi) mean_hi=mean;
564     if (RMS<RMS_lo) RMS_lo=RMS;
565     if (RMS>RMS_hi) RMS_hi=RMS;
566     }
567    
568     //adjust range to include endpoints
569     mean_lo = mean_lo - 0.05*(mean_hi-mean_lo);
570     mean_hi = mean_hi + 0.05*(mean_hi-mean_lo);
571     RMS_lo = RMS_lo - 0.05*(RMS_hi-RMS_lo);
572     RMS_hi = RMS_hi + 0.05*(RMS_hi-RMS_lo);
573    
574     TH1* means=new TH1F("MEANS","MEANS",50,mean_lo,mean_hi);
575     means->SetDirectory(0);
576    
577     TH1* RMSs=new TH1F("RMSs","RMSs",50,RMS_lo,RMS_hi);
578     RMSs->SetDirectory(0);
579    
580     for (ii=ids.begin(); ii!=ids.end(); ii++) {
581     TH1* h=histKeys.GetAHistogram(*ii,ht,et);
582     if (h==0) continue;
583     means->Fill(h->GetMean());
584     RMSs->Fill(h->GetRMS());
585     }
586    
587     TCanvas * myplot2 = new TCanvas("Statistics","Statistics",
588     40,40,800,600);
589    
590     myplot2->Divide(1,2);
591    
592     myplot2->cd(1);
593     means->Draw();
594     myplot2->cd(2);
595     RMSs->Draw();
596    
597     }
598    
599    
600     void PlotAllDisplay::displayElecOne(int fiber, int fiberChan, int crate,int Slot,int tb, int evtType, int flavType){
601    
602    
603     MyElectronicsId id = {fiber,fiberChan,crate,Slot,tb};
604     displayElecOne(id,evtType,flavType);
605    
606     }
607    
608     void PlotAllDisplay::displayElecOne(const MyElectronicsId& id,
609     int evtType, int flavType){
610    
611     HistoManager::EventType et=(HistoManager::EventType)evtType;
612     HistoManager::HistType ht=(HistoManager::HistType)flavType;
613    
614    
615    
616    
617     TH1* h=histKeys.GetAHistogram(id,ht,et);
618    
619     if (h==0) {
620     printf("The fiber/fiber channel/crate/slot values were not found!\n");
621     printf("Make sure the correct event type is selected and the correct fiber/fiber channel/crate/slot values are entered.\n");
622     return;
623     }
624    
625     if (m_movie==0) {
626     m_movie=new TCanvas("Selected","Selected",50,50,800,600);
627     m_movie->Divide(3,2);
628     }
629    
630     n_movie=(n_movie%6)+1;
631     m_movie->cd(n_movie);
632    
633     if (ht==HistoManager::PULSE)
634     h->Draw("HIST");
635     else
636     h->Draw();
637     m_movie->Flush();
638     m_movie->Update();
639     m_movie->Paint();
640     }
641    
642    
643     void PlotAllDisplay:: CrateDisplaySelector(int crate, int evtType, int flavType,int plotStatType)
644     {
645     HistoManager::EventType et=(HistoManager::EventType)evtType;
646     HistoManager::HistType ht=(HistoManager::HistType)flavType;
647    
648     std::vector<MyElectronicsId> FirstKeyIds = histKeys.getElecIdsForType(ht,et);
649     std::vector<MyElectronicsId> KeyIds;
650    
651     for(std::vector<MyElectronicsId>::iterator kk=FirstKeyIds.begin();kk!=FirstKeyIds.end();kk++){
652     if(kk->crate==crate){KeyIds.push_back(*kk);}
653     }
654    
655     if (KeyIds.empty()) {
656     printf("No histograms found for specified event type and flavor type\n");
657     return;
658     }
659     int htrChan=0;
660     int fpga=0;
661     int htrChan_lo=10000;
662     int htrChan_hi=-10000;
663     int fpga_lo=10000;
664     int fpga_hi=-10000;
665    
666     for(std::vector<MyElectronicsId>::iterator jj=KeyIds.begin();
667     jj!=KeyIds.end();
668     jj++) {
669    
670     htrChan=(jj->fiber-1)*3+jj->fiberChan+1;
671     fpga=jj->Slot;
672     //if((jj->tb)==1){fpga=jj->Slot;}else{fpga=-(jj->Slot);}
673    
674    
675     if( htrChan>htrChan_hi ) htrChan_hi=htrChan;
676     if(htrChan<htrChan_lo ) htrChan_lo=htrChan;
677     if( fpga>fpga_hi ) fpga_hi=fpga;
678     if( fpga<fpga_lo ) fpga_lo=fpga;
679    
680    
681     htrChan=0;fpga=0;
682    
683     }
684    
685     printf("htrChan_lo=%d htrChan_hi=%d fpga_lo=%d fpga_hi=%d\n",
686     htrChan_lo,htrChan_hi,fpga_lo,fpga_hi);
687    
688     HcalElectronicsSelector* vs=
689     new HcalElectronicsSelector(new PlotAllElecAdapter(this,evtType,flavType),
690     htrChan_lo,htrChan_hi,fpga_lo,fpga_hi,crate);
691    
692     for (std::vector<MyElectronicsId>::iterator ii=KeyIds.begin();
693     ii!=KeyIds.end();
694     ii++) {
695    
696     htrChan=(ii->fiber-1)*3+ii->fiberChan+1;
697     if((ii->tb)==1){fpga=ii->Slot;}else{fpga=-(ii->Slot);}
698    
699     TH1* h=histKeys.GetAHistogram(*ii,ht,et);
700     if (h==0) {
701     printf("htrChan=%d, fpga=%d not found\n", htrChan, fpga);
702     continue;
703     }
704    
705     if (!plotStatType)
706     vs->fill(*ii,h->GetMean());
707     else
708     vs->fill(*ii,h->GetRMS());
709     }
710    
711     vs->Update();
712     }
713    
714